Closed T45K closed 4 years ago
@T45K Thank you for reporting the problem. Is it possible to give the pair of clones or methods for which the bug occurred?
@tsantalis Sorry for the late reply.
The code fragment is jfreechat/src/main/java/org/jfrer/chart/renderer/category/AreaRenderer.java l.323 ~ 330
, and it is clone pair of org/jfrer/chart/renderer/category/BarRenderer.java l.1083 ~ 1090
and org/jfrer/chart/renderer/category/LineAndShapeRenderer.java l.835 ~ 842
.
The three clones are the following code fragments:
// /jfreechart/src/main/java/org/jfree/chart/renderer/category/AreaRenderer.java
// submit the current data point as a crosshair candidate
int datasetIndex = plot.indexOf(dataset);
updateCrosshairValues(state.getCrosshairState(),
dataset.getRowKey(row), dataset.getColumnKey(column), yy1,
datasetIndex, x1, y1, orientation);
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, area);
}
// /jfreechart/src/main/java/org/jfree/chart/renderer/category/BarRenderer.java
// submit the current data point as a crosshair candidate
int datasetIndex = plot.indexOf(dataset);
updateCrosshairValues(state.getCrosshairState(),
dataset.getRowKey(row), dataset.getColumnKey(column), value,
datasetIndex, barW0, barL0, orientation);
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, bar);
}
// /jfreechart/src/main/java/org/jfree/chart/renderer/category/LineAndShapeRenderer.java
// submit the current data point as a crosshair candidate
int datasetIndex = plot.indexOf(dataset);
updateCrosshairValues(state.getCrosshairState(),
dataset.getRowKey(row), dataset.getColumnKey(column),
value, datasetIndex, x1, y1, orientation);
// add an item entity, if this information is being collected
EntityCollection entities = state.getEntityCollection();
if (entities != null) {
addItemEntity(entities, dataset, row, column, shape);
}
The clones have differences only in variable identifiers and the types of some variables (float
<-> double
).
All clone fragments can be extracted in a separate method. Therefore, the clones should be refactorable.
There is one problem with the line range given by CCFinder.
In all clone fragments, CCFinder reports the end of the clone fragments in line if (entities != null) {
This makes the fragments syntactically invalid, because the if
AST node is incomplete.
We spent a lot of effort to correct the output of clone detection tools, so that the final clone fragments processed for refactoring are syntactically valid.
NPE occurred when I used jdeodorant-commandline on JFreeChart.
My Environment: Mac OS X Catalina, AdoptOpenJDK8 JDeodorant(8db9766bd84d6ef7bbe4c2e6f3dc9b6789a7cab7) JDeodorant-Commandline(latest) Target: JFreeChart ,
d03e68acaff59e7ba1b3573af3c45c9b028f715d
stack trace