Files
fixminer_source/python/data/defects4j-bugs.json
T
2020-04-06 21:30:39 +02:00

27544 lines
1.1 MiB
Plaintext

[
{
"bugId": 6,
"changedFiles": {
"org/jfree/chart/util/ShapeList.java": {
"changes": [
[
111
]
]
}
},
"diff": "--- a/source/org/jfree/chart/util/ShapeList.java\n+++ b/source/org/jfree/chart/util/ShapeList.java\n@@ -108,7 +108,14 @@ public boolean equals(Object obj) {\n if (!(obj instanceof ShapeList)) {\n return false;\n }\n- return super.equals(obj);\n+ ShapeList that = (ShapeList) obj;\n+ int listSize = size();\n+ for (int i = 0; i < listSize; i++) {\n+ if (!ShapeUtilities.equal((Shape) get(i), (Shape) that.get(i))) {\n+ return false;\n+ }\n+ }\n+ return true;\n \n }\n \n",
"failingTests": [
{
"className": " org.jfree.chart.util.junit.ShapeListTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<org.jfree.chart.util.ShapeList@d0e55451> but was:<org.jfree.chart.util.ShapeList@d951b68f>",
"methodName": "testSerialization"
},
{
"className": " org.jfree.chart.util.junit.ShapeListTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEquals"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrongComp"
],
"repairTools": [
"rtCardumen"
],
"revisionId": "1166"
},
{
"bugId": 10,
"changedFiles": {
"org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java": {
"changes": [
[
65
]
]
}
},
"diff": "--- a/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java\n+++ b/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java\n@@ -62,7 +62,7 @@ public StandardToolTipTagFragmentGenerator() {\n * @return The formatted HTML area tag attribute(s).\r\n */\r\n public String generateToolTipFragment(String toolTipText) {\r\n- return \" title=\\\"\" + toolTipText\r\n+ return \" title=\\\"\" + ImageMapUtilities.htmlEscape(toolTipText) \r\n + \"\\\" alt=\\\"\\\"\";\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.chart.imagemap.junit.StandardToolTipTagFragmentGeneratorTests",
"error": "junit.framework.ComparisonFailure",
"message": "expected:< title=\"Series [&quot;A&quot;], 100.0\" alt=\"\"> but was:< title=\"Series [\"A\"], 100.0\" alt=\"\">",
"methodName": "testGenerateURLFragment"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "1065"
},
{
"bugId": 9,
"changedFiles": {
"org/jfree/data/time/TimeSeries.java": {
"changes": [
[
944
]
]
}
},
"diff": "--- a/source/org/jfree/data/time/TimeSeries.java\n+++ b/source/org/jfree/data/time/TimeSeries.java\n@@ -941,7 +941,7 @@ public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end)\n endIndex = -(endIndex + 1); // this is first item AFTER end period\r\n endIndex = endIndex - 1; // so this is last item BEFORE end\r\n }\r\n- if (endIndex < 0) {\r\n+ if ((endIndex < 0) || (endIndex < startIndex)) {\r\n emptyRange = true;\r\n }\r\n if (emptyRange) {\r\n",
"failingTests": [
{
"className": " org.jfree.data.time.junit.TimeSeriesTests",
"error": "java.lang.IllegalArgumentException",
"message": "Requires start <= end.",
"methodName": "testBug1864222"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condExpExpand"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtJAID",
"rtNopol"
],
"revisionId": "1083"
},
{
"bugId": 8,
"changedFiles": {
"org/jfree/data/time/Week.java": {
"changes": [
[
175
]
]
}
},
"diff": "--- a/source/org/jfree/data/time/Week.java\n+++ b/source/org/jfree/data/time/Week.java\n@@ -172,7 +172,7 @@ public Week(Date time) {\n */\r\n public Week(Date time, TimeZone zone) {\r\n // defer argument checking...\r\n- this(time, RegularTimePeriod.DEFAULT_TIME_ZONE, Locale.getDefault());\r\n+ this(time, zone, Locale.getDefault());\r\n }\r\n \r\n /**\r\n",
"failingTests": [
{
"className": " org.jfree.data.time.junit.WeekTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<35> but was:<34>",
"methodName": "testConstructor"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes params passed to constructor.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtElixir",
"rtHDRepair"
],
"revisionId": "1085"
},
{
"bugId": 7,
"changedFiles": {
"org/jfree/data/time/TimePeriodValues.java": {
"changes": [
[
300
],
[
302
]
]
}
},
"diff": "--- a/source/org/jfree/data/time/TimePeriodValues.java\n+++ b/source/org/jfree/data/time/TimePeriodValues.java\n@@ -297,9 +297,9 @@ private void updateBounds(TimePeriod period, int index) {\n }\r\n \r\n if (this.maxMiddleIndex >= 0) {\r\n- long s = getDataItem(this.minMiddleIndex).getPeriod().getStart()\r\n+ long s = getDataItem(this.maxMiddleIndex).getPeriod().getStart()\r\n .getTime();\r\n- long e = getDataItem(this.minMiddleIndex).getPeriod().getEnd()\r\n+ long e = getDataItem(this.maxMiddleIndex).getPeriod().getEnd()\r\n .getTime();\r\n long maxMiddle = s + (e - s) / 2;\r\n if (middle > maxMiddle) {\r\n",
"failingTests": [
{
"className": " org.jfree.data.time.junit.TimePeriodValuesTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<3>",
"methodName": "testGetMaxMiddleIndex"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignExpChange",
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"copyPaste",
"expArithMod",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL",
"rtGenProg"
],
"revisionId": "1087"
},
{
"bugId": 5,
"changedFiles": {
"org/jfree/data/xy/XYSeries.java": {
"changes": [
[
548
]
],
"inserts": [
[
545,
546,
547,
548
]
]
}
},
"diff": "--- a/source/org/jfree/data/xy/XYSeries.java\n+++ b/source/org/jfree/data/xy/XYSeries.java\n@@ -541,11 +541,15 @@ public XYDataItem addOrUpdate(Number x, Number y) {\n if (x == null) {\r\n throw new IllegalArgumentException(\"Null 'x' argument.\");\r\n }\r\n+ if (this.allowDuplicateXValues) {\r\n+ add(x, y);\r\n+ return null;\r\n+ }\r\n \r\n // if we get to here, we know that duplicate X values are not permitted\r\n XYDataItem overwritten = null;\r\n int index = indexOf(x);\r\n- if (index >= 0 && !this.allowDuplicateXValues) {\r\n+ if (index >= 0) {\r\n XYDataItem existing = (XYDataItem) this.data.get(index);\r\n try {\r\n overwritten = (XYDataItem) existing.clone();\r\n",
"failingTests": [
{
"className": " org.jfree.data.xy.junit.XYSeriesTests",
"error": "java.lang.IndexOutOfBoundsException",
"message": "Index: -1, Size: 1",
"methodName": "testBug1955483"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 4,
"spreadCodeOnly": 2
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd",
"condExpRed",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicReduce"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "1696"
},
{
"bugId": 3,
"changedFiles": {
"org/jfree/data/time/TimeSeries.java": {
"inserts": [
[
1057,
1058
]
]
}
},
"diff": "--- a/source/org/jfree/data/time/TimeSeries.java\n+++ b/source/org/jfree/data/time/TimeSeries.java\n@@ -1054,6 +1054,8 @@ public TimeSeries createCopy(int start, int end)\n throw new IllegalArgumentException(\"Requires start <= end.\");\r\n }\r\n TimeSeries copy = (TimeSeries) super.clone();\r\n+ copy.minY = Double.NaN;\r\n+ copy.maxY = Double.NaN;\r\n copy.data = new java.util.ArrayList();\r\n if (this.data.size() > 0) {\r\n for (int index = start; index <= end; index++) {\r\n",
"failingTests": [
{
"className": " org.jfree.data.time.junit.TimeSeriesTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<101.0> but was:<102.0>",
"methodName": "testCreateCopy3"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Missing initialization",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd"
],
"repairPatterns": [
"initFix",
"notClassified"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtNopol"
],
"revisionId": "2227"
},
{
"bugId": 4,
"changedFiles": {
"org/jfree/chart/plot/XYPlot.java": {
"inserts": [
[
4492,
4493
],
[
4501
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/XYPlot.java\n+++ b/source/org/jfree/chart/plot/XYPlot.java\n@@ -4490,6 +4490,7 @@ public Range getDataRange(ValueAxis axis) {\n }\r\n }\r\n \r\n+ if (r != null) {\r\n Collection c = r.getAnnotations();\r\n Iterator i = c.iterator();\r\n while (i.hasNext()) {\r\n@@ -4498,6 +4499,7 @@ public Range getDataRange(ValueAxis axis) {\n includedAnnotations.add(a);\r\n }\r\n }\r\n+ }\r\n }\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.chart.axis.junit.LogAxisTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testXYAutoRange1"
},
{
"className": " org.jfree.chart.axis.junit.LogAxisTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testXYAutoRange2"
},
{
"className": " org.jfree.chart.axis.junit.NumberAxisTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testXYAutoRange1"
},
{
"className": " org.jfree.chart.axis.junit.NumberAxisTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testXYAutoRange2"
},
{
"className": " org.jfree.chart.axis.junit.ValueAxisTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testAxisMargins"
},
{
"className": " org.jfree.chart.junit.JFreeChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSerialization4"
},
{
"className": " org.jfree.chart.junit.ScatterPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.ScatterPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSetSeriesToolTipGenerator"
},
{
"className": " org.jfree.chart.junit.ScatterPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplaceDataset"
},
{
"className": " org.jfree.chart.junit.TimeSeriesChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.TimeSeriesChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSetSeriesToolTipGenerator"
},
{
"className": " org.jfree.chart.junit.TimeSeriesChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplaceDataset"
},
{
"className": " org.jfree.chart.junit.XYAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.XYAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSetSeriesToolTipGenerator"
},
{
"className": " org.jfree.chart.junit.XYAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplaceDataset"
},
{
"className": " org.jfree.chart.junit.XYStepAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.XYStepAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSetSeriesToolTipGenerator"
},
{
"className": " org.jfree.chart.junit.XYStepAreaChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplaceDataset"
},
{
"className": " org.jfree.chart.junit.XYStepChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.XYStepChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testSetSeriesToolTipGenerator"
},
{
"className": " org.jfree.chart.junit.XYStepChartTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplaceDataset"
},
{
"className": " org.jfree.chart.plot.junit.XYPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testDrawRangeGridlines"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 8,
"spreadCodeOnly": 8
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"missNullCheckN",
"wrapsIf"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "2183"
},
{
"bugId": 2,
"changedFiles": {
"org/jfree/data/general/DatasetUtilities.java": {
"inserts": [
[
755,
756,
757
],
[
758,
759
],
[
761,
762
],
[
1242,
1243,
1244
],
[
1245,
1246
],
[
1248,
1249
]
]
}
},
"diff": "--- a/source/org/jfree/data/general/DatasetUtilities.java\n+++ b/source/org/jfree/data/general/DatasetUtilities.java\n@@ -752,12 +752,19 @@ public static Range iterateDomainBounds(XYDataset dataset,\n for (int series = 0; series < seriesCount; series++) {\r\n int itemCount = dataset.getItemCount(series);\r\n for (int item = 0; item < itemCount; item++) {\r\n+ double value = intervalXYData.getXValue(series, item);\r\n lvalue = intervalXYData.getStartXValue(series, item);\r\n uvalue = intervalXYData.getEndXValue(series, item);\r\n+ if (!Double.isNaN(value)) {\r\n+ minimum = Math.min(minimum, value);\r\n+ maximum = Math.max(maximum, value);\r\n+ }\r\n if (!Double.isNaN(lvalue)) {\r\n minimum = Math.min(minimum, lvalue);\r\n+ maximum = Math.max(maximum, lvalue);\r\n }\r\n if (!Double.isNaN(uvalue)) {\r\n+ minimum = Math.min(minimum, uvalue);\r\n maximum = Math.max(maximum, uvalue);\r\n }\r\n }\r\n@@ -1239,12 +1246,19 @@ public static Range iterateRangeBounds(XYDataset dataset,\n for (int series = 0; series < seriesCount; series++) {\r\n int itemCount = dataset.getItemCount(series);\r\n for (int item = 0; item < itemCount; item++) {\r\n+ double value = ixyd.getYValue(series, item);\r\n double lvalue = ixyd.getStartYValue(series, item);\r\n double uvalue = ixyd.getEndYValue(series, item);\r\n+ if (!Double.isNaN(value)) {\r\n+ minimum = Math.min(minimum, value);\r\n+ maximum = Math.max(maximum, value);\r\n+ }\r\n if (!Double.isNaN(lvalue)) {\r\n minimum = Math.min(minimum, lvalue);\r\n+ maximum = Math.max(maximum, lvalue);\r\n }\r\n if (!Double.isNaN(uvalue)) {\r\n+ minimum = Math.min(minimum, uvalue);\r\n maximum = Math.max(maximum, uvalue);\r\n }\r\n }\r\n",
"failingTests": [
{
"className": " org.jfree.data.general.junit.DatasetUtilitiesTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testBug2849731_2"
},
{
"className": " org.jfree.data.general.junit.DatasetUtilitiesTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testBug2849731_3"
}
],
"metrics": {
"chunks": 8,
"classes": 1,
"files": 1,
"linesAdd": 14,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 14,
"spreadAllLines": 493,
"spreadCodeOnly": 318
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"missComp"
],
"repairTools": [],
"revisionId": "2242"
},
{
"bugId": 1,
"changedFiles": {
"org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java": {
"changes": [
[
1797
]
]
}
},
"diff": "--- a/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java\n+++ b/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java\n@@ -1794,7 +1794,7 @@ public LegendItemCollection getLegendItems() {\n }\r\n int index = this.plot.getIndexOf(this);\r\n CategoryDataset dataset = this.plot.getDataset(index);\r\n- if (dataset != null) {\r\n+ if (dataset == null) {\r\n return result;\r\n }\r\n int seriesCount = dataset.getRowCount();\r\n",
"failingTests": [
{
"className": " org.jfree.chart.renderer.category.junit.AbstractCategoryItemRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<0>",
"methodName": "test2947660"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Change Operator",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtJAID",
"rtKali"
],
"revisionId": "2266"
},
{
"bugId": 12,
"changedFiles": {
"org/jfree/chart/plot/MultiplePiePlot.java": {
"changes": [
[
145
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/MultiplePiePlot.java\n+++ b/source/org/jfree/chart/plot/MultiplePiePlot.java\n@@ -142,7 +142,7 @@ public MultiplePiePlot() {\n */\r\n public MultiplePiePlot(CategoryDataset dataset) {\r\n super();\r\n- this.dataset = dataset;\r\n+ setDataset(dataset);\r\n PiePlot piePlot = new PiePlot(null);\r\n this.pieChart = new JFreeChart(piePlot);\r\n this.pieChart.removeLegend();\r\n",
"failingTests": [
{
"className": " org.jfree.chart.plot.junit.MultiplePiePlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testConstructor"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "It involves a \"wrap with method\", but the real change is converting from a class attribute assignment to a \"set\" method call.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignRem",
"mcAdd",
"varReplMc"
],
"repairPatterns": [
"singleLine",
"wrapsMethod",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL"
],
"revisionId": "852"
},
{
"bugId": 11,
"changedFiles": {
"org/jfree/chart/util/ShapeUtilities.java": {
"changes": [
[
275
]
]
}
},
"diff": "--- a/source/org/jfree/chart/util/ShapeUtilities.java\n+++ b/source/org/jfree/chart/util/ShapeUtilities.java\n@@ -272,7 +272,7 @@ public static boolean equal(GeneralPath p1, GeneralPath p2) {\n return false;\n }\n PathIterator iterator1 = p1.getPathIterator(null);\n- PathIterator iterator2 = p1.getPathIterator(null);\n+ PathIterator iterator2 = p2.getPathIterator(null);\n double[] d1 = new double[6];\n double[] d2 = new double[6];\n boolean done = iterator1.isDone() && iterator2.isDone();\n",
"failingTests": [
{
"className": " org.jfree.chart.util.junit.ShapeUtilitiesTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEqualGeneralPaths"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaces var referencing of target object of a call.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignExpChange",
"varReplVar"
],
"repairPatterns": [
"singleLine",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtElixir"
],
"revisionId": "1025"
},
{
"bugId": 13,
"changedFiles": {
"org/jfree/chart/block/BorderArrangement.java": {
"changes": [
[
455
]
]
}
},
"diff": "--- a/source/org/jfree/chart/block/BorderArrangement.java\n+++ b/source/org/jfree/chart/block/BorderArrangement.java\n@@ -452,7 +452,7 @@ protected Size2D arrangeFF(BlockContainer container, Graphics2D g2,\n h[3] = h[2];\r\n if (this.rightBlock != null) {\r\n RectangleConstraint c4 = new RectangleConstraint(0.0,\r\n- new Range(0.0, constraint.getWidth() - w[2]),\r\n+ new Range(0.0, Math.max(constraint.getWidth() - w[2], 0.0)),\r\n LengthConstraintType.RANGE, h[2], null,\r\n LengthConstraintType.FIXED);\r\n Size2D size = this.rightBlock.arrange(g2, c4);\r\n",
"failingTests": [
{
"className": " org.jfree.chart.block.junit.BorderArrangementTests",
"error": "java.lang.IllegalArgumentException",
"message": "Range(double, double): require lower (0.0) <= upper (-2.3000000000000007).",
"methodName": "testSizingWithWidthConstraint"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignExpChange",
"mcAdd",
"mcParAdd",
"mcParValChange",
"mcRepl",
"objInstMod"
],
"repairPatterns": [
"initFix",
"missComp",
"singleLine",
"wrapsMethod",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtKali"
],
"revisionId": "822"
},
{
"bugId": 18,
"changedFiles": {
"org/jfree/data/DefaultKeyedValues.java": {
"changes": [
[
335
]
],
"deletes": [
[
318
],
[
320
]
]
},
"org/jfree/data/DefaultKeyedValues2D.java": {
"inserts": [
[
455,
456
],
[
458
],
[
459
]
]
}
},
"diff": "--- a/source/org/jfree/data/DefaultKeyedValues.java\n+++ b/source/org/jfree/data/DefaultKeyedValues.java\n@@ -315,30 +315,29 @@ private void rebuildIndex () {\n public void removeValue(int index) {\n this.keys.remove(index);\n this.values.remove(index);\n- if (index < this.keys.size()) {\n rebuildIndex();\n- }\n }\n \n /**\n * Removes a value from the collection.\n *\n * @param key the item key (<code>null</code> not permitted).\n * \n * @throws IllegalArgumentException if <code>key</code> is \n * <code>null</code>.\n * @throws UnknownKeyException if <code>key</code> is not recognised.\n */\n public void removeValue(Comparable key) {\n int index = getIndex(key);\n if (index < 0) {\n-\t\t\treturn;\n+ throw new UnknownKeyException(\"The key (\" + key \n+ + \") is not recognised.\");\n }\n removeValue(index);\n }\n \n /**\n * Clears all values from the collection.\n * \n * @since 1.0.2\n */\n--- a/source/org/jfree/data/DefaultKeyedValues2D.java\n+++ b/source/org/jfree/data/DefaultKeyedValues2D.java\n@@ -454,12 +454,21 @@ public void removeColumn(int columnIndex) {\n public void removeColumn(Comparable columnKey) {\r\n+ \tif (columnKey == null) {\r\n+ \t\tthrow new IllegalArgumentException(\"Null 'columnKey' argument.\");\r\n+ \t}\r\n+ \tif (!this.columnKeys.contains(columnKey)) {\r\n+ \t\tthrow new UnknownKeyException(\"Unknown key: \" + columnKey);\r\n+ \t}\r\n Iterator iterator = this.rows.iterator();\r\n while (iterator.hasNext()) {\r\n DefaultKeyedValues rowData = (DefaultKeyedValues) iterator.next();\r\n+ int index = rowData.getIndex(columnKey);\r\n+ if (index >= 0) {\r\n rowData.removeValue(columnKey);\r\n+ }\r\n }\r\n this.columnKeys.remove(columnKey);\r\n }\r\n \r\n /**\r\n * Clears all the data and associated keys.\r\n */\r\n",
"failingTests": [
{
"className": " org.jfree.data.category.junit.DefaultCategoryDatasetTests",
"error": "java.lang.IndexOutOfBoundsException",
"message": "Index: 0, Size: 0",
"methodName": "testBug1835955"
},
{
"className": " org.jfree.data.junit.DefaultKeyedValues2DTests",
"error": "java.lang.IndexOutOfBoundsException",
"message": "Index: 0, Size: 0",
"methodName": "testRemoveColumnByKey"
},
{
"className": " org.jfree.data.junit.DefaultKeyedValuesTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRemoveValue"
},
{
"className": " org.jfree.data.junit.DefaultKeyedValuesTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1> but was:<0>",
"methodName": "testGetIndex2"
}
],
"metrics": {
"chunks": 6,
"classes": 2,
"files": 2,
"linesAdd": 10,
"linesMod": 1,
"linesRem": 2,
"methods": 3,
"sizeInLines": 13,
"spreadAllLines": 19,
"spreadCodeOnly": 9
},
"observations": "Replaces return point by throw exception.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranRem",
"exThrowsAdd",
"mcAdd",
"mcRem",
"objInstAdd",
"retRem",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"missNullCheckP",
"unwrapIfElse",
"wrapsIf"
],
"repairTools": [
"rtDeepRepair",
"rtGPFL"
],
"revisionId": "621"
},
{
"bugId": 14,
"changedFiles": {
"org/jfree/chart/plot/CategoryPlot.java": {
"inserts": [
[
2166
],
[
2448
]
]
},
"org/jfree/chart/plot/XYPlot.java": {
"inserts": [
[
2293
],
[
2529
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/CategoryPlot.java\n+++ b/source/org/jfree/chart/plot/CategoryPlot.java\n@@ -2163,6 +2163,9 @@ public boolean removeDomainMarker(int index, Marker marker, Layer layer,\n markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer(\r\n index));\r\n }\r\n+ if (markers == null) {\r\n+ return false;\r\n+ }\r\n boolean removed = markers.remove(marker);\r\n if (removed && notify) {\r\n fireChangeEvent();\r\n@@ -2445,6 +2448,9 @@ public boolean removeRangeMarker(int index, Marker marker, Layer layer,\n markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer(\r\n index));\r\n }\r\n+ if (markers == null) {\r\n+ return false;\r\n+ }\r\n boolean removed = markers.remove(marker);\r\n if (removed && notify) {\r\n fireChangeEvent();\r\n--- a/source/org/jfree/chart/plot/XYPlot.java\n+++ b/source/org/jfree/chart/plot/XYPlot.java\n@@ -2290,6 +2290,9 @@ public boolean removeDomainMarker(int index, Marker marker, Layer layer,\n markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer(\r\n index));\r\n }\r\n+ if (markers == null) {\r\n+ return false;\r\n+ }\r\n boolean removed = markers.remove(marker);\r\n if (removed && notify) {\r\n fireChangeEvent();\r\n@@ -2526,6 +2529,9 @@ public boolean removeRangeMarker(int index, Marker marker, Layer layer,\n markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer(\r\n index));\r\n }\r\n+ if (markers == null) {\r\n+ return false;\r\n+ }\r\n boolean removed = markers.remove(marker);\r\n if (removed && notify) {\r\n fireChangeEvent();\r\n",
"failingTests": [
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testRemoveRangeMarker"
},
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testRemoveDomainMarker"
},
{
"className": " org.jfree.chart.plot.junit.XYPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testRemoveRangeMarker"
},
{
"className": " org.jfree.chart.plot.junit.XYPlotTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testRemoveDomainMarker"
}
],
"metrics": {
"chunks": 4,
"classes": 2,
"files": 2,
"linesAdd": 12,
"linesMod": 0,
"linesRem": 0,
"methods": 4,
"sizeInLines": 12,
"spreadAllLines": 518,
"spreadCodeOnly": 243
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missNullCheckP"
],
"repairTools": [
"rtAcs",
"rtDeepRepair"
],
"revisionId": "811"
},
{
"bugId": 21,
"changedFiles": {
"org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java": {
"inserts": [
[
157,
158
],
[
188,
189
],
[
742
]
]
}
},
"diff": "--- a/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java\n+++ b/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java\n@@ -154,6 +154,7 @@ public void add(BoxAndWhiskerItem item, Comparable rowKey,\n && this.minimumRangeValueColumn == c)) {\r\n updateBounds();\r\n }\r\n+ else {\r\n \r\n double minval = Double.NaN;\r\n if (item.getMinOutlier() != null) {\r\n@@ -185,6 +186,7 @@ else if (minval < this.minimumRangeValue) {\n this.minimumRangeValueRow = r;\r\n this.minimumRangeValueColumn = c;\r\n }\r\n+ }\r\n \r\n this.rangeBounds = new Range(this.minimumRangeValue,\r\n this.maximumRangeValue);\r\n@@ -738,7 +740,44 @@ public List getOutliers(Comparable rowKey, Comparable columnKey) {\n */\r\n private void updateBounds() {\r\n this.minimumRangeValue = Double.NaN;\r\n+ this.minimumRangeValueRow = -1;\r\n+ this.minimumRangeValueColumn = -1;\r\n this.maximumRangeValue = Double.NaN;\r\n+ this.maximumRangeValueRow = -1;\r\n+ this.maximumRangeValueColumn = -1;\r\n+ int rowCount = getRowCount();\r\n+ int columnCount = getColumnCount();\r\n+ for (int r = 0; r < rowCount; r++) {\r\n+ for (int c = 0; c < columnCount; c++) {\r\n+ BoxAndWhiskerItem item = getItem(r, c);\r\n+ if (item != null) {\r\n+ Number min = item.getMinOutlier();\r\n+ if (min != null) {\r\n+ double minv = min.doubleValue();\r\n+ if (!Double.isNaN(minv)) {\r\n+ if (minv < this.minimumRangeValue || Double.isNaN(\r\n+ this.minimumRangeValue)) {\r\n+ this.minimumRangeValue = minv;\r\n+ this.minimumRangeValueRow = r;\r\n+ this.minimumRangeValueColumn = c;\r\n+ }\r\n+ }\r\n+ }\r\n+ Number max = item.getMaxOutlier();\r\n+ if (max != null) {\r\n+ double maxv = max.doubleValue();\r\n+ if (!Double.isNaN(maxv)) {\r\n+ if (maxv > this.maximumRangeValue || Double.isNaN(\r\n+ this.maximumRangeValue)) {\r\n+ this.maximumRangeValue = maxv;\r\n+ this.maximumRangeValueRow = r;\r\n+ this.maximumRangeValueColumn = c;\r\n+ }\r\n+ }\r\n+ }\r\n+ }\r\n+ }\r\n+ }\r\n }\r\n \r\n /**\r\n",
"failingTests": [
{
"className": " org.jfree.data.statistics.junit.DefaultBoxAndWhiskerCategoryDatasetTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<Range[8.5,9.6]> but was:<Range[8.6,9.6]>",
"methodName": "testGetRangeBounds"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 39,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 39,
"spreadAllLines": 585,
"spreadCodeOnly": 239
},
"observations": "It seems that the functionality wasn't implemented before.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranElseAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"wrapsElse"
],
"repairTools": [
"rtNopol"
],
"revisionId": "231"
},
{
"bugId": 15,
"changedFiles": {
"org/jfree/chart/plot/PiePlot.java": {
"inserts": [
[
1378,
1379
],
[
2051
],
[
2053
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/PiePlot.java\n+++ b/source/org/jfree/chart/plot/PiePlot.java\n@@ -1375,6 +1375,9 @@ public void setExplodePercent(Comparable key, double percent) {\n * @return The percent.\r\n */\r\n public double getMaximumExplodePercent() {\r\n+ if (this.dataset == null) {\r\n+ return 0.0;\r\n+ }\r\n double result = 0.0;\r\n Iterator iterator = this.dataset.getKeys().iterator();\r\n while (iterator.hasNext()) {\r\n@@ -2048,8 +2051,10 @@ public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea,\n \r\n PiePlotState state = new PiePlotState(info);\r\n state.setPassesRequired(2);\r\n+ if (this.dataset != null) {\r\n state.setTotal(DatasetUtilities.calculatePieDatasetTotal(\r\n plot.getDataset()));\r\n+ }\r\n state.setLatestAngle(plot.getStartAngle());\r\n return state;\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.chart.plot.junit.PiePlot3DTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullDataset"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 5,
"spreadAllLines": 675,
"spreadCodeOnly": 212
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN",
"missNullCheckP",
"wrapsIf"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali"
],
"revisionId": "749"
},
{
"bugId": 16,
"changedFiles": {
"org/jfree/data/category/DefaultIntervalCategoryDataset.java": {
"changes": [
[
207
],
[
208
],
[
338
]
]
}
},
"diff": "--- a/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java\n+++ b/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java\n@@ -204,8 +204,8 @@ public DefaultIntervalCategoryDataset(Comparable[] seriesKeys,\n \r\n }\r\n else {\r\n- this.seriesKeys = null;\r\n- this.categoryKeys = null;\r\n+ this.seriesKeys = new Comparable[0];\r\n+ this.categoryKeys = new Comparable[0];\r\n }\r\n }\r\n \r\n@@ -335,7 +335,7 @@ public void setCategoryKeys(Comparable[] categoryKeys) {\n if (categoryKeys == null) {\r\n throw new IllegalArgumentException(\"Null 'categoryKeys' argument.\");\r\n }\r\n- if (categoryKeys.length != this.startData[0].length) {\r\n+ if (categoryKeys.length != getCategoryCount()) {\r\n throw new IllegalArgumentException(\r\n \"The number of categories does not match the data.\");\r\n }\r\n",
"failingTests": [
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetCategoryIndex"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSetCategoryKeys"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetSeriesIndex"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetRowCount"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetRowIndex"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetColumnCount"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testGetColumnIndex"
},
{
"className": " org.jfree.data.category.junit.DefaultIntervalCategoryDatasetTests",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testCloning2"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 129,
"spreadCodeOnly": 59
},
"observations": "Variable initialization in constructor + conditional expression change.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignExpChange",
"condExpMod",
"mcAdd",
"objInstAdd",
"varReplMc"
],
"repairPatterns": [
"expLogicMod",
"initFix",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "743"
},
{
"bugId": 17,
"changedFiles": {
"org/jfree/data/time/TimeSeries.java": {
"changes": [
[
857
]
]
}
},
"diff": "--- a/source/org/jfree/data/time/TimeSeries.java\n+++ b/source/org/jfree/data/time/TimeSeries.java\n@@ -854,7 +854,8 @@ public void delete(int start, int end) {\n * subclasses may differ.\r\n */\r\n public Object clone() throws CloneNotSupportedException {\r\n- Object clone = createCopy(0, getItemCount() - 1);\r\n+ TimeSeries clone = (TimeSeries) super.clone();\r\n+ clone.data = (List) ObjectUtilities.deepClone(this.data);\r\n return clone;\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.data.time.junit.TimeSeriesTests",
"error": "java.lang.IllegalArgumentException",
"message": "Requires start <= end.",
"methodName": "testBug1832432"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Type change + computing change.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"assignExpChange",
"mcAdd",
"mcRem",
"varTyChange"
],
"repairPatterns": [
"notClassified",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtElixir",
"rtNopol"
],
"revisionId": "622"
},
{
"bugId": 20,
"changedFiles": {
"org/jfree/chart/plot/ValueMarker.java": {
"changes": [
[
95
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/ValueMarker.java\n+++ b/source/org/jfree/chart/plot/ValueMarker.java\n@@ -92,7 +92,7 @@ public ValueMarker(double value, Paint paint, Stroke stroke) {\n */\r\n public ValueMarker(double value, Paint paint, Stroke stroke, \r\n Paint outlinePaint, Stroke outlineStroke, float alpha) {\r\n- super(paint, stroke, paint, stroke, alpha);\r\n+ super(paint, stroke, outlinePaint, outlineStroke, alpha);\r\n this.value = value;\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.chart.plot.junit.ValueMarkerTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<java.awt.Color[r=0,g=0,b=255]> but was:<java.awt.Color[r=255,g=0,b=0]>",
"methodName": "test1808376"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaces params value passed to constructor.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtssFix"
],
"revisionId": "283"
},
{
"bugId": 19,
"changedFiles": {
"org/jfree/chart/plot/CategoryPlot.java": {
"inserts": [
[
698
],
[
973
]
]
}
},
"diff": "--- a/source/org/jfree/chart/plot/CategoryPlot.java\n+++ b/source/org/jfree/chart/plot/CategoryPlot.java\n@@ -695,6 +695,9 @@ public void setDomainAxes(CategoryAxis[] axes) {\n * @since 1.0.3\r\n */\r\n public int getDomainAxisIndex(CategoryAxis axis) {\r\n+ if (axis == null) {\r\n+ throw new IllegalArgumentException(\"Null 'axis' argument.\");\r\n+ }\r\n return this.domainAxes.indexOf(axis);\r\n }\r\n \r\n@@ -970,6 +973,9 @@ public void setRangeAxes(ValueAxis[] axes) {\n * @since 1.0.7\r\n */\r\n public int getRangeAxisIndex(ValueAxis axis) {\r\n+ if (axis == null) {\r\n+ throw new IllegalArgumentException(\"Null 'axis' argument.\");\r\n+ }\r\n int result = this.rangeAxes.indexOf(axis);\r\n if (result < 0) { // try the parent plot\r\n Plot parent = getParent();\r\n",
"failingTests": [
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testGetRangeAxisIndex"
},
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testGetDomainAxisIndex"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 275,
"spreadCodeOnly": 117
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"copyPaste",
"missNullCheckP"
],
"repairTools": [
"rtAcs"
],
"revisionId": "434"
},
{
"bugId": 22,
"changedFiles": {
"org/jfree/data/KeyedObjects2D.java": {
"changes": [
[
233
],
[
378
]
],
"deletes": [
[
231
]
],
"inserts": [
[
233
],
[
316,
317,
318,
319,
320
],
[
345
],
[
378
],
[
379
]
]
}
},
"diff": "--- a/source/org/jfree/data/KeyedObjects2D.java\n+++ b/source/org/jfree/data/KeyedObjects2D.java\n@@ -228,9 +228,10 @@ public Object getObject(Comparable rowKey, Comparable columnKey) {\n throw new UnknownKeyException(\"Column key (\" + columnKey \r\n + \") not recognised.\");\r\n }\r\n- if (row >= 0) {\r\n KeyedObjects rowData = (KeyedObjects) this.rows.get(row);\r\n- return rowData.getObject(columnKey);\r\n+ int index = rowData.getIndex(columnKey);\r\n+ if (index >= 0) {\r\n+ return rowData.getObject(index);\r\n }\r\n else {\r\n return null;\r\n@@ -315,8 +316,29 @@ public void removeObject(Comparable rowKey, Comparable columnKey) {\n }\r\n \r\n // 2. check whether the column is now empty.\r\n+ allNull = true;\r\n \r\n+ for (int item = 0, itemCount = this.rows.size(); item < itemCount; \r\n+ item++) {\r\n+ row = (KeyedObjects) this.rows.get(item);\r\n+ int columnIndex = row.getIndex(columnKey);\r\n+ if (columnIndex >= 0 && row.getObject(columnIndex) != null) {\r\n+ allNull = false;\r\n+ break;\r\n+ }\r\n+ }\r\n \r\n+ if (allNull) {\r\n+ for (int item = 0, itemCount = this.rows.size(); item < itemCount; \r\n+ item++) {\r\n+ row = (KeyedObjects) this.rows.get(item);\r\n+ int columnIndex = row.getIndex(columnKey);\r\n+ if (columnIndex >= 0) {\r\n+ row.removeValue(columnIndex);\r\n+ }\r\n+ }\r\n+ this.columnKeys.remove(columnKey);\r\n+ }\r\n }\r\n \r\n /**\r\n@@ -342,6 +364,10 @@ public void removeRow(int rowIndex) {\n */\r\n public void removeRow(Comparable rowKey) {\r\n int index = getRowIndex(rowKey);\r\n+ if (index < 0) {\r\n+ throw new UnknownKeyException(\"Row key (\" + rowKey \r\n+ + \") not recognised.\");\r\n+ }\r\n removeRow(index);\r\n }\r\n \r\n@@ -375,7 +401,10 @@ public void removeColumn(Comparable columnKey) {\n Iterator iterator = this.rows.iterator();\r\n while (iterator.hasNext()) {\r\n KeyedObjects rowData = (KeyedObjects) iterator.next();\r\n- rowData.removeValue(columnKey);\r\n+ int i = rowData.getIndex(columnKey);\r\n+ if (i >= 0) {\r\n+ rowData.removeValue(i);\r\n+ }\r\n }\r\n this.columnKeys.remove(columnKey);\r\n }\r\n",
"failingTests": [
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "org.jfree.data.UnknownKeyException",
"message": "The key (C2) is not recognised.",
"methodName": "testRemoveColumnByKey"
},
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<2>",
"methodName": "testRemoveValue"
},
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "org.jfree.data.UnknownKeyException",
"message": "The key (C2) is not recognised.",
"methodName": "testGetValueByKey"
},
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "org.jfree.data.UnknownKeyException",
"message": "The key (C1) is not recognised.",
"methodName": "testRemoveColumnByIndex"
},
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "org.jfree.data.UnknownKeyException",
"message": "The key (C2) is not recognised.",
"methodName": "testSetObject"
},
{
"className": " org.jfree.data.junit.KeyedObjects2DTests",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "-1",
"methodName": "testRemoveRowByKey"
}
],
"metrics": {
"chunks": 7,
"classes": 1,
"files": 1,
"linesAdd": 30,
"linesMod": 2,
"linesRem": 1,
"methods": 3,
"sizeInLines": 33,
"spreadAllLines": 145,
"spreadCodeOnly": 72
},
"observations": "Implicit null check after loop throught a vector and using a flag variable.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranRem",
"exThrowsAdd",
"loopAdd",
"mcAdd",
"mcParValChange",
"objInstAdd",
"retExpChange",
"varAdd",
"varReplVar"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"missComp",
"unwrapIfElse",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "227"
},
{
"bugId": 26,
"changedFiles": {
"org/jfree/chart/axis/Axis.java": {
"inserts": [
[
1192
],
[
1197
]
]
}
},
"diff": "--- a/source/org/jfree/chart/axis/Axis.java\n+++ b/source/org/jfree/chart/axis/Axis.java\n@@ -1189,11 +1189,13 @@ else if (edge == RectangleEdge.RIGHT) {\n }\r\n if (plotState != null && hotspot != null) {\r\n ChartRenderingInfo owner = plotState.getOwner();\r\n+ if (owner != null) {\r\n EntityCollection entities = owner.getEntityCollection();\r\n if (entities != null) {\r\n entities.add(new AxisLabelEntity(this, hotspot, \r\n this.labelToolTip, this.labelURL));\r\n }\r\n+ }\r\n }\r\n return state;\r\n \r\n",
"failingTests": [
{
"className": " org.jfree.chart.junit.AreaChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.BarChart3DTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.BarChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.GanttChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.GanttChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo2"
},
{
"className": " org.jfree.chart.junit.LineChart3DTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.LineChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.StackedAreaChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.StackedBarChart3DTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.StackedBarChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.junit.WaterfallChartTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "test1654215"
},
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSerialization3"
},
{
"className": " org.jfree.chart.plot.junit.CategoryPlotTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSerialization4"
},
{
"className": " org.jfree.chart.renderer.category.junit.BoxAndWhiskerRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.GroupedStackedBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.IntervalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.LayeredBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.LevelRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.MinMaxCategoryRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
},
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalLineAndShapeRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullInfo"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 5,
"spreadCodeOnly": 5
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"missNullCheckN",
"wrapsIf"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtJAID",
"rtKali",
"rtNopol"
],
"revisionId": "103"
},
{
"bugId": 25,
"changedFiles": {
"org/jfree/chart/renderer/category/StatisticalBarRenderer.java": {
"changes": [
[
315
],
[
459
]
],
"inserts": [
[
259,
260
],
[
316
],
[
344,
345
],
[
403,
404
],
[
460
],
[
487,
488
]
]
}
},
"diff": "--- a/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java\n+++ b/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java\n@@ -256,6 +256,9 @@ protected void drawHorizontalItem(Graphics2D g2,\n \r\n // BAR X\r\n Number meanValue = dataset.getMeanValue(row, column);\r\n+ if (meanValue == null) {\r\n+ return;\r\n+ }\r\n \r\n double value = meanValue.doubleValue();\r\n double base = 0.0;\r\n@@ -312,7 +315,9 @@ else if (lclip <= 0.0) { // cases 5, 6, 7 and 8\n }\r\n \r\n // standard deviation lines\r\n- double valueDelta = dataset.getStdDevValue(row, column).doubleValue();\r\n+ Number n = dataset.getStdDevValue(row, column);\r\n+ if (n != null) {\r\n+ double valueDelta = n.doubleValue();\r\n double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() \r\n + valueDelta, dataArea, yAxisLocation);\r\n double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() \r\n@@ -341,6 +346,7 @@ else if (lclip <= 0.0) { // cases 5, 6, 7 and 8\n line = new Line2D.Double(lowVal, rectY + rectHeight * 0.25, \r\n lowVal, rectY + rectHeight * 0.75);\r\n g2.draw(line);\r\n+ }\r\n \r\n CategoryItemLabelGenerator generator = getItemLabelGenerator(row, \r\n column);\r\n@@ -400,6 +406,9 @@ protected void drawVerticalItem(Graphics2D g2,\n \r\n // BAR Y\r\n Number meanValue = dataset.getMeanValue(row, column);\r\n+ if (meanValue == null) {\r\n+ return;\r\n+ }\r\n \r\n double value = meanValue.doubleValue();\r\n double base = 0.0;\r\n@@ -456,7 +465,9 @@ else if (lclip <= 0.0) { // cases 5, 6, 7 and 8\n }\r\n \r\n // standard deviation lines\r\n- double valueDelta = dataset.getStdDevValue(row, column).doubleValue();\r\n+ Number n = dataset.getStdDevValue(row, column);\r\n+ if (n != null) {\r\n+ double valueDelta = n.doubleValue();\r\n double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() \r\n + valueDelta, dataArea, yAxisLocation);\r\n double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() \r\n@@ -484,6 +495,7 @@ else if (lclip <= 0.0) { // cases 5, 6, 7 and 8\n line = new Line2D.Double(rectX + rectWidth / 2.0d - 5.0d, lowVal,\r\n rectX + rectWidth / 2.0d + 5.0d, lowVal);\r\n g2.draw(line);\r\n+ }\r\n \r\n CategoryItemLabelGenerator generator = getItemLabelGenerator(row, \r\n column);\r\n",
"failingTests": [
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullMeanVertical"
},
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullDeviationVertical"
},
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullMeanHorizontal"
},
{
"className": " org.jfree.chart.renderer.category.junit.StatisticalBarRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDrawWithNullDeviationHorizontal"
}
],
"metrics": {
"chunks": 6,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 14,
"spreadAllLines": 226,
"spreadCodeOnly": 185
},
"observations": "",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missNullCheckN",
"missNullCheckP",
"wrapsIf",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "164"
},
{
"bugId": 23,
"changedFiles": {
"org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java": {
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java\n+++ b/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java\n@@ -432,6 +432,25 @@ public void drawItem(Graphics2D g2, CategoryItemRendererState state,\n *\r\n * @since 1.0.7\r\n */\r\n+ public boolean equals(Object obj) {\r\n+ if (obj == this) {\r\n+ return true;\r\n+ }\r\n+ if (!(obj instanceof MinMaxCategoryRenderer)) {\r\n+ return false;\r\n+ }\r\n+ MinMaxCategoryRenderer that = (MinMaxCategoryRenderer) obj;\r\n+ if (this.plotLines != that.plotLines) {\r\n+ return false;\r\n+ }\r\n+ if (!PaintUtilities.equal(this.groupPaint, that.groupPaint)) {\r\n+ return false;\r\n+ }\r\n+ if (!this.groupStroke.equals(that.groupStroke)) {\r\n+ return false;\r\n+ }\r\n+ return super.equals(obj);\r\n+ }\r\n \r\n /**\r\n * Returns an icon.\r\n",
"failingTests": [
{
"className": " org.jfree.chart.renderer.category.junit.MinMaxCategoryRendererTests",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEquals"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 19,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "I don't know if it makes sense to describe everything made in a method definition... specially in cases like that, where many lines of code with specific logic are commited.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"mdAdd",
"mdOverride",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrongComp"
],
"repairTools": [],
"revisionId": "210"
},
{
"bugId": 24,
"changedFiles": {
"org/jfree/chart/renderer/GrayPaintScale.java": {
"changes": [
[
126
]
]
}
},
"diff": "--- a/source/org/jfree/chart/renderer/GrayPaintScale.java\n+++ b/source/org/jfree/chart/renderer/GrayPaintScale.java\n@@ -123,7 +123,7 @@ public double getUpperBound() {\n public Paint getPaint(double value) {\r\n double v = Math.max(value, this.lowerBound);\r\n v = Math.min(v, this.upperBound);\r\n- int g = (int) ((value - this.lowerBound) / (this.upperBound \r\n+ int g = (int) ((v - this.lowerBound) / (this.upperBound \r\n - this.lowerBound) * 255.0);\r\n return new Color(g, g, g);\r\n }\r\n",
"failingTests": [
{
"className": " org.jfree.chart.renderer.junit.GrayPaintScaleTests",
"error": "java.lang.IllegalArgumentException",
"message": "Color parameter outside of expected range: Red Green Blue",
"methodName": "testGetPaint"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaces variable in an assignment expression.",
"program": "jfreechart",
"project": "Chart",
"repairActions": [
"assignExpChange",
"varReplVar"
],
"repairPatterns": [
"expArithMod",
"singleLine",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtJAID",
"rtssFix"
],
"revisionId": "190"
},
{
"bugId": 3,
"changedFiles": {
"com/google/javascript/jscomp/FlowSensitiveInlineVariables.java": {
"changes": [
[
155
],
[
280
]
],
"inserts": [
[
368,
375
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n+++ b/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n@@ -152,7 +152,7 @@ public void enterScope(NodeTraversal t) {\n reachingUses = new MaybeReachingVariableUse(cfg, t.getScope(), compiler);\n reachingUses.analyze();\n for (Candidate c : candidates) {\n- if (c.canInline()) {\n+ if (c.canInline(t.getScope())) {\n c.inlineVariable();\n \n // If definition c has dependencies, then inlining it may have\n@@ -277,7 +277,7 @@ private Node getDefCfgNode() {\n return defMetadata.node;\n }\n \n- private boolean canInline() {\n+ private boolean canInline(final Scope scope) {\n // Cannot inline a parameter.\n if (getDefCfgNode().isFunction()) {\n return false;\n@@ -372,6 +372,12 @@ public boolean apply(Node input) {\n case Token.REGEXP:\n case Token.NEW:\n return true;\n+ case Token.NAME:\n+ Var var = scope.getOwnSlot(input.getString());\n+ if (var != null\n+ && var.getParentNode().isCatch()) {\n+ return true;\n+ }\n }\n return false;\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoNotInlineCatchExpression1a"
},
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoNotInlineCatchExpression1"
},
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoNotInlineCatchExpression3"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 1,
"linesAdd": 6,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 218,
"spreadCodeOnly": 119
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranCaseAdd",
"condBranIfAdd",
"condExpMod",
"mcAdd",
"mcParAdd",
"mcRepl",
"mdParAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "d80fcc04239ab8c4cf781273c4f9bc54cf06f479"
},
{
"bugId": 7,
"changedFiles": {
"com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java": {
"changes": [
[
613
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java\n+++ b/src/com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java\n@@ -610,9 +610,13 @@ public JSType caseNumberType() {\n public JSType caseObjectType(ObjectType type) {\n if (value.equals(\"function\")) {\n JSType ctorType = getNativeType(U2U_CONSTRUCTOR_TYPE);\n- return resultEqualsValue && ctorType.isSubtype(type) ? ctorType : null;\n+ if (resultEqualsValue) {\n // Objects are restricted to \"Function\", subtypes are left\n+ return ctorType.getGreatestSubtype(type);\n+ } else {\n // Only filter out subtypes of \"function\"\n+ return type.isSubtype(ctorType) ? null : type;\n+ }\n }\n return matchesExpectation(\"object\") ? type : null;\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ClosureReverseAbstractInterpreterTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: (Object|boolean|number|string)",
"methodName": "testGoogIsFunction2"
},
{
"className": " com.google.javascript.jscomp.SemanticReverseAbstractInterpreterTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: (Object|boolean|number|string)",
"methodName": "testTypeof3"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 2,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"retRem"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicReduce",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtNopol"
],
"revisionId": "e736b1c92981fafdc87f3f41f66918305f173734"
},
{
"bugId": 5,
"changedFiles": {
"com/google/javascript/jscomp/InlineObjectLiterals.java": {
"inserts": [
[
173,
174,
175,
176,
177,
178,
179,
180,
181,
182,
183,
184,
185
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n+++ b/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n@@ -173,6 +173,9 @@ private boolean isInlinableObject(List<Reference> refs) {\n \n // Deleting a property has different semantics from deleting\n // a variable, so deleted properties should not be inlined.\n+ if (gramps.isDelProp()) {\n+ return false;\n+ }\n \n // NOTE(nicksantos): This pass's object-splitting algorithm has\n // a blind spot. It assumes that if a property isn't defined on an\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineDeletedProperties"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtDynaMoth",
"rtJAID",
"rtNopol"
],
"revisionId": "59eec92e364b2ec2cec9dd63449f5c0134983f18"
},
{
"bugId": 6,
"changedFiles": {
"com/google/javascript/jscomp/TypeValidator.java": {
"deletes": [
[
366
],
[
367
],
[
368
],
[
385
],
[
405
],
[
406
],
[
407
],
[
409
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeValidator.java\n+++ b/src/com/google/javascript/jscomp/TypeValidator.java\n@@ -363,9 +363,6 @@ boolean expectCanAssignToPropertyOf(NodeTraversal t, Node n, JSType rightType,\n JSType leftType, Node owner, String propName) {\n // The NoType check is a hack to make typedefs work OK.\n if (!leftType.isNoType() && !rightType.canAssignTo(leftType)) {\n- if ((leftType.isConstructor() || leftType.isEnumType()) && (rightType.isConstructor() || rightType.isEnumType())) {\n- registerMismatch(rightType, leftType, null);\n- } else {\n // Do not type-check interface methods, because we expect that\n // they will have dummy implementations that do not match the type\n // annotations.\n@@ -382,7 +379,6 @@ boolean expectCanAssignToPropertyOf(NodeTraversal t, Node n, JSType rightType,\n \"assignment to property \" + propName + \" of \" +\n getReadableJSTypeName(owner, true),\n rightType, leftType);\n- }\n return false;\n }\n return true;\n@@ -402,11 +398,7 @@ boolean expectCanAssignToPropertyOf(NodeTraversal t, Node n, JSType rightType,\n boolean expectCanAssignTo(NodeTraversal t, Node n, JSType rightType,\n JSType leftType, String msg) {\n if (!rightType.canAssignTo(leftType)) {\n- if ((leftType.isConstructor() || leftType.isEnumType()) && (rightType.isConstructor() || rightType.isEnumType())) {\n- registerMismatch(rightType, leftType, null);\n- } else {\n mismatch(t, n, msg, rightType, leftType);\n- }\n return false;\n }\n return true;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LooseTypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<1>",
"methodName": "testTypeRedefinition"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testIssue635b"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warning(s) : JSC_DUP_VAR_DECLARATION. variable a.A redefined with type function (new:a.A): undefined, original definition at [testcode]:1 with type enum{a.A} at [testcode] line 1 : 61 expected:<2> but was:<1>",
"methodName": "testTypeRedefinition"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 8,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 36,
"spreadCodeOnly": 20
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranRem",
"mcRem"
],
"repairPatterns": [
"copyPaste",
"unwrapIfElse"
],
"repairTools": [],
"revisionId": "9f7a353385bf0b93cdaeaa56cc5b1450db790127"
},
{
"bugId": 2,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"inserts": [
[
1572,
1573,
1574
],
[
1575
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -1569,9 +1569,13 @@ private void checkInterfaceConflictProperties(NodeTraversal t, Node n,\n ObjectType interfaceType) {\n ObjectType implicitProto = interfaceType.getImplicitPrototype();\n Set<String> currentPropertyNames;\n+ if (implicitProto == null) {\n // This can be the case if interfaceType is proxy to a non-existent\n // object (which is a bad type annotation, but shouldn't crash).\n+ currentPropertyNames = ImmutableSet.of();\n+ } else {\n currentPropertyNames = implicitProto.getOwnPropertyNames();\n+ }\n for (String name : currentPropertyNames) {\n ObjectType oType = properties.get(name);\n if (oType != null) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testBadInterfaceExtendsNonExistentInterfaces"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 3,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"mcAdd"
],
"repairPatterns": [
"missNullCheckP",
"wrapsIfElse"
],
"repairTools": [
"rtNopol"
],
"revisionId": "d1cfe67977d8f3aaa85ec20c262171da394d5977"
},
{
"bugId": 1,
"changedFiles": {
"com/google/javascript/jscomp/RemoveUnusedVars.java": {
"inserts": [
[
370,
371,
372,
373,
374,
375,
376,
377,
378,
379,
380
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/RemoveUnusedVars.java\n+++ b/src/com/google/javascript/jscomp/RemoveUnusedVars.java\n@@ -376,6 +376,9 @@ private void removeUnreferencedFunctionArgs(Scope fnScope) {\n // is removing globals, then it's OK to remove unused function args.\n //\n // See http://code.google.com/p/closure-compiler/issues/detail?id=253\n+ if (!removeGlobals) {\n+ return;\n+ }\n \n Node function = fnScope.getRootNode();\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSimpleModeLeavesUnusedParams"
},
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testForwardDeclareDroppedTypes"
},
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDebugFlag1"
},
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue787"
},
{
"className": " com.google.javascript.jscomp.RemoveUnusedVarsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRemoveGlobal1"
},
{
"className": " com.google.javascript.jscomp.RemoveUnusedVarsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRemoveGlobal2"
},
{
"className": " com.google.javascript.jscomp.RemoveUnusedVarsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRemoveGlobal3"
},
{
"className": " com.google.javascript.jscomp.RemoveUnusedVarsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue168b"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "1dfad5043a207e032a78ef50c3cba50488bcd300"
},
{
"bugId": 4,
"changedFiles": {
"com/google/javascript/rhino/jstype/NamedType.java": {
"changes": [
[
190
],
[
202
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/NamedType.java\n+++ b/src/com/google/javascript/rhino/jstype/NamedType.java\n@@ -187,7 +187,7 @@ JSType resolveInternal(ErrorReporter t, StaticScope<JSType> enclosing) {\n // makes more sense. Now, resolution via registry is first in order to\n // avoid triggering the warnings built into the resolution via properties.\n boolean resolved = resolveViaRegistry(t, enclosing);\n- if (detectImplicitPrototypeCycle()) {\n+ if (detectInheritanceCycle()) {\n handleTypeCycle(t);\n }\n \n@@ -199,7 +199,7 @@ JSType resolveInternal(ErrorReporter t, StaticScope<JSType> enclosing) {\n }\n \n resolveViaProperties(t, enclosing);\n- if (detectImplicitPrototypeCycle()) {\n+ if (detectInheritanceCycle()) {\n handleTypeCycle(t);\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warning(s) : JSC_IMPLEMENTS_NON_INTERFACE. can only implement interfaces at [testcode] line 2 : 29, JSC_IMPLEMENTS_NON_INTERFACE. can only implement interfaces at [testcode] line 3 : 26 expected:<1> but was:<2>",
"methodName": "testImplementsExtendsLoop"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[Parse error. Cycle detected in inheritance chain of type T]> but was:<[can only implement interfaces]>",
"methodName": "testImplementsLoop"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "java.lang.StackOverflowError",
"message": "",
"methodName": "testConversionFromInterfaceToRecursiveConstructor"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 11,
"spreadCodeOnly": 9
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpMod",
"mcRepl"
],
"repairPatterns": [
"copyPaste",
"expLogicMod",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "efefb736fccc2039b5fb079710b3f2ac82b8c6e4"
},
{
"bugId": 8,
"changedFiles": {
"com/google/javascript/jscomp/CollapseVariableDeclarations.java": {
"changes": [
[
202
],
[
203
],
[
204
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CollapseVariableDeclarations.java\n+++ b/src/com/google/javascript/jscomp/CollapseVariableDeclarations.java\n@@ -201,10 +201,14 @@ private boolean canBeRedeclared(Node n, Scope s) {\n Var var = s.getVar(lhs.getString());\n return var != null\n && var.getScope() == s\n+ && !isNamedParameter(var)\n && !blacklistedVars.contains(var);\n }\n }\n \n+ private boolean isNamedParameter(Var v) {\n+ return v.getParentNode().isParamList();\n+ }\n \n private void applyCollapses() {\n for (Collapse collapse : collapses) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CollapseVariableDeclarationsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue820"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 4,
"spreadAllLines": 4,
"spreadCodeOnly": 3
},
"observations": "Adds a new condition in expression and a new method invocated by this condition.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"mdAdd",
"retBranchAdd",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "6300a43566d4adcf8828128267808a8740edc835"
},
{
"bugId": 9,
"changedFiles": {
"com/google/javascript/jscomp/ProcessCommonJSModules.java": {
"changes": [
[
183
]
],
"inserts": [
[
117,
118,
119,
120
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ProcessCommonJSModules.java\n+++ b/src/com/google/javascript/jscomp/ProcessCommonJSModules.java\n@@ -116,6 +116,7 @@ public static String toModuleName(String requiredFilename,\n private String normalizeSourceName(String filename) {\n // The DOS command shell will normalize \"/\" to \"\\\", so we have to\n // wrestle it back.\n+ filename = filename.replace(\"\\\\\", \"/\");\n \n if (filename.indexOf(filenamePrefix) == 0) {\n filename = filename.substring(filenamePrefix.length());\n@@ -180,7 +181,7 @@ private void visitScript(NodeTraversal t, Node script) {\n Preconditions.checkArgument(scriptNodeCount == 1,\n \"ProcessCommonJSModules supports only one invocation per \" +\n \"CompilerInput / script node\");\n- String moduleName = guessCJSModuleName(normalizeSourceName(script.getSourceFileName()));\n+ String moduleName = guessCJSModuleName(script.getSourceFileName());\n script.addChildToFront(IR.var(IR.name(moduleName), IR.objectlit())\n .copyInformationFromForTree(script));\n if (reportDependencies) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<module$[]baz> but was:<module$[foo\\]baz>",
"methodName": "testGuessModuleName"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 64,
"spreadCodeOnly": 43
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"mcAdd",
"mcParValChange",
"mcRem"
],
"repairPatterns": [
"missComp",
"unwrapMethod"
],
"repairTools": [],
"revisionId": "e9c15465c000c19ef4e0b8f68a680589ae4111d7"
},
{
"bugId": 11,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"deletes": [
[
1314
],
[
1315
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -1311,8 +1311,6 @@ private void visitGetProp(NodeTraversal t, Node n, Node parent) {\n \n if (childType.isDict()) {\n report(t, property, TypeValidator.ILLEGAL_PROPERTY_ACCESS, \"'.'\", \"dict\");\n- } else if (n.getJSType() != null && parent.isAssign()) {\n- return;\n } else if (validator.expectNotNullOrUndefined(t, n, childType,\n \"No properties on this expression\", getNativeType(OBJECT_TYPE))) {\n checkPropertyAccess(childType, property.getString(), t, n);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testGetprop4"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testIssue810"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 2,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranRem",
"mcRem",
"retRem"
],
"repairPatterns": [
"condBlockRem"
],
"repairTools": [],
"revisionId": "482b767639e6eec7c30d8898851560c41b66d885"
},
{
"bugId": 12,
"changedFiles": {
"com/google/javascript/jscomp/MaybeReachingVariableUse.java": {
"inserts": [
[
160
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/MaybeReachingVariableUse.java\n+++ b/src/com/google/javascript/jscomp/MaybeReachingVariableUse.java\n@@ -157,6 +157,12 @@ ReachingUses flowThrough(Node n, ReachingUses input) {\n }\n \n private boolean hasExceptionHandler(Node cfgNode) {\n+ List<DiGraphEdge<Node, Branch>> branchEdges = getCfg().getOutEdges(cfgNode);\n+ for (DiGraphEdge<Node, Branch> edge : branchEdges) {\n+ if (edge.getValue() == Branch.ON_EX) {\n+ return true;\n+ }\n+ }\n return false;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue794b"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "d06ac163013a3779fcec7c2f544ba99d08f69f58"
},
{
"bugId": 10,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"changes": [
[
1417
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -1414,7 +1414,7 @@ static boolean mayBeString(Node n) {\n \n static boolean mayBeString(Node n, boolean recurse) {\n if (recurse) {\n- return allResultsMatch(n, MAY_BE_STRING_PREDICATE);\n+ return anyResultsMatch(n, MAY_BE_STRING_PREDICATE);\n } else {\n return mayBeStringHelper(n);\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue821"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtHDRepair",
"rtNopol"
],
"revisionId": "0884a4cbef1c82153ef306477a12af0480385a35"
},
{
"bugId": 14,
"changedFiles": {
"com/google/javascript/jscomp/ControlFlowAnalysis.java": {
"changes": [
[
767
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ControlFlowAnalysis.java\n+++ b/src/com/google/javascript/jscomp/ControlFlowAnalysis.java\n@@ -764,7 +764,7 @@ private static Node computeFollowNode(\n } else if (parent.getLastChild() == node){\n if (cfa != null) {\n for (Node finallyNode : cfa.finallyMap.get(parent)) {\n- cfa.createEdge(fromNode, Branch.UNCOND, finallyNode);\n+ cfa.createEdge(fromNode, Branch.ON_EX, finallyNode);\n }\n }\n return computeFollowNode(fromNode, parent, cfa);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckMissingReturnTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_MISSING_RETURN_STATEMENT. Missing return statement. Function expected to return number. at testcode line 1 : 24 expected:<0> but was:<1>",
"methodName": "testIssue779"
},
{
"className": " com.google.javascript.jscomp.ControlFlowAnalysisTest",
"error": "junit.framework.AssertionFailedError",
"message": "No cross edges found",
"methodName": "testDeepNestedFinally"
},
{
"className": " com.google.javascript.jscomp.ControlFlowAnalysisTest",
"error": "junit.framework.AssertionFailedError",
"message": "No cross edges found",
"methodName": "testDeepNestedBreakwithFinally"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Parameter value change.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"constChange",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtHDRepair",
"rtNopol",
"rtssFix"
],
"revisionId": "4b15b25f400335b6e2820cb690430324748372f9"
},
{
"bugId": 17,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"changes": [
[
1291
]
],
"inserts": [
[
1292,
1293,
1294,
1295
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -1288,8 +1288,12 @@ private JSType getDeclaredType(String sourceName, JSDocInfo info,\n if (info.isConstant()) {\n JSType knownType = null;\n if (rValue != null) {\n- if (rValue.getJSType() != null && !rValue.getJSType().isUnknownType()) {\n+ JSDocInfo rValueInfo = rValue.getJSDocInfo();\n+ if (rValueInfo != null && rValueInfo.hasType()) {\n // If rValue has a type-cast, we use the type in the type-cast.\n+ return rValueInfo.getType().evaluate(scope, typeRegistry);\n+ } else if (rValue.getJSType() != null\n+ && !rValue.getJSType().isUnknownType()) {\n // If rValue's type was already computed during scope creation,\n // then we can safely use that.\n return rValue.getJSType();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<in[consistent return type",
"methodName": "testIssue688"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "Transform If structure in Wrap-with IfElse.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "33ab4df84afbdb36216b8a1ea3a526c438615e26"
},
{
"bugId": 13,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeOptimizationsPass.java": {
"deletes": [
[
126
]
],
"inserts": [
[
128
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeOptimizationsPass.java\n+++ b/src/com/google/javascript/jscomp/PeepholeOptimizationsPass.java\n@@ -123,8 +123,8 @@ private void traverse(Node node) {\n do {\n Node c = node.getFirstChild();\n while(c != null) {\n- traverse(c);\n Node next = c.getNext();\n+ traverse(c);\n c = next;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue787"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 1,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "Only one line of code was moved.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcMove"
],
"repairPatterns": [
"codeMove",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth"
],
"revisionId": "d6d733f461ee5ba26e9326c1c7609f1f00d6d2db"
},
{
"bugId": 21,
"changedFiles": {
"com/google/javascript/jscomp/CheckSideEffects.java": {
"changes": [
[
101
],
[
130
]
],
"deletes": [
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
118
],
[
119
],
[
120
],
[
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
],
[
129
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckSideEffects.java\n+++ b/src/com/google/javascript/jscomp/CheckSideEffects.java\n@@ -98,7 +98,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n // Do not try to remove a block or an expr result. We already handle\n // these cases when we visit the child, and the peephole passes will\n // fix up the tree in more clever ways when these are removed.\n- if (n.isExprResult()) {\n+ if (n.isExprResult() || n.isBlock()) {\n return;\n }\n \n@@ -110,24 +110,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n \n boolean isResultUsed = NodeUtil.isExpressionResultUsed(n);\n boolean isSimpleOp = NodeUtil.isSimpleOperatorType(n.getType());\n- if (parent.getType() == Token.COMMA) {\n- if (isResultUsed) {\n- return;\n- }\n- if (n == parent.getLastChild()) {\n- for (Node an : parent.getAncestors()) {\n- int ancestorType = an.getType();\n- if (ancestorType == Token.COMMA) continue;\n- if (ancestorType != Token.EXPR_RESULT && ancestorType != Token.BLOCK) return;\n- else break;\n- }\n- }\n- } else if (parent.getType() != Token.EXPR_RESULT && parent.getType() != Token.BLOCK) {\n- if (! (parent.getType() == Token.FOR && parent.getChildCount() == 4 && (n == parent.getFirstChild() || n == parent.getFirstChild().getNext().getNext()))) {\n- return;\n- }\n- }\n- if (\n+ if (!isResultUsed &&\n (isSimpleOp || !NodeUtil.mayHaveSideEffects(n, t.getCompiler()))) {\n String msg = \"This code lacks side-effects. Is there a bug?\";\n if (n.isString()) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckSideEffectsTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one warning, repeated 1 time(s). expected:<1> but was:<0>",
"methodName": "testUselessCode"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 17,
"methods": 1,
"sizeInLines": 19,
"spreadAllLines": 11,
"spreadCodeOnly": 7
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranRem",
"condExpExpand",
"loopRem",
"mcAdd",
"mcRem",
"retRem",
"varRem"
],
"repairPatterns": [
"condBlockRem",
"expLogicExpand",
"expLogicMod",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "1787d7b2cff83a0f177dd958033c53e4502406d2"
},
{
"bugId": 15,
"changedFiles": {
"com/google/javascript/jscomp/FlowSensitiveInlineVariables.java": {
"inserts": [
[
101,
102,
103
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n+++ b/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n@@ -99,6 +99,9 @@ public boolean apply(Node n) {\n return true;\n }\n \n+ if (n.isDelProp()) {\n+ return true;\n+ }\n \n for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {\n if (!ControlFlowGraph.isEnteringNewCfgNode(c) && apply(c)) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSimpleForIn"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtNopol"
],
"revisionId": "968b3f467f51c6bfec18af1fbcf980a0f19a1fb3"
},
{
"bugId": 16,
"changedFiles": {
"com/google/javascript/jscomp/ScopedAliases.java": {
"changes": [
[
172
],
[
180
],
[
468
]
],
"inserts": [
[
-1
],
[
174,
175,
176
],
[
180
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ScopedAliases.java\n+++ b/src/com/google/javascript/jscomp/ScopedAliases.java\n@@ -167,17 +167,23 @@ public void applyAlias() {\n \n private class AliasedTypeNode implements AliasUsage {\n private final Node typeReference;\n+ private final Node aliasDefinition;\n private final String aliasName;\n \n- AliasedTypeNode(Node typeReference,\n+ AliasedTypeNode(Node typeReference, Node aliasDefinition,\n String aliasName) {\n this.typeReference = typeReference;\n+ this.aliasDefinition = aliasDefinition;\n this.aliasName = aliasName;\n }\n \n @Override\n public void applyAlias() {\n- typeReference.setString(aliasName);\n+ String typeName = typeReference.getString();\n+ String aliasExpanded =\n+ Preconditions.checkNotNull(aliasDefinition.getQualifiedName());\n+ Preconditions.checkState(typeName.startsWith(aliasName));\n+ typeReference.setString(typeName.replaceFirst(aliasName, aliasExpanded));\n }\n }\n \n@@ -465,7 +471,7 @@ private void fixTypeNode(Node typeNode) {\n Var aliasVar = aliases.get(baseName);\n if (aliasVar != null) {\n Node aliasedNode = aliasVar.getInitialValue();\n- aliasUsages.add(new AliasedTypeNode(typeNode, aliasedNode.getQualifiedName() + name.substring(endIndex)));\n+ aliasUsages.add(new AliasedTypeNode(typeNode, aliasedNode, baseName));\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected no warnings or errors",
"methodName": "testIssue772"
},
{
"className": " com.google.javascript.jscomp.ScopedAliasesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: Node tree inequality:",
"methodName": "testIssue772"
}
],
"metrics": {
"chunks": 5,
"classes": 2,
"files": 1,
"linesAdd": 6,
"linesMod": 3,
"linesRem": 0,
"methods": 3,
"sizeInLines": 9,
"spreadAllLines": 296,
"spreadCodeOnly": 217
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"mcAdd",
"mcParAdd",
"mcParValChange",
"mcRepl",
"mdParAdd",
"objInstMod",
"varAdd"
],
"repairPatterns": [
"initFix",
"wrapsMethod",
"wrongComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "3b97e5e4212c769daa22a96094ed19b4658c8760"
},
{
"bugId": 18,
"changedFiles": {
"com/google/javascript/jscomp/Compiler.java": {
"changes": [
[
1288
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Compiler.java\n+++ b/src/com/google/javascript/jscomp/Compiler.java\n@@ -1285,7 +1285,7 @@ Node parseInputs() {\n \n // Check if the sources need to be re-ordered.\n boolean staleInputs = false;\n- if (options.dependencyOptions.needsManagement() && options.closurePass) {\n+ if (options.dependencyOptions.needsManagement()) {\n for (CompilerInput input : inputs) {\n // Forward-declare all the provided types, so that they\n // are not flagged even if they are dropped from the process.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDependencySorting"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpRed"
],
"repairPatterns": [
"expLogicReduce",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtJAID",
"rtNopol"
],
"revisionId": "ea119a2d06328852763f9ee447c3bf74fa1f83dc"
},
{
"bugId": 20,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java": {
"changes": [
[
220
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n+++ b/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n@@ -217,7 +217,8 @@ private Node tryFoldSimpleFunctionCall(Node n) {\n // slightly different semantics than '' + (a). See\n // http://code.google.com/p/closure-compiler/issues/detail?id=759\n Node value = callTarget.getNext();\n- if (value != null) {\n+ if (value != null && value.getNext() == null &&\n+ NodeUtil.isImmutableValue(value)) {\n Node addition = IR.add(\n IR.string(\"\").srcref(callTarget),\n value.detachFromParent());\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeSubstituteAlternateSyntaxTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSimpleFunctionCall"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"missNullCheckP",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "ebf229b05f4ee71bc05d70830f5dd5683271d661"
},
{
"bugId": 19,
"changedFiles": {
"com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java": {
"inserts": [
[
159,
162,
163,
171,
172,
173,
174
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java\n+++ b/src/com/google/javascript/jscomp/type/ChainableReverseAbstractInterpreter.java\n@@ -169,7 +169,9 @@ protected void declareNameInScope(FlowScope scope, Node node, JSType type) {\n scope.inferQualifiedSlot(node, qualifiedName, origType, type);\n break;\n \n+ case Token.THIS:\n // \"this\" references aren't currently modeled in the CFG.\n+ break;\n \n default:\n throw new IllegalArgumentException(\"Node cannot be refined. \\n\" +\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeInferenceTest",
"error": "java.lang.IllegalArgumentException",
"message": "Node cannot be refined. ",
"methodName": "testNoThisInference"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [
"rtDynaMoth"
],
"revisionId": "686146c4de7d2bd985156ae15175365633dd0f94"
},
{
"bugId": 23,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeFoldConstants.java": {
"changes": [
[
1451
]
],
"inserts": [
[
1452
],
[
1453,
1454
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n+++ b/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n@@ -1448,8 +1448,14 @@ private Node tryFoldArrayAccess(Node n, Node left, Node right) {\n \n Node current = left.getFirstChild();\n Node elem = null;\n- for (int i = 0; current != null && i < intIndex; i++) {\n+ for (int i = 0; current != null; i++) {\n+ if (i != intIndex) {\n+ if (mayHaveSideEffects(current)) {\n+ return n;\n+ }\n+ } else {\n elem = current;\n+ }\n \n current = current.getNext();\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_INDEX_OUT_OF_BOUNDS_ERROR. Array index out of bounds: NUMBER 0.0 1 [source_file: testcode] at testcode line 1 : 10 expected:<0> but was:<1>",
"methodName": "testFoldGetElem"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"condBranIfElseAdd",
"loopCondChange",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"expLogicReduce",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "b59cdd9e2dc64d2db86b90982c200a78f2f85e50"
},
{
"bugId": 24,
"changedFiles": {
"com/google/javascript/jscomp/ScopedAliases.java": {
"inserts": [
[
287,
288,
289,
290,
291
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ScopedAliases.java\n+++ b/src/com/google/javascript/jscomp/ScopedAliases.java\n@@ -275,8 +275,8 @@ private void findAliases(NodeTraversal t) {\n Node n = v.getNode();\n int type = n.getType();\n Node parent = n.getParent();\n- if (parent.isVar()) {\n- if (n.hasChildren() && n.getFirstChild().isQualifiedName()) {\n+ if (parent.isVar() &&\n+ n.hasChildren() && n.getFirstChild().isQualifiedName()) {\n String name = n.getString();\n Var aliasVar = scope.getVar(name);\n aliases.put(name, aliasVar);\n@@ -284,15 +284,16 @@ private void findAliases(NodeTraversal t) {\n String qualifiedName =\n aliasVar.getInitialValue().getQualifiedName();\n transformation.addAlias(name, qualifiedName);\n+ } else if (v.isBleedingFunction()) {\n // Bleeding functions already get a BAD_PARAMETERS error, so just\n // do nothing.\n+ } else if (parent.getType() == Token.LP) {\n // Parameters of the scope function also get a BAD_PARAMETERS\n // error.\n } else {\n // TODO(robbyw): Support using locals for private variables.\n report(t, n, GOOG_SCOPE_NON_ALIAS_LOCAL, n.getString());\n }\n- }\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ScopedAliasesTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testNonAliasLocal"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 2,
"linesRem": 1,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 15,
"spreadCodeOnly": 9
},
"observations": "Again, a kind of Wrap-with-IfElse where some conditionals were missing.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"condBranRem",
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand",
"missComp"
],
"repairTools": [],
"revisionId": "70ca6014779735bdc52ca0e80e528257829a15e7"
},
{
"bugId": 22,
"changedFiles": {
"com/google/javascript/jscomp/CheckSideEffects.java": {
"changes": [
[
101
],
[
102
],
[
103
],
[
104
],
[
105
],
[
106
],
[
107
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
118
],
[
119
],
[
120
],
[
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
]
],
"deletes": [
[
134
],
[
135
],
[
136
],
[
137
],
[
138
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckSideEffects.java\n+++ b/src/com/google/javascript/jscomp/CheckSideEffects.java\n@@ -98,44 +98,20 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n // Do not try to remove a block or an expr result. We already handle\n // these cases when we visit the child, and the peephole passes will\n // fix up the tree in more clever ways when these are removed.\n- if (parent.getType() == Token.COMMA) {\n- Node gramps = parent.getParent();\n- if (gramps.isCall() && parent == gramps.getFirstChild()) {\n- if (n == parent.getFirstChild() && parent.getChildCount() == 2 && n.getNext().isName() && \"eval\".equals(n.getNext().getString())) {\n+ if (n.isExprResult() || n.isBlock()) {\n return;\n- }\n }\n \n // This no-op statement was there so that JSDoc information could\n // be attached to the name. This check should not complain about it.\n- if (n == parent.getLastChild()) {\n- for (Node an : parent.getAncestors()) {\n- int ancestorType = an.getType();\n- if (ancestorType == Token.COMMA)\n- continue;\n- if (ancestorType != Token.EXPR_RESULT && ancestorType != Token.BLOCK)\n- return;\n- else\n- break;\n- }\n- }\n- } else if (parent.getType() != Token.EXPR_RESULT && parent.getType() != Token.BLOCK) {\n- if (parent.getType() == Token.FOR && parent.getChildCount() == 4 && (n == parent.getFirstChild() ||\n- n == parent.getFirstChild().getNext().getNext())) {\n- } else {\n+ if (n.isQualifiedName() && n.getJSDocInfo() != null) {\n return;\n- }\n }\n \n boolean isResultUsed = NodeUtil.isExpressionResultUsed(n);\n boolean isSimpleOp = NodeUtil.isSimpleOperatorType(n.getType());\n if (!isResultUsed &&\n (isSimpleOp || !NodeUtil.mayHaveSideEffects(n, t.getCompiler()))) {\n- if (n.isQualifiedName() && n.getJSDocInfo() != null) {\n- return;\n- } else if (n.isExprResult()) {\n- return;\n- }\n String msg = \"This code lacks side-effects. Is there a bug?\";\n if (n.isString()) {\n msg = \"Is there a missing '+' on the previous line?\";\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckSideEffectsTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one warning, repeated 1 time(s). expected:<1> but was:<0>",
"methodName": "testUselessCode"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 24,
"methods": 1,
"sizeInLines": 26,
"spreadAllLines": 12,
"spreadCodeOnly": 8
},
"observations": "It seems that the old conditions were wrong, so a replacement was made. It simplifies too the implementation. It is similar to a Wrap-with-If operation plus a move of some conditionals.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranIfAdd",
"condBranRem",
"loopRem",
"mcAdd",
"mcRem",
"retRem",
"varRem"
],
"repairPatterns": [
"condBlockRem",
"expLogicMod",
"missNullCheckN",
"unwrapIfElse",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "43a55234ef122a1ed98681ce0350506207b878d5"
},
{
"bugId": 26,
"changedFiles": {
"com/google/javascript/jscomp/ProcessCommonJSModules.java": {
"inserts": [
[
-1
],
[
207,
208
],
[
228
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ProcessCommonJSModules.java\n+++ b/src/com/google/javascript/jscomp/ProcessCommonJSModules.java\n@@ -125,6 +125,7 @@ private String normalizeSourceName(String filename) {\n AbstractPostOrderCallback {\n \n private int scriptNodeCount = 0;\n+ private Set<String> modulesWithExports = Sets.newHashSet();\n \n @Override\n public void visit(NodeTraversal t, Node n, Node parent) {\n@@ -204,6 +205,9 @@ private void visitScript(NodeTraversal t, Node script) {\n */\n private void emitOptionalModuleExportsOverride(Node script,\n String moduleName) {\n+ if (!modulesWithExports.contains(moduleName)) {\n+ return;\n+ }\n \n Node moduleExportsProp = IR.getprop(IR.name(moduleName),\n IR.string(\"module$exports\"));\n@@ -225,6 +229,7 @@ private void visitModuleExports(Node prop) {\n Node exports = prop.getChildAtIndex(1);\n exports.putProp(Node.ORIGINALNAME_PROP, \"exports\");\n exports.setString(\"module$exports\");\n+ modulesWithExports.add(moduleName);\n }\n \n /**\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTransformAMDAndProcessCJS"
},
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testProcessCJS"
},
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testExports"
},
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testModuleName"
},
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDash"
},
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testVarRenaming"
},
{
"className": " com.google.javascript.jscomp.ProcessCommonJSModulesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testWithoutExports"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 100,
"spreadCodeOnly": 71
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "372eb11e44b8559004bfe78a5b4003caf0072135"
},
{
"bugId": 25,
"changedFiles": {
"com/google/javascript/jscomp/TypeInference.java": {
"deletes": [
[
1038
],
[
1059
],
[
1060
],
[
1061
]
],
"inserts": [
[
1036,
1037
],
[
1055
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeInference.java\n+++ b/src/com/google/javascript/jscomp/TypeInference.java\n@@ -1033,9 +1033,9 @@ private void updateTypeOfThisOnClosure(Node n, FunctionType fnType) {\n }\n \n private FlowScope traverseNew(Node n, FlowScope scope) {\n+ scope = traverseChildren(n, scope);\n \n Node constructor = n.getFirstChild();\n- scope = traverse(constructor, scope);\n JSType constructorType = constructor.getJSType();\n JSType type = null;\n if (constructorType != null) {\n@@ -1052,13 +1052,11 @@ private FlowScope traverseNew(Node n, FlowScope scope) {\n }\n if (ct != null && ct.isConstructor()) {\n type = ct.getInstanceType();\n+ backwardsInferenceFromCallSite(n, ct);\n }\n }\n }\n n.setJSType(type);\n- for (Node arg = constructor.getNext(); arg != null; arg = arg.getNext()) {\n- scope = traverse(arg, scope);\n- }\n return scope;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeInferenceTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<{[foo: (number|undefined)]}> but was:<{[]}>",
"methodName": "testBackwardsInferenceNew"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 4,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 22,
"spreadCodeOnly": 18
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"assignRem",
"loopRem",
"mcAdd",
"mcRem"
],
"repairPatterns": [
"blockRemove",
"notClassified"
],
"repairTools": [],
"revisionId": "2e904fcdc3bc09e3bff557fcfca383ba7e450095"
},
{
"bugId": 27,
"changedFiles": {
"com/google/javascript/rhino/IR.java": {
"changes": [
[
224
],
[
225
],
[
233
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/IR.java\n+++ b/src/com/google/javascript/rhino/IR.java\n@@ -108,6 +108,9 @@ public static Node block(Node ... stmts) {\n return block;\n }\n \n+ private static Node blockUnchecked(Node stmt) {\n+ return new Node(Token.BLOCK, stmt);\n+ }\n \n public static Node script(Node ... stmts) {\n // TODO(johnlenz): finish setting up the SCRIPT node\n@@ -221,8 +224,8 @@ public static Node labelName(String name) {\n }\n \n public static Node tryFinally(Node tryBody, Node finallyBody) {\n- Preconditions.checkState(tryBody.isLabelName());\n- Preconditions.checkState(finallyBody.isLabelName());\n+ Preconditions.checkState(tryBody.isBlock());\n+ Preconditions.checkState(finallyBody.isBlock());\n Node catchBody = block().copyInformationFrom(tryBody);\n return new Node(Token.TRY, tryBody, catchBody, finallyBody);\n }\n@@ -230,7 +233,7 @@ public static Node tryFinally(Node tryBody, Node finallyBody) {\n public static Node tryCatch(Node tryBody, Node catchNode) {\n Preconditions.checkState(tryBody.isBlock());\n Preconditions.checkState(catchNode.isCatch());\n- Node catchBody = block(catchNode).copyInformationFrom(catchNode);\n+ Node catchBody = blockUnchecked(catchNode).copyInformationFrom(catchNode);\n return new Node(Token.TRY, tryBody, catchBody);\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.rhino.IRTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testIssue727_1"
},
{
"className": " com.google.javascript.rhino.IRTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testIssue727_2"
},
{
"className": " com.google.javascript.rhino.IRTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testIssue727_3"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 3,
"linesRem": 0,
"methods": 3,
"sizeInLines": 6,
"spreadAllLines": 120,
"spreadCodeOnly": 99
},
"observations": "A Node object is instantiated in the call. Adds new method and replace calls.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcParValChange",
"mcRepl",
"mdAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"copyPaste",
"wrongComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "7a8983042131c5a9c2b5421ae42075cbb8ef1aeb"
},
{
"bugId": 29,
"changedFiles": {
"com/google/javascript/jscomp/InlineObjectLiterals.java": {
"inserts": [
[
156,
157
],
[
172,
173,
174,
175,
176,
177,
178,
179,
180,
181
],
[
215,
216,
217
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n+++ b/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n@@ -154,6 +154,7 @@ private boolean isVarInlineForbidden(Var var) {\n */\n private boolean isInlinableObject(List<Reference> refs) {\n boolean ret = false;\n+ Set<String> validProperties = Sets.newHashSet();\n for (Reference ref : refs) {\n Node name = ref.getNode();\n Node parent = ref.getParent();\n@@ -178,6 +179,14 @@ private boolean isInlinableObject(List<Reference> refs) {\n // We short-circuit this problem by bailing out if we see a reference\n // to a property that isn't defined on the object literal. This\n // isn't a perfect algorithm, but it should catch most cases.\n+ String propName = parent.getLastChild().getString();\n+ if (!validProperties.contains(propName)) {\n+ if (NodeUtil.isVarOrSimpleAssignLhs(parent, gramps)) {\n+ validProperties.add(propName);\n+ } else {\n+ return false;\n+ }\n+ }\n continue;\n }\n \n@@ -213,6 +222,7 @@ private boolean isInlinableObject(List<Reference> refs) {\n return false;\n }\n \n+ validProperties.add(child.getString());\n \n Node childVal = child.getFirstChild();\n // Check if childVal is the parent of any of the passed in\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testObject10"
},
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testObject12"
},
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testObject22"
},
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue724"
},
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue724"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 10,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 10,
"spreadAllLines": 59,
"spreadCodeOnly": 28
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "6924915efab89f921fd0779fe200fecc1bf80847"
},
{
"bugId": 30,
"changedFiles": {
"com/google/javascript/jscomp/FlowSensitiveInlineVariables.java": {
"changes": [
[
157
]
]
},
"com/google/javascript/jscomp/MustBeReachingVariableDef.java": {
"changes": [
[
396
]
],
"inserts": [
[
-1
],
[
398
],
[
399
],
[
430,
431
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n+++ b/src/com/google/javascript/jscomp/FlowSensitiveInlineVariables.java\n@@ -154,7 +154,7 @@ public void exitScope(NodeTraversal t) {}\n \n @Override\n public void process(Node externs, Node root) {\n- (new NodeTraversal(compiler, this)).traverse(root);\n+ (new NodeTraversal(compiler, this)).traverseRoots(externs, root);\n }\n \n @Override\n--- a/src/com/google/javascript/jscomp/MustBeReachingVariableDef.java\n+++ b/src/com/google/javascript/jscomp/MustBeReachingVariableDef.java\n@@ -68,6 +68,7 @@\n private static class Definition {\n final Node node;\n final Set<Var> depends = Sets.newHashSet();\n+ private boolean unknownDependencies = false;\n \n Definition(Node node) {\n this.node = node;\n@@ -393,9 +394,13 @@ private void computeDependence(final Definition def, Node rValue) {\n new AbstractCfgNodeTraversalCallback() {\n @Override\n public void visit(NodeTraversal t, Node n, Node parent) {\n- if (n.isName() && jsScope.isDeclared(n.getString(), true)) {\n+ if (n.isName()) {\n Var dep = jsScope.getVar(n.getString());\n+ if (dep == null) {\n+ def.unknownDependencies = true;\n+ } else {\n def.depends.add(dep);\n+ }\n }\n }\n });\n@@ -427,6 +432,9 @@ boolean dependsOnOuterScopeVars(String name, Node useNode) {\n GraphNode<Node, Branch> n = getCfg().getNode(useNode);\n FlowState<MustDef> state = n.getAnnotation();\n Definition def = state.getIn().reachingDef.get(jsScope.getVar(name));\n+ if (def.unknownDependencies) {\n+ return true;\n+ }\n \n for (Var s : def.depends) {\n if (s.scope != jsScope) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineAcrossSideEffect1"
},
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCanInlineAcrossNoSideEffect"
},
{
"className": " com.google.javascript.jscomp.FlowSensitiveInlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue698"
}
],
"metrics": {
"chunks": 6,
"classes": 3,
"files": 2,
"linesAdd": 8,
"linesMod": 2,
"linesRem": 0,
"methods": 3,
"sizeInLines": 10,
"spreadAllLines": 358,
"spreadCodeOnly": 237
},
"observations": "Adds a new class attribute with its initialization.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpRed",
"mcParAdd",
"mcRem",
"mcRepl",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicReduce",
"initFix",
"missNullCheckP",
"wrapsIfElse",
"wrongMethodRef"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "38e2b8f247423734adec3dbd76fa22da1a3561a8"
},
{
"bugId": 31,
"changedFiles": {
"com/google/javascript/jscomp/Compiler.java": {
"deletes": [
[
1285
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Compiler.java\n+++ b/src/com/google/javascript/jscomp/Compiler.java\n@@ -1282,7 +1282,6 @@ Node parseInputs() {\n \n // Check if the sources need to be re-ordered.\n if (options.dependencyOptions.needsManagement() &&\n- !options.skipAllPasses &&\n options.closurePass) {\n for (CompilerInput input : inputs) {\n // Forward-declare all the provided types, so that they\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDependencySortingWhitespaceMode"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 1,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpRed"
],
"repairPatterns": [
"expLogicReduce",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtJAID",
"rtNopol",
"rtssFix"
],
"revisionId": "0a670cb51fd56c12c19f98884c9513792ebc3f76"
},
{
"bugId": 32,
"changedFiles": {
"com/google/javascript/jscomp/parsing/JsDocInfoParser.java": {
"deletes": [
[
1414
],
[
1415
],
[
1416
]
],
"inserts": [
[
1331,
1332,
1333,
1334,
1335,
1336,
1337,
1338,
1339,
1340,
1341,
1342,
1343,
1344,
1345,
1346,
1347,
1348,
1349,
1350,
1351,
1352,
1353,
1354,
1355,
1356,
1357,
1358,
1359
],
[
1363,
1364
],
[
1380,
1381,
1382,
1383
],
[
1386,
1387,
1388,
1389,
1390,
1391
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n+++ b/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n@@ -1355,12 +1355,14 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,\n // Track the start of the line to count whitespace that\n // the tokenizer skipped. Because this case is rare, it's easier\n // to do this here than in the tokenizer.\n+ int lineStartChar = -1;\n \n do {\n switch (token) {\n case STAR:\n if (ignoreStar) {\n // Mark the position after the star as the new start of the line.\n+ lineStartChar = stream.getCharno() + 1;\n } else {\n // The star is part of the comment.\n if (builder.length() > 0) {\n@@ -1379,6 +1381,7 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,\n }\n \n ignoreStar = true;\n+ lineStartChar = 0;\n token = next();\n continue;\n \n@@ -1386,7 +1389,19 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,\n ignoreStar = false;\n state = State.SEARCHING_ANNOTATION;\n \n+ boolean isEOC = token == JsDocToken.EOC;\n+ if (!isEOC) {\n+ if (lineStartChar != -1 && option == WhitespaceOption.PRESERVE) {\n+ int numSpaces = stream.getCharno() - lineStartChar;\n+ for (int i = 0; i < numSpaces; i++) {\n+ builder.append(' ');\n+ }\n+ lineStartChar = -1;\n+ } else if (builder.length() > 0) {\n // All tokens must be separated by a space.\n+ builder.append(' ');\n+ }\n+ }\n \n if (token == JsDocToken.EOC ||\n token == JsDocToken.EOF ||\n@@ -1411,9 +1426,6 @@ private ExtractionInfo extractMultilineTextualBlock(JsDocToken token,\n return new ExtractionInfo(multilineText, token);\n }\n \n- if (builder.length() > 0) {\n- builder.append(' ');\n- }\n builder.append(toString(token));\n \n line = stream.getRemainingJSDocLine();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:</*",
"methodName": "testIssue701"
},
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:< Foo",
"methodName": "testParseLicense"
},
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:< Foo",
"methodName": "testParsePreserve"
},
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:< Foo",
"methodName": "testParseLicenseAscii"
}
],
"metrics": {
"chunks": 6,
"classes": 1,
"files": 1,
"linesAdd": 15,
"linesMod": 0,
"linesRem": 3,
"methods": 1,
"sizeInLines": 18,
"spreadAllLines": 56,
"spreadCodeOnly": 38
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condBranRem",
"loopAdd",
"mcAdd",
"mcRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRem",
"missComp"
],
"repairTools": [],
"revisionId": "66c8c695fd8130e3ede6f77c6e5cc1ec96a0e9b3"
},
{
"bugId": 33,
"changedFiles": {
"com/google/javascript/rhino/jstype/PrototypeObjectType.java": {
"inserts": [
[
556,
557,
558,
559,
560,
561,
562,
563,
564,
565,
566,
567
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/PrototypeObjectType.java\n+++ b/src/com/google/javascript/rhino/jstype/PrototypeObjectType.java\n@@ -554,6 +554,9 @@ JSType resolveInternal(ErrorReporter t, StaticScope<JSType> scope) {\n @Override\n public void matchConstraint(ObjectType constraintObj) {\n // We only want to match contraints on anonymous types.\n+ if (hasReferenceName()) {\n+ return;\n+ }\n \n // Handle the case where the constraint object is a record type.\n //\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testIssue700"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtJAID",
"rtNopol"
],
"revisionId": "382422adae8e9f07fc23c94089c0ebe08a2174bc"
},
{
"bugId": 28,
"changedFiles": {
"com/google/javascript/jscomp/InlineCostEstimator.java": {
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineCostEstimator.java\n+++ b/src/com/google/javascript/jscomp/InlineCostEstimator.java\n@@ -99,5 +99,9 @@ void addIdentifier(String identifier) {\n * Constants (true, false, null) are considered basically free,\n * because it's likely that they will get folded when we're done.\n */\n+ @Override\n+ void addConstant(String newcode) {\n+ add(\"0\");\n+ }\n }\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineCostEstimatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<4>",
"methodName": "testCost"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue728"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Overrides the addConstant method. Replaces method calls.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"mdAdd",
"mdOverride"
],
"repairPatterns": [
"notClassified",
"wrongComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "59dbb7a28680caad08ddb1658123fe0cbb1ae689"
},
{
"bugId": 34,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
122
],
[
123
],
[
124
],
[
754
]
]
},
"com/google/javascript/jscomp/CodePrinter.java": {
"changes": [
[
334
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -119,9 +119,7 @@ void add(Node n, Context context) {\n cc.addOp(opstr, true);\n addExpr(last, p, rhsContext);\n } else {\n- addExpr(first, p, context);\n- cc.addOp(opstr, true);\n- addExpr(last, p + 1, rhsContext);\n+ unrollBinaryOperator(n, type, opstr, context, rhsContext, p, p + 1);\n }\n return;\n }\n@@ -751,7 +749,7 @@ private void unrollBinaryOperator(\n Node current = firstNonOperator;\n do {\n current = current.getParent();\n- cc.listSeparator();\n+ cc.addOp(opStr, true);\n addExpr(current.getFirstChild().getNext(), rightPrecedence, rhsContext);\n } while (current != n);\n }\n--- a/src/com/google/javascript/jscomp/CodePrinter.java\n+++ b/src/com/google/javascript/jscomp/CodePrinter.java\n@@ -331,7 +331,7 @@ void endCaseBody() {\n @Override\n void appendOp(String op, boolean binOp) {\n if (binOp) {\n- if (getLastChar() != ' ') {\n+ if (getLastChar() != ' ' && op.charAt(0) != ',') {\n append(\" \");\n }\n append(op);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "java.lang.StackOverflowError",
"message": "",
"methodName": "testManyAdds"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 2,
"methods": 3,
"sizeInLines": 5,
"spreadAllLines": 629,
"spreadCodeOnly": 505
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd",
"mcParAdd",
"mcRepl",
"varReplVar"
],
"repairPatterns": [
"expLogicExpand",
"wrongMethodRef",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "87b154f89cba3c67045cd7a783b79231d0630a4c"
},
{
"bugId": 35,
"changedFiles": {
"com/google/javascript/jscomp/TypeInference.java": {
"changes": [
[
1121
],
[
1122
],
[
1123
],
[
1124
],
[
1125
],
[
1126
],
[
1127
],
[
1128
],
[
1129
],
[
1130
],
[
1131
],
[
1132
],
[
1133
],
[
1134
],
[
1135
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeInference.java\n+++ b/src/com/google/javascript/jscomp/TypeInference.java\n@@ -1118,21 +1118,8 @@ private void inferPropertyTypesToMatchConstraint(\n \n ObjectType constraintObj =\n ObjectType.cast(constraint.restrictByNotNullOrUndefined());\n- if (constraintObj != null && constraintObj.isRecordType()) {\n- ObjectType objType = ObjectType.cast(type.restrictByNotNullOrUndefined());\n- if (objType != null) {\n- for (String prop : constraintObj.getOwnPropertyNames()) {\n- JSType propType = constraintObj.getPropertyType(prop);\n- if (!objType.isPropertyTypeDeclared(prop)) {\n- JSType typeToInfer = propType;\n- if (!objType.hasProperty(prop)) {\n- typeToInfer =\n- getNativeType(VOID_TYPE).getLeastSupertype(propType);\n- }\n- objType.defineInferredProperty(prop, typeToInfer, null);\n- }\n- }\n- }\n+ if (constraintObj != null) {\n+ type.matchConstraint(constraintObj);\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testIssue669"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 13,
"methods": 1,
"sizeInLines": 15,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Simplifies an existent null check. It's a kind of conditional block replacement.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranRem",
"condExpRed",
"loopRem",
"mcAdd",
"mcRem",
"varRem"
],
"repairPatterns": [
"condBlockRem",
"expLogicReduce"
],
"repairTools": [
"rtNopol"
],
"revisionId": "22784dc96c391b01692ce686eb93b9aa0ef74ede"
},
{
"bugId": 37,
"changedFiles": {
"com/google/javascript/jscomp/NodeTraversal.java": {
"changes": [
[
541
]
]
},
"com/google/javascript/jscomp/parsing/IRFactory.java": {
"inserts": [
[
667,
668,
669,
670
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeTraversal.java\n+++ b/src/com/google/javascript/jscomp/NodeTraversal.java\n@@ -538,7 +538,7 @@ private void traverseFunction(Node n, Node parent) {\n \n // Body\n Preconditions.checkState(body.getNext() == null &&\n- body.isBlock());\n+ body.isBlock(), body);\n traverseBranch(body, n);\n \n popScope();\n--- a/src/com/google/javascript/jscomp/parsing/IRFactory.java\n+++ b/src/com/google/javascript/jscomp/parsing/IRFactory.java\n@@ -664,9 +664,13 @@ Node processFunctionNode(FunctionNode functionNode) {\n node.addChildToBack(lp);\n \n Node bodyNode = transform(functionNode.getBody());\n+ if (!bodyNode.isBlock()) {\n // When in ideMode Rhino tries to parse some constructs the compiler\n // doesn't support, repair it here. see Rhino's\n // Parser#parseFunctionBodyExpr.\n+ Preconditions.checkState(config.isIdeMode);\n+ bodyNode = IR.block();\n+ }\n parseDirectives(bodyNode);\n node.addChildToBack(bodyNode);\n return node;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "java.lang.RuntimeException",
"message": "java.lang.RuntimeException: INTERNAL COMPILER ERROR.",
"methodName": "testIncompleteFunction"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 5,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "Replaces method call by overloaded method with extra parameters.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"mcParAdd",
"mcRepl"
],
"repairPatterns": [
"condBlockOthersAdd",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "7e93d521cb67ce33018315234fafe8a5aa30ee1e"
},
{
"bugId": 36,
"changedFiles": {
"com/google/javascript/jscomp/InlineVariables.java": {
"inserts": [
[
572,
573,
574,
575
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineVariables.java\n+++ b/src/com/google/javascript/jscomp/InlineVariables.java\n@@ -572,6 +572,9 @@ private boolean canInline(\n \n // issue 668: Don't inline singleton getter methods\n // calls as this confused class removing logic.\n+ if (convention.getSingletonGetterClassName(callNode) != null) {\n+ return false;\n+ }\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSingletonGetter1"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "be397ee0d0be2aad8f71d12f097b17563866445a"
},
{
"bugId": 39,
"changedFiles": {
"com/google/javascript/rhino/jstype/PrototypeObjectType.java": {
"changes": [
[
380
],
[
383
],
[
394
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/PrototypeObjectType.java\n+++ b/src/com/google/javascript/rhino/jstype/PrototypeObjectType.java\n@@ -377,10 +377,10 @@ String toStringHelper(boolean forAnnotations) {\n \n sb.append(property);\n sb.append(\": \");\n- sb.append(getPropertyType(property).toString());\n+ sb.append(getPropertyType(property).toStringHelper(forAnnotations));\n \n ++i;\n- if (i == MAX_PRETTY_PRINTED_PROPERTIES) {\n+ if (!forAnnotations && i == MAX_PRETTY_PRINTED_PROPERTIES) {\n sb.append(\", ...\");\n break;\n }\n@@ -391,7 +391,7 @@ String toStringHelper(boolean forAnnotations) {\n prettyPrint = true;\n return sb.toString();\n } else {\n- return \"{...}\";\n+ return forAnnotations ? \"?\" : \"{...}\";\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.rhino.jstype.RecordTypeTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<{loop: [?], number: number, st...> but was:<{loop: [{...}], number: number, st...>",
"methodName": "testRecursiveRecord"
},
{
"className": " com.google.javascript.rhino.jstype.RecordTypeTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...number, a4: number, [a5: number, a6: number]}> but was:<...number, a4: number, [...]}>",
"methodName": "testLongToString"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 12,
"spreadCodeOnly": 9
},
"observations": "If-else implicit in \"exp?a:b\" construct",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"condExpExpand",
"mcParAdd",
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"wrapsIfElse",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "d577973fb378dfe0d05991ec0dfa6c1f40e574ee"
},
{
"bugId": 45,
"changedFiles": {
"com/google/javascript/jscomp/RemoveUnusedVars.java": {
"changes": [
[
741
],
[
904
]
],
"inserts": [
[
731,
732
],
[
739
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/RemoveUnusedVars.java\n+++ b/src/com/google/javascript/jscomp/RemoveUnusedVars.java\n@@ -729,6 +729,7 @@ private void interpretAssigns() {\n assignedToUnknownValue = true;\n }\n \n+ boolean maybeEscaped = false;\n for (Assign assign : assignsByVar.get(var)) {\n if (assign.isPropertyAssign) {\n hasPropertyAssign = true;\n@@ -736,9 +737,12 @@ private void interpretAssigns() {\n assign.assignNode.getLastChild(), true)) {\n assignedToUnknownValue = true;\n }\n+ if (assign.maybeAliased) {\n+ maybeEscaped = true;\n+ }\n }\n \n- if (assignedToUnknownValue && hasPropertyAssign) {\n+ if ((assignedToUnknownValue || maybeEscaped) && hasPropertyAssign) {\n changes = markReferencedVar(var) || changes;\n maybeUnreferenced.remove(current);\n current--;\n@@ -901,7 +905,7 @@ void apply() {\n this.nameNode = nameNode;\n this.isPropertyAssign = isPropertyAssign;\n \n- this.maybeAliased = !assignNode.getParent().isExprResult();\n+ this.maybeAliased = NodeUtil.isExpressionResultUsed(assignNode);\n this.mayHaveSecondarySideEffects =\n maybeAliased ||\n NodeUtil.mayHaveSideEffects(assignNode.getFirstChild()) ||\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.RemoveUnusedVarsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue618_1"
}
],
"metrics": {
"chunks": 4,
"classes": 2,
"files": 1,
"linesAdd": 4,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 171,
"spreadCodeOnly": 107
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condExpExpand",
"condExpMod",
"mcAdd",
"mcRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand",
"initFix",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "6aa71f116df0102a98c463f471ad8ddd4dba01f8"
},
{
"bugId": 38,
"changedFiles": {
"com/google/javascript/jscomp/CodeConsumer.java": {
"changes": [
[
245
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeConsumer.java\n+++ b/src/com/google/javascript/jscomp/CodeConsumer.java\n@@ -242,7 +242,7 @@ void addNumber(double x) {\n // x--4 (which is a syntax error).\n char prev = getLastChar();\n boolean negativeZero = isNegativeZero(x);\n- if (x < 0 && prev == '-') {\n+ if ((x < 0 || negativeZero) && prev == '-') {\n add(\" \");\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<x-[ ]-0.0> but was:<x-[]-0.0>",
"methodName": "testMinusNegativeZero"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Parentesis added has no effect on expression evaluation, so a conditional expression expansion was considered only.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtNopol"
],
"revisionId": "8cf08115c6b252f8c6b54348a4089dccc45a01fb"
},
{
"bugId": 40,
"changedFiles": {
"com/google/javascript/jscomp/NameAnalyzer.java": {
"changes": [
[
635
]
],
"deletes": [
[
636
],
[
639
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NameAnalyzer.java\n+++ b/src/com/google/javascript/jscomp/NameAnalyzer.java\n@@ -632,11 +632,9 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n Node nameNode = n.getFirstChild();\n NameInformation ns = createNameInformation(t, nameNode, n);\n if (ns != null && ns.onlyAffectsClassDef) {\n- JsName name = getName(ns.name, false);\n- if (name != null) {\n+ JsName name = getName(ns.name, true);\n refNodes.add(new ClassDefiningFunctionNode(\n name, n, parent, parent.getParent()));\n- }\n }\n }\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "java.lang.RuntimeException",
"message": "java.lang.RuntimeException: INTERNAL COMPILER ERROR.",
"methodName": "testIssue284"
},
{
"className": " com.google.javascript.jscomp.NameAnalyzerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue284"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 2,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "Removed a null check, maintaining the branch code.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranRem",
"mcParValChange"
],
"repairPatterns": [
"constChange",
"unwrapIfElse"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtJAID",
"rtNopol",
"rtssFix"
],
"revisionId": "6ebc0c3d7d4da7d2cf95f53d4ea790e89d3abc7a"
},
{
"bugId": 42,
"changedFiles": {
"com/google/javascript/jscomp/parsing/IRFactory.java": {
"inserts": [
[
568,
569,
570
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/IRFactory.java\n+++ b/src/com/google/javascript/jscomp/parsing/IRFactory.java\n@@ -565,8 +565,15 @@ Node processExpressionStatement(ExpressionStatement statementNode) {\n \n @Override\n Node processForInLoop(ForInLoop loopNode) {\n+ if (loopNode.isForEach()) {\n+ errorReporter.error(\n+ \"unsupported language extension: for each\",\n+ sourceName,\n+ loopNode.getLineno(), \"\", 0);\n \n // Return the bare minimum to put the AST in a valid state.\n+ return newNode(Token.EXPR_RESULT, Node.newNumber(0));\n+ }\n return newNode(\n Token.FOR,\n transform(loopNode.getIterator()),\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testForEach"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 2,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "fb01427a445ebfeb3af5e220a98ccaced339b73e"
},
{
"bugId": 41,
"changedFiles": {
"com/google/javascript/jscomp/FunctionTypeBuilder.java": {
"inserts": [
[
290,
291,
292,
293
],
[
481,
482,
483,
484
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionTypeBuilder.java\n+++ b/src/com/google/javascript/jscomp/FunctionTypeBuilder.java\n@@ -289,6 +289,9 @@ FunctionTypeBuilder inferFromOverriddenFunction(\n }\n \n // Clone any remaining params that aren't in the function literal.\n+ while (oldParams.hasNext()) {\n+ paramBuilder.newParameterFromNode(oldParams.next());\n+ }\n \n parametersNode = paramBuilder.build();\n }\n@@ -480,6 +483,12 @@ FunctionTypeBuilder inferParameterTypes(@Nullable Node argsParent,\n }\n \n // Copy over any old parameters that aren't in the param list.\n+ if (!isVarArgs) {\n+ while (oldParameterType != null && !isVarArgs) {\n+ builder.newParameterFromNode(oldParameterType);\n+ oldParameterType = oldParameterType.getNext();\n+ }\n+ }\n \n if (templateTypeName != null && !foundTemplateType) {\n reportError(TEMPLATE_TYPE_EXPECTED, fnName);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LooseTypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testMethodInference6"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[actual parameter 2 of Bar.prototype.add does not match formal parameter",
"methodName": "testIssue368"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testMethodInference6"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 9,
"spreadAllLines": 191,
"spreadCodeOnly": 138
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"missNullCheckN"
],
"repairTools": [],
"revisionId": "00b1517c53912ac6843c257c0a6ead1176e8c5ee"
},
{
"bugId": 44,
"changedFiles": {
"com/google/javascript/jscomp/CodeConsumer.java": {
"inserts": [
[
194,
195,
196,
197,
198,
199
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeConsumer.java\n+++ b/src/com/google/javascript/jscomp/CodeConsumer.java\n@@ -191,11 +191,13 @@ void add(String newcode) {\n // need space to separate. This is not pretty printing.\n // For example: \"return foo;\"\n append(\" \");\n+ } else if (c == '/' && getLastChar() == '/') {\n // Do not allow a forward slash to appear after a DIV.\n // For example,\n // REGEXP DIV REGEXP\n // is valid and should print like\n // / // / /\n+ append(\" \");\n }\n \n append(newcode);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<alert(/ //[ ]/ /)> but was:<alert(/ //[]/ /)>",
"methodName": "testIssue620"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 5,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "64bb2291f9a9bbab67d865dffe603f8a0df8ef30"
},
{
"bugId": 43,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"inserts": [
[
-1
],
[
545,
546,
547
],
[
580
],
[
581
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -390,50 +390,51 @@ private void identifyNameNode(\n private JSType getNativeType(JSTypeNative nativeType) {\n return typeRegistry.getNativeType(nativeType);\n }\n \n private abstract class AbstractScopeBuilder\n implements NodeTraversal.Callback {\n \n /**\n * The scope that we're builidng.\n */\n final Scope scope;\n \n private final List<DeferredSetType> deferredSetTypes =\n Lists.newArrayList();\n \n /**\n * Functions that we found in the global scope and not in externs.\n */\n private final List<Node> nonExternFunctions = Lists.newArrayList();\n \n /**\n * Object literals with a @lends annotation aren't analyzed until we\n * reach the root of the statement they're defined in.\n *\n * This ensures that if there are any @lends annotations on the object\n * literals, the type on the @lends annotation resolves correctly.\n *\n * For more information, see\n * http://code.google.com/p/closure-compiler/issues/detail?id=314\n */\n+ private List<Node> lentObjectLiterals = null;\n \n /**\n * Type-less stubs.\n *\n * If at the end of traversal, we still don't have types for these\n * stubs, then we should declare UNKNOWN types.\n */\n private final List<StubDeclaration> stubDeclarations =\n Lists.newArrayList();\n \n /**\n * The current source file that we're in.\n */\n private String sourceName = null;\n \n /**\n * The InputId of the current node.\n */\n private InputId inputId;\n \n@@ -498,90 +499,106 @@ public final boolean shouldTraverse(NodeTraversal t, Node n,\n public void visit(NodeTraversal t, Node n, Node parent) {\n inputId = t.getInputId();\n attachLiteralTypes(t, n);\n \n switch (n.getType()) {\n case Token.CALL:\n checkForClassDefiningCalls(t, n, parent);\n checkForCallingConventionDefiningCalls(n, delegateCallingConventions);\n break;\n \n case Token.FUNCTION:\n if (t.getInput() == null || !t.getInput().isExtern()) {\n nonExternFunctions.add(n);\n }\n \n // Hoisted functions are handled during pre-traversal.\n if (!NodeUtil.isHoistedFunctionDeclaration(n)) {\n defineFunctionLiteral(n, parent);\n }\n break;\n \n case Token.ASSIGN:\n // Handle initialization of properties.\n Node firstChild = n.getFirstChild();\n if (firstChild.isGetProp() &&\n firstChild.isQualifiedName()) {\n maybeDeclareQualifiedName(t, n.getJSDocInfo(),\n firstChild, n, firstChild.getNext());\n }\n break;\n \n case Token.CATCH:\n defineCatch(n, parent);\n break;\n \n case Token.VAR:\n defineVar(n, parent);\n break;\n \n case Token.GETPROP:\n // Handle stubbed properties.\n if (parent.isExprResult() &&\n n.isQualifiedName()) {\n maybeDeclareQualifiedName(t, n.getJSDocInfo(), n, parent, null);\n }\n break;\n }\n \n // Analyze any @lends object literals in this statement.\n+ if (n.getParent() != null && NodeUtil.isStatement(n) &&\n+ lentObjectLiterals != null) {\n+ for (Node objLit : lentObjectLiterals) {\n+ defineObjectLiteral(objLit);\n+ }\n+ lentObjectLiterals.clear();\n+ }\n }\n \n private void attachLiteralTypes(NodeTraversal t, Node n) {\n switch (n.getType()) {\n case Token.NULL:\n n.setJSType(getNativeType(NULL_TYPE));\n break;\n \n case Token.VOID:\n n.setJSType(getNativeType(VOID_TYPE));\n break;\n \n case Token.STRING:\n // Defer keys to the Token.OBJECTLIT case\n if (!NodeUtil.isObjectLitKey(n, n.getParent())) {\n n.setJSType(getNativeType(STRING_TYPE));\n }\n break;\n \n case Token.NUMBER:\n n.setJSType(getNativeType(NUMBER_TYPE));\n break;\n \n case Token.TRUE:\n case Token.FALSE:\n n.setJSType(getNativeType(BOOLEAN_TYPE));\n break;\n \n case Token.REGEXP:\n n.setJSType(getNativeType(REGEXP_TYPE));\n break;\n \n case Token.OBJECTLIT:\n+ JSDocInfo info = n.getJSDocInfo();\n+ if (info != null &&\n+ info.getLendsName() != null) {\n+ if (lentObjectLiterals == null) {\n+ lentObjectLiterals = Lists.newArrayList();\n+ }\n+ lentObjectLiterals.add(n);\n+ } else {\n defineObjectLiteral(n);\n+ }\n break;\n \n // NOTE(nicksantos): If we ever support Array tuples,\n // we will need to put ARRAYLIT here as well.\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[inconsistent return type",
"methodName": "testLends10"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[inconsistent return type",
"methodName": "testLends11"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 17,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 17,
"spreadAllLines": 161,
"spreadCodeOnly": 108
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"missNullCheckN",
"missNullCheckP",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "f636f23bdef4b27752ca249a28463ec1b6af1f0b"
},
{
"bugId": 46,
"changedFiles": {
"com/google/javascript/rhino/jstype/RecordType.java": {
"deletes": [
[
140
],
[
141
],
[
142
],
[
143
],
[
144
],
[
145
],
[
146
],
[
147
],
[
148
],
[
149
],
[
150
],
[
151
],
[
152
],
[
153
],
[
154
],
[
155
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/RecordType.java\n+++ b/src/com/google/javascript/rhino/jstype/RecordType.java\n@@ -137,22 +137,6 @@ boolean defineProperty(String propertyName, JSType type,\n propertyNode);\n }\n \n- @Override\n- public JSType getLeastSupertype(JSType that) {\n- if (!that.isRecordType()) {\n- return super.getLeastSupertype(that);\n- }\n- RecordTypeBuilder builder = new RecordTypeBuilder(registry);\n- for (String property : properties.keySet()) {\n- if (that.toMaybeRecordType().hasProperty(property) &&\n- that.toMaybeRecordType().getPropertyType(property).isEquivalentTo(\n- getPropertyType(property))) {\n- builder.addProperty(property, getPropertyType(property),\n- getPropertyNode(property));\n- }\n- }\n- return builder.build();\n- }\n JSType getGreatestSubtypeHelper(JSType that) {\n if (that.isRecordType()) {\n RecordType thatRecord = that.toMaybeRecordType();\n",
"failingTests": [
{
"className": " com.google.javascript.rhino.jstype.JSTypeTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: ({a: number, b: string}|{b: string, c: string, e: number})",
"methodName": "testRecordTypeLeastSuperType2"
},
{
"className": " com.google.javascript.rhino.jstype.JSTypeTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: ({a: number, b: string}|{d: number, e: string, f: string})",
"methodName": "testRecordTypeLeastSuperType3"
},
{
"className": " com.google.javascript.rhino.jstype.RecordTypeTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: ({a: number, b: number}|{b: number, c: number})",
"methodName": "testSupAndInf"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 16,
"methods": 1,
"sizeInLines": 16,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Removes Overriding method. Adds and initializes local variable.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranRem",
"loopRem",
"mcRem",
"mdOverride",
"mdRem",
"objInstRem",
"retRem",
"varRem"
],
"repairPatterns": [
"blockRemove",
"condBlockRem",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth"
],
"revisionId": "4a1a31c6a50a0fbe25fa33277909bd51f1deb8e9"
},
{
"bugId": 47,
"changedFiles": {
"com/google/debugging/sourcemap/SourceMapConsumerV3.java": {
"changes": [
[
489
],
[
490
]
]
},
"com/google/javascript/jscomp/SourceMap.java": {
"changes": [
[
141
]
],
"inserts": [
[
133,
134,
135,
136,
137,
138,
139
]
]
}
},
"diff": "--- a/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java\n+++ b/src/com/google/debugging/sourcemap/SourceMapConsumerV3.java\n@@ -486,8 +486,8 @@ private OriginalMapping getOriginalMappingForEntry(Entry entry) {\n // Adjust the line/column here to be start at 1.\n Builder x = OriginalMapping.newBuilder()\n .setOriginalFile(sources[entry.getSourceFileId()])\n- .setLineNumber(entry.getSourceLine())\n- .setColumnPosition(entry.getSourceColumn());\n+ .setLineNumber(entry.getSourceLine() + 1)\n+ .setColumnPosition(entry.getSourceColumn() + 1);\n if (entry.getNameId() != UNMAPPED) {\n x.setIdentifier(names[entry.getNameId()]);\n }\n--- a/src/com/google/javascript/jscomp/SourceMap.java\n+++ b/src/com/google/javascript/jscomp/SourceMap.java\n@@ -135,10 +135,15 @@ public void addMapping(\n // zero based.\n // We don't change this for the v1 or v2 source maps but for\n // v3 we make them both 0 based.\n+ int lineBaseOffset = 1;\n+ if (generator instanceof SourceMapGeneratorV1\n+ || generator instanceof SourceMapGeneratorV2) {\n+ lineBaseOffset = 0;\n+ }\n \n generator.addMapping(\n sourceFile, originalName,\n- new FilePosition(node.getLineno(), node.getCharno()),\n+ new FilePosition(node.getLineno() - lineBaseOffset, node.getCharno()),\n outputStartPosition, outputEndPosition);\n }\n \n",
"failingTests": [
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<5> but was:<4>",
"methodName": "testParseSourceMetaMap"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testGoldenOutput0a"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testMultilineMapping"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testMultiFunctionMapping"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testLiteralMappingsGoldenOutput"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testMultilineMapping2"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testBasicMappingGoldenOutput"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<5> but was:<4>",
"methodName": "testSourceMapMerging"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testLiteralMappings"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testBasicMapping1"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10> but was:<9>",
"methodName": "testBasicMapping2"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testGoldenOutput1"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testGoldenOutput2"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testGoldenOutput3"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...t\":1,",
"methodName": "testGoldenOutput4"
},
{
"className": " com.google.debugging.sourcemap.SourceMapGeneratorV3Test",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...",
"methodName": "testGoldenOutput5"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 5,
"linesMod": 3,
"linesRem": 0,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 3,
"spreadCodeOnly": 2
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcParValChange",
"objInstMod",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"initFix"
],
"repairTools": [],
"revisionId": "aedce35970673f20696d5721acba13e986cc764c"
},
{
"bugId": 48,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"changes": [
[
1521
],
[
1523
],
[
1524
],
[
1525
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -1518,11 +1518,14 @@ void maybeDeclareQualifiedName(NodeTraversal t, JSDocInfo info,\n || FunctionTypeBuilder.isFunctionTypeDeclaration(info));\n }\n \n- if (inferred) {\n+ if (inferred && rhsValue != null && rhsValue.isFunction()) {\n // Determining declaration for #2\n- inferred = !(rhsValue != null &&\n- rhsValue.isFunction() &&\n- (info != null || !scope.isDeclared(qName, false)));\n+ if (info != null) {\n+ inferred = false;\n+ } else if (!scope.isDeclared(qName, false) &&\n+ n.isUnscopedQualifiedName()) {\n+ inferred = false;\n+ }\n }\n \n if (!inferred) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testIssue586"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfElseAdd",
"condExpExpand",
"mcAdd",
"mcRem"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand"
],
"repairTools": [
"rtDynaMoth"
],
"revisionId": "46da17d59abb4f9c48b6ffd31601c212490b970b"
},
{
"bugId": 49,
"changedFiles": {
"com/google/javascript/jscomp/MakeDeclaredNamesUnique.java": {
"deletes": [
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
]
],
"inserts": [
[
117,
139,
140,
150
],
[
172,
173,
174,
175
],
[
158,
170,
171,
176,
177,
178,
179,
180,
181,
185
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java\n+++ b/src/com/google/javascript/jscomp/MakeDeclaredNamesUnique.java\n@@ -88,14 +88,6 @@ public void enterScope(NodeTraversal t) {\n renamer = nameStack.peek().forChildScope();\n }\n \n- if (declarationRoot.getType() == Token.FUNCTION) {\n- for (Node c = declarationRoot.getFirstChild().getNext().getFirstChild(); c != null; c = c.getNext()) {\n- String name = c.getString();\n- renamer.addDeclaredName(name);\n- }\n- Node functionBody = declarationRoot.getLastChild();\n- findDeclaredNames(functionBody, null, renamer);\n- } else \n if (declarationRoot.getType() != Token.FUNCTION) {\n // Add the block declarations\n findDeclaredNames(declarationRoot, null, renamer);\n@@ -127,11 +119,22 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {\n renamer.addDeclaredName(name);\n }\n \n+ nameStack.push(renamer);\n+ }\n+ break;\n \n+ case Token.LP: {\n+ Renamer renamer = nameStack.peek().forChildScope();\n \n // Add the function parameters\n+ for (Node c = n.getFirstChild(); c != null; c = c.getNext()) {\n+ String name = c.getString();\n+ renamer.addDeclaredName(name);\n+ }\n \n // Add the function body declarations\n+ Node functionBody = n.getNext();\n+ findDeclaredNames(functionBody, null, renamer);\n \n nameStack.push(renamer);\n }\n@@ -170,13 +173,16 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n \n case Token.FUNCTION:\n // Remove the function body scope\n+ nameStack.pop();\n // Remove function recursive name (if any).\n nameStack.pop();\n break;\n \n+ case Token.LP:\n // Note: The parameters and function body variables live in the\n // same scope, we introduce the scope when in the \"shouldTraverse\"\n // visit of LP, but remove it when when we exit the function above.\n+ break;\n \n case Token.CATCH:\n // Remove catch except name from the stack of names.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline19b"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineIntoLoop"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline13"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline14"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline15"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline16"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline17"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline18"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInline19"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBug1897706"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctionWithInnerFunction5"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutateWithParameters3"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutateCallInLoopVars1"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutateInitializeUninitializedVars1"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutateInitializeUninitializedVars2"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutateFunctionDefinition"
},
{
"className": " com.google.javascript.jscomp.FunctionToBlockMutatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMutate8"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testLoopWithFunctionWithFunction"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables16"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables18"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCostBasedInlining11"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMixedModeInliningCosting3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineNeverMutateConstants"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineWithThis7"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAnonymous1"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAnonymous3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables1"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables6"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testShadowVariables7"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFunctionExpressionCallInlining11b"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexInlineNoResultNoParamCall3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCostBasedInlining9"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMethodWithFunctionWithFunction"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFunctionExpressionYCombinator"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexInlineVars7"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexFunctionWithFunctionDefinition2a"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexInline7"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFunctionExpressionOmega"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions15b"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions15d"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions16a"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBug4944818"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexSample"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified1"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified2"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified4"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified5"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified6"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified7"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue423"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexFunctionWithFunctionDefinition2"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testComplexFunctionWithFunctionDefinition3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDecomposeFunctionExpressionInCall"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineNeverOverrideNewValues"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineBlockMutableArgs1"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineBlockMutableArgs2"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineBlockMutableArgs3"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineBlockMutableArgs4"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions10"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions13"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions22"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions23"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions9"
},
{
"className": " com.google.javascript.jscomp.MakeDeclaredNamesUniqueTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMakeLocalNamesUniqueWithContext5"
}
],
"metrics": {
"chunks": 8,
"classes": 1,
"files": 1,
"linesAdd": 14,
"linesMod": 0,
"linesRem": 8,
"methods": 3,
"sizeInLines": 22,
"spreadAllLines": 81,
"spreadCodeOnly": 53
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignRem",
"condBranCaseAdd",
"condBranRem",
"loopAdd",
"loopRem",
"mcAdd",
"mcRem",
"varAdd",
"varRem"
],
"repairPatterns": [
"blockRemove",
"condBlockOthersAdd",
"condBlockRem",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "1a7ba5cb0111dd3ed9afd9691cab39b3c341e408"
},
{
"bugId": 50,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java": {
"changes": [
[
376
]
],
"inserts": [
[
388,
389,
390,
391
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java\n+++ b/src/com/google/javascript/jscomp/PeepholeReplaceKnownMethods.java\n@@ -373,7 +373,7 @@ private Node tryFoldArrayJoin(Node n) {\n \n Node right = callTarget.getNext();\n if (right != null) {\n- if (!NodeUtil.isImmutableValue(right)) {\n+ if (right.getNext() != null || !NodeUtil.isImmutableValue(right)) {\n return n;\n }\n }\n@@ -386,7 +386,12 @@ private Node tryFoldArrayJoin(Node n) {\n return n;\n }\n \n+ if (right != null && right.getType() == Token.STRING\n+ && \",\".equals(right.getString())) {\n // \",\" is the default, it doesn't need to be explicit\n+ n.removeChild(right);\n+ reportCodeChange();\n+ }\n \n String joinString = (right == null) ? \",\" : NodeUtil.getStringValue(right);\n List<Node> arrayFoldedChildren = Lists.newLinkedList();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeReplaceKnownMethodsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testStringJoinAdd"
},
{
"className": " com.google.javascript.jscomp.PeepholeReplaceKnownMethodsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoStringJoin"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 13,
"spreadCodeOnly": 9
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand",
"missNullCheckN"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "c3b630fc9c2a1c4eb7cb718f8d324bfb306cb9df"
},
{
"bugId": 53,
"changedFiles": {
"com/google/javascript/jscomp/InlineObjectLiterals.java": {
"inserts": [
[
331,
332,
333
],
[
350,
351
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n+++ b/src/com/google/javascript/jscomp/InlineObjectLiterals.java\n@@ -328,6 +328,9 @@ private void replaceAssignmentExpression(Var v, Reference ref,\n }\n \n Node replacement;\n+ if (nodes.isEmpty()) {\n+ replacement = new Node(Token.TRUE);\n+ } else {\n // All assignments evaluate to true, so make sure that the\n // expr statement evaluates to true in case it matters.\n nodes.add(new Node(Token.TRUE));\n@@ -347,6 +350,7 @@ private void replaceAssignmentExpression(Var v, Reference ref,\n }\n cur.addChildToFront(nodes.get(i));\n cur.addChildToFront(nodes.get(i + 1));\n+ }\n \n Node replace = ref.getParent();\n replacement.copyInformationFromForTree(replace);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineObjectLiteralsTest",
"error": "java.lang.RuntimeException",
"message": "INTERNAL COMPILER ERROR.",
"methodName": "testBug545"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 19,
"spreadCodeOnly": 13
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "9959716b01fc5231ae68bc7a24454ce45d341606"
},
{
"bugId": 51,
"changedFiles": {
"com/google/javascript/jscomp/CodeConsumer.java": {
"changes": [
[
241
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeConsumer.java\n+++ b/src/com/google/javascript/jscomp/CodeConsumer.java\n@@ -238,7 +238,7 @@ void addNumber(double x) {\n add(\" \");\n }\n \n- if ((long) x == x) {\n+ if ((long) x == x && !isNegativeZero(x)) {\n long value = (long) x;\n long mantissa = value;\n int exp = 0;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x=[-0.]0> but was:<var x=[]0>",
"methodName": "testIssue582"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtHDRepair"
],
"revisionId": "a02241e5df48e44e23dc0e66dbef3fdc3c91eb3e"
},
{
"bugId": 52,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
745
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -742,7 +742,7 @@ static boolean isSimpleNumber(String s) {\n return false;\n }\n }\n- return len > 0;\n+ return len > 0 && s.charAt(0) != '0';\n }\n \n static double getSimpleNumber(String s) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x={[\"010\"]:1}> but was:<var x={[10]:1}>",
"methodName": "testNumericKeys"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [],
"revisionId": "5909c3db59b16886917456ab950ef9661a7fe6b1"
},
{
"bugId": 59,
"changedFiles": {
"com/google/javascript/jscomp/Compiler.java": {
"changes": [
[
255
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Compiler.java\n+++ b/src/com/google/javascript/jscomp/Compiler.java\n@@ -252,7 +252,8 @@ public void initOptions(CompilerOptions options) {\n CheckLevel.OFF);\n }\n \n- if (options.checkGlobalThisLevel.isOn()) {\n+ if (options.checkGlobalThisLevel.isOn() &&\n+ !options.disables(DiagnosticGroups.GLOBAL_THIS)) {\n options.setWarningLevel(\n DiagnosticGroups.GLOBAL_THIS,\n options.checkGlobalThisLevel);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected no warnings or errors",
"methodName": "testCheckGlobalThisOff"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtDynaMoth"
],
"revisionId": "49b4ef31c850611a5c85d95140b4cedda7f4c59a"
},
{
"bugId": 55,
"changedFiles": {
"com/google/javascript/jscomp/FunctionRewriter.java": {
"changes": [
[
117
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionRewriter.java\n+++ b/src/com/google/javascript/jscomp/FunctionRewriter.java\n@@ -114,7 +114,8 @@ public Node parseHelperCode(Reducer reducer) {\n }\n \n private static boolean isReduceableFunctionExpression(Node n) {\n- return NodeUtil.isFunctionExpression(n);\n+ return NodeUtil.isFunctionExpression(n)\n+ && !NodeUtil.isGetOrSetKey(n.getParent());\n }\n \n /**\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FunctionRewriterTest",
"error": "java.lang.IllegalStateException",
"message": "Expected function but was call Reference node CALL 4 [free_call: 1] [source_file: testcode]",
"methodName": "testIssue538"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "f2c0cb1f67ecb3315c0cb11326c9cb04db07ee8a"
},
{
"bugId": 54,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"changes": [
[
1413
]
],
"inserts": [
[
1408,
1409,
1410,
1411,
1412,
1413
]
]
},
"com/google/javascript/rhino/jstype/FunctionType.java": {
"changes": [
[
366
]
],
"deletes": [
[
341
]
],
"inserts": [
[
365,
366
],
[
371,
372,
373,
374,
375
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -1410,7 +1410,13 @@ void maybeDeclareQualifiedName(NodeTraversal t, JSDocInfo info,\n // then they are responsible for making sure that the object literal's\n // implicit prototype is set up appropriately. We just obey\n // the @extends tag.\n- if (!qVar.isTypeInferred()) {\n+ ObjectType qVarType = ObjectType.cast(qVar.getType());\n+ if (qVarType != null &&\n+ rhsValue != null &&\n+ rhsValue.getType() == Token.OBJECTLIT) {\n+ typeRegistry.resetImplicitPrototype(\n+ rhsValue.getJSType(), qVarType.getImplicitPrototype());\n+ } else if (!qVar.isTypeInferred()) {\n // If the programmer has declared that F inherits from Super,\n // and they assign F.prototype to some arbitrary expression,\n // there's not much we can do. We just ignore the expression,\n--- a/src/com/google/javascript/rhino/jstype/FunctionType.java\n+++ b/src/com/google/javascript/rhino/jstype/FunctionType.java\n@@ -338,7 +338,6 @@ public void setPrototypeBasedOn(ObjectType baseType) {\n //\n // In the second case, we just use the anonymous object as the prototype.\n if (baseType.hasReferenceName() ||\n- baseType.isUnknownType() ||\n isNativeObjectType() ||\n baseType.isFunctionPrototypeType() ||\n !(baseType instanceof PrototypeObjectType)) {\n@@ -363,14 +362,18 @@ public boolean setPrototype(PrototypeObjectType prototype) {\n return false;\n }\n \n- boolean replacedPrototype = prototype != null;\n+ PrototypeObjectType oldPrototype = this.prototype;\n+ boolean replacedPrototype = oldPrototype != null;\n \n this.prototype = prototype;\n this.prototypeSlot = new SimpleSlot(\"prototype\", prototype, true);\n this.prototype.setOwnerFunction(this);\n \n+ if (oldPrototype != null) {\n // Disassociating the old prototype makes this easier to debug--\n // we don't have to worry about two prototypes running around.\n+ oldPrototype.setOwnerFunction(null);\n+ }\n \n if (isConstructor() || isInterface()) {\n FunctionType superClass = getSuperClassConstructor();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[Function Foo.prototype.method: called with 1 argument(s). Function requires at least 0 argument(s) and no more than 0 argument(s).]> but was:<[Property baz never defined on Bar]>",
"methodName": "testIssue537a"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[Function Bar.prototype.baz: called with 1 argument(s). Function requires at least 0 argument(s) and no more than 0 argument(s).]> but was:<[Property baz never defined on Bar]>",
"methodName": "testIssue537b"
},
{
"className": " com.google.javascript.jscomp.TypedScopeCreatorTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[?]> but was:<[number]>",
"methodName": "testPropertyOnUnknownSuperClass2"
}
],
"metrics": {
"chunks": 5,
"classes": 2,
"files": 2,
"linesAdd": 10,
"linesMod": 2,
"linesRem": 1,
"methods": 3,
"sizeInLines": 13,
"spreadAllLines": 31,
"spreadCodeOnly": 18
},
"observations": "One of the chunks have a kind of Wrap-with-IfElse done with the replacement of existent conditional block.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpRed",
"mcAdd",
"mcRem",
"varAdd",
"varReplVar"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicReduce",
"missComp",
"missNullCheckN",
"wrapsIfElse",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "7e9b8336568ea7f05c33e1b58eb67fa6d4eee756"
},
{
"bugId": 56,
"changedFiles": {
"com/google/javascript/jscomp/SourceFile.java": {
"inserts": [
[
239,
240,
241,
242
],
[
243
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/SourceFile.java\n+++ b/src/com/google/javascript/jscomp/SourceFile.java\n@@ -239,7 +239,11 @@ public String getLine(int lineNumber) {\n // If next new line cannot be found, there are two cases\n // 1. pos already reaches the end of file, then null should be returned\n // 2. otherwise, return the contents between pos and the end of file.\n+ if (pos >= js.length()) {\n return null;\n+ } else {\n+ return js.substring(pos, js.length());\n+ }\n } else {\n return js.substring(pos, js.indexOf('\\n', pos));\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.JSCompilerSourceExcerptProviderTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<foo2:third line> but was:<null>",
"methodName": "testExceptNoNewLine"
},
{
"className": " com.google.javascript.jscomp.JsMessageExtractorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSyntaxError1"
},
{
"className": " com.google.javascript.jscomp.JsMessageExtractorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSyntaxError2"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "9e921fa973c603473f745fff76c44620fd7719e3"
},
{
"bugId": 58,
"changedFiles": {
"com/google/javascript/jscomp/LiveVariablesAnalysis.java": {
"inserts": [
[
206
],
[
208
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/LiveVariablesAnalysis.java\n+++ b/src/com/google/javascript/jscomp/LiveVariablesAnalysis.java\n@@ -203,8 +203,12 @@ private void computeGenKill(Node n, BitSet gen, BitSet kill,\n // for(var x in y) {...}\n lhs = lhs.getLastChild();\n }\n+ if (NodeUtil.isName(lhs)) {\n addToSetIfLocal(lhs, kill);\n addToSetIfLocal(lhs, gen);\n+ } else {\n+ computeGenKill(lhs, gen, kill, conditional);\n+ }\n computeGenKill(rhs, gen, kill, conditional);\n }\n return;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LiveVariableAnalysisTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testExpressionInForIn"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "f640b5dec722422c93a9a624cd21d30b5e321858"
},
{
"bugId": 57,
"changedFiles": {
"com/google/javascript/jscomp/ClosureCodingConvention.java": {
"changes": [
[
197
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ClosureCodingConvention.java\n+++ b/src/com/google/javascript/jscomp/ClosureCodingConvention.java\n@@ -194,7 +194,7 @@ private static String extractClassNameIfGoog(Node node, Node parent,\n String qualifiedName = callee.getQualifiedName();\n if (functionName.equals(qualifiedName)) {\n Node target = callee.getNext();\n- if (target != null) {\n+ if (target != null && target.getType() == Token.STRING) {\n className = target.getString();\n }\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ClosureCodingConventionTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: foo",
"methodName": "testRequire"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Altought there is a null check in the conditional expression, the expression is expanded with an extra condition not related to null-check.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [],
"revisionId": "f759f431d5a7a2261b44440bca9cfab93ae25302"
},
{
"bugId": 62,
"changedFiles": {
"com/google/javascript/jscomp/LightweightMessageFormatter.java": {
"changes": [
[
98
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/LightweightMessageFormatter.java\n+++ b/src/com/google/javascript/jscomp/LightweightMessageFormatter.java\n@@ -95,7 +95,7 @@ private String format(JSError error, boolean warning) {\n // charno == sourceExpert.length() means something is missing\n // at the end of the line\n if (excerpt.equals(LINE)\n- && 0 <= charno && charno < sourceExcerpt.length()) {\n+ && 0 <= charno && charno <= sourceExcerpt.length()) {\n for (int i = 0; i < charno; i++) {\n char c = sourceExcerpt.charAt(i);\n if (Character.isWhitespace(c)) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LightweightMessageFormatterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...ion here",
"methodName": "testFormatErrorSpaceEndOfLine1"
},
{
"className": " com.google.javascript.jscomp.LightweightMessageFormatterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...iption here",
"methodName": "testFormatErrorSpaceEndOfLine2"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Just changed the operator in \"if\" condition",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtHDRepair",
"rtJAID",
"rtNopol"
],
"revisionId": "b12d1d6489329c989b15635f6f7f06681b3f6582"
},
{
"bugId": 60,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"inserts": [
[
76,
80,
83,
88,
93,
103,
107,
108,
109
],
[
136
],
[
137,
138
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -105,6 +105,8 @@ static TernaryValue getImpureBooleanValue(Node n) {\n // ignoring side-effects\n return TernaryValue.TRUE;\n \n+ case Token.VOID:\n+ return TernaryValue.FALSE;\n \n default:\n return getPureBooleanValue(n);\n@@ -133,7 +135,10 @@ static TernaryValue getPureBooleanValue(Node n) {\n return TernaryValue.FALSE;\n \n case Token.VOID:\n+ if (!mayHaveSideEffects(n.getFirstChild())) {\n return TernaryValue.FALSE;\n+ }\n+ break;\n \n case Token.NAME:\n String name = n.getString();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue504"
},
{
"className": " com.google.javascript.jscomp.NodeUtilTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<unknown> but was:<false>",
"methodName": "testGetBooleanValue"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 5,
"spreadAllLines": 29,
"spreadCodeOnly": 17
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrapsIf"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "fbaadc736f0031dd84bebea33abae497b47158cb"
},
{
"bugId": 63,
"changedFiles": {
"com/google/javascript/jscomp/LightweightMessageFormatter.java": {
"changes": [
[
98
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/LightweightMessageFormatter.java\n+++ b/src/com/google/javascript/jscomp/LightweightMessageFormatter.java\n@@ -95,7 +95,7 @@ private String format(JSError error, boolean warning) {\n // charno == sourceExpert.length() means something is missing\n // at the end of the line\n if (excerpt.equals(LINE)\n- && 0 <= charno && charno < sourceExcerpt.length()) {\n+ && 0 <= charno && charno <= sourceExcerpt.length()) {\n for (int i = 0; i < charno; i++) {\n char c = sourceExcerpt.charAt(i);\n if (Character.isWhitespace(c)) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LightweightMessageFormatterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...ion here",
"methodName": "testFormatErrorSpaceEndOfLine1"
},
{
"className": " com.google.javascript.jscomp.LightweightMessageFormatterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...iption here",
"methodName": "testFormatErrorSpaceEndOfLine2"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Same as bug 62",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtJAID",
"rtNopol"
],
"revisionId": "37b0e1b0b5860e6cd4f48519c1105623778dc44f"
},
{
"bugId": 61,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"inserts": [
[
956,
957,
958,
959
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -955,6 +955,12 @@ static boolean functionCallHasSideEffects(\n }\n \n // Functions in the \"Math\" namespace have no side effects.\n+ if (nameNode.getFirstChild().getType() == Token.NAME) {\n+ String namespaceName = nameNode.getFirstChild().getString();\n+ if (namespaceName.equals(\"Math\")) {\n+ return false;\n+ }\n+ }\n \n if (compiler != null && !compiler.hasRegExpGlobalReferences()) {\n if (nameNode.getFirstChild().getType() == Token.REGEXP\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeRemoveDeadCodeTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCall1"
},
{
"className": " com.google.javascript.jscomp.PeepholeRemoveDeadCodeTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCall2"
},
{
"className": " com.google.javascript.jscomp.PeepholeRemoveDeadCodeTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRemoveUselessOps"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "34e4616a924bf272c076039e143e20f1d792731e"
},
{
"bugId": 64,
"changedFiles": {
"com/google/javascript/jscomp/Compiler.java": {
"changes": [
[
1432
],
[
1461
],
[
1467
],
[
1473
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Compiler.java\n+++ b/src/com/google/javascript/jscomp/Compiler.java\n@@ -1429,7 +1429,7 @@ public Void call() throws Exception {\n \n // if LanguageMode is ECMASCRIPT5_STRICT, only print 'use strict'\n // for the first input file\n- String code = toSource(root, sourceMap);\n+ String code = toSource(root, sourceMap, inputSeqNum == 0);\n if (!code.isEmpty()) {\n cb.append(code);\n \n@@ -1458,19 +1458,19 @@ public Void call() throws Exception {\n @Override\n String toSource(Node n) {\n initCompilerOptionsIfTesting();\n- return toSource(n, null);\n+ return toSource(n, null, true);\n }\n \n /**\n * Generates JavaScript source code for an AST.\n */\n- private String toSource(Node n, SourceMap sourceMap) {\n+ private String toSource(Node n, SourceMap sourceMap, boolean firstOutput) {\n CodePrinter.Builder builder = new CodePrinter.Builder(n);\n builder.setPrettyPrint(options.prettyPrint);\n builder.setLineBreak(options.lineBreak);\n builder.setSourceMap(sourceMap);\n builder.setSourceMapDetailLevel(options.sourceMapDetailLevel);\n- builder.setTagAsStrict(\n+ builder.setTagAsStrict(firstOutput &&\n options.getLanguageOut() == LanguageMode.ECMASCRIPT5_STRICT);\n builder.setLineLengthThreshold(options.lineLengthThreshold);\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<17> but was:<-1>",
"methodName": "testES5StrictUseStrictMultipleInputs"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 4,
"linesRem": 0,
"methods": 3,
"sizeInLines": 4,
"spreadAllLines": 38,
"spreadCodeOnly": 25
},
"observations": "New parameters are added in three method calls (call to overloaded methods). A logic expression passed to a method call is changed.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcParAdd",
"mcParValChange",
"mcRepl",
"mdParAdd",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand"
],
"repairTools": [],
"revisionId": "de726510af4329fb8eeb8a54b2d93d8d37c87545"
},
{
"bugId": 65,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
1015
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -1012,7 +1012,7 @@ static String strEscape(String s, char quote,\n for (int i = 0; i < s.length(); i++) {\n char c = s.charAt(i);\n switch (c) {\n- case '\\0': sb.append(\"\\\\0\"); break;\n+ case '\\0': sb.append(\"\\\\000\"); break;\n case '\\n': sb.append(\"\\\\n\"); break;\n case '\\r': sb.append(\"\\\\r\"); break;\n case '\\t': sb.append(\"\\\\t\"); break;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x=\"\\0[00]\"> but was:<var x=\"\\0[]\">",
"methodName": "testZero"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcParValChange"
],
"repairPatterns": [
"constChange",
"singleLine"
],
"repairTools": [],
"revisionId": "48aea0ff7d027507362007415963a4b662fb10a7"
},
{
"bugId": 66,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"inserts": [
[
516,
517
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -513,7 +513,9 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n // Object literal keys are handled with OBJECTLIT\n if (!NodeUtil.isObjectLitKey(n, n.getParent())) {\n ensureTyped(t, n, STRING_TYPE);\n+ } else {\n // Object literal keys are not typeable\n+ typeable = false;\n }\n break;\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<100.0> but was:<62.5>",
"methodName": "testGetTypedPercent5"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<100.0> but was:<66.66666666666667>",
"methodName": "testGetTypedPercent6"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranElseAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "59a30b48325cccadabae8687fdf603d72e26c157"
},
{
"bugId": 73,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
1045
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -1042,7 +1042,7 @@ static String strEscape(String s, char quote,\n // No charsetEncoder provided - pass straight latin characters\n // through, and escape the rest. Doing the explicit character\n // check is measurably faster than using the CharsetEncoder.\n- if (c > 0x1f && c <= 0x7f) {\n+ if (c > 0x1f && c < 0x7f) {\n sb.append(c);\n } else {\n // Other characters can be misinterpreted by some js parsers,\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x=\"[\\u007f]\"> but was:<var x=\"[]\">",
"methodName": "testUnicode"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtHDRepair",
"rtJAID",
"rtssFix"
],
"revisionId": "ee8344091722c28c9351e78dcb4155fbfddfd1af"
},
{
"bugId": 67,
"changedFiles": {
"com/google/javascript/jscomp/AnalyzePrototypeProperties.java": {
"changes": [
[
318
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java\n+++ b/src/com/google/javascript/jscomp/AnalyzePrototypeProperties.java\n@@ -315,7 +315,7 @@ private boolean isPrototypePropertyAssign(Node assign) {\n Node n = assign.getFirstChild();\n if (n != null && NodeUtil.isVarOrSimpleAssignLhs(n, assign)\n && n.getType() == Token.GETPROP\n- ) {\n+ && assign.getParent().getType() == Token.EXPR_RESULT) {\n // We want to exclude the assignment itself from the usage list\n boolean isChainedProperty =\n n.getFirstChild().getType() == Token.GETPROP;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.RemoveUnusedPrototypePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAliasing7"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "aa89d05b48332d68b8e6ebcee427b2ac3b4e3184"
},
{
"bugId": 74,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeFoldConstants.java": {
"changes": [
[
907
],
[
908
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n+++ b/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n@@ -904,8 +904,8 @@ private Node tryFoldComparison(Node n, Node left, Node right) {\n && right.getString().equals(\"undefined\"))\n || (Token.VOID == right.getType()\n && NodeUtil.isLiteralValue(right.getFirstChild(), false)));\n- int lhType = left.getType();\n- int rhType = right.getType();\n+ int lhType = getNormalizedNodeType(left);\n+ int rhType = getNormalizedNodeType(right);\n switch (lhType) {\n case Token.VOID:\n if (!NodeUtil.isLiteralValue(left.getFirstChild(), false)) {\n@@ -1071,6 +1071,19 @@ private Node tryFoldComparison(Node n, Node left, Node right) {\n /**\n * @return Translate NOT expressions into TRUE or FALSE when possible.\n */\n+ private int getNormalizedNodeType(Node n) {\n+ int type = n.getType();\n+ if (type == Token.NOT) {\n+ TernaryValue value = NodeUtil.getPureBooleanValue(n);\n+ switch (value) {\n+ case TRUE:\n+ return Token.TRUE;\n+ case FALSE:\n+ return Token.FALSE;\n+ }\n+ }\n+ return type;\n+ }\n \n /**\n * The result of the comparison as a Boolean or null if the\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFoldComparison3"
},
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.ComparisonFailure",
"message": "Expressions did not fold the same",
"methodName": "testInvertibleOperators"
},
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.ComparisonFailure",
"message": "Expressions did not fold the same",
"methodName": "testCommutativeOperators"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 13,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 15,
"spreadAllLines": 165,
"spreadCodeOnly": 136
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranCaseAdd",
"condBranIfAdd",
"mcAdd",
"mcRepl",
"mdAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "03fee32a06ccf8257b2da67b9034270be38805ae"
},
{
"bugId": 71,
"changedFiles": {
"com/google/javascript/jscomp/CheckAccessControls.java": {
"changes": [
[
416
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckAccessControls.java\n+++ b/src/com/google/javascript/jscomp/CheckAccessControls.java\n@@ -413,7 +413,7 @@ private void checkPropertyVisibility(NodeTraversal t,\n if (objectType != null) {\n // Is this a normal property access, or are we trying to override\n // an existing property?\n- boolean isOverride = t.inGlobalScope() &&\n+ boolean isOverride = parent.getJSDocInfo() != null &&\n parent.getType() == Token.ASSIGN &&\n parent.getFirstChild() == getprop;\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckAccessControlsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Overriding private property of Foo.prototype.",
"methodName": "testNoPrivateAccessForProperties6"
},
{
"className": " com.google.javascript.jscomp.CheckAccessControlsTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testNoPrivateAccessForProperties8"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "The null-check is done in a boolean expression assigned to a variable and not to a conditional test.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcAdd",
"mcRem"
],
"repairPatterns": [
"expLogicMod",
"missNullCheckN",
"singleLine"
],
"repairTools": [],
"revisionId": "db1fdf97454a6e4ff2d29cab5f1ef2273b54c0b4"
},
{
"bugId": 68,
"changedFiles": {
"com/google/javascript/jscomp/parsing/JsDocInfoParser.java": {
"deletes": [
[
869
]
],
"inserts": [
[
871
],
[
1708,
1709
],
[
1761
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n+++ b/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n@@ -865,9 +865,9 @@ boolean parse() {\n }\n break;\n }\n+ }\n \n token = eatTokensUntilEOL();\n- }\n continue retry;\n }\n }\n@@ -1706,6 +1706,7 @@ private Node parseBasicTypeExpression(JsDocToken token) {\n }\n }\n \n+ restoreLookAhead(token);\n return reportGenericTypeSyntaxWarning();\n }\n \n@@ -1758,6 +1759,7 @@ private Node parseFunctionType(JsDocToken token) {\n // NOTE(nicksantos): We're not implementing generics at the moment, so\n // just throw out TypeParameters.\n if (token != JsDocToken.LP) {\n+ restoreLookAhead(token);\n return reportTypeSyntaxWarning(\"msg.jsdoc.missing.lp\");\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "extra warning: Unexpected end of file",
"methodName": "testIssue477"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 1,
"methods": 3,
"sizeInLines": 4,
"spreadAllLines": 892,
"spreadCodeOnly": 554
},
"observations": "An assignment was moved outside a branch.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd"
],
"repairPatterns": [
"codeMove",
"copyPaste",
"missComp",
"unwrapIfElse"
],
"repairTools": [],
"revisionId": "9d5a6e3082dd99f6c44df1b3526b9e83b79aa7da"
},
{
"bugId": 69,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"inserts": [
[
1577,
1578,
1579,
1580,
1581
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -1577,6 +1577,13 @@ private void visitCall(NodeTraversal t, Node n) {\n \n // Functions with explcit 'this' types must be called in a GETPROP\n // or GETELEM.\n+ if (functionType.isOrdinaryFunction() &&\n+ !functionType.getTypeOfThis().isUnknownType() &&\n+ !functionType.getTypeOfThis().isNativeObjectType() &&\n+ !(child.getType() == Token.GETELEM ||\n+ child.getType() == Token.GETPROP)) {\n+ report(t, n, EXPECTED_THIS_TYPE, functionType.toString());\n+ }\n \n visitParameterList(t, n, functionType);\n ensureTyped(t, n, functionType.getReturnType());\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testThisTypeOfFunction2"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testThisTypeOfFunction3"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testThisTypeOfFunction4"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [],
"revisionId": "63df133d0850805818d1e280ba47dcefc9763c89"
},
{
"bugId": 70,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"changes": [
[
1745
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -1742,7 +1742,7 @@ private void declareArguments(Node functionNode) {\n for (Node astParameter : astParameters.children()) {\n if (jsDocParameter != null) {\n defineSlot(astParameter, functionNode,\n- jsDocParameter.getJSType(), true);\n+ jsDocParameter.getJSType(), false);\n jsDocParameter = jsDocParameter.getNext();\n } else {\n defineSlot(astParameter, functionNode, null, true);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.LooseTypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<1>",
"methodName": "testDuplicateLocalVarDecl"
},
{
"className": " com.google.javascript.jscomp.LooseTypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testFunctionArguments13"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testScoping12"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warning(s) : JSC_DUP_VAR_DECLARATION. variable x redefined with type string, original definition at [testcode] :2 with type number at [testcode] line 2 : 42 expected:<2> but was:<1>",
"methodName": "testDuplicateLocalVarDecl"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testFunctionArguments13"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcParValChange"
],
"repairPatterns": [
"constChange",
"singleLine"
],
"repairTools": [
"rtJAID",
"rtssFix"
],
"revisionId": "ec4a34c2bd87ba54fa8770affdeeea4f3c42089b"
},
{
"bugId": 72,
"changedFiles": {
"com/google/javascript/jscomp/FunctionToBlockMutator.java": {
"inserts": [
[
151,
152
]
]
},
"com/google/javascript/jscomp/RenameLabels.java": {
"changes": [
[
215
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionToBlockMutator.java\n+++ b/src/com/google/javascript/jscomp/FunctionToBlockMutator.java\n@@ -149,6 +149,8 @@ private void makeLocalNamesUnique(Node fnNode, boolean isCallInLoop) {\n \"inline_\",\n isCallInLoop)));\n // Make label names unique to this instance.\n+ new RenameLabels(compiler, new LabelNameSupplier(idSupplier), false)\n+ .process(null, fnNode);\n }\n \n static class LabelNameSupplier implements Supplier<String> {\n--- a/src/com/google/javascript/jscomp/RenameLabels.java\n+++ b/src/com/google/javascript/jscomp/RenameLabels.java\n@@ -212,7 +212,7 @@ private void visitLabel(Node node, Node parent) {\n String name = nameNode.getString();\n LabelInfo li = getLabelInfo(name);\n // This is a label...\n- if (li.referenced) {\n+ if (li.referenced || !removeUnused) {\n String newName = getNameForId(li.id);\n if (!name.equals(newName)) {\n // ... and it is used, give it the short name.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions31"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Instantiates an anonymous object and make a method call on it.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"expLogicExpand",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "e323b879de2e53e5eedf6e7afb0d582382c6248d"
},
{
"bugId": 76,
"changedFiles": {
"com/google/javascript/jscomp/DeadAssignmentsElimination.java": {
"deletes": [
[
309
],
[
318
],
[
313
],
[
314
],
[
315
],
[
316
],
[
317
],
[
372
],
[
377
]
],
"inserts": [
[
297,
298,
299,
300,
301
],
[
302,
303,
304,
305,
306
],
[
311,
312,
313
],
[
320
],
[
340,
341
],
[
362,
363,
364
],
[
365
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/DeadAssignmentsElimination.java\n+++ b/src/com/google/javascript/jscomp/DeadAssignmentsElimination.java\n@@ -297,26 +297,40 @@ private boolean isVariableStillLiveWithinExpression(\n // If the currently node is the first child of\n // AND/OR, be conservative only consider the READs\n // of the second operand.\n+ if (n.getNext() != null) {\n+ state = isVariableReadBeforeKill(\n+ n.getNext(), variable);\n+ if (state == VariableLiveness.KILL) {\n+ state = VariableLiveness.MAYBE_LIVE;\n+ }\n+ }\n+ break;\n \n case Token.HOOK:\n // If current node is the condition, check each following\n // branch, otherwise it is a conditional branch and the\n // other branch can be ignored.\n+ if (n.getNext() != null && n.getNext().getNext() != null) {\n+ state = checkHookBranchReadBeforeKill(\n+ n.getNext(), n.getNext().getNext(), variable);\n+ }\n+ break;\n \n default:\n for(Node sibling = n.getNext(); sibling != null;\n sibling = sibling.getNext()) {\n- if (!ControlFlowGraph.isEnteringNewCfgNode(sibling)) {\n state = isVariableReadBeforeKill(sibling, variable);\n+ if (state != VariableLiveness.MAYBE_LIVE) {\n+ break;\n+ }\n+ }\n+ }\n \n // If we see a READ or KILL there is no need to continue.\n if (state == VariableLiveness.READ) {\n return true;\n } else if (state == VariableLiveness.KILL) {\n return false;\n- }\n- }\n- }\n }\n n = n.getParent();\n }\n@@ -337,6 +351,9 @@ private boolean isVariableStillLiveWithinExpression(\n */\n private VariableLiveness isVariableReadBeforeKill(\n Node n, String variable) {\n+ if (ControlFlowGraph.isEnteringNewCfgNode(n)) { // Not a FUNCTION\n+ return VariableLiveness.MAYBE_LIVE;\n+ }\n \n if (NodeUtil.isName(n) && variable.equals(n.getString())) {\n if (NodeUtil.isLhs(n, n.getParent())) {\n@@ -359,9 +376,25 @@ private VariableLiveness isVariableReadBeforeKill(\n // Conditionals\n case Token.OR:\n case Token.AND:\n+ VariableLiveness v1 = isVariableReadBeforeKill(\n+ n.getFirstChild(), variable);\n+ VariableLiveness v2 = isVariableReadBeforeKill(\n+ n.getLastChild(), variable);\n // With a AND/OR the first branch always runs, but the second is\n // may not.\n+ if (v1 != VariableLiveness.MAYBE_LIVE) {\n+ return v1;\n+ } else if (v2 == VariableLiveness.READ) {\n+ return VariableLiveness.READ;\n+ } else {\n+ return VariableLiveness.MAYBE_LIVE;\n+ }\n case Token.HOOK:\n+ VariableLiveness first = isVariableReadBeforeKill(\n+ n.getFirstChild(), variable);\n+ if (first != VariableLiveness.MAYBE_LIVE) {\n+ return first;\n+ }\n return checkHookBranchReadBeforeKill(\n n.getFirstChild().getNext(), n.getLastChild(), variable);\n \n@@ -369,13 +402,11 @@ private VariableLiveness isVariableReadBeforeKill(\n // Expressions are evaluated left-right, depth first.\n for (Node child = n.getFirstChild();\n child != null; child = child.getNext()) {\n- if (!ControlFlowGraph.isEnteringNewCfgNode(child)) { // Not a FUNCTION\n VariableLiveness state = isVariableReadBeforeKill(child, variable);\n if (state != VariableLiveness.MAYBE_LIVE) {\n return state;\n }\n }\n- }\n }\n \n return VariableLiveness.MAYBE_LIVE;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInExpression2"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue384b"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue384c"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue384d"
}
],
"metrics": {
"chunks": 11,
"classes": 1,
"files": 1,
"linesAdd": 37,
"linesMod": 0,
"linesRem": 6,
"methods": 2,
"sizeInLines": 43,
"spreadAllLines": 73,
"spreadCodeOnly": 48
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condBranRem",
"condExpMod",
"mcAdd",
"mcRem",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp",
"missNullCheckN",
"unwrapIfElse"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "78b01c3a435cd175ce3ee70f97b2f8faac342cdc"
},
{
"bugId": 79,
"changedFiles": {
"com/google/javascript/jscomp/Normalize.java": {
"changes": [
[
122
]
]
},
"com/google/javascript/jscomp/VarCheck.java": {
"inserts": [
[
221
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Normalize.java\n+++ b/src/com/google/javascript/jscomp/Normalize.java\n@@ -119,7 +119,7 @@ private void reportCodeChange(String changeDescription) {\n public void process(Node externs, Node root) {\n new NodeTraversal(\n compiler, new NormalizeStatements(compiler, assertOnChange))\n- .traverse(root);\n+ .traverseRoots(externs, root);\n if (MAKE_LOCAL_NAMES_UNIQUE) {\n MakeDeclaredNamesUnique renamer = new MakeDeclaredNamesUnique();\n NodeTraversal t = new NodeTraversal(compiler, renamer);\n--- a/src/com/google/javascript/jscomp/VarCheck.java\n+++ b/src/com/google/javascript/jscomp/VarCheck.java\n@@ -218,6 +218,7 @@ private void createSynthesizedExternVar(String varName) {\n getSynthesizedExternsRoot().addChildToBack(\n new Node(Token.VAR, nameNode));\n varsToDeclareInExterns.remove(varName);\n+ compiler.reportCodeChange();\n }\n \n /**\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.NormalizeTest",
"error": "java.lang.RuntimeException",
"message": "INTERNAL COMPILER ERROR.",
"methodName": "testIssue"
},
{
"className": " com.google.javascript.jscomp.VarCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "compiler.reportCodeChange() should have been called",
"methodName": "testPropReferenceInExterns1"
},
{
"className": " com.google.javascript.jscomp.VarCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "compiler.reportCodeChange() should have been called",
"methodName": "testPropReferenceInExterns3"
},
{
"className": " com.google.javascript.jscomp.VarCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "compiler.reportCodeChange() should have been called",
"methodName": "testVarReferenceInExterns"
},
{
"className": " com.google.javascript.jscomp.VarCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "compiler.reportCodeChange() should have been called",
"methodName": "testCallInExterns"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Calls overloaded method with extra parameters.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"mcParAdd",
"mcRepl"
],
"repairPatterns": [
"missComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "5d397618f3c86d9c444a4c4c6441267b8a89a21d"
},
{
"bugId": 77,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"inserts": [
[
966,
967,
968,
969,
970,
971,
972,
981,
998
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -963,6 +963,7 @@ static String strEscape(String s, char quote,\n for (int i = 0; i < s.length(); i++) {\n char c = s.charAt(i);\n switch (c) {\n+ case '\\0': sb.append(\"\\\\0\"); break;\n case '\\n': sb.append(\"\\\\n\"); break;\n case '\\r': sb.append(\"\\\\r\"); break;\n case '\\t': sb.append(\"\\\\t\"); break;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x=\"\\[]0\"> but was:<var x=\"\\[u000]0\">",
"methodName": "testZero"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"singleLine"
],
"repairTools": [],
"revisionId": "b88400ce0e9c1a0dadfd3417c256b02a82f38fe1"
},
{
"bugId": 75,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"changes": [
[
375
]
],
"inserts": [
[
313,
314,
315
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -310,7 +310,10 @@ static Double getNumberValue(Node n) {\n }\n \n static Double getStringNumberValue(String rawJsString) {\n+ if (rawJsString.contains(\"\\u000b\")) {\n // vertical tab is not always whitespace\n+ return null;\n+ }\n \n String s = trimJsWhiteSpace(rawJsString);\n // return ScriptRuntime.toNumber(s);\n@@ -372,7 +375,7 @@ static String trimJsWhiteSpace(String s) {\n static TernaryValue isStrWhiteSpaceChar(int c) {\n switch (c) {\n case '\\u000B': // <VT>\n- return TernaryValue.TRUE;\n+ return TernaryValue.UNKNOWN; // IE says \"no\", EcmaScript says \"yes\"\n case ' ': // <SP>\n case '\\n': // <LF>\n case '\\r': // <CR>\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIEString"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 4,
"spreadAllLines": 62,
"spreadCodeOnly": 46
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"retExpChange",
"varReplVar"
],
"repairPatterns": [
"condBlockRetAdd",
"constChange",
"wrongVarRef"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "c6cc58a9bc617483366141386e047b085b4e83ff"
},
{
"bugId": 78,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeFoldConstants.java": {
"deletes": [
[
711
],
[
718
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n+++ b/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n@@ -708,14 +708,12 @@ private Node performArithmeticOp(int opType, Node left, Node right) {\n break;\n case Token.MOD:\n if (rval == 0) {\n- error(DiagnosticType.error(\"JSC_DIVIDE_BY_0_ERROR\", \"Divide by 0\"), right);\n return null;\n }\n result = lval % rval;\n break;\n case Token.DIV:\n if (rval == 0) {\n- error(DiagnosticType.error(\"JSC_DIVIDE_BY_0_ERROR\", \"Divide by 0\"), right);\n return null;\n }\n result = lval / rval;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_DIVIDE_BY_0_ERROR. Divide by 0 at testcode line 1 : 8 expected:<0> but was:<1>",
"methodName": "testFoldArithmetic"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 2,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 6,
"spreadCodeOnly": 6
},
"observations": "Removes error invocation call.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcRem"
],
"repairPatterns": [
"copyPaste"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "25829b0395164533782d608399096803321225a7"
},
{
"bugId": 83,
"changedFiles": {
"com/google/javascript/jscomp/CommandLineRunner.java": {
"changes": [
[
334
]
],
"inserts": [
[
334
],
[
335,
336
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CommandLineRunner.java\n+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java\n@@ -331,7 +331,10 @@ public BooleanOptionHandler(\n \n @Override\n public int parseArguments(Parameters params) throws CmdLineException {\n- String param = params.getParameter(0);\n+ String param = null;\n+ try {\n+ param = params.getParameter(0);\n+ } catch (CmdLineException e) {}\n \n if (param == null) {\n setter.addValue(true);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testVersionFlag2"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "The existent code was splitted in declaration of var \"param\" out of the wrap and assignment, with Wrap-with-TryCatch.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"exTryCatchAdd"
],
"repairPatterns": [
"wrapsTryCatch"
],
"repairTools": [],
"revisionId": "43c245f0ff8d409e81e25687e69d34666b7cf26a"
},
{
"bugId": 80,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"inserts": [
[
1244,
1245,
1246,
1247,
1248,
1249,
1250,
1251,
1252,
1253,
1254,
1255,
1256,
1257,
1258,
1259,
1260,
1261,
1262
],
[
2910,
2911,
2912
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -1259,6 +1259,7 @@ static boolean isBooleanResultHelper(Node n) {\n // Inversion\n case Token.NOT:\n // delete operator returns a boolean.\n+ case Token.DELPROP:\n return true;\n default:\n return false;\n@@ -2907,6 +2908,7 @@ static boolean evaluatesToLocalValue(Node value, Predicate<Node> locals) {\n case Token.OBJECTLIT:\n // Literals objects with non-literal children are allowed.\n return true;\n+ case Token.DELPROP:\n case Token.IN:\n // TODO(johnlenz): should IN operator be included in #isSimpleOperator?\n return true;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.NodeUtilTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIsBooleanResult"
},
{
"className": " com.google.javascript.jscomp.NodeUtilTest",
"error": "java.lang.IllegalStateException",
"message": "Unexpected expression nodeDELPROP 1 [sourcename: [testcode] ] [parenthesized: true]",
"methodName": "testLocalValue1"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 1648,
"spreadCodeOnly": 989
},
"observations": "These blocks are inserted as extra switch clauses. Should be a \"Missing Condition\", \"Missing Block\" or both?",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd"
],
"repairPatterns": [
"expLogicExpand"
],
"repairTools": [],
"revisionId": "58786c3f717fa506280127265cd68fedf17de0a9"
},
{
"bugId": 81,
"changedFiles": {
"com/google/javascript/jscomp/parsing/IRFactory.java": {
"inserts": [
[
517
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/IRFactory.java\n+++ b/src/com/google/javascript/jscomp/parsing/IRFactory.java\n@@ -514,6 +514,13 @@ Node processFunctionNode(FunctionNode functionNode) {\n Name name = functionNode.getFunctionName();\n Boolean isUnnamedFunction = false;\n if (name == null) {\n+ int functionType = functionNode.getFunctionType();\n+ if (functionType != FunctionNode.FUNCTION_EXPRESSION) {\n+ errorReporter.error(\n+ \"unnamed function statement\",\n+ sourceName,\n+ functionNode.getLineno(), \"\", 0);\n+ }\n name = new Name();\n name.setIdentifier(\"\");\n isUnnamedFunction = true;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testUnnamedFunctionStatement"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "084b868bc2fbf9d6d0319e5a362ade1d7f43f899"
},
{
"bugId": 82,
"changedFiles": {
"com/google/javascript/rhino/jstype/JSType.java": {
"changes": [
[
163
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/JSType.java\n+++ b/src/com/google/javascript/rhino/jstype/JSType.java\n@@ -160,7 +160,9 @@ public boolean isNoObjectType() {\n }\n \n public final boolean isEmptyType() {\n- return isNoType() || isNoObjectType() || isNoResolvedType();\n+ return isNoType() || isNoObjectType() || isNoResolvedType() ||\n+ (registry.getNativeFunctionType(\n+ JSTypeNative.LEAST_FUNCTION_TYPE) == this);\n }\n \n public boolean isNumberObjectType() {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testIssue301"
},
{
"className": " com.google.javascript.rhino.jstype.FunctionTypeTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEmptyFunctionTypes"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [],
"revisionId": "a857aec27d79fc234fddd4a72c1215af0251b2d8"
},
{
"bugId": 85,
"changedFiles": {
"com/google/javascript/jscomp/UnreachableCodeElimination.java": {
"changes": [
[
183
]
],
"deletes": [
[
153
],
[
154
],
[
155
],
[
156
],
[
157
],
[
158
],
[
160
],
[
161
],
[
162
],
[
163
],
[
164
],
[
165
],
[
166
]
],
"inserts": [
[
196
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/UnreachableCodeElimination.java\n+++ b/src/com/google/javascript/jscomp/UnreachableCodeElimination.java\n@@ -150,20 +150,7 @@ private Node tryRemoveUnconditionalBranching(Node n) {\n return n;\n }\n \n- if (n.getParent() == null) {\n- List<DiGraphEdge<Node,Branch>> outEdges = gNode.getOutEdges();\n- if (outEdges.size() == 1) {\n- return tryRemoveUnconditionalBranching(outEdges.get(0).getDestination().getValue());\n- }\n- }\n switch (n.getType()) {\n- case Token.BLOCK:\n- if (n.hasChildren()) {\n- Node first = n.getFirstChild();\n- return tryRemoveUnconditionalBranching(first);\n- } else {\n- return tryRemoveUnconditionalBranching(ControlFlowAnalysis.computeFollowNode(n));\n- }\n case Token.RETURN:\n if (n.hasChildren()) {\n break;\n@@ -180,7 +167,7 @@ private Node tryRemoveUnconditionalBranching(Node n) {\n (n.getNext() == null || n.getNext().getType() == Token.FUNCTION)) {\n \n Preconditions.checkState(outEdges.get(0).getValue() == Branch.UNCOND);\n- Node fallThrough = tryRemoveUnconditionalBranching(computeFollowing(n));\n+ Node fallThrough = computeFollowing(n);\n Node nextCfgNode = outEdges.get(0).getDestination().getValue();\n if (nextCfgNode == fallThrough) {\n removeDeadExprStatementSafely(n);\n@@ -193,6 +180,13 @@ private Node tryRemoveUnconditionalBranching(Node n) {\n \n private Node computeFollowing(Node n) {\n Node next = ControlFlowAnalysis.computeFollowNode(n);\n+ while (next != null && next.getType() == Token.BLOCK) {\n+ if (next.hasChildren()) {\n+ next = next.getFirstChild();\n+ } else {\n+ next = computeFollowing(next);\n+ }\n+ }\n return next;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCascadedRemovalOfUnlessUnconditonalJumps"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "java.lang.RuntimeException",
"message": "INTERNAL COMPILER ERROR.",
"methodName": "testIssue311"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 1,
"linesRem": 13,
"methods": 2,
"sizeInLines": 21,
"spreadAllLines": 29,
"spreadCodeOnly": 22
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfElseAdd",
"condBranRem",
"loopAdd",
"mcAdd",
"mcRem",
"retRem",
"varRem"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRem",
"missNullCheckN",
"unwrapMethod"
],
"repairTools": [],
"revisionId": "21a2103d7fa5664ea324ef9ee25b4a8922e50955"
},
{
"bugId": 86,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"changes": [
[
2465
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -2462,7 +2462,7 @@ static boolean evaluatesToLocalValue(Node value, Predicate<Node> locals) {\n // TODO(nicksantos): This needs to be changed so that it\n // returns true iff we're sure the value was never aliased from inside\n // the constructor (similar to callHasLocalResult)\n- return true;\n+ return false;\n case Token.FUNCTION:\n case Token.REGEXP:\n case Token.ARRAYLIT:\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.NodeUtilTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testLocalValue1"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[A]> but was:<[A, f]>",
"methodName": "testLocalizedSideEffects8"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[A]> but was:<[A, f]>",
"methodName": "testLocalizedSideEffects9"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[externObjSEThis]> but was:<[externObjSEThis, NEW STRING externObjSEThisMethod]>",
"methodName": "testAnnotationInExterns_new4"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[externObjSEThis]> but was:<[externObjSEThis, NEW STRING externObjSEThisMethod, f]>",
"methodName": "testAnnotationInExterns_new6"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[]> but was:<[NEW STRING setLocation]>",
"methodName": "testIssue303b"
},
{
"className": " com.google.javascript.jscomp.PureFunctionIdentifierTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[]> but was:<[NEW STRING setLocation]>",
"methodName": "testIssue303"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"retExpChange"
],
"repairPatterns": [
"constChange",
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtssFix"
],
"revisionId": "0907b6618a60b2de23c8f7ec2217a37dc5e9a091"
},
{
"bugId": 84,
"changedFiles": {
"com/google/javascript/jscomp/parsing/IRFactory.java": {
"inserts": [
[
341
],
[
797,
798
],
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/IRFactory.java\n+++ b/src/com/google/javascript/jscomp/parsing/IRFactory.java\n@@ -338,6 +338,13 @@ Node processArrayLiteral(ArrayLiteral literalNode) {\n @Override\n Node processAssignment(Assignment assignmentNode) {\n Node assign = processInfixExpression(assignmentNode);\n+ Node target = assign.getFirstChild();\n+ if (!validAssignmentTarget(target)) {\n+ errorReporter.error(\n+ \"invalid assignment target\",\n+ sourceName,\n+ target.getLineno(), \"\", 0);\n+ }\n return assign;\n }\n \n@@ -794,6 +801,17 @@ Node processUnaryExpression(UnaryExpression exprNode) {\n operand.setDouble(-operand.getDouble());\n return operand;\n } else {\n+ if (type == Token.INC || type == Token.DEC) {\n+ if (!validAssignmentTarget(operand)) {\n+ String msg = (type == Token.INC)\n+ ? \"invalid increment target\"\n+ : \"invalid decrement target\";\n+ errorReporter.error(\n+ msg,\n+ sourceName,\n+ operand.getLineno(), \"\", 0);\n+ }\n+ }\n \n Node node = newNode(type, operand);\n if (exprNode.isPostfix()) {\n@@ -803,6 +821,15 @@ Node processUnaryExpression(UnaryExpression exprNode) {\n }\n }\n \n+ private boolean validAssignmentTarget(Node target) {\n+ switch (target.getType()) {\n+ case Token.NAME:\n+ case Token.GETPROP:\n+ case Token.GETELEM:\n+ return true;\n+ }\n+ return false;\n+ }\n \n @Override\n Node processVariableDeclaration(VariableDeclaration declarationNode) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDestructuringAssignForbidden4"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 27,
"linesMod": 0,
"linesRem": 0,
"methods": 3,
"sizeInLines": 27,
"spreadAllLines": 465,
"spreadCodeOnly": 377
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranCaseAdd",
"condBranIfAdd",
"mcAdd",
"mdAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "4839e1ea57f9a1a26debd2cc8f22beef7282b490"
},
{
"bugId": 89,
"changedFiles": {
"com/google/javascript/jscomp/CollapseProperties.java": {
"inserts": [
[
483,
484,
485,
486
]
]
},
"com/google/javascript/jscomp/GlobalNamespace.java": {
"changes": [
[
920
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CollapseProperties.java\n+++ b/src/com/google/javascript/jscomp/CollapseProperties.java\n@@ -481,6 +481,9 @@ private void updateSimpleDeclaration(String alias, Name refName, Ref ref) {\n Node greatGramps = gramps.getParent();\n Node greatGreatGramps = greatGramps.getParent();\n \n+ if (rvalue != null && rvalue.getType() == Token.FUNCTION) {\n+ checkForHosedThisReferences(rvalue, refName.docInfo, refName);\n+ }\n \n // Create the new alias node.\n Node nameNode = NodeUtil.newName(\n--- a/src/com/google/javascript/jscomp/GlobalNamespace.java\n+++ b/src/com/google/javascript/jscomp/GlobalNamespace.java\n@@ -917,7 +917,7 @@ boolean canCollapseUnannotatedChildNames() {\n }\n \n // If this is aliased, then its properties can't be collapsed either.\n- if (type != Type.FUNCTION && aliasingGets > 0) {\n+ if (aliasingGets > 0) {\n return false;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAddPropertyToChildOfUncollapsibleFunctionInLocalScope"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAliasCreatedForFunctionDepth1_1"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAliasCreatedForFunctionDepth1_2"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAliasCreatedForFunctionDepth1_3"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAddPropertyToUncollapsibleNamedCtorInLocalScopeDepth1"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAddPropertyToUncollapsibleFunctionInLocalScopeDepth1"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAddPropertyToUncollapsibleFunctionInLocalScopeDepth2"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAliasCreatedForFunctionDepth2"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"condExpRed",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicReduce",
"missNullCheckN"
],
"repairTools": [],
"revisionId": "4b065734d8afb5ab0d241ee5da22af0fa9d75ec3"
},
{
"bugId": 88,
"changedFiles": {
"com/google/javascript/jscomp/DeadAssignmentsElimination.java": {
"inserts": [
[
327,
328,
329,
330
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/DeadAssignmentsElimination.java\n+++ b/src/com/google/javascript/jscomp/DeadAssignmentsElimination.java\n@@ -324,9 +324,15 @@ private VariableLiveness isVariableReadBeforeKill(\n Node n, String variable) {\n if (NodeUtil.isName(n) && variable.equals(n.getString())) {\n if (NodeUtil.isLhs(n, n.getParent())) {\n+ Preconditions.checkState(n.getParent().getType() == Token.ASSIGN);\n // The expression to which the assignment is made is evaluated before\n // the RHS is evaluated (normal left to right evaluation) but the KILL\n // occurs after the RHS is evaluated.\n+ Node rhs = n.getNext();\n+ VariableLiveness state = isVariableReadBeforeKill(rhs, variable);\n+ if (state == VariableLiveness.READ) {\n+ return state;\n+ }\n return VariableLiveness.KILL;\n } else {\n return VariableLiveness.READ;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297a"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297b"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297c"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297d"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297e"
},
{
"className": " com.google.javascript.jscomp.DeadAssignmentsEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue297f"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "6a17da87f9e132bdc147b33223826da040c77a6b"
},
{
"bugId": 87,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java": {
"changes": [
[
533
]
],
"inserts": [
[
523,
524,
525,
526,
527,
528,
529,
530,
531,
532,
533
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n+++ b/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n@@ -520,17 +520,29 @@ private boolean isFoldableExpressBlock(Node n) {\n if (n.getType() == Token.BLOCK) {\n if (n.hasOneChild()) {\n Node maybeExpr = n.getFirstChild();\n+ if (maybeExpr.getType() == Token.EXPR_RESULT) {\n // IE has a bug where event handlers behave differently when\n // their return value is used vs. when their return value is in\n // an EXPR_RESULT. It's pretty freaking weird. See:\n // http://code.google.com/p/closure-compiler/issues/detail?id=291\n // We try to detect this case, and not fold EXPR_RESULTs\n // into other expressions.\n+ if (maybeExpr.getFirstChild().getType() == Token.CALL) {\n+ Node calledFn = maybeExpr.getFirstChild().getFirstChild();\n \n // We only have to worry about methods with an implicit 'this'\n // param, or this doesn't happen.\n+ if (calledFn.getType() == Token.GETELEM) {\n+ return false;\n+ } else if (calledFn.getType() == Token.GETPROP &&\n+ calledFn.getLastChild().getString().startsWith(\"on\")) {\n+ return false;\n+ }\n+ }\n \n- return NodeUtil.isExpressionNode(maybeExpr);\n+ return true;\n+ }\n+ return false;\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeSubstituteAlternateSyntaxTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue291"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 13,
"spreadAllLines": 10,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrongComp"
],
"repairTools": [],
"revisionId": "f64a3f51bd346547ce6e1edb30601df73dff27d9"
},
{
"bugId": 92,
"changedFiles": {
"com/google/javascript/jscomp/ProcessClosurePrimitives.java": {
"changes": [
[
789
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n+++ b/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n@@ -786,7 +786,7 @@ void replace() {\n } else {\n // In this case, the name was implicitly provided by two independent\n // modules. We need to move this code up to a common module.\n- int indexOfDot = namespace.indexOf('.');\n+ int indexOfDot = namespace.lastIndexOf('.');\n if (indexOfDot == -1) {\n // Any old place is fine.\n compiler.getNodeForCodeInsertion(minimumModule)\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ProcessClosurePrimitivesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testProvideInIndependentModules4"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcRepl"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "8980b60033b1c6853cbca593ec89d3d332adf7dc"
},
{
"bugId": 95,
"changedFiles": {
"com/google/javascript/jscomp/TypedScopeCreator.java": {
"inserts": [
[
899,
900,
901,
902,
903,
904
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypedScopeCreator.java\n+++ b/src/com/google/javascript/jscomp/TypedScopeCreator.java\n@@ -896,9 +896,16 @@ void defineSlot(Node n, Node parent, JSType type, boolean inferred) {\n // scope where the root object appears. This helps out people\n // who declare \"global\" names in an anonymous namespace.\n Scope scopeToDeclareIn = scope;\n+ if (n.getType() == Token.GETPROP && !scope.isGlobal() &&\n+ isQnameRootedInGlobalScope(n)) {\n+ Scope globalScope = scope.getGlobalScope();\n \n // don't try to declare in the global scope if there's\n // already a symbol there with this name.\n+ if (!globalScope.isDeclared(variableName, false)) {\n+ scopeToDeclareIn = scope.getGlobalScope();\n+ }\n+ }\n \n // declared in closest scope?\n if (scopeToDeclareIn.isDeclared(variableName, false)) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testQualifiedNameInference5"
},
{
"className": " com.google.javascript.jscomp.TypedScopeCreatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testGlobalQualifiedNameInLocalScope"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [],
"revisionId": "f6607996d6d3bd6820ce3848d147991b27600a12"
},
{
"bugId": 90,
"changedFiles": {
"com/google/javascript/jscomp/FunctionTypeBuilder.java": {
"changes": [
[
184
]
]
},
"com/google/javascript/rhino/jstype/FunctionType.java": {
"inserts": [
[
880
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionTypeBuilder.java\n+++ b/src/com/google/javascript/jscomp/FunctionTypeBuilder.java\n@@ -181,7 +181,7 @@ public boolean apply(JSType type) {\n // create interfaces JSType, ObjectType, FunctionType etc and have\n // separate implementation instead of the class hierarchy, so that\n // union types can also be object types, etc.\n- if (!type.isSubtype(\n+ if (!type.restrictByNotNullOrUndefined().isSubtype(\n typeRegistry.getNativeType(OBJECT_TYPE))) {\n reportWarning(THIS_TYPE_NON_OBJECT, type.toString());\n return false;\n--- a/src/com/google/javascript/rhino/jstype/FunctionType.java\n+++ b/src/com/google/javascript/rhino/jstype/FunctionType.java\n@@ -877,6 +877,9 @@ JSType resolveInternal(ErrorReporter t, StaticScope<JSType> scope) {\n // mean \"nullable Foo\". For certain tags (like @extends) we de-nullify\n // the name for them.\n JSType maybeTypeOfThis = safeResolve(typeOfThis, t, scope);\n+ if (maybeTypeOfThis != null) {\n+ maybeTypeOfThis = maybeTypeOfThis.restrictByNotNullOrUndefined();\n+ }\n if (maybeTypeOfThis instanceof ObjectType) {\n typeOfThis = (ObjectType) maybeTypeOfThis;\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testBackwardsTypedefUse8"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[actual parameter 1 of g does not match formal parameter",
"methodName": "testBackwardsTypedefUse9"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condExpMod",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"missNullCheckN"
],
"repairTools": [],
"revisionId": "c5e143f7df0c3d73f6634488cac8ad8e7054fe05"
},
{
"bugId": 94,
"changedFiles": {
"com/google/javascript/jscomp/NodeUtil.java": {
"inserts": [
[
327,
328,
329,
330,
331,
332,
333,
334,
335
],
[
333,
334,
335
],
[
335,
336,
337
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NodeUtil.java\n+++ b/src/com/google/javascript/jscomp/NodeUtil.java\n@@ -326,14 +326,33 @@ static boolean isValidDefineValue(Node val, Set<String> defines) {\n return true;\n \n // Binary operators are only valid if both children are valid.\n+ case Token.ADD:\n case Token.BITAND:\n case Token.BITNOT:\n case Token.BITOR:\n case Token.BITXOR:\n+ case Token.DIV:\n+ case Token.EQ:\n+ case Token.GE:\n+ case Token.GT:\n+ case Token.LE:\n+ case Token.LSH:\n+ case Token.LT:\n+ case Token.MOD:\n+ case Token.MUL:\n+ case Token.NE:\n+ case Token.RSH:\n+ case Token.SHEQ:\n+ case Token.SHNE:\n+ case Token.SUB:\n+ case Token.URSH:\n+ return isValidDefineValue(val.getFirstChild(), defines)\n+ && isValidDefineValue(val.getLastChild(), defines);\n \n // Uniary operators are valid if the child is valid.\n case Token.NOT:\n case Token.NEG:\n+ case Token.POS:\n return isValidDefineValue(val.getFirstChild(), defines);\n \n // Names are valid if and only if they are defines themselves.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.NodeUtilTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testValidDefine"
},
{
"className": " com.google.javascript.jscomp.ProcessDefinesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_INVALID_DEFINE_INIT_ERROR. illegal initialization of @define variable DEF_OVERRIDE_STRING at testcode line 1 : 54 expected:<0> but was:<1>",
"methodName": "testOverridingString1"
},
{
"className": " com.google.javascript.jscomp.ProcessDefinesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_INVALID_DEFINE_INIT_ERROR. illegal initialization of @define variable DEF_OVERRIDE_STRING at testcode line 1 : 54 expected:<0> but was:<1>",
"methodName": "testOverridingString3"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 19,
"spreadAllLines": 8,
"spreadCodeOnly": 6
},
"observations": "Many \"case\" conditions were added, sharing the same consequent action. Equivalent to \"if ( x || y || z || ... ) then do this\". These blocks are inserted as extra switch clauses. Should be a \"Missing Condition\", \"Missing Block\" or both?",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicExpand"
],
"repairTools": [],
"revisionId": "7cc748592670105f9d783b1b85f0f27e938db4ff"
},
{
"bugId": 91,
"changedFiles": {
"com/google/javascript/jscomp/CheckGlobalThis.java": {
"inserts": [
[
113,
114,
115
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckGlobalThis.java\n+++ b/src/com/google/javascript/jscomp/CheckGlobalThis.java\n@@ -112,6 +112,15 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {\n }\n \n // Don't traverse functions that are getting lent to a prototype.\n+ Node gramps = parent.getParent();\n+ if (NodeUtil.isObjectLitKey(parent, gramps)) {\n+ JSDocInfo maybeLends = gramps.getJSDocInfo();\n+ if (maybeLends != null &&\n+ maybeLends.getLendsName() != null &&\n+ maybeLends.getLendsName().endsWith(\".prototype\")) {\n+ return false;\n+ }\n+ }\n }\n \n if (parent != null && parent.getType() == Token.ASSIGN) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 110 expected:<0> but was:<1>",
"methodName": "testLendsAnnotation3"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "7eb2d84de101a125d41d3a1157f4eed789ca4a0d"
},
{
"bugId": 93,
"changedFiles": {
"com/google/javascript/jscomp/ProcessClosurePrimitives.java": {
"changes": [
[
789
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n+++ b/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n@@ -786,7 +786,7 @@ void replace() {\n } else {\n // In this case, the name was implicitly provided by two independent\n // modules. We need to move this code up to a common module.\n- int indexOfDot = namespace.indexOf('.');\n+ int indexOfDot = namespace.lastIndexOf('.');\n if (indexOfDot == -1) {\n // Any old place is fine.\n compiler.getNodeForCodeInsertion(minimumModule)\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ProcessClosurePrimitivesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testProvideInIndependentModules4"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Same change/commit as #92.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcRepl"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "9d1e18e87a41f2a610ed70f3a1d57abbce7a1cd7"
},
{
"bugId": 97,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeFoldConstants.java": {
"changes": [
[
698
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n+++ b/src/com/google/javascript/jscomp/PeepholeFoldConstants.java\n@@ -695,7 +695,8 @@ private Node tryFoldShift(Node n, Node left, Node right) {\n // JavaScript handles zero shifts on signed numbers differently than\n // Java as an Java int can not represent the unsigned 32-bit number\n // where JavaScript can so use a long here.\n- result = lvalInt >>> rvalInt;\n+ long lvalLong = lvalInt & 0xffffffffL;\n+ result = lvalLong >>> rvalInt;\n break;\n default:\n throw new AssertionError(\"Unknown shift operator: \" +\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeFoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFoldBitShifts"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"varAdd"
],
"repairPatterns": [
"expArithMod",
"missComp",
"singleLine"
],
"repairTools": [],
"revisionId": "ee749e286b477f8d6f53ff5960a38453baf50f31"
},
{
"bugId": 96,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"changes": [
[
1409
]
],
"inserts": [
[
1410,
1411,
1412
],
[
1413
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -1406,10 +1406,13 @@ private void visitParameterList(NodeTraversal t, Node call,\n Node parameter = null;\n Node argument = null;\n while (arguments.hasNext() &&\n- parameters.hasNext()) {\n+ (parameters.hasNext() ||\n+ parameter != null && parameter.isVarArgs())) {\n // If there are no parameters left in the list, then the while loop\n // above implies that this must be a var_args function.\n+ if (parameters.hasNext()) {\n parameter = parameters.next();\n+ }\n argument = arguments.next();\n ordinal++;\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected a warning",
"methodName": "testFunctionArguments16"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 3,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"loopCondChange",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"missNullCheckN",
"wrapsIf"
],
"repairTools": [],
"revisionId": "807aaf2569e9eb09761068c5aeb95654daea30d9"
},
{
"bugId": 101,
"changedFiles": {
"com/google/javascript/jscomp/CommandLineRunner.java": {
"changes": [
[
434
]
],
"deletes": [
[
433
],
[
435
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CommandLineRunner.java\n+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java\n@@ -430,10 +430,8 @@ protected CompilerOptions createOptions() {\n for (FormattingOption formattingOption : flags.formatting) {\n formattingOption.applyToOptions(options);\n }\n- if (flags.process_closure_primitives) {\n- options.closurePass = true;\n- }\n \n+ options.closurePass = flags.process_closure_primitives;\n initOptionsFromFlags(options);\n return options;\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testProcessClosurePrimitives"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 3,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"condBranRem"
],
"repairPatterns": [
"condBlockRem"
],
"repairTools": [],
"revisionId": "369282db85567f1bf2c9635d0c0043d47f114814"
},
{
"bugId": 100,
"changedFiles": {
"com/google/javascript/jscomp/CheckGlobalThis.java": {
"changes": [
[
146
]
],
"inserts": [
[
93,
94,
95,
96,
97,
98,
99
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckGlobalThis.java\n+++ b/src/com/google/javascript/jscomp/CheckGlobalThis.java\n@@ -96,6 +96,13 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {\n // var a = function() { }; // or\n // function a() {} // or\n // a.x = function() {};\n+ int pType = parent.getType();\n+ if (!(pType == Token.BLOCK ||\n+ pType == Token.SCRIPT ||\n+ pType == Token.NAME ||\n+ pType == Token.ASSIGN)) {\n+ return false;\n+ }\n }\n \n if (parent != null && parent.getType() == Token.ASSIGN) {\n@@ -143,7 +150,7 @@ private boolean shouldReportThis(Node n, Node parent) {\n }\n \n // Also report a THIS with a property access.\n- return false;\n+ return parent != null && NodeUtil.isGet(parent);\n }\n \n /**\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 35 expected:<0> but was:<1>",
"methodName": "testStaticFunction6"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 41 expected:<0> but was:<1>",
"methodName": "testStaticFunction7"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testStaticFunction8"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testGlobalThis7"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 39 expected:<0> but was:<1>",
"methodName": "testStaticMethod2"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 41 expected:<0> but was:<1>",
"methodName": "testStaticMethod3"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testInnerFunction1"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testInnerFunction2"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testInnerFunction3"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 47,
"spreadCodeOnly": 34
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN",
"wrongComp"
],
"repairTools": [],
"revisionId": "6d00ac1a68612aade8a19d7ecc9b180f00ae5234"
},
{
"bugId": 98,
"changedFiles": {
"com/google/javascript/jscomp/ReferenceCollectingCallback.java": {
"inserts": [
[
359,
360,
361,
362
],
[
-1
],
[
556,
557,
558,
559,
560,
561,
562
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ReferenceCollectingCallback.java\n+++ b/src/com/google/javascript/jscomp/ReferenceCollectingCallback.java\n@@ -354,15 +354,23 @@ Reference getInitializingReferenceForConstants() {\n boolean isAssignedOnceInLifetime() {\n Reference ref = getOneAndOnlyAssignment();\n if (ref == null) {\n return false;\n }\n \n // Make sure this assignment is not in a loop.\n+ for (BasicBlock block = ref.getBasicBlock();\n+ block != null; block = block.getParent()) {\n+ if (block.isFunction) {\n+ break;\n+ } else if (block.isLoop) {\n+ return false;\n+ }\n+ }\n \n return true;\n }\n \n /**\n * @return The one and only assignment. Returns if there are 0 or 2+\n * assignments.\n */\n@@ -523,41 +531,52 @@ Scope getScope() {\n public String getSourceName() {\n return sourceName;\n }\n }\n \n /**\n * Represents a section of code that is uninterrupted by control structures\n * (conditional or iterative logic).\n */\n static final class BasicBlock {\n \n private final BasicBlock parent;\n \n /**\n * Determines whether the block may not be part of the normal control flow,\n * but instead \"hoisted\" to the top of the scope.\n */\n private final boolean isHoisted;\n \n /**\n * Whether this block denotes a function scope.\n */\n+ private final boolean isFunction;\n \n /**\n * Whether this block denotes a loop.\n */\n+ private final boolean isLoop;\n \n /**\n * Creates a new block.\n * @param parent The containing block.\n * @param root The root node of the block.\n */\n BasicBlock(BasicBlock parent, Node root) {\n this.parent = parent;\n \n // only named functions may be hoisted.\n this.isHoisted = NodeUtil.isHoistedFunctionDeclaration(root);\n \n+ this.isFunction = root.getType() == Token.FUNCTION;\n \n+ if (root.getParent() != null) {\n+ int pType = root.getParent().getType();\n+ this.isLoop = pType == Token.DO ||\n+ pType == Token.WHILE ||\n+ pType == Token.FOR;\n+ } else {\n+ this.isLoop = false;\n+ }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineAliasesInLoop"
}
],
"metrics": {
"chunks": 5,
"classes": 2,
"files": 1,
"linesAdd": 19,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 19,
"spreadAllLines": 201,
"spreadCodeOnly": 127
},
"observations": "New class attributes were added.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"loopAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp",
"missNullCheckN"
],
"repairTools": [],
"revisionId": "d1df970451b5a18956448097b3afb43f3a82263d"
},
{
"bugId": 99,
"changedFiles": {
"com/google/javascript/jscomp/CheckGlobalThis.java": {
"changes": [
[
91
],
[
92
],
[
129
]
],
"inserts": [
[
123,
124,
125
],
[
132
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CheckGlobalThis.java\n+++ b/src/com/google/javascript/jscomp/CheckGlobalThis.java\n@@ -89,6 +89,7 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {\n JSDocInfo jsDoc = getFunctionJsDocInfo(n);\n if (jsDoc != null &&\n (jsDoc.isConstructor() ||\n+ jsDoc.isInterface() ||\n jsDoc.hasThisType() ||\n jsDoc.isOverride())) {\n return false;\n@@ -122,13 +123,17 @@ public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {\n } else {\n // Only traverse the right side if it's not an assignment to a prototype\n // property or subproperty.\n+ if (NodeUtil.isGet(lhs)) {\n if (lhs.getType() == Token.GETPROP &&\n lhs.getLastChild().getString().equals(\"prototype\")) {\n return false;\n }\n- if (lhs.getQualifiedName() != null && lhs.getQualifiedName().contains(\".prototype.\")) {\n+ Node llhs = lhs.getFirstChild();\n+ if (llhs.getType() == Token.GETPROP &&\n+ llhs.getLastChild().getString().equals(\"prototype\")) {\n return false;\n }\n+ }\n }\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. expected:<1> but was:<0>",
"methodName": "testPropertyOfMethod"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 39 expected:<0> but was:<1>",
"methodName": "testMethod4"
},
{
"className": " com.google.javascript.jscomp.CheckGlobalThisTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USED_GLOBAL_THIS. dangerous use of the global this object at testcode line 1 : 54 expected:<0> but was:<1>",
"methodName": "testInterface1"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 39,
"spreadCodeOnly": 26
},
"observations": "Changed condition in expression, adds an extra computing in line 131.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranRem",
"condExpExpand",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"expLogicExpand",
"expLogicMod",
"wrapsIf"
],
"repairTools": [],
"revisionId": "8aa879a4eeb18cfc8d13e6c843a32b7f41ccd516"
},
{
"bugId": 104,
"changedFiles": {
"com/google/javascript/rhino/jstype/UnionType.java": {
"changes": [
[
291
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/jstype/UnionType.java\n+++ b/src/com/google/javascript/rhino/jstype/UnionType.java\n@@ -288,7 +288,7 @@ JSType meet(JSType that) {\n builder.addAlternate(that);\n }\n JSType result = builder.build();\n- if (result != null) {\n+ if (!result.isNoType()) {\n return result;\n } else if (this.isObject() && that.isObject()) {\n return getNativeType(JSTypeNative.NO_OBJECT_TYPE);\n",
"failingTests": [
{
"className": " com.google.javascript.rhino.jstype.UnionTypeTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<NoObject> but was:<None>",
"methodName": "testGreatestSubtypeUnionTypes5"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "A Null-Check was removed and replaced by another condition.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpMod",
"mcAdd"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [],
"revisionId": "67289ae4cbaba3ae70cd2e8fb92f3f2898039dfb"
},
{
"bugId": 105,
"changedFiles": {
"com/google/javascript/jscomp/FoldConstants.java": {
"changes": [
[
1477
],
[
1483
],
[
1488
],
[
1492
],
[
1500
]
],
"inserts": [
[
1484
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FoldConstants.java\n+++ b/src/com/google/javascript/jscomp/FoldConstants.java\n@@ -1474,22 +1474,24 @@ void tryFoldStringJoin(NodeTraversal t, Node n, Node left, Node right,\n \n String joinString = NodeUtil.getStringValue(right);\n List<Node> arrayFoldedChildren = Lists.newLinkedList();\n- StringBuilder sb = new StringBuilder();\n+ StringBuilder sb = null;\n int foldedSize = 0;\n Node elem = arrayNode.getFirstChild();\n // Merges adjacent String nodes.\n while (elem != null) {\n if (NodeUtil.isImmutableValue(elem)) {\n- if (sb.length() > 0) {\n+ if (sb == null) {\n+ sb = new StringBuilder();\n+ } else {\n sb.append(joinString);\n }\n sb.append(NodeUtil.getStringValue(elem));\n } else {\n- if (sb.length() > 0) {\n+ if (sb != null) {\n // + 2 for the quotes.\n foldedSize += sb.length() + 2;\n arrayFoldedChildren.add(Node.newString(sb.toString()));\n- sb = new StringBuilder();\n+ sb = null;\n }\n foldedSize += InlineCostEstimator.getCost(elem);\n arrayFoldedChildren.add(elem);\n@@ -1497,7 +1499,7 @@ void tryFoldStringJoin(NodeTraversal t, Node n, Node left, Node right,\n elem = elem.getNext();\n }\n \n- if (sb.length() > 0) {\n+ if (sb != null) {\n // + 2 for the quotes.\n foldedSize += sb.length() + 2;\n arrayFoldedChildren.add(Node.newString(sb.toString()));\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FoldConstantsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testStringJoinAdd"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 5,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 19,
"spreadCodeOnly": 16
},
"observations": "Moves the instantiation of StringBuilder to another place.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfElseAdd",
"condExpMod",
"mcRem",
"objInstAdd",
"objInstRem"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"expLogicMod",
"initFix"
],
"repairTools": [],
"revisionId": "113a08f59e8116fb11a7d4ceb11d5bb09b74ac3c"
},
{
"bugId": 106,
"changedFiles": {
"com/google/javascript/jscomp/GlobalNamespace.java": {
"inserts": [
[
903,
904,
905,
906,
907,
908
]
]
},
"com/google/javascript/rhino/JSDocInfoBuilder.java": {
"deletes": [
[
189
],
[
191
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/GlobalNamespace.java\n+++ b/src/com/google/javascript/jscomp/GlobalNamespace.java\n@@ -904,6 +904,10 @@ boolean canCollapseUnannotatedChildNames() {\n // Don't try to collapse if the one global set is a twin reference.\n // We could theoretically handle this case in CollapseProperties, but\n // it's probably not worth the effort.\n+ Preconditions.checkNotNull(declaration);\n+ if (declaration.getTwin() != null) {\n+ return false;\n+ }\n \n if (isClassOrEnum) {\n return true;\n--- a/src/com/google/javascript/rhino/JSDocInfoBuilder.java\n+++ b/src/com/google/javascript/rhino/JSDocInfoBuilder.java\n@@ -186,9 +186,7 @@ public void markName(String name, int lineno, int charno) {\n * @return {@code true} if the description was recorded.\n */\n public boolean recordBlockDescription(String description) {\n- if (parseDocumentation) {\n populated = true;\n- }\n return currentInfo.documentBlock(description);\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckSideEffectsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_USELESS_CODE. Suspicious code. This code lacks side-effects. Is there a bug? at testcode line 1 expected:<0> but was:<1>",
"methodName": "testJSDocComments"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTwinReferenceCancelsChildCollapsing"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCrashInNestedAssign"
},
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "java.lang.IllegalArgumentException",
"message": "",
"methodName": "testCrashInCommaOperator"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 2,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"condBranRem",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN",
"unwrapIfElse"
],
"repairTools": [],
"revisionId": "e609670bb56e0c7216c9476a5f6a5594e7f1acdb"
},
{
"bugId": 102,
"changedFiles": {
"com/google/javascript/jscomp/Normalize.java": {
"deletes": [
[
94
]
],
"inserts": [
[
89
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/Normalize.java\n+++ b/src/com/google/javascript/jscomp/Normalize.java\n@@ -86,12 +86,12 @@ private void reportCodeChange(String changeDescription) {\n @Override\n public void process(Node externs, Node root) {\n NodeTraversal.traverse(compiler, root, this);\n+ removeDuplicateDeclarations(root);\n if (MAKE_LOCAL_NAMES_UNIQUE) {\n MakeDeclaredNamesUnique renamer = new MakeDeclaredNamesUnique();\n NodeTraversal t = new NodeTraversal(compiler, renamer);\n t.traverseRoots(externs, root);\n }\n- removeDuplicateDeclarations(root);\n new PropogateConstantAnnotations(compiler, assertOnChange)\n .process(externs, root);\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CompilerRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue115"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 1,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 5,
"spreadCodeOnly": 5
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcMove"
],
"repairPatterns": [
"codeMove",
"singleLine"
],
"repairTools": [],
"revisionId": "d48c365ba8251057a71a2e2b7aabff640209e31b"
},
{
"bugId": 103,
"changedFiles": {
"com/google/javascript/jscomp/ControlFlowAnalysis.java": {
"inserts": [
[
886,
887,
888,
889,
890,
891,
892,
893,
894
]
]
},
"com/google/javascript/jscomp/DisambiguateProperties.java": {
"inserts": [
[
761,
762,
763,
764,
765,
766
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ControlFlowAnalysis.java\n+++ b/src/com/google/javascript/jscomp/ControlFlowAnalysis.java\n@@ -891,6 +891,7 @@ private static boolean mayThrowException(Node n) {\n case Token.ASSIGN:\n case Token.INC:\n case Token.DEC:\n+ case Token.INSTANCEOF:\n return true;\n case Token.FUNCTION:\n return false;\n--- a/src/com/google/javascript/jscomp/DisambiguateProperties.java\n+++ b/src/com/google/javascript/jscomp/DisambiguateProperties.java\n@@ -760,9 +760,16 @@ public JSTypeSystem(AbstractCompiler compiler) {\n }\n // If the property does not exist on the referenced type but the original\n // type is an object type, see if any subtype has the property.\n+ if (foundType == null) {\n+ ObjectType maybeType = ObjectType.cast(\n+ registry.getGreatestSubtypeWithProperty(type, field));\n // getGreatestSubtypeWithProperty does not guarantee that the property\n // is defined on the returned type, it just indicates that it might be,\n // so we have to double check.\n+ if (maybeType != null && maybeType.hasOwnProperty(field)) {\n+ foundType = maybeType;\n+ }\n+ }\n return foundType;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckUnreachableCodeTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_UNREACHABLE_CODE. unreachable code at testcode line 1 expected:<0> but was:<1>",
"methodName": "testInstanceOfThrowsException"
},
{
"className": " com.google.javascript.jscomp.ControlFlowAnalysisTest",
"error": "junit.framework.AssertionFailedError",
"message": "No cross edges found",
"methodName": "testInstanceOf"
},
{
"className": " com.google.javascript.jscomp.DisambiguatePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSupertypeReferenceOfSubtypeProperty"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranCaseAdd",
"condBranIfAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand",
"missNullCheckN",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "2f5cb1622371de540fe20dcbe0411651ec89f952"
},
{
"bugId": 107,
"changedFiles": {
"com/google/javascript/jscomp/CommandLineRunner.java": {
"inserts": [
[
862
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CommandLineRunner.java\n+++ b/src/com/google/javascript/jscomp/CommandLineRunner.java\n@@ -859,6 +859,7 @@ protected CompilerOptions createOptions() {\n // so we might as well inline it. But shut off the i18n warnings,\n // because the user didn't really ask for i18n.\n options.messageBundle = new EmptyMessageBundle();\n+ options.setWarningLevel(JsMessageVisitor.MSG_CONVENTIONS, CheckLevel.OFF);\n }\n \n return options;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CommandLineRunnerTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected no warnings or errors",
"methodName": "testGetMsgWiringNoWarnings"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"mcAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [],
"revisionId": "49e9565febba904484396e2aef7dbe86f55e9cc5"
},
{
"bugId": 108,
"changedFiles": {
"com/google/javascript/jscomp/ScopedAliases.java": {
"changes": [
[
581
]
],
"inserts": [
[
-1
],
[
315,
316,
317,
318,
319,
320
],
[
432
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ScopedAliases.java\n+++ b/src/com/google/javascript/jscomp/ScopedAliases.java\n@@ -256,6 +256,7 @@ public void applyAlias() {\n private final Map<String, Var> aliases = Maps.newHashMap();\n \n // Also temporary and cleared for each scope.\n+ private final Set<Node> injectedDecls = Sets.newHashSet();\n \n // Suppose you create an alias.\n // var x = goog.x;\n@@ -313,6 +314,7 @@ public void exitScope(NodeTraversal t) {\n \n if (t.getScopeDepth() == 2) {\n renameNamespaceShadows(t);\n+ injectedDecls.clear();\n aliases.clear();\n forbiddenLocals.clear();\n transformation = null;\n@@ -429,6 +431,7 @@ private void findAliases(NodeTraversal t) {\n } else {\n grandparent.addChildBefore(newDecl, varNode);\n }\n+ injectedDecls.add(newDecl.getFirstChild());\n }\n \n // Rewrite \"var name = EXPR;\" to \"var name = $jscomp.scope.name;\"\n@@ -578,7 +581,7 @@ public void visit(NodeTraversal t, Node n, Node parent) {\n // When we inject declarations, we duplicate jsdoc. Make sure\n // we only process that jsdoc once.\n JSDocInfo info = n.getJSDocInfo();\n- if (info != null) {\n+ if (info != null && !injectedDecls.contains(n)) {\n for (Node node : info.getTypeNodes()) {\n fixTypeNode(node);\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ScopedAliasesTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testIssue1144"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 3,
"sizeInLines": 4,
"spreadAllLines": 322,
"spreadCodeOnly": 230
},
"observations": "Added new class attribute and its initialization. An existent conditional expression with Null-Check was expanded with another condition.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condExpExpand",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"expLogicExpand",
"initFix",
"missComp"
],
"repairTools": [],
"revisionId": "aae547f4d911dfbf42ca5a31aeb401ac83725a14"
},
{
"bugId": 109,
"changedFiles": {
"com/google/javascript/jscomp/parsing/JsDocInfoParser.java": {
"changes": [
[
1908
]
],
"inserts": [
[
1908
],
[
1909
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n+++ b/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n@@ -1905,7 +1905,11 @@ private Node parseTypeExpression(JsDocToken token) {\n * For expressions on the right hand side of a this: or new:\n */\n private Node parseContextTypeExpression(JsDocToken token) {\n- return parseTypeName(token);\n+ if (token == JsDocToken.QMARK) {\n+ return newNode(Token.QMARK);\n+ } else {\n+ return parseBasicTypeExpression(token);\n+ }\n }\n \n /**\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "extra warning: Bad type annotation. type not recognized due to syntax error",
"methodName": "testStructuralConstructor2"
},
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "extra warning: Bad type annotation. type not recognized due to syntax error",
"methodName": "testStructuralConstructor3"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"mcRepl",
"retBranchAdd",
"retExpChange"
],
"repairPatterns": [
"condBlockRetAdd",
"wrapsIfElse",
"wrongComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "7d26b7bcae8311f3c032bae3f1df27b590a4c174"
},
{
"bugId": 117,
"changedFiles": {
"com/google/javascript/jscomp/TypeValidator.java": {
"deletes": [
[
756
],
[
757
],
[
758
],
[
759
],
[
760
],
[
761
],
[
762
],
[
763
],
[
764
],
[
765
],
[
766
],
[
767
]
],
"inserts": [
[
725,
726,
727,
728,
729,
730,
731
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeValidator.java\n+++ b/src/com/google/javascript/jscomp/TypeValidator.java\n@@ -722,8 +722,20 @@ private String formatFoundRequired(String description, JSType found,\n * to an Object type, if possible.\n */\n String getReadableJSTypeName(Node n, boolean dereference) {\n+ JSType type = getJSType(n);\n+ if (dereference) {\n+ ObjectType dereferenced = type.dereference();\n+ if (dereferenced != null) {\n+ type = dereferenced;\n+ }\n+ }\n \n // The best type name is the actual type name.\n+ if (type.isFunctionPrototypeType() ||\n+ (type.toObjectType() != null &&\n+ type.toObjectType().getConstructor() != null)) {\n+ return type.toString();\n+ }\n \n // If we're analyzing a GETPROP, the property may be inherited by the\n // prototype chain. So climb the prototype chain and find out where\n@@ -753,18 +765,6 @@ String getReadableJSTypeName(Node n, boolean dereference) {\n }\n }\n \n- JSType type = getJSType(n);\n- if (dereference) {\n- ObjectType dereferenced = type.dereference();\n- if (dereferenced != null) {\n- type = dereferenced;\n- }\n- }\n- if (type.isFunctionPrototypeType() ||\n- (type.toObjectType() != null &&\n- type.toObjectType().getConstructor() != null)) {\n- return type.toString();\n- }\n String qualifiedName = n.getQualifiedName();\n if (qualifiedName != null) {\n return qualifiedName;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...p never defined on C[2]> but was:<...p never defined on C[3.c2_]>",
"methodName": "testIssue1047"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 0,
"linesRem": 12,
"methods": 1,
"sizeInLines": 24,
"spreadAllLines": 31,
"spreadCodeOnly": 20
},
"observations": "Move a block of code.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfAdd",
"condBranRem",
"mcMove",
"retBranchAdd",
"retRem",
"varAdd",
"varRem"
],
"repairPatterns": [
"codeMove"
],
"repairTools": [],
"revisionId": "871bca1f36c5c06aa880ce21429da63a76f8f6e9"
},
{
"bugId": 112,
"changedFiles": {
"com/google/javascript/jscomp/TypeInference.java": {
"changes": [
[
1192
],
[
1193
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeInference.java\n+++ b/src/com/google/javascript/jscomp/TypeInference.java\n@@ -1189,9 +1189,15 @@ private boolean inferTemplatedTypesForCall(\n }\n \n // Try to infer the template types\n- Map<TemplateType, JSType> inferred = \n- inferTemplateTypesFromParameters(fnType, n);\n-\n+ Map<TemplateType, JSType> inferred = Maps.filterKeys(\n+ inferTemplateTypesFromParameters(fnType, n),\n+ new Predicate<TemplateType>() {\n+\n+ @Override\n+ public boolean apply(TemplateType key) {\n+ return keys.contains(key);\n+ }}\n+ );\n \n // Replace all template types. If we couldn't find a replacement, we\n // replace it with UNKNOWN.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testIssue1058"
},
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "unexpected warnings(s):",
"methodName": "testTemplatized11"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Adds an inline interface implementation for a parameter of type Predicate on filterKeys method call.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcAdd",
"mdAdd",
"mdOverride",
"objInstAdd",
"tyImpInterf"
],
"repairPatterns": [
"wrapsMethod"
],
"repairTools": [],
"revisionId": "b168c8822b2d3d12515ec6477812674c8805bcf3"
},
{
"bugId": 114,
"changedFiles": {
"com/google/javascript/jscomp/NameAnalyzer.java": {
"changes": [
[
578
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/NameAnalyzer.java\n+++ b/src/com/google/javascript/jscomp/NameAnalyzer.java\n@@ -575,7 +575,7 @@ private void recordAssignment(NodeTraversal t, Node n, Node recordNode) {\n } else {\n recordDepScope(nameNode, ns);\n }\n- } else {\n+ } else if (!(parent.isCall() && parent.getFirstChild() == n)) {\n // The rhs of the assignment is the caller, so it's used by the\n // context. Don't associate it w/ the lhs.\n // FYI: this fixes only the specific case where the assignment is the\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.NameAnalyzerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAssignWithCall"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"singleLine",
"wrapsIf"
],
"repairTools": [
"rtNopol"
],
"revisionId": "5f03c6817341d39d8dead76c7511fd6bb0b9009f"
},
{
"bugId": 113,
"changedFiles": {
"com/google/javascript/jscomp/ProcessClosurePrimitives.java": {
"changes": [
[
329
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n+++ b/src/com/google/javascript/jscomp/ProcessClosurePrimitives.java\n@@ -326,7 +326,7 @@ private void processRequireCall(NodeTraversal t, Node n, Node parent) {\n // the checks for broken requires turned off. In these cases, we\n // allow broken requires to be preserved by the first run to\n // let them be caught in the subsequent run.\n- if (provided != null) {\n+ if (provided != null || requiresLevel.isOn()) {\n parent.detachFromParent();\n compiler.reportCodeChange();\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.VarCheckTest",
"error": "junit.framework.AssertionFailedError",
"message": "There should be one error. required \"namespace.Class1\" namespace never provided",
"methodName": "testNoUndeclaredVarWhenUsingClosurePass"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Again, an existent condition with Null-Check was expanded with other condition.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtNopol"
],
"revisionId": "0fb76a81bbdd8ab84a00b8be2099abfb83c88668"
},
{
"bugId": 115,
"changedFiles": {
"com/google/javascript/jscomp/FunctionInjector.java": {
"deletes": [
[
697
],
[
698
],
[
699
],
[
700
],
[
701
],
[
702
],
[
703
],
[
704
],
[
730
],
[
731
],
[
732
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionInjector.java\n+++ b/src/com/google/javascript/jscomp/FunctionInjector.java\n@@ -694,14 +694,6 @@ private CanInlineResult canInlineReferenceDirectly(\n \n Node block = fnNode.getLastChild();\n \n- boolean hasSideEffects = false;\n- if (block.hasChildren()) {\n- Preconditions.checkState(block.hasOneChild());\n- Node stmt = block.getFirstChild();\n- if (stmt.isReturn()) {\n- hasSideEffects = NodeUtil.mayHaveSideEffects(stmt.getFirstChild(), compiler);\n- }\n- }\n // CALL NODE: [ NAME, ARG1, ARG2, ... ]\n Node cArg = callNode.getFirstChild().getNext();\n \n@@ -727,9 +719,6 @@ private CanInlineResult canInlineReferenceDirectly(\n // For each named parameter check if a mutable argument use more than one.\n if (fnParam != null) {\n if (cArg != null) {\n- if (hasSideEffects && NodeUtil.canBeSideEffected(cArg)) {\n- return CanInlineResult.NO;\n- }\n // Check for arguments that are evaluated more than once.\n // Note: Unlike block inlining, there it is not possible that a\n // parameter reference will be in a loop.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBug4944818"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoubleInlining1"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified8"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testNoInlineIfParametersModified9"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions22"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions23"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions6"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 11,
"methods": 1,
"sizeInLines": 11,
"spreadAllLines": 25,
"spreadCodeOnly": 15
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranRem",
"mcRem",
"retRem",
"varRem"
],
"repairPatterns": [
"blockRemove",
"condBlockRem"
],
"repairTools": [
"rtNopol"
],
"revisionId": "4597738e8898f738c1f969fe90479728be81cc80"
},
{
"bugId": 116,
"changedFiles": {
"com/google/javascript/jscomp/FunctionInjector.java": {
"inserts": [
[
696,
697,
698,
699
],
[
723,
724,
725,
726,
727
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/FunctionInjector.java\n+++ b/src/com/google/javascript/jscomp/FunctionInjector.java\n@@ -694,6 +694,15 @@ private CanInlineResult canInlineReferenceDirectly(\n \n Node block = fnNode.getLastChild();\n \n+ boolean hasSideEffects = false; // empty function case\n+ if (block.hasChildren()) {\n+ Preconditions.checkState(block.hasOneChild());\n+ Node stmt = block.getFirstChild();\n+ if (stmt.isReturn()) {\n+ hasSideEffects = NodeUtil.mayHaveSideEffects(\n+ stmt.getFirstChild(), compiler);\n+ }\n+ }\n \n // CALL NODE: [ NAME, ARG1, ARG2, ... ]\n Node cArg = callNode.getFirstChild().getNext();\n@@ -720,6 +729,9 @@ private CanInlineResult canInlineReferenceDirectly(\n // For each named parameter check if a mutable argument use more than one.\n if (fnParam != null) {\n if (cArg != null) {\n+ if (hasSideEffects && NodeUtil.canBeSideEffected(cArg)) {\n+ return CanInlineResult.NO;\n+ }\n \n // Check for arguments that are evaluated more than once.\n // Note: Unlike block inlining, there it is not possible that a\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<NO> but was:<YES>",
"methodName": "testIssue1101a"
},
{
"className": " com.google.javascript.jscomp.FunctionInjectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<NO> but was:<YES>",
"methodName": "testIssue1101b"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBug4944818"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoubleInlining2"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue1101"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineIfParametersModified8"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineIfParametersModified9"
},
{
"className": " com.google.javascript.jscomp.InlineFunctionsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testInlineFunctions6"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 12,
"spreadAllLines": 26,
"spreadCodeOnly": 15
},
"observations": "Strange... what is removed in 115 is added again in 116.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "b80dfd3b0e5e4b490b7afb469320d18bac4520b4"
},
{
"bugId": 111,
"changedFiles": {
"com/google/javascript/jscomp/type/ClosureReverseAbstractInterpreter.java": {
"changes": [
[
54
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/type/ClosureReverseAbstractInterpreter.java\n+++ b/src/com/google/javascript/jscomp/type/ClosureReverseAbstractInterpreter.java\n@@ -51,7 +51,8 @@\n new RestrictByTrueTypeOfResultVisitor() {\n @Override\n protected JSType caseTopType(JSType topType) {\n- return topType;\n+ return topType.isAllType() ?\n+ getNativeType(ARRAY_TYPE) : topType;\n }\n \n @Override\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ClosureReverseAbstractInterpreterTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: Array",
"methodName": "testGoogIsArray2"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrapsIfElse"
],
"repairTools": [
"rtNopol"
],
"revisionId": "6f981f77e5bd9e2eecbd851a2a02933cdb9af0d8"
},
{
"bugId": 110,
"changedFiles": {
"com/google/javascript/jscomp/ScopedAliases.java": {
"changes": [
[
366
],
[
368
],
[
369
],
[
371
]
],
"inserts": [
[
357,
358
],
[
380,
381,
382,
383,
384,
385,
386,
387,
388,
389,
390,
391,
392,
393,
394,
395,
396,
397,
398
],
[
407,
408
],
[
409
]
]
},
"com/google/javascript/rhino/Node.java": {
"inserts": [
[
554,
555
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ScopedAliases.java\n+++ b/src/com/google/javascript/jscomp/ScopedAliases.java\n@@ -355,6 +355,7 @@ private void findAliases(NodeTraversal t) {\n Node n = v.getNode();\n Node parent = n.getParent();\n boolean isVar = parent.isVar();\n+ boolean isFunctionDecl = NodeUtil.isFunctionDeclaration(parent);\n if (isVar && n.getFirstChild() != null && n.getFirstChild().isQualifiedName()) {\n recordAlias(v);\n } else if (v.isBleedingFunction()) {\n@@ -363,12 +364,13 @@ private void findAliases(NodeTraversal t) {\n } else if (parent.getType() == Token.LP) {\n // Parameters of the scope function also get a BAD_PARAMETERS\n // error.\n- } else if (isVar) {\n+ } else if (isVar || isFunctionDecl) {\n+ boolean isHoisted = NodeUtil.isHoistedFunctionDeclaration(parent);\n Node grandparent = parent.getParent();\n- Node value = n.hasChildren() ?\n- v.getInitialValue().detachFromParent() :\n+ Node value = v.getInitialValue() != null ?\n+ v.getInitialValue() :\n null;\n- Node varNode = parent;\n+ Node varNode = null;\n \n String name = n.getString();\n int nameCount = scopedAliasNames.count(name);\n@@ -380,7 +382,9 @@ private void findAliases(NodeTraversal t) {\n \n // First, we need to free up the function expression (EXPR)\n // to be used in another expression.\n+ if (isFunctionDecl) {\n // Replace \"function NAME() { ... }\" with \"var NAME;\".\n+ Node existingName = v.getNameNode();\n \n // We can't keep the local name on the function expression,\n // because IE is buggy and will leak the name into the global\n@@ -389,9 +393,19 @@ private void findAliases(NodeTraversal t) {\n //\n // This will only cause problems if this is a hoisted, recursive\n // function, and the programmer is using the hoisting.\n+ Node newName = IR.name(\"\").useSourceInfoFrom(existingName);\n+ value.replaceChild(existingName, newName);\n \n+ varNode = IR.var(existingName).useSourceInfoFrom(existingName);\n+ grandparent.replaceChild(parent, varNode);\n+ } else {\n+ if (value != null) {\n // If this is a VAR, we can just detach the expression and\n // the tree will still be valid.\n+ value.detachFromParent();\n+ }\n+ varNode = parent;\n+ }\n \n // Add $jscomp.scope.name = EXPR;\n // Make sure we copy over all the jsdoc and debug info.\n@@ -405,7 +419,11 @@ private void findAliases(NodeTraversal t) {\n NodeUtil.setDebugInformation(\n newDecl.getFirstChild().getFirstChild(), n, name);\n \n+ if (isHoisted) {\n+ grandparent.addChildToFront(newDecl);\n+ } else {\n grandparent.addChildBefore(newDecl, varNode);\n+ }\n }\n \n // Rewrite \"var name = EXPR;\" to \"var name = $jscomp.scope.name;\"\n--- a/src/com/google/javascript/rhino/Node.java\n+++ b/src/com/google/javascript/rhino/Node.java\n@@ -551,6 +551,9 @@ public Node getChildBefore(Node child) {\n return null;\n }\n Node n = first;\n+ if (n == null) {\n+ throw new RuntimeException(\"node is not a child\");\n+ }\n \n while (n.next != child) {\n n = n.next;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ScopedAliasesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_GOOG_SCOPE_NON_ALIAS_LOCAL. The local variable f is in a goog.scope and is not an alias. at testcode line 1 : 39 expected:<0> but was:<1>",
"methodName": "testHoistedFunctionDeclaration"
},
{
"className": " com.google.javascript.jscomp.ScopedAliasesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected error(s): JSC_GOOG_SCOPE_NON_ALIAS_LOCAL. The local variable f is in a goog.scope and is not an alias. at testcode line 1 : 41 expected:<0> but was:<1>",
"methodName": "testFunctionDeclaration"
}
],
"metrics": {
"chunks": 12,
"classes": 2,
"files": 2,
"linesAdd": 21,
"linesMod": 4,
"linesRem": 0,
"methods": 2,
"sizeInLines": 25,
"spreadAllLines": 47,
"spreadCodeOnly": 22
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpExpand",
"condExpMod",
"exThrowsAdd",
"mcAdd",
"mcRem",
"objInstAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"expLogicExpand",
"expLogicMod",
"initFix",
"missNullCheckN",
"missNullCheckP",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "13fb7fcbcad87f8df63535491627bf7b01471064"
},
{
"bugId": 118,
"changedFiles": {
"com/google/javascript/jscomp/DisambiguateProperties.java": {
"inserts": [
[
494,
495,
496,
497
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/DisambiguateProperties.java\n+++ b/src/com/google/javascript/jscomp/DisambiguateProperties.java\n@@ -492,6 +492,9 @@ private void handleObjectLit(NodeTraversal t, Node n) {\n child != null;\n child = child.getNext()) {\n // Maybe STRING, GET, SET\n+ if (child.isQuotedString()) {\n+ continue;\n+ }\n \n // We should never see a mix of numbers and strings.\n String name = child.getString();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.DisambiguatePropertiesTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<{[]}> but was:<{[a=[[Foo.prototype]]]}>",
"methodName": "testOneType4"
},
{
"className": " com.google.javascript.jscomp.DisambiguatePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTwoTypes4"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "f17961ae4d3d7cf5ea291d82804239982d009ef7"
},
{
"bugId": 120,
"changedFiles": {
"com/google/javascript/jscomp/ReferenceCollectingCallback.java": {
"inserts": [
[
431
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ReferenceCollectingCallback.java\n+++ b/src/com/google/javascript/jscomp/ReferenceCollectingCallback.java\n@@ -428,6 +428,9 @@ boolean isAssignedOnceInLifetime() {\n for (BasicBlock block = ref.getBasicBlock();\n block != null; block = block.getParent()) {\n if (block.isFunction) {\n+ if (ref.getSymbol().getScope() != ref.scope) {\n+ return false;\n+ }\n break;\n } else if (block.isLoop) {\n return false;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testExternalIssue1053"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtNopol"
],
"revisionId": "0123fd5303c85d0d26add64aa2e19fee33f73aaa"
},
{
"bugId": 119,
"changedFiles": {
"com/google/javascript/jscomp/GlobalNamespace.java": {
"inserts": [
[
366,
367,
368
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/GlobalNamespace.java\n+++ b/src/com/google/javascript/jscomp/GlobalNamespace.java\n@@ -363,6 +363,7 @@ public void collect(JSModule module, Scope scope, Node n) {\n isSet = true;\n type = Name.Type.FUNCTION;\n break;\n+ case Token.CATCH:\n case Token.INC:\n case Token.DEC:\n isSet = true;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CheckGlobalNamesTest",
"error": "junit.framework.AssertionFailedError",
"message": "Unexpected warning(s): JSC_UNDEFINED_NAME. e is never defined at testcode line 1 : 48",
"methodName": "testGlobalCatch"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "\"Case\" Added to switch... Should be considered a \"missing block\" too?",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranCaseAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtNopol"
],
"revisionId": "046e0b226e963bc584c2a6cd3c2b471777c5cc53"
},
{
"bugId": 121,
"changedFiles": {
"com/google/javascript/jscomp/InlineVariables.java": {
"changes": [
[
304
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/InlineVariables.java\n+++ b/src/com/google/javascript/jscomp/InlineVariables.java\n@@ -301,10 +301,12 @@ private void inlineNonConstants(\n if (!maybeModifiedArguments &&\n !staleVars.contains(v) &&\n referenceInfo.isWellDefined() &&\n- referenceInfo.isAssignedOnceInLifetime()) {\n+ referenceInfo.isAssignedOnceInLifetime() &&\n // Inlining the variable based solely on well-defined and assigned\n // once is *NOT* correct. We relax the correctness requirement if\n // the variable is declared constant.\n+ (isInlineableDeclaredConstant(v, referenceInfo) ||\n+ referenceInfo.isOnlyAssignmentSameScopeAsDeclaration())) {\n List<Reference> refs = referenceInfo.references;\n for (int i = 1 /* start from a read */; i < refs.size(); i++) {\n Node nameNode = refs.get(i).getNode();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.InlineVariablesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testExternalIssue1053"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtNopol"
],
"revisionId": "2aee36e667526ff8b0b5e6dad66506acee920ea6"
},
{
"bugId": 123,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
285
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -282,7 +282,7 @@ void add(Node n, Context context) {\n case Token.HOOK: {\n Preconditions.checkState(childCount == 3);\n int p = NodeUtil.precedence(type);\n- Context rhsContext = Context.OTHER;\n+ Context rhsContext = getContextForNoInOperator(context);\n addExpr(first, p + 1, context);\n cc.addOp(\"?\", true);\n addExpr(first.getNext(), 1, rhsContext);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<for(a=c?0:[(0 in d)];;)foo()> but was:<for(a=c?0:[0 in d];;)foo()>",
"methodName": "testPrintInOperatorInForLoop"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes value in assignment from constant to method call.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignExpChange",
"mcAdd",
"varReplMc"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongComp",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "8d11b8cc7a6183222b61c9bd398fed5448c59109"
},
{
"bugId": 122,
"changedFiles": {
"com/google/javascript/jscomp/parsing/IRFactory.java": {
"changes": [
[
252
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/IRFactory.java\n+++ b/src/com/google/javascript/jscomp/parsing/IRFactory.java\n@@ -249,7 +249,8 @@ private Node transformBlock(AstNode node) {\n * Check to see if the given block comment looks like it should be JSDoc.\n */\n private void handleBlockComment(Comment comment) {\n- if (comment.getValue().indexOf(\"/* @\") != -1 || comment.getValue().indexOf(\"\\n * @\") != -1) {\n+ Pattern p = Pattern.compile(\"(/|(\\n[ \\t]*))\\\\*[ \\t]*@[a-zA-Z]\");\n+ if (p.matcher(comment.getValue()).find()) {\n errorReporter.warning(\n SUSPICIOUS_COMMENT_WARNING,\n sourceName,\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSuspiciousBlockCommentWarning3"
},
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSuspiciousBlockCommentWarning4"
},
{
"className": " com.google.javascript.jscomp.parsing.ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSuspiciousBlockCommentWarning5"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"condExpMod",
"mcAdd",
"mcRem",
"varAdd"
],
"repairPatterns": [
"expLogicMod",
"wrongComp"
],
"repairTools": [],
"revisionId": "a8a456b183c9600658bcb0c72091bae1a30a4fda"
},
{
"bugId": 126,
"changedFiles": {
"com/google/javascript/jscomp/MinimizeExitPoints.java": {
"deletes": [
[
141
],
[
142
],
[
143
],
[
144
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/MinimizeExitPoints.java\n+++ b/src/com/google/javascript/jscomp/MinimizeExitPoints.java\n@@ -138,10 +138,6 @@ void tryMinimizeExits(Node n, int exitType, String labelName) {\n * can cause problems if it changes the completion type of the finally\n * block. See ECMA 262 Sections 8.9 & 12.14\n */\n- if (NodeUtil.hasFinally(n)) {\n- Node finallyBlock = n.getLastChild();\n- tryMinimizeExits(finallyBlock, exitType, labelName);\n- }\n }\n \n // Just a 'label'.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.MinimizeExitPointsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDontRemoveBreakInTryFinally"
},
{
"className": " com.google.javascript.jscomp.MinimizeExitPointsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFunctionReturnOptimization"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 4,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignRem",
"condBranRem",
"mcRem",
"varRem"
],
"repairPatterns": [
"condBlockRem"
],
"repairTools": [
"rtDynaMoth",
"rtHDRepair",
"rtJAID",
"rtNopol",
"rtssFix"
],
"revisionId": "bd2803b6d9ab600906b262ae51cb3591160b5f3c"
},
{
"bugId": 124,
"changedFiles": {
"com/google/javascript/jscomp/ExploitAssigns.java": {
"inserts": [
[
212,
213
],
[
214
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/ExploitAssigns.java\n+++ b/src/com/google/javascript/jscomp/ExploitAssigns.java\n@@ -210,7 +210,9 @@ private boolean isSafeReplacement(Node node, Node replacement) {\n }\n Preconditions.checkArgument(node.isGetProp());\n \n+ while (node.isGetProp()) {\n node = node.getFirstChild();\n+ }\n if (node.isName()\n && isNameAssignedTo(node.getString(), replacement)) {\n return false;\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ExploitAssignsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue1017"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"loopAdd",
"mcAdd"
],
"repairPatterns": [
"missComp",
"wrapsLoop"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "e7f4269d0289f4d47217207ec456219db8efe47c"
},
{
"bugId": 127,
"changedFiles": {
"com/google/javascript/jscomp/UnreachableCodeElimination.java": {
"changes": [
[
170
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/UnreachableCodeElimination.java\n+++ b/src/com/google/javascript/jscomp/UnreachableCodeElimination.java\n@@ -167,13 +167,22 @@ private void tryRemoveUnconditionalBranching(Node n) {\n outEdges.get(0).getValue() == Branch.UNCOND);\n Node fallThrough = computeFollowing(n);\n Node nextCfgNode = outEdges.get(0).getDestination().getValue();\n- if (nextCfgNode == fallThrough) {\n+ if (nextCfgNode == fallThrough && !inFinally(n.getParent(), n)) {\n removeNode(n);\n }\n }\n }\n }\n \n+ private boolean inFinally(Node parent, Node child) {\n+ if (parent == null || parent.isFunction()) {\n+ return false;\n+ } else if (NodeUtil.isTryFinallyNode(parent, child)) {\n+ return true;\n+ } else {\n+ return inFinally(parent.getParent(), parent);\n+ }\n+ }\n \n private Node computeFollowing(Node n) {\n Node next = ControlFlowAnalysis.computeFollowNode(n);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue4177428_return"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDontRemoveBreakInTryFinally"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue4177428_continue"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDontRemoveBreakInTryFinallySwitch"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue4177428a"
},
{
"className": " com.google.javascript.jscomp.UnreachableCodeEliminationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue4177428c"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 10,
"spreadAllLines": 6,
"spreadCodeOnly": 5
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfElseAdd",
"condExpExpand",
"mcAdd",
"mdAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicExpand",
"missComp",
"missNullCheckP"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "211dc0161ae737f59cac22f30b048d56a059d14b"
},
{
"bugId": 125,
"changedFiles": {
"com/google/javascript/jscomp/TypeCheck.java": {
"changes": [
[
1661
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/TypeCheck.java\n+++ b/src/com/google/javascript/jscomp/TypeCheck.java\n@@ -1658,7 +1658,7 @@ private void visitNew(NodeTraversal t, Node n) {\n JSType type = getJSType(constructor).restrictByNotNullOrUndefined();\n if (type.isConstructor() || type.isEmptyType() || type.isUnknownType()) {\n FunctionType fnType = type.toMaybeFunctionType();\n- if (fnType != null) {\n+ if (fnType != null && fnType.hasInstanceType()) {\n visitParameterList(t, n, fnType);\n ensureTyped(t, n, fnType.getInstanceType());\n } else {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.TypeCheckTest",
"error": "java.lang.IllegalStateException",
"message": "",
"methodName": "testIssue1002"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Again, conditional expression with Null-Check was expanded with new condition.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtJAID"
],
"revisionId": "8cef00180a5cf67d047919c89668a6405030dbab"
},
{
"bugId": 128,
"changedFiles": {
"com/google/javascript/jscomp/CodeGenerator.java": {
"changes": [
[
791
]
],
"inserts": [
[
785
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CodeGenerator.java\n+++ b/src/com/google/javascript/jscomp/CodeGenerator.java\n@@ -782,13 +782,16 @@ private void unrollBinaryOperator(\n \n static boolean isSimpleNumber(String s) {\n int len = s.length();\n+ if (len == 0) {\n+ return false;\n+ }\n for (int index = 0; index < len; index++) {\n char c = s.charAt(index);\n if (c < '0' || c > '9') {\n return false;\n }\n }\n- return len > 0 && s.charAt(0) != '0';\n+ return len == 1 || s.charAt(0) != '0';\n }\n \n static double getSimpleNumber(String s) {\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CodePrinterTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<var x={[0]:1}> but was:<var x={[\"0\"]:1}>",
"methodName": "testIssue942"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 6,
"spreadCodeOnly": 6
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condBranIfAdd",
"retBranchAdd",
"retExpChange"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicMod"
],
"repairTools": [],
"revisionId": "d82fb38b0121bf690cea58df293185c7e91ded9c"
},
{
"bugId": 3,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"inserts": [
[
593
],
[
597
],
[
601
],
[
605
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -590,18 +590,22 @@ public static Number createNumber(final String str) throws NumberFormatException\n //Must be a Float, Double, BigDecimal\n final boolean allZeros = isAllZeros(mant) && isAllZeros(exp);\n try {\n+ if(numDecimals <= 7){// If number has 7 or fewer digits past the decimal point then make it a float\n final Float f = createFloat(str);\n if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {\n return f;\n }\n+ }\n } catch (final NumberFormatException nfe) { // NOPMD\n // ignore the bad number\n }\n try {\n+ if(numDecimals <= 16){// If number has between 8 and 16 digits past the decimal point then make it a double\n final Double d = createDouble(str);\n if (!(d.isInfinite() || (d.doubleValue() == 0.0D && !allZeros))) {\n return d;\n }\n+ }\n } catch (final NumberFormatException nfe) { // NOPMD\n // ignore the bad number\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testStringCreateNumberEnsureNoPrecisionLoss"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 12,
"spreadCodeOnly": 11
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"copyPaste",
"wrapsIf"
],
"repairTools": [],
"revisionId": "2c9c8753165dc7ce5dd1d5a6d741b445b33302c2"
},
{
"bugId": 2,
"changedFiles": {
"org/apache/commons/lang3/LocaleUtils.java": {
"inserts": [
[
92
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/LocaleUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/LocaleUtils.java\n@@ -89,6 +89,9 @@ public static Locale toLocale(final String str) {\n if (str == null) {\n return null;\n }\n+ if (str.contains(\"#\")) { // LANG-879 - Cannot handle Java 7 script & extensions\n+ throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n+ }\n final int len = str.length();\n if (len < 2) {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.LocaleUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Failed 2 test(s)",
"methodName": "testParseAllLocales"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [],
"revisionId": "09d39029b16dee61022dc8afde4d84f523f37813"
},
{
"bugId": 5,
"changedFiles": {
"org/apache/commons/lang3/LocaleUtils.java": {
"inserts": [
[
97
],
[
128
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/LocaleUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/LocaleUtils.java\n@@ -94,6 +94,26 @@ public static Locale toLocale(final String str) {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n }\n final char ch0 = str.charAt(0);\n+ if (ch0 == '_') {\n+ if (len < 3) {\n+ throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n+ }\n+ final char ch1 = str.charAt(1);\n+ final char ch2 = str.charAt(2);\n+ if (!Character.isUpperCase(ch1) || !Character.isUpperCase(ch2)) {\n+ throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n+ }\n+ if (len == 3) {\n+ return new Locale(\"\", str.substring(1, 3));\n+ }\n+ if (len < 5) {\n+ throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n+ }\n+ if (str.charAt(3) != '_') {\n+ throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n+ }\n+ return new Locale(\"\", str.substring(1, 3), str.substring(4));\n+ } else {\n final char ch1 = str.charAt(1);\n if (!Character.isLowerCase(ch0) || !Character.isLowerCase(ch1)) {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n@@ -125,6 +145,7 @@ public static Locale toLocale(final String str) {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n }\n return new Locale(str.substring(0, 2), str.substring(3, 5), str.substring(6));\n+ }\n }\n \n //-----------------------------------------------------------------------\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.LocaleUtilsTest",
"error": "java.lang.IllegalArgumentException",
"message": "Invalid locale format: _GB",
"methodName": "testLang865"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 21,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 21,
"spreadAllLines": 31,
"spreadCodeOnly": 31
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockRetAdd",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "75944e541d358d5b06ebbba3098a919fbf2539d4"
},
{
"bugId": 130,
"changedFiles": {
"com/google/javascript/jscomp/CollapseProperties.java": {
"changes": [
[
172
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/CollapseProperties.java\n+++ b/src/com/google/javascript/jscomp/CollapseProperties.java\n@@ -169,7 +169,7 @@ private void inlineAliases(GlobalNamespace namespace) {\n continue;\n }\n \n- if (name.globalSets == 1 && name.localSets == 0 &&\n+ if (!name.inExterns && name.globalSets == 1 && name.localSets == 0 &&\n name.aliasingGets > 0) {\n // {@code name} meets condition (b). Find all of its local aliases\n // and try to inline them.\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.CollapsePropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue931"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "9fac3ccd2fa9e6137584f079db1a6f5962a65cf4"
},
{
"bugId": 4,
"changedFiles": {
"org/apache/commons/lang3/text/translate/LookupTranslator.java": {
"changes": [
[
31
],
[
46
],
[
51
],
[
77
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java\n@@ -28,7 +28,7 @@\n */\n public class LookupTranslator extends CharSequenceTranslator {\n \n- private final HashMap<CharSequence, CharSequence> lookupMap;\n+ private final HashMap<String, CharSequence> lookupMap;\n private final int shortest;\n private final int longest;\n \n@@ -43,12 +43,12 @@\n * @param lookup CharSequence[][] table of size [*][2]\n */\n public LookupTranslator(final CharSequence[]... lookup) {\n- lookupMap = new HashMap<CharSequence, CharSequence>();\n+ lookupMap = new HashMap<String, CharSequence>();\n int _shortest = Integer.MAX_VALUE;\n int _longest = 0;\n if (lookup != null) {\n for (final CharSequence[] seq : lookup) {\n- this.lookupMap.put(seq[0], seq[1]);\n+ this.lookupMap.put(seq[0].toString(), seq[1]);\n final int sz = seq[0].length();\n if (sz < _shortest) {\n _shortest = sz;\n@@ -74,7 +74,7 @@ public int translate(final CharSequence input, final int index, final Writer out\n // descend so as to get a greedy algorithm\n for (int i = max; i >= shortest; i--) {\n final CharSequence subSeq = input.subSequence(index, index + i);\n- final CharSequence result = lookupMap.get(subSeq);\n+ final CharSequence result = lookupMap.get(subSeq.toString());\n if (result != null) {\n out.write(result.toString());\n return i;\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.text.translate.LookupTranslatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "Incorrect codepoint consumption expected:<3> but was:<0>",
"methodName": "testLang882"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 43,
"spreadCodeOnly": 27
},
"observations": "Type change with adjust in related calls/operations.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignExpChange",
"mcAdd",
"objInstMod",
"varReplMc",
"varTyChange"
],
"repairPatterns": [
"initFix",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "fb47b96ab635d7cc6e9edefdddc46f1baf63b117"
},
{
"bugId": 129,
"changedFiles": {
"com/google/javascript/jscomp/PrepareAst.java": {
"inserts": [
[
164,
165,
166,
167
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PrepareAst.java\n+++ b/src/com/google/javascript/jscomp/PrepareAst.java\n@@ -163,6 +163,9 @@ private void annotateCalls(Node n) {\n Node first = n.getFirstChild();\n \n // ignore cast nodes.\n+ while (first.isCast()) {\n+ first = first.getFirstChild();\n+ }\n \n if (!NodeUtil.isGet(first)) {\n n.putBooleanProp(Node.FREE_CALL, true);\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.IntegrationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue937"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Adds a loop to iterate over child of nodes.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd",
"loopAdd",
"mcAdd"
],
"repairPatterns": [
"missComp",
"notClassified"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "79a8906570f44e5f519282bd32595985ed089aed"
},
{
"bugId": 1,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"changes": [
[
468
],
[
471
]
],
"inserts": [
[
467
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -464,11 +464,20 @@ public static Number createNumber(final String str) throws NumberFormatException\n }\n }\n if (pfxLen > 0) { // we have a hex number\n+ char firstSigDigit = 0; // strip leading zeroes\n+ for(int i = pfxLen; i < str.length(); i++) {\n+ firstSigDigit = str.charAt(i);\n+ if (firstSigDigit == '0') { // count leading zeroes\n+ pfxLen++;\n+ } else {\n+ break;\n+ }\n+ }\n final int hexDigits = str.length() - pfxLen;\n- if (hexDigits > 16) { // too many for Long\n+ if (hexDigits > 16 || (hexDigits == 16 && firstSigDigit > '7')) { // too many for Long\n return createBigInteger(str);\n }\n- if (hexDigits > 8) { // too many for an int\n+ if (hexDigits > 8 || (hexDigits == 8 && firstSigDigit > '7')) { // too many for an int\n return createLong(str);\n }\n return createInteger(str);\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "java.lang.NumberFormatException",
"message": "For input string: \"80000000\"",
"methodName": "TestLang747"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 11,
"spreadAllLines": 3,
"spreadCodeOnly": 3
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"condExpExpand",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"expLogicExpand",
"missComp"
],
"repairTools": [],
"revisionId": "687b2e62b7c6e81cd9d5c872b7fa9cc8fd3f1509"
},
{
"bugId": 132,
"changedFiles": {
"com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java": {
"changes": [
[
782
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n+++ b/src/com/google/javascript/jscomp/PeepholeSubstituteAlternateSyntax.java\n@@ -779,7 +779,9 @@ private Node tryMinimizeIf(Node n) {\n // evaluates LHS before cond]\n // NOTE - there are some circumstances where we can\n // proceed even if there are side effects...\n- !mayEffectMutableState(lhs)) {\n+ !mayEffectMutableState(lhs) &&\n+ (!mayHaveSideEffects(cond) ||\n+ (thenOp.isAssign() && thenOp.getFirstChild().isName()))) {\n \n n.removeChild(cond);\n Node assignName = thenOp.removeFirstChild();\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.PeepholeSubstituteAlternateSyntaxTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testIssue925"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "5b9485903b5e7d926f49dc91b915a256df92591c"
},
{
"bugId": 6,
"changedFiles": {
"org/apache/commons/lang3/text/translate/CharSequenceTranslator.java": {
"changes": [
[
95
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java\n@@ -92,7 +92,7 @@ public final void translate(CharSequence input, Writer out) throws IOException {\n // // contract with translators is that they have to understand codepoints \n // // and they just took care of a surrogate pair\n for (int pt = 0; pt < consumed; pt++) {\n- pos += Character.charCount(Character.codePointAt(input, pos));\n+ pos += Character.charCount(Character.codePointAt(input, pt));\n }\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 2",
"methodName": "testEscapeSurrogatePairs"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"expArithMod",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtElixir",
"rtHDRepair",
"rtssFix"
],
"revisionId": "cff0f1ae37bb2b7ab2dcdb10dec1f3cad7532e1c"
},
{
"bugId": 133,
"changedFiles": {
"com/google/javascript/jscomp/parsing/JsDocInfoParser.java": {
"inserts": [
[
2400,
2401
]
]
}
},
"diff": "--- a/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n+++ b/src/com/google/javascript/jscomp/parsing/JsDocInfoParser.java\n@@ -2398,6 +2398,7 @@ private void skipEOLs() {\n */\n private String getRemainingJSDocLine() {\n String result = stream.getRemainingJSDocLine();\n+ unreadToken = NO_UNREAD_TOKEN;\n return result;\n }\n \n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.parsing.JsDocInfoParserTest",
"error": "java.lang.IllegalStateException",
"message": "Recorded bad position information",
"methodName": "testTextExtents"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "It seems that the variable is reseted by method.",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"assignAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "4fbbc47cb18f241b23dd2d4bf9c15d45b2473523"
},
{
"bugId": 7,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"deletes": [
[
452
],
[
453
],
[
454
]
],
"inserts": [
[
721,
722,
723,
724,
725
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -449,9 +449,6 @@ public static Number createNumber(String str) throws NumberFormatException {\n if (StringUtils.isBlank(str)) {\n throw new NumberFormatException(\"A blank string is not a valid number\");\n } \n- if (str.startsWith(\"--\")) {\n- return null;\n- }\n if (str.startsWith(\"0x\") || str.startsWith(\"-0x\") || str.startsWith(\"0X\") || str.startsWith(\"-0X\")) {\n int hexDigits = str.length() - 2; // drop 0x\n if (str.startsWith(\"-\")) { // drop -\n@@ -718,10 +715,13 @@ public static BigDecimal createBigDecimal(String str) {\n if (StringUtils.isBlank(str)) {\n throw new NumberFormatException(\"A blank string is not a valid number\");\n }\n+ if (str.trim().startsWith(\"--\")) {\n // this is protection for poorness in java.lang.BigDecimal.\n // it accepts this as a legal value, but it does not appear \n // to be in specification of class. OS X Java parses it to \n // a wrong value.\n+ throw new NumberFormatException(str + \" is not a valid number.\");\n+ }\n return new BigDecimal(str);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected NumberFormatException",
"methodName": "testCreateNumber"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 3,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 270,
"spreadCodeOnly": 167
},
"observations": "In one of the chunks, removes a conditional block with return.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condExpMod",
"exThrowsAdd",
"mcAdd",
"mcRem",
"objInstAdd",
"retRem"
],
"repairPatterns": [
"blockRemove",
"condBlockExcAdd",
"condBlockRem"
],
"repairTools": [
"rtAcs",
"rtCardumen",
"rtDeepRepair",
"rtGPFL"
],
"revisionId": "e71f6dd3f2f70c640ae73d28b432b3a69ffcab4b"
},
{
"bugId": 131,
"changedFiles": {
"com/google/javascript/rhino/TokenStream.java": {
"changes": [
[
193
],
[
194
],
[
199
]
]
}
},
"diff": "--- a/src/com/google/javascript/rhino/TokenStream.java\n+++ b/src/com/google/javascript/rhino/TokenStream.java\n@@ -191,12 +191,13 @@ public static boolean isJSIdentifier(String s) {\n int length = s.length();\n \n if (length == 0 ||\n+ Character.isIdentifierIgnorable(s.charAt(0)) ||\n !Character.isJavaIdentifierStart(s.charAt(0))) {\n return false;\n }\n \n for (int i = 1; i < length; i++) {\n- if (\n+ if (Character.isIdentifierIgnorable(s.charAt(i)) ||\n !Character.isJavaIdentifierPart(s.charAt(i))) {\n return false;\n }\n",
"failingTests": [
{
"className": " com.google.javascript.jscomp.ConvertToDottedPropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testQuotedProps"
},
{
"className": " com.google.javascript.jscomp.ConvertToDottedPropertiesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDoNotConvert"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 5,
"spreadCodeOnly": 4
},
"observations": "",
"program": "closure-compiler",
"project": "Closure",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"copyPaste",
"expLogicExpand"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "7f6700e2b54af3af409f3e8851a0d98a72beef4b"
},
{
"bugId": 8,
"changedFiles": {
"org/apache/commons/lang3/time/FastDatePrinter.java": {
"deletes": [
[
1098
],
[
1112
]
],
"inserts": [
[
1134
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java\n+++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java\n@@ -1095,7 +1095,6 @@ static String getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Local\n private static class TimeZoneNameRule implements Rule {\n private final Locale mLocale;\n private final int mStyle;\n- private final TimeZone zone;\n private final String mStandard;\n private final String mDaylight;\n \n@@ -1109,7 +1108,6 @@ static String getTimeZoneDisplay(TimeZone tz, boolean daylight, int style, Local\n TimeZoneNameRule(TimeZone timeZone, Locale locale, int style) {\n mLocale = locale;\n mStyle = style;\n- zone = timeZone;\n \n mStandard = getTimeZoneDisplay(timeZone, false, style, locale);\n mDaylight = getTimeZoneDisplay(timeZone, true, style, locale);\n@@ -1131,6 +1129,7 @@ public int estimateLength() {\n */\n @Override\n public void appendTo(StringBuffer buffer, Calendar calendar) {\n+ TimeZone zone = calendar.getTimeZone();\n if (zone.useDaylightTime()\n && calendar.get(Calendar.DST_OFFSET) != 0) {\n buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormat_PrinterTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<11:03PM [CL]T> but was:<11:03PM [PS]T>",
"methodName": "testCalendarTimezoneRespected"
},
{
"className": " org.apache.commons.lang3.time.FastDatePrinterTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<11:03PM [CL]T> but was:<11:03PM [PS]T>",
"methodName": "testCalendarTimezoneRespected"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 2,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 34,
"spreadCodeOnly": 14
},
"observations": "Transformed a class attribute in local var.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"assignRem",
"mcAdd",
"varAdd",
"varRem"
],
"repairPatterns": [
"initFix",
"notClassified",
"wrongComp"
],
"repairTools": [],
"revisionId": "a4a455053e7e4a77320efd6db0814f4de82d754d"
},
{
"bugId": 10,
"changedFiles": {
"org/apache/commons/lang3/time/FastDateParser.java": {
"deletes": [
[
304
],
[
307
],
[
308
],
[
309
],
[
310
],
[
311
],
[
312
],
[
313
],
[
314
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java\n+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java\n@@ -301,17 +301,8 @@ public Date parse(String source, ParsePosition pos) {\n * @return The <code>StringBuilder</code>\n */\n private static StringBuilder escapeRegex(StringBuilder regex, String value, boolean unquote) {\n- boolean wasWhite= false;\n for(int i= 0; i<value.length(); ++i) {\n char c= value.charAt(i);\n- if(Character.isWhitespace(c)) {\n- if(!wasWhite) {\n- wasWhite= true;\n- regex.append(\"\\\\s*+\");\n- }\n- continue;\n- }\n- wasWhite= false;\n switch(c) {\n case '\\'':\n if(unquote) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormat_ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "Parsed dates should be equal expected:<null> but was:<Mon Mar 02 21:00:00 PST 1970>",
"methodName": "testLANG_831"
},
{
"className": " org.apache.commons.lang3.time.FastDateParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected FDF failure, but got Mon Mar 02 21:00:00 PST 1970 for [M E,3 Tue] using (\\p{IsNd}++)\\s*+(Fri|Friday|Mon|Monday|Sat|Saturday|Sun|Sunday|Thu|Thursday|Tue|Tuesday|Wed|Wednesday)",
"methodName": "testLANG_831"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 9,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignRem",
"condBranIfAdd",
"mcRem",
"varRem"
],
"repairPatterns": [
"condBlockRem"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair"
],
"revisionId": "afe5dff79fc23d222ba1f1481fbbf55e09d2e6da"
},
{
"bugId": 11,
"changedFiles": {
"org/apache/commons/lang3/RandomStringUtils.java": {
"inserts": [
[
245
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java\n@@ -242,6 +242,10 @@ public static String random(int count, int start, int end, boolean letters, bool\n start = ' '; \n }\n }\n+ } else {\n+ if (end <= start) {\n+ throw new IllegalArgumentException(\"Parameter end (\" + end + \") must be greater than start (\" + start + \")\");\n+ }\n }\n \n char[] buffer = new char[count];\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.RandomStringUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Message (n must be positive) must contain 'start'",
"methodName": "testLANG807"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranElseAdd",
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "c821fafce06adefc040e8983fb12d49399a48627"
},
{
"bugId": 9,
"changedFiles": {
"org/apache/commons/lang3/time/FastDateParser.java": {
"inserts": [
[
144
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java\n+++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java\n@@ -141,6 +141,9 @@ private void init() {\n currentFormatField= nextFormatField;\n currentStrategy= nextStrategy;\n }\n+ if (patternMatcher.regionStart() != patternMatcher.regionEnd()) {\n+ throw new IllegalArgumentException(\"Failed to parse \\\"\"+pattern+\"\\\" ; gave up at index \"+patternMatcher.regionStart());\n+ }\n if(currentStrategy.addRegex(this, regex)) {\n collector.add(currentStrategy);\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormat_ParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "Parsed dates should be equal expected:<null> but was:<Fri Jan 02 21:00:00 PST 1970>",
"methodName": "testLANG_832"
},
{
"className": " org.apache.commons.lang3.time.FastDateParserTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected FDF failure, but got Fri Jan 02 21:00:00 PST 1970 for ['d'd',d3] using d(\\p{IsNd}++)",
"methodName": "testLANG_832"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [],
"revisionId": "c45d5bff75edfef6387d40e681f9dc7c9b517bbb"
},
{
"bugId": 13,
"changedFiles": {
"org/apache/commons/lang3/SerializationUtils.java": {
"inserts": [
[
-1
],
[
250,
251,
252
],
[
268
],
[
269
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java\n@@ -217,58 +217,77 @@ public static Object deserialize(InputStream inputStream) {\n public static Object deserialize(byte[] objectData) {\n if (objectData == null) {\n throw new IllegalArgumentException(\"The byte[] must not be null\");\n }\n ByteArrayInputStream bais = new ByteArrayInputStream(objectData);\n return deserialize(bais);\n }\n \n /**\n * <p>Custom specialization of the standard JDK {@link java.io.ObjectInputStream}\n * that uses a custom <code>ClassLoader</code> to resolve a class.\n * If the specified <code>ClassLoader</code> is not able to resolve the class,\n * the context classloader of the current thread will be used.\n * This way, the standard deserialization work also in web-application\n * containers and application servers, no matter in which of the\n * <code>ClassLoader</code> the particular class that encapsulates\n * serialization/deserialization lives. </p>\n * \n * <p>For more in-depth information about the problem for which this\n * class here is a workaround, see the JIRA issue LANG-626. </p>\n */\n static class ClassLoaderAwareObjectInputStream extends ObjectInputStream {\n+ private static final Map<String, Class<?>> primitiveTypes = \n+ new HashMap<String, Class<?>>();\n private ClassLoader classLoader;\n \n /**\n * Constructor.\n * @param in The <code>InputStream</code>.\n * @param classLoader classloader to use\n * @throws IOException if an I/O error occurs while reading stream header.\n * @see java.io.ObjectInputStream\n */\n public ClassLoaderAwareObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException {\n super(in);\n this.classLoader = classLoader;\n \n+ primitiveTypes.put(\"byte\", byte.class);\n+ primitiveTypes.put(\"short\", short.class);\n+ primitiveTypes.put(\"int\", int.class);\n+ primitiveTypes.put(\"long\", long.class);\n+ primitiveTypes.put(\"float\", float.class);\n+ primitiveTypes.put(\"double\", double.class);\n+ primitiveTypes.put(\"boolean\", boolean.class);\n+ primitiveTypes.put(\"char\", char.class);\n+ primitiveTypes.put(\"void\", void.class);\n }\n \n /**\n * Overriden version that uses the parametrized <code>ClassLoader</code> or the <code>ClassLoader</code>\n * of the current <code>Thread</code> to resolve the class.\n * @param desc An instance of class <code>ObjectStreamClass</code>.\n * @return A <code>Class</code> object corresponding to <code>desc</code>.\n * @throws IOException Any of the usual Input/Output exceptions.\n * @throws ClassNotFoundException If class of a serialized object cannot be found.\n */\n @Override\n protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {\n String name = desc.getName();\n try {\n return Class.forName(name, false, classLoader);\n } catch (ClassNotFoundException ex) {\n+ try {\n return Class.forName(name, false, Thread.currentThread().getContextClassLoader());\n+ } catch (ClassNotFoundException cnfe) {\n+ Class<?> cls = primitiveTypes.get(name);\n+ if (cls != null)\n+ return cls;\n+ else\n+ throw cnfe;\n+ }\n }\n }\n \n }\n \n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.SerializationUtilsTest",
"error": "org.apache.commons.lang3.SerializationException",
"message": "ClassNotFoundException while reading cloned object data",
"methodName": "testPrimitiveTypeClassSerialization"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 19,
"spreadAllLines": 30,
"spreadCodeOnly": 12
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"exThrowsAdd",
"exTryCatchAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockRetAdd",
"initFix",
"wrapsTryCatch"
],
"repairTools": [],
"revisionId": "bd59a1908a1df3364918be7b07782500616b15ac"
},
{
"bugId": 12,
"changedFiles": {
"org/apache/commons/lang3/RandomStringUtils.java": {
"inserts": [
[
230,
231
],
[
232
],
[
238
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java\n@@ -227,14 +227,21 @@ public static String random(int count, int start, int end, boolean letters, bool\n } else if (count < 0) {\n throw new IllegalArgumentException(\"Requested random string length \" + count + \" is less than 0.\");\n }\n+ if (chars != null && chars.length == 0) {\n+ throw new IllegalArgumentException(\"The chars array must not be empty\");\n+ }\n \n if (start == 0 && end == 0) {\n+ if (chars != null) {\n+ end = chars.length;\n+ } else {\n if (!letters && !numbers) {\n end = Integer.MAX_VALUE;\n } else {\n end = 'z' + 1;\n start = ' '; \n }\n+ }\n }\n \n char[] buffer = new char[count];\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.RandomStringUtilsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "2094380118",
"methodName": "testExceptions"
},
{
"className": " org.apache.commons.lang3.RandomStringUtilsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "117011530",
"methodName": "testLANG805"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 8,
"spreadCodeOnly": 7
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"missNullCheckN",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "c9d786a4fe2639581047d878a64bab6fb24f1ab3"
},
{
"bugId": 18,
"changedFiles": {
"org/apache/commons/lang3/time/FastDateFormat.java": {
"changes": [
[
495
],
[
496
],
[
498
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java\n+++ b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java\n@@ -492,10 +492,10 @@ private void init() {\n rule = new TextField(Calendar.ERA, ERAs);\n break;\n case 'y': // year (number)\n- if (tokenLen >= 4) {\n- rule = selectNumberRule(Calendar.YEAR, tokenLen);\n- } else {\n+ if (tokenLen == 2) {\n rule = TwoDigitYearField.INSTANCE;\n+ } else {\n+ rule = selectNumberRule(Calendar.YEAR, tokenLen < 4 ? 4 : tokenLen);\n }\n break;\n case 'M': // month in year (text and number)\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormatTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<AD AD AD AD 2003 [2003 03 20]03 January Jan 01 1 ...> but was:<AD AD AD AD 2003 [03 03 ]03 January Jan 01 1 ...>",
"methodName": "testFormat"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 2,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "An existent if-else structure is removed and a new one is placed in an action that resembles a wrap-with replacement. An aditional wrap-with-IfElse is present in IfElse-CondExp form.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfElseAdd",
"condExpMod",
"mcParValChange"
],
"repairPatterns": [
"expLogicMod",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "2aa9dca994b006ccbfcb528de5ff0da6a5578411"
},
{
"bugId": 17,
"changedFiles": {
"org/apache/commons/lang3/text/translate/CharSequenceTranslator.java": {
"changes": [
[
83
]
],
"deletes": [
[
90
],
[
101
],
[
94
],
[
96
],
[
97
],
[
98
],
[
102
]
],
"inserts": [
[
88,
89
],
[
89
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java\n@@ -80,26 +80,20 @@ public final void translate(CharSequence input, Writer out) throws IOException {\n return;\n }\n int pos = 0;\n- int len = Character.codePointCount(input, 0, input.length());\n+ int len = input.length();\n while (pos < len) {\n int consumed = translate(input, pos, out);\n if (consumed == 0) {\n char[] c = Character.toChars(Character.codePointAt(input, pos));\n out.write(c);\n+ pos+= c.length;\n+ continue;\n }\n- else {\n // // contract with translators is that they have to understand codepoints \n // // and they just took care of a surrogate pair\n for (int pt = 0; pt < consumed; pt++) {\n- if (pos < len - 2) {\n pos += Character.charCount(Character.codePointAt(input, pos));\n- } else {\n- pos++;\n- }\n- }\n- pos--;\n }\n- pos++;\n }\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringEscapeUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<𠮷[A]> but was:<𠮷[?]>",
"methodName": "testLang720"
}
],
"metrics": {
"chunks": 6,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 8,
"methods": 1,
"sizeInLines": 11,
"spreadAllLines": 11,
"spreadCodeOnly": 9
},
"observations": "Unwraps input.length() from \"Character.codePointCount()\" method. Unwraps \"for loop\" from else branch. Unwraps \"pos += ...\" from if-else branch.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"assignExpChange",
"assignRem",
"condBranIfElseAdd",
"condBranRem",
"mcRem"
],
"repairPatterns": [
"initFix",
"missComp",
"unwrapIfElse",
"unwrapMethod"
],
"repairTools": [],
"revisionId": "b4255e6d071dc8d48bfc51037cecb29097b9a49d"
},
{
"bugId": 14,
"changedFiles": {
"org/apache/commons/lang3/StringUtils.java": {
"inserts": [
[
788
],
[
789
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/StringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java\n@@ -785,7 +785,10 @@ public static boolean equals(CharSequence cs1, CharSequence cs2) {\n if (cs1 == null || cs2 == null) {\n return false;\n }\n+ if (cs1 instanceof String && cs2 instanceof String) {\n return cs1.equals(cs2);\n+ }\n+ return CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, Math.max(cs1.length(), cs2.length()));\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEquals"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [
"rtCardumen"
],
"revisionId": "cf7211f9d7d70d56501d8c4c827bf9ce3cac5f0b"
},
{
"bugId": 16,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"changes": [
[
458
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -455,7 +455,7 @@ public static Number createNumber(String str) throws NumberFormatException {\n // a wrong value.\n return null;\n }\n- if (str.startsWith(\"0x\") || str.startsWith(\"-0x\")) {\n+ if (str.startsWith(\"0x\") || str.startsWith(\"-0x\") || str.startsWith(\"0X\") || str.startsWith(\"-0X\")) {\n return createInteger(str);\n } \n char lastChar = str.charAt(str.length() - 1);\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "java.lang.NumberFormatException",
"message": "0Xfade is not a valid number.",
"methodName": "testCreateNumber"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [],
"revisionId": "13c7f19a5ad506340a7c8d8601ef4bf2426ab325"
},
{
"bugId": 15,
"changedFiles": {
"org/apache/commons/lang3/reflect/TypeUtils.java": {
"changes": [
[
219
],
[
220
],
[
221
],
[
675
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java\n@@ -216,9 +216,9 @@ private static boolean isAssignable(Type type, ParameterizedType toParameterized\n toClass, typeVarAssigns);\n \n // now to check each type argument\n- for (Map.Entry<TypeVariable<?>, Type> entry : toTypeVarAssigns.entrySet()) {\n- Type toTypeArg = entry.getValue();\n- Type fromTypeArg = fromTypeVarAssigns.get(entry.getKey());\n+ for (TypeVariable<?> var : toTypeVarAssigns.keySet()) {\n+ Type toTypeArg = unrollVariableAssignments(var, toTypeVarAssigns);\n+ Type fromTypeArg = unrollVariableAssignments(var, fromTypeVarAssigns);\n \n // parameters must either be absent from the subject type, within\n // the bounds of the wildcard type, or be an exact match to the\n@@ -672,7 +672,7 @@ private static Type substituteTypeVariables(Type type, Map<TypeVariable<?>, Type\n : new HashMap<TypeVariable<?>, Type>(subtypeVarAssigns);\n \n // has target class been reached?\n- if (cls.getTypeParameters().length > 0 || toClass.equals(cls)) {\n+ if (toClass.equals(cls)) {\n return typeVarAssigns;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang3.reflect.TypeUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<0>",
"methodName": "testGetTypeArguments"
},
{
"className": " org.apache.commons.lang3.reflect.TypeUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "type class org.apache.commons.lang3.reflect.TypeUtilsTest$Thing not assignable to org.apache.commons.lang3.reflect.TypeUtilsTest.org.apache.commons.lang3.reflect.TypeUtilsTest$This<java.lang.String, java.lang.String>!",
"methodName": "testIsAssignable"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 453,
"spreadCodeOnly": 226
},
"observations": "Change local var type.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignExpChange",
"condExpRed",
"loopCondChange",
"mcAdd"
],
"repairPatterns": [
"expLogicReduce",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "8185a9e681d6de5f40b0ed07b40730c9761bad37"
},
{
"bugId": 21,
"changedFiles": {
"org/apache/commons/lang3/time/DateUtils.java": {
"changes": [
[
265
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java\n@@ -262,7 +262,7 @@ public static boolean isSameLocalTime(Calendar cal1, Calendar cal2) {\n return (cal1.get(Calendar.MILLISECOND) == cal2.get(Calendar.MILLISECOND) &&\n cal1.get(Calendar.SECOND) == cal2.get(Calendar.SECOND) &&\n cal1.get(Calendar.MINUTE) == cal2.get(Calendar.MINUTE) &&\n- cal1.get(Calendar.HOUR) == cal2.get(Calendar.HOUR) &&\n+ cal1.get(Calendar.HOUR_OF_DAY) == cal2.get(Calendar.HOUR_OF_DAY) &&\n cal1.get(Calendar.DAY_OF_YEAR) == cal2.get(Calendar.DAY_OF_YEAR) &&\n cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&\n cal1.get(Calendar.ERA) == cal2.get(Calendar.ERA) &&\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.DateUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "LANG-677",
"methodName": "testIsSameLocalTime_Cal"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcParValChange",
"retExpChange",
"varReplVar"
],
"repairPatterns": [
"constChange",
"expLogicMod",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtssFix"
],
"revisionId": "55f642725742513824975af0e5e91cb1920b6d72"
},
{
"bugId": 19,
"changedFiles": {
"org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java": {
"changes": [
[
40
],
[
54
],
[
80
]
],
"inserts": [
[
48,
49,
50
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java\n@@ -37,7 +37,7 @@\n public int translate(CharSequence input, int index, Writer out) throws IOException {\n int seqEnd = input.length();\n // Uses -2 to ensure there is something after the &#\n- if(input.charAt(index) == '&' && index < seqEnd - 1 && input.charAt(index + 1) == '#') {\n+ if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {\n int start = index + 2;\n boolean isHex = false;\n \n@@ -47,11 +47,16 @@ public int translate(CharSequence input, int index, Writer out) throws IOExcepti\n isHex = true;\n \n // Check there's more than just an x after the &#\n+ if(start == seqEnd) {\n+ return 0;\n+ }\n }\n \n int end = start;\n // Note that this supports character codes without a ; on the end\n- while(input.charAt(end) != ';') \n+ while(end < seqEnd && ( (input.charAt(end) >= '0' && input.charAt(end) <= '9') ||\n+ (input.charAt(end) >= 'a' && input.charAt(end) <= 'f') ||\n+ (input.charAt(end) >= 'A' && input.charAt(end) <= 'F') ) )\n {\n end++;\n }\n@@ -76,8 +81,9 @@ public int translate(CharSequence input, int index, Writer out) throws IOExcepti\n out.write(entityValue);\n }\n \n+ boolean semiNext = (end != seqEnd) && (input.charAt(end) == ';');\n \n- return 2 + (end - start) + (isHex ? 1 : 0) + 1;\n+ return 2 + (end - start) + (isHex ? 1 : 0) + (semiNext ? 1 : 0);\n }\n return 0;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.text.translate.NumericEntityUnescaperTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 19",
"methodName": "testUnfinishedEntity"
},
{
"className": " org.apache.commons.lang3.text.translate.NumericEntityUnescaperTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 7",
"methodName": "testOutOfBounds"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 38,
"spreadCodeOnly": 29
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpMod",
"loopCondChange",
"mcAdd",
"mcRem",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"constChange",
"expArithMod",
"expLogicMod",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "0b3a8a3128890f710700d04e38df48b883d11d91"
},
{
"bugId": 23,
"changedFiles": {
"org/apache/commons/lang3/text/ExtendedMessageFormat.java": {
"inserts": [
[
-1
],
[
-1
],
[
-1
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java\n+++ b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java\n@@ -70,6 +70,7 @@\n */\n public class ExtendedMessageFormat extends MessageFormat {\n private static final long serialVersionUID = -2362048321261811743L;\n+ private static final int HASH_SEED = 31;\n \n private static final String DUMMY_PATTERN = \"\";\n private static final String ESCAPED_QUOTE = \"''\";\n@@ -260,12 +261,42 @@ public void setFormatsByArgumentIndex(Format[] newFormats) {\n * @param obj the object to compare to\n * @return true if this object equals the other, otherwise false\n */\n+ @Override\n+ public boolean equals(Object obj) {\n+ if (obj == this) {\n+ return true;\n+ }\n+ if (obj == null) {\n+ return false;\n+ }\n+ if (!super.equals(obj)) {\n+ return false;\n+ }\n+ if (ObjectUtils.notEqual(getClass(), obj.getClass())) {\n+ return false;\n+ }\n+ ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj;\n+ if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) {\n+ return false;\n+ }\n+ if (ObjectUtils.notEqual(registry, rhs.registry)) {\n+ return false;\n+ }\n+ return true;\n+ }\n \n /**\n * Return the hashcode.\n *\n * @return the hashcode\n */\n+ @Override\n+ public int hashCode() {\n+ int result = super.hashCode();\n+ result = HASH_SEED * result + ObjectUtils.hashCode(registry);\n+ result = HASH_SEED * result + ObjectUtils.hashCode(toPattern);\n+ return result;\n+ }\n \n /**\n * Get a custom format from a format description.\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.text.ExtendedMessageFormatTest",
"error": "junit.framework.AssertionFailedError",
"message": "registry, hashcode()",
"methodName": "testEqualsHashcode"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 31,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 31,
"spreadAllLines": 196,
"spreadCodeOnly": 105
},
"observations": "Implements equals and hascode to work with hash structures of Collections",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"mdAdd",
"mdOverride",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"fixAPI",
"wrongComp"
],
"repairTools": [],
"revisionId": "46356183872f2cba5e340993c6d85597a4f3cdbb"
},
{
"bugId": 22,
"changedFiles": {
"org/apache/commons/lang3/math/Fraction.java": {
"changes": [
[
584
]
],
"inserts": [
[
582,
583,
584
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/Fraction.java\n+++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java\n@@ -580,8 +580,14 @@ public Fraction pow(int power) {\n */\n private static int greatestCommonDivisor(int u, int v) {\n // From Commons Math:\n+ if ((u == 0) || (v == 0)) {\n+ if ((u == Integer.MIN_VALUE) || (v == Integer.MIN_VALUE)) {\n+ throw new ArithmeticException(\"overflow: gcd is 2^31\");\n+ }\n+ return Math.abs(u) + Math.abs(v);\n+ }\n //if either operand is abs 1, return 1:\n- if (Math.abs(u) <= 1 || Math.abs(v) <= 1) {\n+ if (Math.abs(u) == 1 || Math.abs(v) == 1) {\n return 1;\n }\n // keep u and v negative, as negative integers range down to\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1073741824> but was:<-2147483648>",
"methodName": "testReducedFactory_int_int"
},
{
"className": " org.apache.commons.lang3.math.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1073741824> but was:<-2147483648>",
"methodName": "testReduce"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condExpMod",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockRetAdd",
"expLogicMod",
"missComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL"
],
"revisionId": "0b2b82ad923b0455cde93286e3f504a1abd0863b"
},
{
"bugId": 20,
"changedFiles": {
"org/apache/commons/lang3/StringUtils.java": {
"changes": [
[
3298
],
[
3383
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/StringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java\n@@ -3295,7 +3295,7 @@ public static String join(Object[] array, char separator, int startIndex, int en\n return EMPTY;\n }\n \n- StringBuilder buf = new StringBuilder((array[startIndex] == null ? 16 : array[startIndex].toString().length()) + 1);\n+ StringBuilder buf = new StringBuilder(noOfItems * 16);\n \n for (int i = startIndex; i < endIndex; i++) {\n if (i > startIndex) {\n@@ -3380,7 +3380,7 @@ public static String join(Object[] array, String separator, int startIndex, int\n return EMPTY;\n }\n \n- StringBuilder buf = new StringBuilder((array[startIndex] == null ? 16 : array[startIndex].toString().length()) + separator.length());\n+ StringBuilder buf = new StringBuilder(noOfItems * 16);\n \n for (int i = startIndex; i < endIndex; i++) {\n if (i > startIndex) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testJoin_ArrayChar"
},
{
"className": " org.apache.commons.lang3.StringUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testJoin_Objectarray"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 84,
"spreadCodeOnly": 27
},
"observations": "Null-Check is removed from \"buf\" initialization.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignExpChange",
"condBranRem",
"mcRem",
"objInstMod"
],
"repairPatterns": [
"condBlockRem",
"copyPaste",
"initFix"
],
"repairTools": [
"rtDeepRepair"
],
"revisionId": "f08213cc4c35fd71e98aa5233fcb2db3333793a2"
},
{
"bugId": 24,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"changes": [
[
1413
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -1410,7 +1410,7 @@ public static boolean isNumber(String str) {\n if (chars[i] == 'l'\n || chars[i] == 'L') {\n // not allowing L with an exponent or decimal point\n- return foundDigit && !hasExp;\n+ return foundDigit && !hasExp && !hasDecPoint;\n }\n // last character is illegal\n return false;\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "isNumber(String) LANG-664 failed",
"methodName": "testIsNumber"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtAcs",
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtJAID"
],
"revisionId": "81903abbb25ff92597d5f1e3acc648d12bdee444"
},
{
"bugId": 26,
"changedFiles": {
"org/apache/commons/lang3/time/FastDateFormat.java": {
"changes": [
[
820
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java\n+++ b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java\n@@ -817,7 +817,7 @@ public String format(long millis) {\n * @return the formatted string\n */\n public String format(Date date) {\n- Calendar c = new GregorianCalendar(mTimeZone);\n+ Calendar c = new GregorianCalendar(mTimeZone, mLocale);\n c.setTime(date);\n return applyRules(c, new StringBuffer(mMaxLengthEstimate)).toString();\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormatTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<fredag, week [53]> but was:<fredag, week [01]>",
"methodName": "testLang645"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Adds a new parameter to constructor call (call overloaded constructor)",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"objInstMod"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongMethodRef"
],
"repairTools": [
"rtElixir"
],
"revisionId": "75d5b74a1a7ef68c5169f4b44cdf972c1ab07ee0"
},
{
"bugId": 25,
"changedFiles": {
"org/apache/commons/lang3/text/translate/EntityArrays.java": {
"changes": [
[
74
],
[
75
],
[
76
],
[
77
],
[
78
],
[
79
],
[
80
],
[
81
],
[
82
],
[
83
],
[
84
],
[
85
],
[
86
],
[
87
],
[
88
],
[
89
],
[
90
],
[
91
],
[
92
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
98
],
[
99
],
[
100
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/EntityArrays.java\n@@ -71,33 +71,33 @@\n {\"\\u00C7\", \"&Ccedil;\"}, // - uppercase C, cedilla\n {\"\\u00C8\", \"&Egrave;\"}, // - uppercase E, grave accent\n {\"\\u00C9\", \"&Eacute;\"}, // - uppercase E, acute accent\n- {\"\\u00CB\", \"&Ecirc;\"}, // - uppercase E, circumflex accent\n- {\"\\u00CC\", \"&Euml;\"}, // - uppercase E, umlaut\n- {\"\\u00CD\", \"&Igrave;\"}, // - uppercase I, grave accent\n- {\"\\u00CE\", \"&Iacute;\"}, // - uppercase I, acute accent\n- {\"\\u00CF\", \"&Icirc;\"}, // - uppercase I, circumflex accent\n- {\"\\u00D0\", \"&Iuml;\"}, // - uppercase I, umlaut\n- {\"\\u00D1\", \"&ETH;\"}, // - uppercase Eth, Icelandic\n- {\"\\u00D2\", \"&Ntilde;\"}, // - uppercase N, tilde\n- {\"\\u00D3\", \"&Ograve;\"}, // - uppercase O, grave accent\n- {\"\\u00D4\", \"&Oacute;\"}, // - uppercase O, acute accent\n- {\"\\u00D5\", \"&Ocirc;\"}, // - uppercase O, circumflex accent\n- {\"\\u00D6\", \"&Otilde;\"}, // - uppercase O, tilde\n- {\"\\u00D7\", \"&Ouml;\"}, // - uppercase O, umlaut\n- {\"\\u00D8\", \"&times;\"}, // multiplication sign\n- {\"\\u00D9\", \"&Oslash;\"}, // - uppercase O, slash\n- {\"\\u00DA\", \"&Ugrave;\"}, // - uppercase U, grave accent\n- {\"\\u00DB\", \"&Uacute;\"}, // - uppercase U, acute accent\n- {\"\\u00DC\", \"&Ucirc;\"}, // - uppercase U, circumflex accent\n- {\"\\u00DD\", \"&Uuml;\"}, // - uppercase U, umlaut\n- {\"\\u00DE\", \"&Yacute;\"}, // - uppercase Y, acute accent\n- {\"\\u00DF\", \"&THORN;\"}, // - uppercase THORN, Icelandic\n- {\"\\u00E0\", \"&szlig;\"}, // - lowercase sharps, German\n- {\"\\u00E1\", \"&agrave;\"}, // - lowercase a, grave accent\n- {\"\\u00E2\", \"&aacute;\"}, // - lowercase a, acute accent\n- {\"\\u00E3\", \"&acirc;\"}, // - lowercase a, circumflex accent\n- {\"\\u00E4\", \"&atilde;\"}, // - lowercase a, tilde\n- {\"\\u00E5\", \"&auml;\"}, // - lowercase a, umlaut\n+ {\"\\u00CA\", \"&Ecirc;\"}, // - uppercase E, circumflex accent\n+ {\"\\u00CB\", \"&Euml;\"}, // - uppercase E, umlaut\n+ {\"\\u00CC\", \"&Igrave;\"}, // - uppercase I, grave accent\n+ {\"\\u00CD\", \"&Iacute;\"}, // - uppercase I, acute accent\n+ {\"\\u00CE\", \"&Icirc;\"}, // - uppercase I, circumflex accent\n+ {\"\\u00CF\", \"&Iuml;\"}, // - uppercase I, umlaut\n+ {\"\\u00D0\", \"&ETH;\"}, // - uppercase Eth, Icelandic\n+ {\"\\u00D1\", \"&Ntilde;\"}, // - uppercase N, tilde\n+ {\"\\u00D2\", \"&Ograve;\"}, // - uppercase O, grave accent\n+ {\"\\u00D3\", \"&Oacute;\"}, // - uppercase O, acute accent\n+ {\"\\u00D4\", \"&Ocirc;\"}, // - uppercase O, circumflex accent\n+ {\"\\u00D5\", \"&Otilde;\"}, // - uppercase O, tilde\n+ {\"\\u00D6\", \"&Ouml;\"}, // - uppercase O, umlaut\n+ {\"\\u00D7\", \"&times;\"}, // multiplication sign\n+ {\"\\u00D8\", \"&Oslash;\"}, // - uppercase O, slash\n+ {\"\\u00D9\", \"&Ugrave;\"}, // - uppercase U, grave accent\n+ {\"\\u00DA\", \"&Uacute;\"}, // - uppercase U, acute accent\n+ {\"\\u00DB\", \"&Ucirc;\"}, // - uppercase U, circumflex accent\n+ {\"\\u00DC\", \"&Uuml;\"}, // - uppercase U, umlaut\n+ {\"\\u00DD\", \"&Yacute;\"}, // - uppercase Y, acute accent\n+ {\"\\u00DE\", \"&THORN;\"}, // - uppercase THORN, Icelandic\n+ {\"\\u00DF\", \"&szlig;\"}, // - lowercase sharps, German\n+ {\"\\u00E0\", \"&agrave;\"}, // - lowercase a, grave accent\n+ {\"\\u00E1\", \"&aacute;\"}, // - lowercase a, acute accent\n+ {\"\\u00E2\", \"&acirc;\"}, // - lowercase a, circumflex accent\n+ {\"\\u00E3\", \"&atilde;\"}, // - lowercase a, tilde\n+ {\"\\u00E4\", \"&auml;\"}, // - lowercase a, umlaut\n {\"\\u00E5\", \"&aring;\"}, // - lowercase a, ring\n {\"\\u00E6\", \"&aelig;\"}, // - lowercase ae\n {\"\\u00E7\", \"&ccedil;\"}, // - lowercase c, cedilla\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.text.translate.EntityArraysTest",
"error": "junit.framework.AssertionFailedError",
"message": "One or more errors detected",
"methodName": "testISO8859_1_ESCAPE"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 27,
"linesRem": 0,
"methods": 1,
"sizeInLines": 27,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes keys in a vector of type key-value.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"objInstMod"
],
"repairPatterns": [
"constChange",
"initFix"
],
"repairTools": [],
"revisionId": "2bae68787d15c3d3540380164e62759485078ec1"
},
{
"bugId": 29,
"changedFiles": {
"org/apache/commons/lang3/SystemUtils.java": {
"changes": [
[
1672
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/SystemUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java\n@@ -1669,7 +1669,7 @@ static float toJavaVersionFloat(String version) {\n * \n * @return the version, for example 131 for Java 1.3.1\n */\n- static float toJavaVersionInt(String version) {\n+ static int toJavaVersionInt(String version) {\n return toVersionInt(toJavaVersionIntArray(version, JAVA_VERSION_TRIM_SIZE));\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang3.SystemUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<0.0>",
"methodName": "testJavaVersionAsInt"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes return type of method.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mdRetTyChange"
],
"repairPatterns": [
"singleLine"
],
"repairTools": [],
"revisionId": "982e295053663787bb0396b81a8956c3c87dc25b"
},
{
"bugId": 30,
"changedFiles": {
"org/apache/commons/lang3/StringUtils.java": {
"changes": [
[
1443
],
[
1455
],
[
1457
],
[
1497
],
[
1576
]
],
"inserts": [
[
1376,
1377
],
[
1377
],
[
1381,
1382
],
[
1383
],
[
1456,
1457
],
[
1533,
1534
],
[
1534
],
[
1539
],
[
1540
],
[
1576
],
[
1579
],
[
1678,
1679
],
[
1679
],
[
1683,
1684,
1685
],
[
1686
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/StringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java\n@@ -1373,13 +1373,21 @@ public static int indexOfAny(CharSequence cs, char[] searchChars) {\n return INDEX_NOT_FOUND;\n }\n int csLen = cs.length();\n+ int csLast = csLen - 1;\n int searchLen = searchChars.length;\n+ int searchLast = searchLen - 1;\n for (int i = 0; i < csLen; i++) {\n char ch = cs.charAt(i);\n for (int j = 0; j < searchLen; j++) {\n if (searchChars[j] == ch) {\n+ if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {\n // ch is a supplementary character\n+ if (searchChars[j + 1] == cs.charAt(i + 1)) {\n+ return i;\n+ }\n+ } else {\n return i;\n+ }\n }\n }\n }\n@@ -1440,7 +1448,7 @@ public static int indexOfAny(CharSequence cs, String searchChars) {\n * <code>false</code> if no match or null input\n * @since 2.4\n */\n- public static boolean containsAny(CharSequence cs, char[] searchChars) {\n+ public static boolean containsAny(String cs, char[] searchChars) {\n if (isEmpty(cs) || ArrayUtils.isEmpty(searchChars)) {\n return false;\n }\n@@ -1452,9 +1460,12 @@ public static boolean containsAny(CharSequence cs, char[] searchChars) {\n char ch = cs.charAt(i);\n for (int j = 0; j < searchLength; j++) {\n if (searchChars[j] == ch) {\n- if (i < csLast && j < searchLast && ch >= Character.MIN_HIGH_SURROGATE && ch <= Character.MAX_HIGH_SURROGATE) {\n+ if (Character.isHighSurrogate(ch)) {\n+ if (j == searchLast) {\n // missing low surrogate, fine, like String.indexOf(String)\n- if (searchChars[j + 1] == cs.charAt(i + 1)) {\n+ return true;\n+ }\n+ if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {\n return true;\n }\n } else {\n@@ -1494,7 +1505,7 @@ public static boolean containsAny(CharSequence cs, char[] searchChars) {\n * @return the <code>true</code> if any of the chars are found, <code>false</code> if no match or null input\n * @since 2.4\n */\n- public static boolean containsAny(CharSequence cs, String searchChars) {\n+ public static boolean containsAny(String cs, String searchChars) {\n if (searchChars == null) {\n return false;\n }\n@@ -1530,13 +1541,21 @@ public static int indexOfAnyBut(CharSequence cs, char[] searchChars) {\n return INDEX_NOT_FOUND;\n }\n int csLen = cs.length();\n+ int csLast = csLen - 1;\n int searchLen = searchChars.length;\n+ int searchLast = searchLen - 1;\n outer:\n for (int i = 0; i < csLen; i++) {\n char ch = cs.charAt(i);\n for (int j = 0; j < searchLen; j++) {\n if (searchChars[j] == ch) {\n+ if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {\n+ if (searchChars[j + 1] == cs.charAt(i + 1)) {\n+ continue outer;\n+ }\n+ } else {\n continue outer;\n+ }\n }\n }\n return i;\n@@ -1573,8 +1592,16 @@ public static int indexOfAnyBut(String str, String searchChars) {\n int strLen = str.length();\n for (int i = 0; i < strLen; i++) {\n char ch = str.charAt(i);\n- if (searchChars.indexOf(ch) < 0) {\n+ boolean chFound = searchChars.indexOf(ch) >= 0;\n+ if (i + 1 < strLen && Character.isHighSurrogate(ch)) {\n+ char ch2 = str.charAt(i + 1);\n+ if (chFound && searchChars.indexOf(ch2) < 0) {\n return i;\n+ }\n+ } else {\n+ if (!chFound) {\n+ return i;\n+ }\n }\n }\n return INDEX_NOT_FOUND;\n@@ -1675,14 +1702,25 @@ public static boolean containsNone(CharSequence cs, char[] searchChars) {\n return true;\n }\n int csLen = cs.length();\n+ int csLast = csLen - 1;\n int searchLen = searchChars.length;\n+ int searchLast = searchLen - 1;\n for (int i = 0; i < csLen; i++) {\n char ch = cs.charAt(i);\n for (int j = 0; j < searchLen; j++) {\n if (searchChars[j] == ch) {\n+ if (Character.isHighSurrogate(ch)) {\n+ if (j == searchLast) {\n // missing low surrogate, fine, like String.indexOf(String)\n+ return false;\n+ }\n+ if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {\n+ return false;\n+ }\n+ } else {\n // ch is in the Basic Multilingual Plane\n return false;\n+ }\n }\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<true> but was:<false>",
"methodName": "testContainsNone_CharArrayWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<true> but was:<false>",
"methodName": "testContainsNone_StringWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<false> but was:<true>",
"methodName": "testContainsAny_StringCharArrayWithBadSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<3>",
"methodName": "testIndexOfAnyBut_StringStringWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<false> but was:<true>",
"methodName": "testContainsAny_StringWithBadSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<0>",
"methodName": "testIndexOfAny_StringCharArrayWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<3>",
"methodName": "testIndexOfAnyBut_StringCharArrayWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<true> but was:<false>",
"methodName": "testContainsNone_StringWithBadSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2> but was:<0>",
"methodName": "testIndexOfAny_StringStringWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<true> but was:<false>",
"methodName": "testContainsNone_CharArrayWithBadSupplementaryChars"
}
],
"metrics": {
"chunks": 20,
"classes": 1,
"files": 1,
"linesAdd": 38,
"linesMod": 5,
"linesRem": 0,
"methods": 6,
"sizeInLines": 43,
"spreadAllLines": 305,
"spreadCodeOnly": 102
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpExpand",
"condExpMod",
"condExpRed",
"mcAdd",
"mcRem",
"mdParTyChange",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"copyPaste",
"expLogicExpand",
"expLogicMod",
"missComp",
"wrapsIf",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "19b6372018c6b800f8e2bf1b85e15ef4cbd500da"
},
{
"bugId": 28,
"changedFiles": {
"org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java": {
"inserts": [
[
62,
63
],
[
64
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java\n+++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java\n@@ -60,7 +60,13 @@ public int translate(CharSequence input, int index, Writer out) throws IOExcepti\n return 0;\n }\n \n+ if(entityValue > 0xFFFF) {\n+ char[] chrs = Character.toChars(entityValue);\n+ out.write(chrs[0]);\n+ out.write(chrs[1]);\n+ } else {\n out.write(entityValue);\n+ }\n return 2 + (end - start) + (isHex ? 1 : 0) + 1;\n }\n return 0;\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.text.translate.NumericEntityUnescaperTest",
"error": "junit.framework.ComparisonFailure",
"message": "Failed to unescape numeric entities supplementary characters expected:<[𐰢]> but was:<[ఢ]>",
"methodName": "testSupplementaryUnescaping"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "3e1afecc200d7e3be9537c95b7cf52a7c5031300"
},
{
"bugId": 27,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"changes": [
[
479
]
],
"inserts": [
[
489
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -476,7 +476,7 @@ public static Number createNumber(String str) throws NumberFormatException {\n if (decPos > -1) {\n \n if (expPos > -1) {\n- if (expPos < decPos) {\n+ if (expPos < decPos || expPos > str.length()) {\n throw new NumberFormatException(str + \" is not a valid number.\");\n }\n dec = str.substring(decPos + 1, expPos);\n@@ -486,6 +486,9 @@ public static Number createNumber(String str) throws NumberFormatException {\n mant = str.substring(0, decPos);\n } else {\n if (expPos > -1) {\n+ if (expPos > str.length()) {\n+ throw new NumberFormatException(str + \" is not a valid number.\");\n+ }\n mant = str.substring(0, expPos);\n } else {\n mant = str;\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 4",
"methodName": "testCreateNumber"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 9,
"spreadCodeOnly": 9
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condExpExpand",
"exThrowsAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"expLogicExpand"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair"
],
"revisionId": "c2560c028173c3bc0a4627d4ce5ce221bcc9be66"
},
{
"bugId": 31,
"changedFiles": {
"org/apache/commons/lang3/StringUtils.java": {
"inserts": [
[
1445,
1446
],
[
1446
],
[
1450,
1451,
1452
],
[
1453
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/StringUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/StringUtils.java\n@@ -1443,13 +1443,21 @@ public static boolean containsAny(CharSequence cs, char[] searchChars) {\n \t\t}\n \t\tint csLength = cs.length();\n \t\tint searchLength = searchChars.length;\n+\t\tint csLastIndex = csLength - 1;\n+\t\tint searchLastIndex = searchLength - 1;\n \t\tfor (int i = 0; i < csLength; i++) {\n \t\t\tchar ch = cs.charAt(i);\n \t\t\tfor (int j = 0; j < searchLength; j++) {\n \t\t\t\tif (searchChars[j] == ch) {\n+\t\t\t\t\tif (i < csLastIndex && j < searchLastIndex && ch >= Character.MIN_HIGH_SURROGATE && ch <= Character.MAX_HIGH_SURROGATE) {\n \t\t\t\t\t\t// ch is a supplementary character\n+\t\t\t\t\t\tif (searchChars[j + 1] == cs.charAt(i + 1)) {\n+\t\t\t\t\t\t\treturn true;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t} else {\n \t\t\t\t\t\t// ch is in the Basic Multilingual Plane\n \t\t\t\t\t\treturn true;\n+\t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<false> but was:<true>",
"methodName": "testContainsAnyCharArrayWithSupplementaryChars"
},
{
"className": " org.apache.commons.lang3.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<false> but was:<true>",
"methodName": "testContainsAnyStringWithSupplementaryChars"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 7,
"spreadCodeOnly": 5
},
"observations": "Partially the same as Lang 30",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "38bf7048571f3bc8dd34d14691906426444e4381"
},
{
"bugId": 32,
"changedFiles": {
"org/apache/commons/lang3/builder/HashCodeBuilder.java": {
"changes": [
[
104
],
[
105
],
[
106
],
[
107
],
[
108
],
[
109
],
[
152
],
[
538
]
],
"inserts": [
[
522
],
[
538
],
[
539
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java\n+++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java\n@@ -101,12 +101,7 @@\n * \n * @since 2.3\n */\n- private static final ThreadLocal<Set<IDKey>> REGISTRY = new ThreadLocal<Set<IDKey>>() {\n- @Override\n- protected Set<IDKey> initialValue() {\n- return new HashSet<IDKey>();\n- }\n- };\n+ private static final ThreadLocal<Set<IDKey>> REGISTRY = new ThreadLocal<Set<IDKey>>();\n \n /*\n * N.B. we cannot store the actual objects in a HashSet, as that would use the very hashCode()\n@@ -149,7 +144,8 @@\n * @since 2.3\n */\n static boolean isRegistered(Object value) {\n- return getRegistry().contains(new IDKey(value));\n+ Set<IDKey> registry = getRegistry();\n+ return registry != null && registry.contains(new IDKey(value));\n }\n \n /**\n@@ -519,6 +515,11 @@ public static int reflectionHashCode(Object object, String[] excludeFields) {\n * The object to register.\n */\n static void register(Object value) {\n+ synchronized (HashCodeBuilder.class) {\n+ if (getRegistry() == null) {\n+ REGISTRY.set(new HashSet<IDKey>());\n+ }\n+ }\n getRegistry().add(new IDKey(value));\n }\n \n@@ -535,7 +536,15 @@ static void register(Object value) {\n * @since 2.3\n */\n static void unregister(Object value) {\n- getRegistry().remove(new IDKey(value));\n+ Set<IDKey> s = getRegistry();\n+ if (s != null) {\n+ s.remove(new IDKey(value));\n+ synchronized (HashCodeBuilder.class) {\n+ if (s.isEmpty()) {\n+ REGISTRY.remove();\n+ }\n+ }\n+ }\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.builder.HashCodeBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: []",
"methodName": "testReflectionObjectCycle"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 14,
"linesMod": 3,
"linesRem": 5,
"methods": 3,
"sizeInLines": 22,
"spreadAllLines": 427,
"spreadCodeOnly": 74
},
"observations": "Applies null check using synchronized block with object lock (HashCodeBuilder.class)",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"mdOverride",
"mdRem",
"objInstMod",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicMod",
"initFix",
"missNullCheckN",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "006fca88e86bd6f650d4d021d2ff3573a572827d"
},
{
"bugId": 33,
"changedFiles": {
"org/apache/commons/lang3/ClassUtils.java": {
"changes": [
[
910
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/ClassUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java\n@@ -907,7 +907,7 @@ private static String toCanonicalName(String className) {\n }\n Class<?>[] classes = new Class[array.length];\n for (int i = 0; i < array.length; i++) {\n- classes[i] = array[i].getClass();\n+ classes[i] = array[i] == null ? null : array[i].getClass();\n }\n return classes;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.ClassUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testToClass_object"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Wrap-with applied with IfElse-Expression",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfElseAdd"
],
"repairPatterns": [
"missNullCheckP",
"singleLine",
"wrapsIfElse"
],
"repairTools": [
"rtElixir",
"rtJAID",
"rtssFix"
],
"revisionId": "0603aef594fa60126c2d45f2ab164eee39f7b44c"
},
{
"bugId": 34,
"changedFiles": {
"org/apache/commons/lang3/builder/ToStringStyle.java": {
"changes": [
[
148
],
[
164
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java\n+++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java\n@@ -145,7 +145,7 @@\n * @return Set the registry of objects being traversed\n */\n static Map<Object, Object> getRegistry() {\n- return REGISTRY.get() != null ? REGISTRY.get() : Collections.<Object, Object>emptyMap();\n+ return REGISTRY.get();\n }\n \n /**\n@@ -161,7 +161,7 @@\n */\n static boolean isRegistered(Object value) {\n Map<Object, Object> m = getRegistry();\n- return m.containsKey(value);\n+ return m != null && m.containsKey(value);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionHierarchy"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testSelfInstanceTwoVarsReflectionObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionArrayCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionLongArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionArrayArrayCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionFloatArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionDoubleArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionBooleanArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionyteArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionDoubleArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionIntArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionLongArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionhortArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionObjectArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionBooleanArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testSimpleReflectionObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionByteArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionArrayCycleLevel2"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionArrayAndObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionCharArrayArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionShortArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testSelfInstanceVarReflectionObjectCycle"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionIntArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionCharArray"
},
{
"className": " org.apache.commons.lang3.builder.ToStringBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: {}",
"methodName": "testReflectionFloatArrayArray"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 15,
"spreadCodeOnly": 3
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranRem",
"mcRem",
"retExpChange"
],
"repairPatterns": [
"expLogicExpand",
"missNullCheckN",
"unwrapIfElse"
],
"repairTools": [],
"revisionId": "496525b0d626dd5049528cdef61d71681154b660"
},
{
"bugId": 37,
"changedFiles": {
"org/apache/commons/lang3/ArrayUtils.java": {
"inserts": [
[
2962
],
[
2963,
2964
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang3/ArrayUtils.java\n+++ b/src/java/org/apache/commons/lang3/ArrayUtils.java\n@@ -2959,8 +2959,16 @@ public static boolean isEmpty(boolean[] array) {\n final Class<?> type1 = array1.getClass().getComponentType();\n T[] joinedArray = (T[]) Array.newInstance(type1, array1.length + array2.length);\n System.arraycopy(array1, 0, joinedArray, 0, array1.length);\n+ try {\n System.arraycopy(array2, 0, joinedArray, array1.length, array2.length);\n+ } catch (ArrayStoreException ase) {\n // Check if problem is incompatible types\n+ final Class<?> type2 = array2.getClass().getComponentType();\n+ if (!type1.isAssignableFrom(type2)){\n+ throw new IllegalArgumentException(\"Cannot store \"+type2.getName()+\" in an array of \"+type1.getName());\n+ }\n+ throw ase; // No, so rethrow original\n+ }\n return joinedArray;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang3.ArrayUtilsAddTest",
"error": "java.lang.ArrayStoreException",
"message": "",
"methodName": "testJira567"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 2,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"exTryCatchAdd",
"mcAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"wrapsTryCatch"
],
"repairTools": [],
"revisionId": "ea140fb5c327e2b58f6c5bf1057c7dede909a50c"
},
{
"bugId": 35,
"changedFiles": {
"org/apache/commons/lang3/ArrayUtils.java": {
"changes": [
[
3295
],
[
3574
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java\n+++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java\n@@ -3292,7 +3292,7 @@ public static boolean isEmpty(boolean[] array) {\n } else if (element != null) {\n type = element.getClass();\n } else {\n- type = Object.class;\n+ throw new IllegalArgumentException(\"Arguments cannot both be null\"); \n }\n @SuppressWarnings(\"unchecked\") // type must be T\n T[] newArray = (T[]) copyArrayGrow1(array, type);\n@@ -3571,7 +3571,7 @@ private static Object copyArrayGrow1(Object array, Class<?> newArrayComponentTyp\n } else if (element != null) {\n clss = element.getClass();\n } else {\n- return (T[]) new Object[] { null };\n+ throw new IllegalArgumentException(\"Array and element cannot both be null\"); \n }\n @SuppressWarnings(\"unchecked\") // the add method creates an array of type clss, which is type T\n final T[] newArray = (T[]) add(array, index, element, clss);\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.ArrayUtilsAddTest",
"error": "java.lang.ClassCastException",
"message": "[Ljava.lang.Object; cannot be cast to [Ljava.lang.String;",
"methodName": "testLANG571"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 278,
"spreadCodeOnly": 62
},
"observations": "Changes return of a null object to throw an Exception. The only statement of an existent \"else block\" is replaced by an exception throw.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignRem",
"exThrowsAdd",
"objInstAdd",
"retRem"
],
"repairPatterns": [
"notClassified"
],
"repairTools": [
"rtAcs"
],
"revisionId": "80bd78ea0685d28ddec9b8162d652db9dec949ce"
},
{
"bugId": 38,
"changedFiles": {
"org/apache/commons/lang3/time/FastDateFormat.java": {
"inserts": [
[
872
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang3/time/FastDateFormat.java\n+++ b/src/java/org/apache/commons/lang3/time/FastDateFormat.java\n@@ -869,6 +869,7 @@ public StringBuffer format(Date date, StringBuffer buf) {\n */\n public StringBuffer format(Calendar calendar, StringBuffer buf) {\n if (mTimeZoneForced) {\n+ calendar.getTime(); /// LANG-538\n calendar = (Calendar) calendar.clone();\n calendar.setTimeZone(mTimeZone);\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.time.FastDateFormatTest",
"error": "junit.framework.ComparisonFailure",
"message": "dateTime expected:<2009-10-16T[16]:42:16.000Z> but was:<2009-10-16T[08]:42:16.000Z>",
"methodName": "testLang538"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtJAID"
],
"revisionId": "a95e76eefb91bdd9cf1c22734874a3d3c95ed327"
},
{
"bugId": 42,
"changedFiles": {
"org/apache/commons/lang/Entities.java": {
"changes": [
[
828
]
],
"inserts": [
[
831
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/Entities.java\n+++ b/src/java/org/apache/commons/lang/Entities.java\n@@ -825,10 +825,15 @@ public String escape(String str) {\n public void escape(Writer writer, String str) throws IOException {\n int len = str.length();\n for (int i = 0; i < len; i++) {\n- char c = str.charAt(i);\n+ int c = Character.codePointAt(str, i); \n String entityName = this.entityName(c);\n if (entityName == null) {\n- if (c > 0x7F) {\n+ if (c >= 0x010000 && i < len - 1) {\n+ writer.write(\"&#\");\n+ writer.write(Integer.toString(c, 10));\n+ writer.write(';');\n+ i++;\n+ } else if (c > 0x7F) { \n writer.write(\"&#\");\n writer.write(Integer.toString(c, 10));\n writer.write(';');\n",
"failingTests": [
{
"className": " org.apache.commons.lang.StringEscapeUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "High unicode was not escaped correctly expected:<&#[119650];> but was:<&#[55348;&#57186];>",
"methodName": "testEscapeHtmlHighUnicode"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfElseAdd",
"mcAdd",
"mcRepl",
"varTyChange"
],
"repairPatterns": [
"wrapsIfElse",
"wrongComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "dd2ae757d12554f290931f0b3c05e33ad993ecd1"
},
{
"bugId": 43,
"changedFiles": {
"org/apache/commons/lang/text/ExtendedMessageFormat.java": {
"inserts": [
[
422
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java\n+++ b/src/java/org/apache/commons/lang/text/ExtendedMessageFormat.java\n@@ -419,6 +419,7 @@ private StringBuffer appendQuotedString(String pattern, ParsePosition pos,\n int start = pos.getIndex();\n char[] c = pattern.toCharArray();\n if (escapingOn && c[start] == QUOTE) {\n+ next(pos);\n return appendTo == null ? null : appendTo.append(QUOTE);\n }\n int lastHold = start;\n",
"failingTests": [
{
"className": " org.apache.commons.lang.text.ExtendedMessageFormatTest",
"error": "java.lang.OutOfMemoryError",
"message": "Java heap space",
"methodName": "testEscapedQuote_LANG_477"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [
"rtElixir",
"rtHDRepair",
"rtssFix"
],
"revisionId": "eb3e2ae1f3734986a9f0225c661888baac3cb13b"
},
{
"bugId": 36,
"changedFiles": {
"org/apache/commons/lang3/math/NumberUtils.java": {
"changes": [
[
491
]
],
"inserts": [
[
1388
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang3/math/NumberUtils.java\n+++ b/src/java/org/apache/commons/lang3/math/NumberUtils.java\n@@ -488,7 +488,7 @@ public static Number createNumber(String str) throws NumberFormatException {\n }\n dec = null;\n }\n- if (!Character.isDigit(lastChar)) {\n+ if (!Character.isDigit(lastChar) && lastChar != '.') {\n if (expPos > -1 && expPos < str.length() - 1) {\n exp = str.substring(expPos + 1, str.length() - 1);\n } else {\n@@ -1385,6 +1385,14 @@ public static boolean isNumber(String str) {\n // can't have an E at the last byte\n return false;\n }\n+ if (chars[i] == '.') {\n+ if (hasDecPoint || hasExp) {\n+ // two decimal points or dec in exponent\n+ return false;\n+ }\n+ // single trailing decimal point after non-exponent is ok\n+ return foundDigit;\n+ }\n if (!allowSigns\n && (chars[i] == 'd'\n || chars[i] == 'D'\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "java.lang.NumberFormatException",
"message": "2. is not a valid number.",
"methodName": "testCreateNumber"
},
{
"className": " org.apache.commons.lang3.math.NumberUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "isNumber(String) LANG-521 failed",
"methodName": "testIsNumber"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 896,
"spreadCodeOnly": 471
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"condExpExpand",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expLogicExpand"
],
"repairTools": [],
"revisionId": "da0612b348fcfa7679b92a5e9b8e1603e8e2da3a"
},
{
"bugId": 39,
"changedFiles": {
"org/apache/commons/lang3/StringUtils.java": {
"inserts": [
[
3676
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang3/StringUtils.java\n+++ b/src/java/org/apache/commons/lang3/StringUtils.java\n@@ -3673,6 +3673,9 @@ private static String replaceEach(String text, String[] searchList, String[] rep\n \n // count the replacement text elements that are larger than their corresponding text being replaced\n for (int i = 0; i < searchList.length; i++) {\n+ if (searchList[i] == null || replacementList[i] == null) {\n+ continue;\n+ }\n int greater = replacementList[i].length() - searchList[i].length();\n if (greater > 0) {\n increase += 3 * greater; // assume 3 matches\n",
"failingTests": [
{
"className": " org.apache.commons.lang3.StringUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testReplace_StringStringArrayStringArray"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"missNullCheckP"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtJAID"
],
"revisionId": "cb40e35f5e0990fad4c5278964fcc24e112dde8c"
},
{
"bugId": 41,
"changedFiles": {
"org/apache/commons/lang/ClassUtils.java": {
"changes": [
[
203
],
[
245
]
],
"inserts": [
[
190,
191,
192,
193,
194,
195,
196
],
[
248,
249,
250,
251,
252
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/ClassUtils.java\n+++ b/src/java/org/apache/commons/lang/ClassUtils.java\n@@ -188,10 +188,23 @@ public static String getShortClassName(String className) {\n return StringUtils.EMPTY;\n }\n \n+ StringBuffer arrayPrefix = new StringBuffer();\n \n // Handle array encoding\n+ if (className.startsWith(\"[\")) {\n+ while (className.charAt(0) == '[') {\n+ className = className.substring(1);\n+ arrayPrefix.append(\"[]\");\n+ }\n // Strip Object type encoding\n+ if (className.charAt(0) == 'L' && className.charAt(className.length() - 1) == ';') {\n+ className = className.substring(1, className.length() - 1);\n+ }\n+ }\n \n+ if (reverseAbbreviationMap.containsKey(className)) {\n+ className = reverseAbbreviationMap.get(className);\n+ }\n \n int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);\n int innerIdx = className.indexOf(\n@@ -200,7 +213,7 @@ public static String getShortClassName(String className) {\n if (innerIdx != -1) {\n out = out.replace(INNER_CLASS_SEPARATOR_CHAR, PACKAGE_SEPARATOR_CHAR);\n }\n- return out;\n+ return out + arrayPrefix;\n }\n \n // Package name\n@@ -242,12 +255,18 @@ public static String getPackageName(Class<?> cls) {\n * @return the package name or an empty string\n */\n public static String getPackageName(String className) {\n- if (className == null) {\n+ if (className == null || className.length() == 0) {\n return StringUtils.EMPTY;\n }\n \n // Strip array encoding\n+ while (className.charAt(0) == '[') {\n+ className = className.substring(1);\n+ }\n // Strip Object type encoding\n+ if (className.charAt(0) == 'L' && className.charAt(className.length() - 1) == ';') {\n+ className = className.substring(1);\n+ }\n \n int i = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);\n if (i == -1) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang.ClassUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<String[[]]> but was:<String[;]>",
"methodName": "test_getShortClassName_Class"
},
{
"className": " org.apache.commons.lang.ClassUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[]java.lang> but was:<[[L]java.lang>",
"methodName": "test_getPackageName_Class"
}
],
"metrics": {
"chunks": 8,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 21,
"spreadAllLines": 58,
"spreadCodeOnly": 23
},
"observations": "Existent condittional expression with null-check is expanded.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condExpExpand",
"loopAdd",
"mcAdd",
"objInstAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicExpand",
"missComp"
],
"repairTools": [],
"revisionId": "4d3629f310e84cc24c0e5f09d97f5126692d0128"
},
{
"bugId": 40,
"changedFiles": {
"org/apache/commons/lang/StringUtils.java": {
"changes": [
[
1048
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/StringUtils.java\n+++ b/src/java/org/apache/commons/lang/StringUtils.java\n@@ -1045,7 +1045,14 @@ public static boolean containsIgnoreCase(String str, String searchStr) {\n if (str == null || searchStr == null) {\n return false;\n }\n- return contains(str.toUpperCase(), searchStr.toUpperCase());\n+ int len = searchStr.length();\n+ int max = str.length() - len;\n+ for (int i = 0; i <= max; i++) {\n+ if (str.regionMatches(true, i, searchStr, 0, len)) {\n+ return true;\n+ }\n+ }\n+ return false;\n }\n \n // IndexOfAny chars\n",
"failingTests": [
{
"className": " org.apache.commons.lang.StringUtilsEqualsIndexOfTest",
"error": "junit.framework.AssertionFailedError",
"message": "en: 0 ß SS",
"methodName": "testContainsIgnoreCase_LocaleIndependence"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"loopAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrongComp"
],
"repairTools": [],
"revisionId": "8b1a8e178abb46cc048a3982636b8ec4e6ffc8dc"
},
{
"bugId": 44,
"changedFiles": {
"org/apache/commons/lang/NumberUtils.java": {
"inserts": [
[
145
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/NumberUtils.java\n+++ b/src/java/org/apache/commons/lang/NumberUtils.java\n@@ -142,6 +142,9 @@ public static Number createNumber(String val) throws NumberFormatException {\n if (val.length() == 0) {\n throw new NumberFormatException(\"\\\"\\\" is not a valid number.\");\n }\n+ if (val.length() == 1 && !Character.isDigit(val.charAt(0))) {\n+ throw new NumberFormatException(val + \" is not a valid number.\");\n+ }\n if (val.startsWith(\"--\")) {\n // this is protection for poorness in java.lang.BigDecimal.\n // it accepts this as a legal value, but it does not appear \n",
"failingTests": [
{
"className": " org.apache.commons.lang.NumberUtilsTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 0",
"methodName": "testLang457"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [
"rtDynaMoth",
"rtElixir",
"rtNopol"
],
"revisionId": "81f10d7f1ef52d44f43b38d81ac3dc1c83d45134"
},
{
"bugId": 45,
"changedFiles": {
"org/apache/commons/lang/WordUtils.java": {
"inserts": [
[
613,
614,
615,
616,
617,
618
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/WordUtils.java\n+++ b/src/java/org/apache/commons/lang/WordUtils.java\n@@ -613,6 +613,9 @@ public static String abbreviate(String str, int lower, int upper, String appendT\n \n // if the lower value is greater than the length of the string,\n // set to the length of the string\n+ if (lower > str.length()) {\n+ lower = str.length(); \n+ }\n // if the upper value is -1 (i.e. no limit) or is greater\n // than the length of the string, set to the length of the string\n if (upper == -1 || upper > str.length()) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang.WordUtilsTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 15",
"methodName": "testAbbreviate"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [
"rtJAID"
],
"revisionId": "d95fcd8e24568b4f9d3cb9da922a4029e293c793"
},
{
"bugId": 47,
"changedFiles": {
"org/apache/commons/lang/text/StrBuilder.java": {
"inserts": [
[
1186
],
[
1230
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/text/StrBuilder.java\n+++ b/src/java/org/apache/commons/lang/text/StrBuilder.java\n@@ -1183,6 +1183,9 @@ public StrBuilder appendFixedWidthPadLeft(Object obj, int width, char padChar) {\n if (width > 0) {\n ensureCapacity(size + width);\n String str = (obj == null ? getNullText() : obj.toString());\n+ if (str == null) {\n+ str = \"\";\n+ }\n int strLen = str.length();\n if (strLen >= width) {\n str.getChars(strLen - width, strLen, buffer, size);\n@@ -1227,6 +1230,9 @@ public StrBuilder appendFixedWidthPadRight(Object obj, int width, char padChar)\n if (width > 0) {\n ensureCapacity(size + width);\n String str = (obj == null ? getNullText() : obj.toString());\n+ if (str == null) {\n+ str = \"\";\n+ }\n int strLen = str.length();\n if (strLen >= width) {\n str.getChars(0, width, buffer, size);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.text.StrBuilderTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testLang412Left"
},
{
"className": " org.apache.commons.lang.text.StrBuilderTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testLang412Right"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 44,
"spreadCodeOnly": 21
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "d5e343049c2610c31ddacb24f0d173942f6d5ac9"
},
{
"bugId": 48,
"changedFiles": {
"org/apache/commons/lang/builder/EqualsBuilder.java": {
"inserts": [
[
380,
381
],
[
382
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/builder/EqualsBuilder.java\n+++ b/src/java/org/apache/commons/lang/builder/EqualsBuilder.java\n@@ -377,8 +377,12 @@ public EqualsBuilder append(Object lhs, Object rhs) {\n }\n Class lhsClass = lhs.getClass();\n if (!lhsClass.isArray()) {\n+ if (lhs instanceof java.math.BigDecimal) {\n+ isEquals = (((java.math.BigDecimal)lhs).compareTo(rhs) == 0);\n+ } else {\n // The simple case, not an array, just test the element\n isEquals = lhs.equals(rhs);\n+ }\n } else if (lhs.getClass() != rhs.getClass()) {\n // Here when we compare different dimensions, for example: a boolean[][] to a boolean[] \n this.setEquals(false);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.builder.EqualsBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBigDecimal"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 2,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"mcAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "eb8f74efb75e71fc91e515a38becc2aac203e339"
},
{
"bugId": 52,
"changedFiles": {
"org/apache/commons/lang/StringEscapeUtils.java": {
"inserts": [
[
222,
228,
232,
236
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/StringEscapeUtils.java\n+++ b/src/java/org/apache/commons/lang/StringEscapeUtils.java\n@@ -233,6 +233,10 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape\n out.write('\\\\');\n out.write('\\\\');\n break;\n+ case '/':\n+ out.write('\\\\');\n+ out.write('/');\n+ break;\n default :\n out.write(ch);\n break;\n",
"failingTests": [
{
"className": " org.apache.commons.lang.StringEscapeUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...ipt>alert(\\'aaa\\');<[\\]/script>\\';> but was:<...ipt>alert(\\'aaa\\');<[]/script>\\';>",
"methodName": "testEscapeJavaScript"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranCaseAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "868f6976aea222e96259843f56df9aed8e48584b"
},
{
"bugId": 53,
"changedFiles": {
"org/apache/commons/lang/time/DateUtils.java": {
"deletes": [
[
643
],
[
644
],
[
645
],
[
652
],
[
653
],
[
654
]
],
"inserts": [
[
647,
648,
649
],
[
656,
657,
658
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/DateUtils.java\n+++ b/src/java/org/apache/commons/lang/time/DateUtils.java\n@@ -640,18 +640,18 @@ private static void modify(Calendar val, int field, boolean round) {\n int millisecs = val.get(Calendar.MILLISECOND);\n if (!round || millisecs < 500) {\n time = time - millisecs;\n+ }\n if (field == Calendar.SECOND) {\n done = true;\n- }\n }\n \n // truncate seconds\n int seconds = val.get(Calendar.SECOND);\n if (!done && (!round || seconds < 30)) {\n time = time - (seconds * 1000L);\n+ }\n if (field == Calendar.MINUTE) {\n done = true;\n- }\n }\n \n // truncate minutes\n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.DateUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Minute Round Up Failed expected:<Mon Jul 02 08:09:00 PDT 2007> but was:<Mon Jul 02 08:01:00 PDT 2007>",
"methodName": "testRoundLang346"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 2,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 10,
"spreadCodeOnly": 8
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [],
"repairPatterns": [
"codeMove",
"copyPaste",
"unwrapIfElse"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "d3b1163073c7aeb6011a5b65bfadad15bfc0f108"
},
{
"bugId": 46,
"changedFiles": {
"org/apache/commons/lang/StringEscapeUtils.java": {
"changes": [
[
86
],
[
102
],
[
127
],
[
143
],
[
154
],
[
160
],
[
178
]
],
"inserts": [
[
244
],
[
245
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/StringEscapeUtils.java\n+++ b/src/java/org/apache/commons/lang/StringEscapeUtils.java\n@@ -83,7 +83,7 @@ public StringEscapeUtils() {\n * @return String with escaped values, <code>null</code> if null string input\n */\n public static String escapeJava(String str) {\n- return escapeJavaStyleString(str, false);\n+ return escapeJavaStyleString(str, false, false);\n }\n \n /**\n@@ -99,7 +99,7 @@ public static String escapeJava(String str) {\n * @throws IOException if error occurs on underlying Writer\n */\n public static void escapeJava(Writer out, String str) throws IOException {\n- escapeJavaStyleString(out, str, false);\n+ escapeJavaStyleString(out, str, false, false);\n }\n \n /**\n@@ -124,7 +124,7 @@ public static void escapeJava(Writer out, String str) throws IOException {\n * @return String with escaped values, <code>null</code> if null string input\n */\n public static String escapeJavaScript(String str) {\n- return escapeJavaStyleString(str, true);\n+ return escapeJavaStyleString(str, true, true);\n }\n \n /**\n@@ -140,7 +140,7 @@ public static String escapeJavaScript(String str) {\n * @throws IOException if error occurs on underlying Writer\n **/\n public static void escapeJavaScript(Writer out, String str) throws IOException {\n- escapeJavaStyleString(out, str, true);\n+ escapeJavaStyleString(out, str, true, true);\n }\n \n /**\n@@ -151,13 +151,13 @@ public static void escapeJavaScript(Writer out, String str) throws IOException {\n * @param escapeForwardSlash TODO\n * @return the escaped string\n */\n- private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes) {\n+ private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {\n if (str == null) {\n return null;\n }\n try {\n StringWriter writer = new StringWriter(str.length() * 2);\n- escapeJavaStyleString(writer, str, escapeSingleQuotes);\n+ escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);\n return writer.toString();\n } catch (IOException ioe) {\n // this should never ever happen while writing to a StringWriter\n@@ -175,7 +175,8 @@ private static String escapeJavaStyleString(String str, boolean escapeSingleQuot\n * @param escapeForwardSlash TODO\n * @throws IOException if an IOException occurs\n */\n- private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote) throws IOException {\n+ private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,\n+ boolean escapeForwardSlash) throws IOException {\n if (out == null) {\n throw new IllegalArgumentException(\"The Writer must not be null\");\n }\n@@ -241,7 +242,9 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape\n out.write('\\\\');\n break;\n case '/' :\n+ if (escapeForwardSlash) {\n out.write('\\\\');\n+ }\n out.write('/');\n break;\n default :\n",
"failingTests": [
{
"className": " org.apache.commons.lang.StringEscapeUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...tring with a slash ([]/) in it> but was:<...tring with a slash ([\\]/) in it>",
"methodName": "testEscapeJavaWithSlash"
}
],
"metrics": {
"chunks": 9,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 7,
"linesRem": 0,
"methods": 6,
"sizeInLines": 10,
"spreadAllLines": 152,
"spreadCodeOnly": 82
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"mcParAdd",
"mcRepl",
"mdParAdd",
"retExpChange"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [],
"revisionId": "916639bda234a8e5a030361c4068667764b34cb7"
},
{
"bugId": 50,
"changedFiles": {
"org/apache/commons/lang/time/FastDateFormat.java": {
"changes": [
[
285
],
[
465
]
],
"deletes": [
[
286
],
[
292
],
[
293
],
[
294
],
[
466
],
[
471
],
[
472
],
[
473
]
],
"inserts": [
[
286,
287
],
[
288,
289,
290
],
[
466,
467
],
[
468,
469
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/FastDateFormat.java\n+++ b/src/java/org/apache/commons/lang/time/FastDateFormat.java\n@@ -282,16 +282,14 @@ public static synchronized FastDateFormat getDateInstance(int style, TimeZone ti\n key = new Pair(key, timeZone);\n }\n \n- if (locale != null) {\n- key = new Pair(key, locale);\n+ if (locale == null) {\n+ locale = Locale.getDefault();\n }\n \n+ key = new Pair(key, locale);\n \n FastDateFormat format = (FastDateFormat) cDateInstanceCache.get(key);\n if (format == null) {\n- if (locale == null) {\n- locale = Locale.getDefault();\n- }\n try {\n SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateInstance(style, locale);\n String pattern = formatter.toPattern();\n@@ -462,15 +460,13 @@ public static synchronized FastDateFormat getDateTimeInstance(int dateStyle, int\n if (timeZone != null) {\n key = new Pair(key, timeZone);\n }\n- if (locale != null) {\n- key = new Pair(key, locale);\n+ if (locale == null) {\n+ locale = Locale.getDefault();\n }\n+ key = new Pair(key, locale);\n \n FastDateFormat format = (FastDateFormat) cDateTimeInstanceCache.get(key);\n if (format == null) {\n- if (locale == null) {\n- locale = Locale.getDefault();\n- }\n try {\n SimpleDateFormat formatter = (SimpleDateFormat) DateFormat.getDateTimeInstance(dateStyle, timeStyle,\n locale);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.FastDateFormatTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected same:<de_DE> was not:<en_US>",
"methodName": "test_changeDefault_Locale_DateInstance"
},
{
"className": " org.apache.commons.lang.time.FastDateFormatTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected same:<de_DE> was not:<en_US>",
"methodName": "test_changeDefault_Locale_DateTimeInstance"
}
],
"metrics": {
"chunks": 6,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 4,
"linesRem": 6,
"methods": 2,
"sizeInLines": 12,
"spreadAllLines": 179,
"spreadCodeOnly": 68
},
"observations": "Replaces some existent Null-Chek, inverting postive by negative.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"assignRem",
"condBranRem",
"condExpMod",
"mcAdd",
"mcRem",
"objInstAdd",
"objInstRem"
],
"repairPatterns": [
"condBlockRem",
"copyPaste",
"expLogicMod",
"unwrapIfElse",
"wrongComp"
],
"repairTools": [],
"revisionId": "659ef247b1452b6d5b9f92271357381fa59fea50"
},
{
"bugId": 51,
"changedFiles": {
"org/apache/commons/lang/BooleanUtils.java": {
"inserts": [
[
682
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/BooleanUtils.java\n+++ b/src/java/org/apache/commons/lang/BooleanUtils.java\n@@ -679,6 +679,7 @@ public static boolean toBoolean(String str) {\n (str.charAt(1) == 'E' || str.charAt(1) == 'e') &&\n (str.charAt(2) == 'S' || str.charAt(2) == 's');\n }\n+ return false;\n }\n case 4: {\n char ch = str.charAt(0);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.BooleanUtilsTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 3",
"methodName": "test_toBoolean_String"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Adds a return statement that does the role of an \"else\" branch.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"retBranchAdd"
],
"repairPatterns": [
"singleLine"
],
"repairTools": [
"rtDynaMoth",
"rtElixir",
"rtJAID",
"rtNopol"
],
"revisionId": "a5589b39e985e64861bd920aa7b13ab32c215b06"
},
{
"bugId": 49,
"changedFiles": {
"org/apache/commons/lang/math/Fraction.java": {
"inserts": [
[
466
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/math/Fraction.java\n+++ b/src/java/org/apache/commons/lang/math/Fraction.java\n@@ -463,6 +463,9 @@ public double doubleValue() {\n * @return a new reduced fraction instance, or this if no simplification possible\n */\n public Fraction reduce() {\n+ if (numerator == 0) {\n+ return equals(ZERO) ? this : ZERO;\n+ }\n int gcd = greatestCommonDivisor(Math.abs(numerator), denominator);\n if (gcd == 1) {\n return this;\n",
"failingTests": [
{
"className": " org.apache.commons.lang.math.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<100>",
"methodName": "testReduce"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "0ac772a4e3b07287c435fdc3c812f67277c85cc8"
},
{
"bugId": 54,
"changedFiles": {
"org/apache/commons/lang/LocaleUtils.java": {
"inserts": [
[
114
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/LocaleUtils.java\n+++ b/src/java/org/apache/commons/lang/LocaleUtils.java\n@@ -111,6 +111,9 @@ public static Locale toLocale(String str) {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n }\n char ch3 = str.charAt(3);\n+ if (ch3 == '_') {\n+ return new Locale(str.substring(0, 2), \"\", str.substring(4));\n+ }\n char ch4 = str.charAt(4);\n if (ch3 < 'A' || ch3 > 'Z' || ch4 < 'A' || ch4 > 'Z') {\n throw new IllegalArgumentException(\"Invalid locale format: \" + str);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.IllegalArgumentException",
"message": "Invalid locale format: fr__POSIX",
"methodName": "testLang328"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "e89e8d62b911340cc5b293465cdae909f3dfd640"
},
{
"bugId": 57,
"changedFiles": {
"org/apache/commons/lang/LocaleUtils.java": {
"changes": [
[
223
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/LocaleUtils.java\n+++ b/src/java/org/apache/commons/lang/LocaleUtils.java\n@@ -220,7 +220,7 @@ public static Set availableLocaleSet() {\n * @return true if the locale is a known locale\n */\n public static boolean isAvailableLocale(Locale locale) {\n- return cAvailableLocaleSet.contains(locale);\n+ return availableLocaleList().contains(locale);\n }\n \n //-----------------------------------------------------------------------\n",
"failingTests": [
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testAvailableLocaleSet"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testIsAvailableLocale"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testAvailableLocaleList"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testCountriesByLanguage"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testLocaleLookupList_LocaleLocale"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testLanguagesByCountry"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testToLocale_1Part"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testToLocale_2Part"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testToLocale_3Part"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testLocaleLookupList_Locale"
},
{
"className": " org.apache.commons.lang.LocaleUtilsTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testConstructor"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes direct acces of an object to method call.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcAdd",
"retExpChange",
"varReplMc"
],
"repairPatterns": [
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtElixir",
"rtHDRepair"
],
"revisionId": "bbd990b81fd7f8ab9dde75c8070b973b9ce500fc"
},
{
"bugId": 58,
"changedFiles": {
"org/apache/commons/lang/math/NumberUtils.java": {
"changes": [
[
454
],
[
455
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/math/NumberUtils.java\n+++ b/src/java/org/apache/commons/lang/math/NumberUtils.java\n@@ -451,8 +451,7 @@ public static Number createNumber(String str) throws NumberFormatException {\n case 'L' :\n if (dec == null\n && exp == null\n- && isDigits(numeric.substring(1))\n- && (numeric.charAt(0) == '-' || Character.isDigit(numeric.charAt(0)))) {\n+ && (numeric.charAt(0) == '-' && isDigits(numeric.substring(1)) || isDigits(numeric))) {\n try {\n return createLong(numeric);\n } catch (NumberFormatException nfe) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang.math.NumberUtilsTest",
"error": "java.lang.NumberFormatException",
"message": "1l is not a valid number.",
"methodName": "testLang300"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 1,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod"
],
"repairTools": [
"rtDynaMoth",
"rtElixir",
"rtNopol"
],
"revisionId": "1fd45a4f68ea497dfbdf1a67b8b8805a4a9b1166"
},
{
"bugId": 56,
"changedFiles": {
"org/apache/commons/lang/time/FastDateFormat.java": {
"changes": [
[
140
],
[
144
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/FastDateFormat.java\n+++ b/src/java/org/apache/commons/lang/time/FastDateFormat.java\n@@ -1,152 +1,152 @@\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n * \n * http://www.apache.org/licenses/LICENSE-2.0\n * \n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n package org.apache.commons.lang.time;\n \n import java.io.IOException;\n import java.io.ObjectInputStream;\n \n import java.text.DateFormat;\n import java.text.DateFormatSymbols;\n import java.text.FieldPosition;\n import java.text.Format;\n import java.text.ParsePosition;\n import java.text.SimpleDateFormat;\n import java.util.ArrayList;\n import java.util.Calendar;\n import java.util.Date;\n import java.util.GregorianCalendar;\n import java.util.HashMap;\n import java.util.List;\n import java.util.Locale;\n import java.util.Map;\n import java.util.TimeZone;\n \n import org.apache.commons.lang.Validate;\n \n /**\n * <p>FastDateFormat is a fast and thread-safe version of\n * {@link java.text.SimpleDateFormat}.</p>\n * \n * <p>This class can be used as a direct replacement to\n * <code>SimpleDateFormat</code> in most formatting situations.\n * This class is especially useful in multi-threaded server environments.\n * <code>SimpleDateFormat</code> is not thread-safe in any JDK version,\n * nor will it be as Sun have closed the bug/RFE.\n * </p>\n *\n * <p>Only formatting is supported, but all patterns are compatible with\n * SimpleDateFormat (except time zones - see below).</p>\n *\n * <p>Java 1.4 introduced a new pattern letter, <code>'Z'</code>, to represent\n * time zones in RFC822 format (eg. <code>+0800</code> or <code>-1100</code>).\n * This pattern letter can be used here (on all JDK versions).</p>\n *\n * <p>In addition, the pattern <code>'ZZ'</code> has been made to represent\n * ISO8601 full format time zones (eg. <code>+08:00</code> or <code>-11:00</code>).\n * This introduces a minor incompatibility with Java 1.4, but at a gain of\n * useful functionality.</p>\n *\n * @author TeaTrove project\n * @author Brian S O'Neill\n * @author Sean Schofield\n * @author Gary Gregory\n * @author Stephen Colebourne\n * @author Nikolay Metchev\n * @since 2.0\n * @version $Id$\n */\n public class FastDateFormat extends Format {\n // A lot of the speed in this class comes from caching, but some comes\n // from the special int to StringBuffer conversion.\n //\n // The following produces a padded 2 digit number:\n // buffer.append((char)(value / 10 + '0'));\n // buffer.append((char)(value % 10 + '0'));\n //\n // Note that the fastest append to StringBuffer is a single char (used here).\n // Note that Integer.toString() is not called, the conversion is simply\n // taking the value and adding (mathematically) the ASCII value for '0'.\n // So, don't change this code! It works and is very fast.\n \n /**\n * Required for serialization support.\n * \n * @see java.io.Serializable\n */\n private static final long serialVersionUID = 1L;\n \n /**\n * FULL locale dependent date or time style.\n */\n public static final int FULL = DateFormat.FULL;\n /**\n * LONG locale dependent date or time style.\n */\n public static final int LONG = DateFormat.LONG;\n /**\n * MEDIUM locale dependent date or time style.\n */\n public static final int MEDIUM = DateFormat.MEDIUM;\n /**\n * SHORT locale dependent date or time style.\n */\n public static final int SHORT = DateFormat.SHORT;\n \n private static String cDefaultPattern;\n \n private static Map cInstanceCache = new HashMap(7);\n private static Map cDateInstanceCache = new HashMap(7);\n private static Map cTimeInstanceCache = new HashMap(7);\n private static Map cDateTimeInstanceCache = new HashMap(7);\n private static Map cTimeZoneDisplayCache = new HashMap(7);\n \n /**\n * The pattern.\n */\n private final String mPattern;\n /**\n * The time zone.\n */\n private final TimeZone mTimeZone;\n /**\n * Whether the time zone overrides any on Calendars.\n */\n private final boolean mTimeZoneForced;\n /**\n * The locale.\n */\n private final Locale mLocale;\n /**\n * Whether the locale overrides the default.\n */\n private final boolean mLocaleForced;\n /**\n * The parsed rules.\n */\n- private Rule[] mRules;\n+ private transient Rule[] mRules;\n /**\n * The estimated maximum length.\n */\n- private int mMaxLengthEstimate;\n+ private transient int mMaxLengthEstimate;\n \n //-----------------------------------------------------------------------\n /**\n * <p>Gets a formatter instance using the default pattern in the\n * default locale.</p>\n * \n * @return a date/time formatter\n */\n@@ -1016,37 +1016,41 @@ public int hashCode() {\n public String toString() {\n return \"FastDateFormat[\" + mPattern + \"]\";\n }\n \n // Serializing\n //-----------------------------------------------------------------------\n+ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {\n+ in.defaultReadObject();\n+ init();\n+ }\n \n // Rules\n //-----------------------------------------------------------------------\n /**\n * <p>Inner class defining a rule.</p>\n */\n private interface Rule {\n /**\n * Returns the estimated lentgh of the result.\n * \n * @return the estimated length\n */\n int estimateLength();\n \n /**\n * Appends the value of the specified calendar to the output buffer based on the rule implementation.\n * \n * @param buffer the output buffer\n * @param calendar calendar to be appended\n */\n void appendTo(StringBuffer buffer, Calendar calendar);\n }\n \n /**\n * <p>Inner class defining a numeric rule.</p>\n */\n private interface NumberRule extends Rule {\n /**\n * Appends the specified value to the output buffer based on the rule implementation.\n * \n * @param buffer the output buffer\n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.FastDateFormatTest",
"error": "org.apache.commons.lang.SerializationException",
"message": "java.io.NotSerializableException: org.apache.commons.lang.time.FastDateFormat$PaddedNumberField",
"methodName": "testLang303"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 880,
"spreadCodeOnly": 425
},
"observations": "Changes types modifiers and overrides method related to Serialization.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcAdd",
"mdAdd",
"mdOverride",
"varModChange"
],
"repairPatterns": [
"missComp",
"notClassified"
],
"repairTools": [],
"revisionId": "672e3a8ead2970181c32cf5fc70a3ea3d020c1fc"
},
{
"bugId": 64,
"changedFiles": {
"org/apache/commons/lang/enums/ValuedEnum.java": {
"inserts": [
[
183
],
[
-1
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/enums/ValuedEnum.java\n+++ b/src/java/org/apache/commons/lang/enums/ValuedEnum.java\n@@ -180,6 +180,16 @@ public final int getValue() {\n * @throws NullPointerException if other is <code>null</code>\n */\n public int compareTo(Object other) {\n+ if (other == this) {\n+ return 0;\n+ }\n+ if (other.getClass() != this.getClass()) {\n+ if (other.getClass().getName().equals(this.getClass().getName())) {\n+ return iValue - getValueInOtherClassLoader(other);\n+ }\n+ throw new ClassCastException(\n+ \"Different enum class '\" + ClassUtils.getShortClassName(other.getClass()) + \"'\");\n+ }\n return iValue - ((ValuedEnum) other).iValue;\n }\n \n@@ -189,9 +199,20 @@ public int compareTo(Object other) {\n * @param other the object to determine the value for\n * @return the value\n */\n+ private int getValueInOtherClassLoader(Object other) {\n+ try {\n+ Method mth = other.getClass().getMethod(\"getValue\", null);\n+ Integer value = (Integer) mth.invoke(other, null);\n+ return value.intValue();\n+ } catch (NoSuchMethodException e) {\n // ignore - should never happen\n+ } catch (IllegalAccessException e) {\n // ignore - should never happen\n+ } catch (InvocationTargetException e) {\n // ignore - should never happen\n+ }\n+ throw new IllegalStateException(\"This should not happen\");\n+ }\n \n /**\n * <p>Human readable description of this <code>Enum</code> item.</p>\n",
"failingTests": [
{
"className": " org.apache.commons.lang.enums.ValuedEnumTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCompareTo_otherEnumType"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 21,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 21,
"spreadAllLines": 12,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"exTryCatchAdd",
"mcAdd",
"mdAdd",
"objInstAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "8de71ae52958ae70fe651b7327319c9beecd9b84"
},
{
"bugId": 55,
"changedFiles": {
"org/apache/commons/lang/time/StopWatch.java": {
"inserts": [
[
118
],
[
119
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/StopWatch.java\n+++ b/src/java/org/apache/commons/lang/time/StopWatch.java\n@@ -115,7 +115,9 @@ public void stop() {\n if(this.runningState != STATE_RUNNING && this.runningState != STATE_SUSPENDED) {\n throw new IllegalStateException(\"Stopwatch is not running. \");\n }\n+ if(this.runningState == STATE_RUNNING) {\n stopTime = System.currentTimeMillis();\n+ }\n this.runningState = STATE_STOPPED;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.StopWatchTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testLang315"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [
"rtDynaMoth",
"rtJAID"
],
"revisionId": "3ef8a796b5ddf87e3e9afec9ba94aac62681b394"
},
{
"bugId": 59,
"changedFiles": {
"org/apache/commons/lang/text/StrBuilder.java": {
"changes": [
[
884
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/text/StrBuilder.java\n+++ b/src/java/org/apache/commons/lang/text/StrBuilder.java\n@@ -881,7 +881,7 @@ public StrBuilder appendFixedWidthPadRight(Object obj, int width, char padChar)\n String str = (obj == null ? getNullText() : obj.toString());\n int strLen = str.length();\n if (strLen >= width) {\n- str.getChars(0, strLen, buffer, size);\n+ str.getChars(0, width, buffer, size);\n } else {\n int padLen = width - strLen;\n str.getChars(0, strLen, buffer, size);\n",
"failingTests": [
{
"className": " org.apache.commons.lang.text.StrBuilderAppendInsertTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "",
"methodName": "testLang299"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"singleLine",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtElixir",
"rtssFix"
],
"revisionId": "c04cd2337786ce7d54ed1fb757192fb8bc8c5e41"
},
{
"bugId": 62,
"changedFiles": {
"org/apache/commons/lang/Entities.java": {
"inserts": [
[
850
],
[
920
],
[
925
],
[
926
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/Entities.java\n+++ b/src/java/org/apache/commons/lang/Entities.java\n@@ -847,6 +847,9 @@ public String unescape(String str) {\n } else {\n entityValue = Integer.parseInt(entityName.substring(1));\n }\n+ if (entityValue > 0xFFFF) {\n+ entityValue = -1;\n+ }\n } catch (NumberFormatException ex) {\n entityValue = -1;\n }\n@@ -917,12 +920,17 @@ public void unescape(Writer writer, String string) throws IOException {\n case 'X' :\n case 'x' : {\n entityValue = Integer.parseInt(entityContent.substring(2), 16);\n+ break;\n }\n default : {\n entityValue = Integer.parseInt(entityContent.substring(1), 10);\n }\n }\n+ if (entityValue > 0xFFFF) {\n+ entityValue = -1;\n+ }\n } catch (NumberFormatException e) {\n+ entityValue = -1;\n }\n }\n } else { //escaped value content is an entity name\n",
"failingTests": [
{
"className": " org.apache.commons.lang.EntitiesTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[&#12345678;]> but was:<[慎]>",
"methodName": "testNumberOverflow"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 76,
"spreadCodeOnly": 61
},
"observations": "Added a \"break\" in \"case\" branch.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"missComp"
],
"repairTools": [],
"revisionId": "1313a65c11dea54f1baf492d4185fb2d673b6716"
},
{
"bugId": 60,
"changedFiles": {
"org/apache/commons/lang/text/StrBuilder.java": {
"changes": [
[
1673
],
[
1730
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/text/StrBuilder.java\n+++ b/src/java/org/apache/commons/lang/text/StrBuilder.java\n@@ -1670,7 +1670,7 @@ public String midString(int index, int length) {\n */\n public boolean contains(char ch) {\n char[] thisBuf = buffer;\n- for (int i = 0; i < thisBuf.length; i++) {\n+ for (int i = 0; i < this.size; i++) {\n if (thisBuf[i] == ch) {\n return true;\n }\n@@ -1727,7 +1727,7 @@ public int indexOf(char ch, int startIndex) {\n return -1;\n }\n char[] thisBuf = buffer;\n- for (int i = startIndex; i < thisBuf.length; i++) {\n+ for (int i = startIndex; i < size; i++) {\n if (thisBuf[i] == ch) {\n return i;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.lang.text.StrBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "The contains(char) method is looking beyond the end of the string",
"methodName": "testLang295"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 56,
"spreadCodeOnly": 21
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"loopCondChange",
"varReplVar"
],
"repairPatterns": [
"expLogicMod",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "a8203b65261110c4a30ff69fe0da7a2390d82757"
},
{
"bugId": 61,
"changedFiles": {
"org/apache/commons/lang/text/StrBuilder.java": {
"changes": [
[
1776
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/text/StrBuilder.java\n+++ b/src/java/org/apache/commons/lang/text/StrBuilder.java\n@@ -1773,7 +1773,7 @@ public int indexOf(String str, int startIndex) {\n return -1;\n }\n char[] thisBuf = buffer;\n- int len = thisBuf.length - strLen;\n+ int len = size - strLen + 1;\n outer:\n for (int i = startIndex; i < len; i++) {\n for (int j = 0; j < strLen; j++) {\n",
"failingTests": [
{
"className": " org.apache.commons.lang.text.StrBuilderTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1> but was:<6>",
"methodName": "testIndexOfLang294"
},
{
"className": " org.apache.commons.lang.text.StrBuilderTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "",
"methodName": "testLang294"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes/fix computing of a variable.",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignExpChange",
"varReplVar"
],
"repairPatterns": [
"expArithMod",
"singleLine",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtJAID"
],
"revisionId": "88c76d207f642831ca899e144159424aaa60cf8e"
},
{
"bugId": 63,
"changedFiles": {
"org/apache/commons/lang/time/DurationFormatUtils.java": {
"changes": [
[
306
]
],
"deletes": [
[
318
],
[
319
],
[
320
],
[
321
],
[
322
],
[
323
],
[
324
],
[
431
],
[
432
],
[
433
],
[
434
],
[
435
],
[
436
],
[
437
],
[
438
],
[
439
],
[
440
],
[
441
],
[
442
]
],
"inserts": [
[
307,
308,
309,
310,
311,
312,
313
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/DurationFormatUtils.java\n+++ b/src/java/org/apache/commons/lang/time/DurationFormatUtils.java\n@@ -303,25 +303,20 @@ public static String formatPeriod(long startMillis, long endMillis, String forma\n days -= 1;\n }\n while (days < 0) {\n- days += 31;\n+ end.add(Calendar.MONTH, -1);\n+ days += end.getActualMaximum(Calendar.DAY_OF_MONTH);\n //days += 31; // TODO: Need tests to show this is bad and the new code is good.\n // HEN: It's a tricky subject. Jan 15th to March 10th. If I count days-first it is \n // 1 month and 26 days, but if I count month-first then it is 1 month and 23 days.\n // Also it's contextual - if asked for no M in the format then I should probably \n // be doing no calculating here.\n months -= 1;\n+ end.add(Calendar.MONTH, 1);\n }\n while (months < 0) {\n months += 12;\n years -= 1;\n }\n- milliseconds -= reduceAndCorrect(start, end, Calendar.MILLISECOND, milliseconds);\n- seconds -= reduceAndCorrect(start, end, Calendar.SECOND, seconds);\n- minutes -= reduceAndCorrect(start, end, Calendar.MINUTE, minutes);\n- hours -= reduceAndCorrect(start, end, Calendar.HOUR_OF_DAY, hours);\n- days -= reduceAndCorrect(start, end, Calendar.DAY_OF_MONTH, days);\n- months -= reduceAndCorrect(start, end, Calendar.MONTH, months);\n- years -= reduceAndCorrect(start, end, Calendar.YEAR, years);\n \n // This next block of code adds in values that \n // aren't requested. This allows the user to ask for the \n@@ -429,18 +424,6 @@ static String format(Token[] tokens, int years, int months, int days, int hours,\n }\n return buffer.toString();\n }\n- static int reduceAndCorrect(Calendar start, Calendar end, int field, int difference) {\n- end.add( field, -1 * difference );\n- int endValue = end.get(field);\n- int startValue = start.get(field);\n- if (endValue < startValue) {\n- int newdiff = startValue - endValue;\n- end.add( field, newdiff );\n- return newdiff;\n- } else {\n- return 0;\n- }\n- }\n \n static final Object y = \"y\";\n static final Object M = \"M\";\n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.DurationFormatUtilsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[09]> but was:<[-2]>",
"methodName": "testJiraLang281"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 19,
"methods": 2,
"sizeInLines": 22,
"spreadAllLines": 118,
"spreadCodeOnly": 91
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignExpChange",
"assignRem",
"condBranRem",
"mcAdd",
"mcRem",
"mdRem",
"retRem",
"varRem"
],
"repairPatterns": [
"blockRemove",
"expArithMod",
"fixAPI",
"wrongComp"
],
"repairTools": [
"rtDynaMoth"
],
"revisionId": "0695c3f71e3fc5abe29d8b9b33eed7faac7e73bf"
},
{
"bugId": 65,
"changedFiles": {
"org/apache/commons/lang/time/DateUtils.java": {
"inserts": [
[
623,
624,
625,
626,
627,
628,
629,
630,
631,
632,
633,
634,
635,
636,
637,
638,
639,
640,
641
],
[
708,
709
],
[
710
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/lang/time/DateUtils.java\n+++ b/src/java/org/apache/commons/lang/time/DateUtils.java\n@@ -621,6 +621,9 @@ private static void modify(Calendar val, int field, boolean round) {\n throw new ArithmeticException(\"Calendar value too large for accurate calculations\");\n }\n \n+ if (field == Calendar.MILLISECOND) {\n+ return;\n+ }\n \n // ----------------- Fix for LANG-59 ---------------------- START ---------------\n // see http://issues.apache.org/jira/browse/LANG-59\n@@ -628,14 +631,39 @@ private static void modify(Calendar val, int field, boolean round) {\n // Manually truncate milliseconds, seconds and minutes, rather than using\n // Calendar methods.\n \n+ Date date = val.getTime();\n+ long time = date.getTime();\n+ boolean done = false;\n \n // truncate milliseconds\n+ int millisecs = val.get(Calendar.MILLISECOND);\n+ if (!round || millisecs < 500) {\n+ time = time - millisecs;\n+ if (field == Calendar.SECOND) {\n+ done = true;\n+ }\n+ }\n \n // truncate seconds\n+ int seconds = val.get(Calendar.SECOND);\n+ if (!done && (!round || seconds < 30)) {\n+ time = time - (seconds * 1000L);\n+ if (field == Calendar.MINUTE) {\n+ done = true;\n+ }\n+ }\n \n // truncate minutes\n+ int minutes = val.get(Calendar.MINUTE);\n+ if (!done && (!round || minutes < 30)) {\n+ time = time - (minutes * 60000L);\n+ }\n \n // reset time\n+ if (date.getTime() != time) {\n+ date.setTime(time);\n+ val.setTime(date);\n+ }\n // ----------------- Fix for LANG-59 ----------------------- END ----------------\n \n boolean roundUp = false;\n@@ -706,7 +734,9 @@ private static void modify(Calendar val, int field, boolean round) {\n roundUp = offset > ((max - min) / 2);\n }\n //We need to remove this field\n+ if (offset != 0) {\n val.set(fields[i][0], val.get(fields[i][0]) - offset);\n+ }\n }\n throw new IllegalArgumentException(\"The field \" + field + \" is not supported\");\n \n",
"failingTests": [
{
"className": " org.apache.commons.lang.time.DateUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Truncate Calendar.SECOND expected:<Sun Oct 31 01:02:03 MDT 2004> but was:<Sun Oct 31 01:02:03 MST 2004>",
"methodName": "testTruncateLang59"
}
],
"metrics": {
"chunks": 8,
"classes": 1,
"files": 1,
"linesAdd": 30,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 30,
"spreadAllLines": 86,
"spreadCodeOnly": 50
},
"observations": "",
"program": "commons-lang",
"project": "Lang",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp",
"wrapsIf"
],
"repairTools": [],
"revisionId": "bb1671667d9085fb76bd06af7f7ad91d2c1c8389"
},
{
"bugId": 2,
"changedFiles": {
"org/apache/commons/math3/distribution/HypergeometricDistribution.java": {
"changes": [
[
268
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/distribution/HypergeometricDistribution.java\n+++ b/src/main/java/org/apache/commons/math3/distribution/HypergeometricDistribution.java\n@@ -265,7 +265,7 @@ private double innerCumulativeProbability(int x0, int x1, int dx) {\n * size {@code n}, the mean is {@code n * m / N}.\n */\n public double getNumericalMean() {\n- return (double) (getSampleSize() * getNumberOfSuccesses()) / (double) getPopulationSize();\n+ return getSampleSize() * (getNumberOfSuccesses() / (double) getPopulationSize());\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.HypergeometricDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "sample=-50",
"methodName": "testMath1021"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Apply a casting to returned value of an expression.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"retExpChange"
],
"repairPatterns": [
"expArithMod",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "c0b655ace5665c0cd32e3f5e5b46edad4d223125"
},
{
"bugId": 1,
"changedFiles": {
"org/apache/commons/math3/fraction/BigFraction.java": {
"inserts": [
[
304,
305,
306
]
]
},
"org/apache/commons/math3/fraction/Fraction.java": {
"inserts": [
[
213,
214,
215
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/fraction/BigFraction.java\n+++ b/src/main/java/org/apache/commons/math3/fraction/BigFraction.java\n@@ -303,6 +303,9 @@ private BigFraction(final double value, final double epsilon,\n if ((p2 > overflow) || (q2 > overflow)) {\n // in maxDenominator mode, if the last fraction was very close to the actual value\n // q2 may overflow in the next iteration; in this case return the last one.\n+ if (epsilon == 0.0 && FastMath.abs(q1) < maxDenominator) {\n+ break;\n+ }\n throw new FractionConversionException(value, p2, q2);\n }\n \n--- a/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n+++ b/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n@@ -212,6 +212,9 @@ private Fraction(double value, double epsilon, int maxDenominator, int maxIterat\n if ((FastMath.abs(p2) > overflow) || (FastMath.abs(q2) > overflow)) {\n // in maxDenominator mode, if the last fraction was very close to the actual value\n // q2 may overflow in the next iteration; in this case return the last one.\n+ if (epsilon == 0.0 && FastMath.abs(q1) < maxDenominator) {\n+ break;\n+ }\n throw new FractionConversionException(value, p2, q2);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.fraction.BigFractionTest",
"error": "org.apache.commons.math3.fraction.FractionConversionException",
"message": "illegal state: Overflow trying to convert 0.5 to fraction (2,499,999,794/4,999,999,587)",
"methodName": "testDigitLimitConstructor"
},
{
"className": " org.apache.commons.math3.fraction.FractionTest",
"error": "org.apache.commons.math3.fraction.FractionConversionException",
"message": "illegal state: Overflow trying to convert 0.5 to fraction (2,499,999,794/4,999,999,587)",
"methodName": "testDigitLimitConstructor"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"missComp"
],
"repairTools": [],
"revisionId": "0da657a65c92b086a301a6ffe9e34ec272f8889c"
},
{
"bugId": 3,
"changedFiles": {
"org/apache/commons/math3/util/MathArrays.java": {
"inserts": [
[
820,
821,
822,
823
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/util/MathArrays.java\n+++ b/src/main/java/org/apache/commons/math3/util/MathArrays.java\n@@ -818,7 +818,10 @@ public static double linearCombination(final double[] a, final double[] b)\n throw new DimensionMismatchException(len, b.length);\n }\n \n+ if (len == 1) {\n // Revert to scalar multiplication.\n+ return a[0] * b[0];\n+ }\n \n final double[] prodHigh = new double[len];\n double prodLowSum = 0;\n",
"failingTests": [
{
"className": " org.apache.commons.math3.util.MathArraysTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "1",
"methodName": "testLinearCombinationWithSingleElementArray"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtAcs"
],
"revisionId": "92c4697300e8ddf06152bc0838c738d50673c1d2"
},
{
"bugId": 5,
"changedFiles": {
"org/apache/commons/math3/complex/Complex.java": {
"changes": [
[
305
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/complex/Complex.java\n+++ b/src/main/java/org/apache/commons/math3/complex/Complex.java\n@@ -302,7 +302,7 @@ public Complex reciprocal() {\n }\n \n if (real == 0.0 && imaginary == 0.0) {\n- return NaN;\n+ return INF;\n }\n \n if (isInfinite) {\n",
"failingTests": [
{
"className": " org.apache.commons.math3.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<(NaN, NaN)> but was:<(Infinity, Infinity)>",
"methodName": "testReciprocalZero"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"retExpChange"
],
"repairPatterns": [
"constChange",
"expArithMod",
"singleLine"
],
"repairTools": [
"rtAcs",
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtJAID"
],
"revisionId": "e54a1c92302f3167b06bc04859b87ac0681bcdf3"
},
{
"bugId": 8,
"changedFiles": {
"org/apache/commons/math3/distribution/DiscreteDistribution.java": {
"changes": [
[
181
],
[
187
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/distribution/DiscreteDistribution.java\n+++ b/src/main/java/org/apache/commons/math3/distribution/DiscreteDistribution.java\n@@ -178,13 +178,13 @@ public T sample() {\n * @throws NotStrictlyPositiveException if {@code sampleSize} is not\n * positive.\n */\n- public T[] sample(int sampleSize) throws NotStrictlyPositiveException {\n+ public Object[] sample(int sampleSize) throws NotStrictlyPositiveException {\n if (sampleSize <= 0) {\n throw new NotStrictlyPositiveException(LocalizedFormats.NUMBER_OF_SAMPLES,\n sampleSize);\n }\n \n- final T[]out = (T[]) java.lang.reflect.Array.newInstance(singletons.get(0).getClass(), sampleSize);\n+ final Object[] out = new Object[sampleSize];\n \n for (int i = 0; i < sampleSize; i++) {\n out[i] = sample();\n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.DiscreteRealDistributionTest",
"error": "java.lang.ArrayStoreException",
"message": "org.apache.commons.math3.distribution.DiscreteRealDistributionTest$2",
"methodName": "testIssue942"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 5,
"spreadCodeOnly": 4
},
"observations": "Ajust the object initialization to reflect type changed.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcRem",
"mdRetTyChange",
"varTyChange"
],
"repairPatterns": [
"notClassified"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL",
"rtGenProg",
"rtKali"
],
"revisionId": "196e63174afdb3df1529c1b97bb8437b16831cc3"
},
{
"bugId": 11,
"changedFiles": {
"org/apache/commons/math3/distribution/MultivariateNormalDistribution.java": {
"changes": [
[
183
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/distribution/MultivariateNormalDistribution.java\n+++ b/src/main/java/org/apache/commons/math3/distribution/MultivariateNormalDistribution.java\n@@ -180,7 +180,7 @@ public double density(final double[] vals) throws DimensionMismatchException {\n throw new DimensionMismatchException(vals.length, dim);\n }\n \n- return FastMath.pow(2 * FastMath.PI, -dim / 2) *\n+ return FastMath.pow(2 * FastMath.PI, -0.5 * dim) *\n FastMath.pow(covarianceMatrixDeterminant, -0.5) *\n getExponentTerm(vals);\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.MultivariateNormalDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.13915687747739694> but was:<0.348814563694205>",
"methodName": "testUnivariateDistribution"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcParValChange",
"retExpChange"
],
"repairPatterns": [
"expArithMod",
"singleLine"
],
"repairTools": [],
"revisionId": "aa2bd1d0656b0001192aa2b2ef779cfd1f3b7e4d"
},
{
"bugId": 6,
"changedFiles": {
"org/apache/commons/math3/optim/BaseOptimizer.java": {
"changes": [
[
51
]
]
},
"org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java": {
"changes": [
[
217
],
[
223
],
[
277
]
],
"deletes": [
[
214
]
]
},
"org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java": {
"inserts": [
[
388,
389,
390
]
]
},
"org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java": {
"changes": [
[
193
],
[
227
]
],
"deletes": [
[
191
]
]
},
"org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java": {
"changes": [
[
158
],
[
175
]
]
},
"org/apache/commons/math3/optim/nonlinear/vector/jacobian/GaussNewtonOptimizer.java": {
"changes": [
[
108
],
[
160
]
],
"deletes": [
[
106
]
]
},
"org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizer.java": {
"changes": [
[
325
],
[
489
]
],
"deletes": [
[
322
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/BaseOptimizer.java\n@@ -48,7 +48,7 @@ protected BaseOptimizer(ConvergenceChecker<PAIR> checker) {\n this.checker = checker;\n \n evaluations = new Incrementor(0, new MaxEvalCallback());\n- iterations = new Incrementor(0, new MaxIterCallback());\n+ iterations = new Incrementor(Integer.MAX_VALUE, new MaxIterCallback());\n }\n \n /**\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/gradient/NonLinearConjugateGradientOptimizer.java\n@@ -211,16 +211,15 @@ protected PointValuePair doOptimize() {\n }\n \n PointValuePair current = null;\n- int iter = 0;\n int maxEval = getMaxEvaluations();\n while (true) {\n- ++iter;\n+ incrementIterationCount();\n \n final double objective = computeObjectiveValue(point);\n PointValuePair previous = current;\n current = new PointValuePair(point, objective);\n if (previous != null) {\n- if (checker.converged(iter, previous, current)) {\n+ if (checker.converged(getIterations(), previous, current)) {\n // We have found an optimum.\n return current;\n }\n@@ -274,7 +273,7 @@ protected PointValuePair doOptimize() {\n steepestDescent = newSteepestDescent;\n \n // Compute conjugate search direction.\n- if (iter % n == 0 ||\n+ if (getIterations() % n == 0 ||\n beta < 0) {\n // Break conjugation: reset search direction.\n searchDirection = steepestDescent.clone();\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/CMAESOptimizer.java\n@@ -385,6 +385,7 @@ protected PointValuePair doOptimize() {\n \n generationLoop:\n for (iterations = 1; iterations <= maxIterations; iterations++) {\n+ incrementIterationCount();\n \n // Generate and evaluate lambda offspring\n final RealMatrix arz = randn1(dimension, lambda);\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/PowellOptimizer.java\n@@ -188,9 +188,8 @@ protected PointValuePair doOptimize() {\n double[] x = guess;\n double fVal = computeObjectiveValue(x);\n double[] x1 = x.clone();\n- int iter = 0;\n while (true) {\n- ++iter;\n+ incrementIterationCount();\n \n double fX = fVal;\n double fX2 = 0;\n@@ -224,7 +223,7 @@ protected PointValuePair doOptimize() {\n final PointValuePair current = new PointValuePair(x, fVal);\n if (!stop) { // User-defined stopping criteria.\n if (checker != null) {\n- stop = checker.converged(iter, previous, current);\n+ stop = checker.converged(getIterations(), previous, current);\n }\n }\n if (stop) {\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/scalar/noderiv/SimplexOptimizer.java\n@@ -155,7 +155,7 @@ public int compare(final PointValuePair o1,\n int iteration = 0;\n final ConvergenceChecker<PointValuePair> checker = getConvergenceChecker();\n while (true) {\n- if (iteration > 0) {\n+ if (getIterations() > 0) {\n boolean converged = true;\n for (int i = 0; i < simplex.getSize(); i++) {\n PointValuePair prev = previous[i];\n@@ -172,7 +172,7 @@ public int compare(final PointValuePair o1,\n previous = simplex.getPoints();\n simplex.iterate(evalFunc, comparator);\n \n-\t\t\t++iteration;\n+ incrementIterationCount();\n }\n }\n \n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/GaussNewtonOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/GaussNewtonOptimizer.java\n@@ -103,9 +103,8 @@ public PointVectorValuePair doOptimize() {\n \n // iterate until convergence is reached\n PointVectorValuePair current = null;\n- int iter = 0;\n for (boolean converged = false; !converged;) {\n- ++iter;\n+ incrementIterationCount();\n \n // evaluate the objective function and its jacobian\n PointVectorValuePair previous = current;\n@@ -157,7 +156,7 @@ public PointVectorValuePair doOptimize() {\n \n // Check convergence.\n if (previous != null) {\n- converged = checker.converged(iter, previous, current);\n+ converged = checker.converged(getIterations(), previous, current);\n if (converged) {\n setCost(computeCost(currentResiduals));\n return current;\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/LevenbergMarquardtOptimizer.java\n@@ -319,10 +319,10 @@ protected PointVectorValuePair doOptimize() {\n // Outer loop.\n lmPar = 0;\n boolean firstIteration = true;\n- int iter = 0;\n final ConvergenceChecker<PointVectorValuePair> checker = getConvergenceChecker();\n while (true) {\n- ++iter;\n+ incrementIterationCount();\n+\n final PointVectorValuePair previous = current;\n \n // QR decomposition of the jacobian matrix\n@@ -486,7 +486,7 @@ protected PointVectorValuePair doOptimize() {\n // tests for convergence.\n if (checker != null) {\n // we use the vectorial convergence checker\n- if (checker.converged(iter, previous, current)) {\n+ if (checker.converged(getIterations(), previous, current)) {\n setCost(currentCost);\n return current;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.gradient.NonLinearConjugateGradientOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTrivial"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testConstrainedRosen"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testElliRotated"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEllipse"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTwoAxes"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCigar"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRosen"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testRastrigin"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDiagonalRosen"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSsDiffPow"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMaximize"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAckley"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCigTab"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDiffPow"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSphere"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTablet"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testCigarWithBoundaries"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.PowellOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSumSinc"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerMultiDirectionalTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMaximize1"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerMultiDirectionalTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMaximize2"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerMultiDirectionalTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMinimize1"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerMultiDirectionalTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMinimize2"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerNelderMeadTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMaximize1"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerNelderMeadTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMaximize2"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerNelderMeadTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMinimize1"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.scalar.noderiv.SimplexOptimizerNelderMeadTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMinimize2"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.vector.jacobian.GaussNewtonOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testGetIterations"
},
{
"className": " org.apache.commons.math3.optim.nonlinear.vector.jacobian.LevenbergMarquardtOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testGetIterations"
}
],
"metrics": {
"chunks": 17,
"classes": 7,
"files": 7,
"linesAdd": 2,
"linesMod": 12,
"linesRem": 4,
"methods": 7,
"sizeInLines": 18,
"spreadAllLines": 327,
"spreadCodeOnly": 240
},
"observations": "A parameter value passed through the constructor during object instantiation is changed. A local variable is removed and expressions to increment it are replaced by equivalent method call.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"assignRem",
"condExpMod",
"mcAdd",
"mcParValChange",
"objInstMod",
"varRem",
"varReplMc"
],
"repairPatterns": [
"constChange",
"copyPaste",
"expLogicMod",
"initFix",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair"
],
"revisionId": "419a052c6842192e78f747d9f5af619c2ca56e78"
},
{
"bugId": 10,
"changedFiles": {
"org/apache/commons/math3/analysis/differentiation/DSCompiler.java": {
"inserts": [
[
1417,
1418,
1419,
1420
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java\n+++ b/src/main/java/org/apache/commons/math3/analysis/differentiation/DSCompiler.java\n@@ -1416,6 +1416,7 @@ public void atan2(final double[] y, final int yOffset,\n }\n \n // fix value to take special cases (+0/+0, +0/-0, -0/+0, -0/-0, +/-infinity) correctly\n+ result[resultOffset] = FastMath.atan2(y[yOffset], x[xOffset]);\n \n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.analysis.differentiation.DerivativeStructureTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<NaN>",
"methodName": "testAtan2SpecialCases"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"mcAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [],
"revisionId": "7e2ffcc9034de41d7787f0b33b5670474f7a10de"
},
{
"bugId": 7,
"changedFiles": {
"org/apache/commons/math3/ode/AbstractIntegrator.java": {
"changes": [
[
346
],
[
347
],
[
363
]
],
"deletes": [
[
357
],
[
358
],
[
359
],
[
370
],
[
371
],
[
372
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java\n+++ b/src/main/java/org/apache/commons/math3/ode/AbstractIntegrator.java\n@@ -343,8 +343,10 @@ public int compare(EventState es0, EventState es1) {\n final double[] eventY = interpolator.getInterpolatedState().clone();\n \n // advance all event states to current time\n- currentEvent.stepAccepted(eventT, eventY);\n- isLastStep = currentEvent.stop();\n+ for (final EventState state : eventsStates) {\n+ state.stepAccepted(eventT, eventY);\n+ isLastStep = isLastStep || state.stop();\n+ }\n \n // handle the first part of the step, up to the event\n for (final StepHandler handler : stepHandlers) {\n@@ -354,22 +356,19 @@ public int compare(EventState es0, EventState es1) {\n if (isLastStep) {\n // the event asked to stop integration\n System.arraycopy(eventY, 0, y, 0, y.length);\n- for (final EventState remaining : occuringEvents) {\n- remaining.stepAccepted(eventT, eventY);\n- }\n return eventT;\n }\n \n- boolean needReset = currentEvent.reset(eventT, eventY);\n+ boolean needReset = false;\n+ for (final EventState state : eventsStates) {\n+ needReset = needReset || state.reset(eventT, eventY);\n+ }\n if (needReset) {\n // some event handler has triggered changes that\n // invalidate the derivatives, we need to recompute them\n System.arraycopy(eventY, 0, y, 0, y.length);\n computeDerivatives(eventT, y, yDot);\n resetOccurred = true;\n- for (final EventState remaining : occuringEvents) {\n- remaining.stepAccepted(eventT, eventY);\n- }\n return eventT;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.ode.nonstiff.DormandPrince853IntegratorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testEventsScheduling"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 3,
"linesRem": 6,
"methods": 1,
"sizeInLines": 14,
"spreadAllLines": 18,
"spreadCodeOnly": 11
},
"observations": "Changes involving adding and removing of many loops.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"assignRem",
"loopRem",
"mcRem",
"varReplVar"
],
"repairPatterns": [
"copyPaste",
"wrapsLoop",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtDeepRepair",
"rtGenProg",
"rtNopol"
],
"revisionId": "1cd68eed57febf806c385bf04a596b922f4c1964"
},
{
"bugId": 12,
"changedFiles": {
"org/apache/commons/math3/random/BitsStreamGenerator.java": {
"changes": [
[
29
]
],
"inserts": [
[
-1
],
[
-1
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/random/BitsStreamGenerator.java\n+++ b/src/main/java/org/apache/commons/math3/random/BitsStreamGenerator.java\n@@ -16,6 +16,7 @@\n */\n package org.apache.commons.math3.random;\n \n+import java.io.Serializable;\n \n import org.apache.commons.math3.exception.NotStrictlyPositiveException;\n import org.apache.commons.math3.util.FastMath;\n@@ -26,8 +27,10 @@\n * @since 2.0\n */\n public abstract class BitsStreamGenerator\n- implements RandomGenerator {\n+ implements RandomGenerator,\n+ Serializable {\n /** Serializable version identifier */\n+ private static final long serialVersionUID = 20130104L;\n /** Next gaussian. */\n private double nextGaussian;\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.GammaDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10.688186123440644> but was:<13.675503685260901>",
"methodName": "testDistributionClone"
},
{
"className": " org.apache.commons.math3.distribution.LogNormalDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<23.951334711900845> but was:<1.9236285029185378>",
"methodName": "testDistributionClone"
},
{
"className": " org.apache.commons.math3.distribution.NormalDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<3.176024051402272> but was:<0.6542132477988758>",
"methodName": "testDistributionClone"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 1,
"linesRem": 0,
"methods": 0,
"sizeInLines": 4,
"spreadAllLines": 11,
"spreadCodeOnly": 3
},
"observations": "imports and implements java.io.Serializable.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"tyImpInterf",
"varAdd"
],
"repairPatterns": [
"notClassified"
],
"repairTools": [],
"revisionId": "cc82d38aaf6ec24758a0a6df9535b8204e22ef12"
},
{
"bugId": 9,
"changedFiles": {
"org/apache/commons/math3/geometry/euclidean/threed/Line.java": {
"changes": [
[
87
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java\n+++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/Line.java\n@@ -84,7 +84,8 @@ public void reset(final Vector3D p1, final Vector3D p2) throws MathIllegalArgume\n * @return a new instance, with reversed direction\n */\n public Line revert() {\n- final Line reverted = new Line(zero, zero.subtract(direction));\n+ final Line reverted = new Line(this);\n+ reverted.direction = reverted.direction.negate();\n return reverted;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.geometry.euclidean.threed.LineTest",
"error": "junit.framework.AssertionFailedError",
"message": "arrays first differed at element [0]; expected:<0.028581782127907646> but was:<0.028581782243293483>",
"methodName": "testRevert"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaced constructor by overloaded version. Changes object attribute value by direct assignment.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"mcAdd",
"objInstMod"
],
"repairPatterns": [
"initFix",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "de98c0f0a566060ac143c39036f06a03f141dc52"
},
{
"bugId": 4,
"changedFiles": {
"org/apache/commons/math3/geometry/euclidean/threed/SubLine.java": {
"inserts": [
[
114,
115,
116
]
]
},
"org/apache/commons/math3/geometry/euclidean/twod/SubLine.java": {
"inserts": [
[
118,
119,
120
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java\n+++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/threed/SubLine.java\n@@ -111,6 +111,9 @@ public Vector3D intersection(final SubLine subLine, final boolean includeEndPoin\n \n // compute the intersection on infinite line\n Vector3D v1D = line.intersection(subLine.line);\n+ if (v1D == null) {\n+ return null;\n+ }\n \n // check location of point with respect to first sub-line\n Location loc1 = remainingRegion.checkPoint(line.toSubSpace(v1D));\n--- a/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java\n+++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/SubLine.java\n@@ -115,6 +115,9 @@ public Vector2D intersection(final SubLine subLine, final boolean includeEndPoin\n \n // compute the intersection on infinite line\n Vector2D v2D = line1.intersection(line2);\n+ if (v2D == null) {\n+ return null;\n+ }\n \n // check location of point with respect to first sub-line\n Location loc1 = getRemainingRegion().checkPoint(line1.toSubSpace(v2D));\n",
"failingTests": [
{
"className": " org.apache.commons.math3.geometry.euclidean.threed.SubLineTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testIntersectionNotIntersecting"
},
{
"className": " org.apache.commons.math3.geometry.euclidean.twod.SubLineTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testIntersectionParallel"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 6,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Almost a copy, the only difference is in involved variable.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missNullCheckP"
],
"repairTools": [
"rtAcs",
"rtNopol"
],
"revisionId": "277e61721f34be16a20da663fd597edf6b51939b"
},
{
"bugId": 13,
"changedFiles": {
"org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java": {
"inserts": [
[
562
],
[
564
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/general/AbstractLeastSquaresOptimizer.java\n@@ -559,7 +559,16 @@ protected void setUp() {\n * @return the square-root of the weight matrix.\n */\n private RealMatrix squareRoot(RealMatrix m) {\n+ if (m instanceof DiagonalMatrix) {\n+ final int dim = m.getRowDimension();\n+ final RealMatrix sqrtM = new DiagonalMatrix(dim);\n+ for (int i = 0; i < dim; i++) {\n+ sqrtM.setEntry(i, i, FastMath.sqrt(m.getEntry(i, i)));\n+ }\n+ return sqrtM;\n+ } else {\n final EigenDecomposition dec = new EigenDecomposition(m);\n return dec.getSquareRoot();\n+ }\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.fitting.PolynomialFitterTest",
"error": "java.lang.OutOfMemoryError",
"message": "Java heap space",
"methodName": "testLargeSample"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "Contains the patch of Math-13",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"loopAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"missComp",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "8079ea5b8d1366445da532906e43afa9291473cf"
},
{
"bugId": 14,
"changedFiles": {
"org/apache/commons/math3/optim/nonlinear/vector/Weight.java": {
"changes": [
[
43
]
],
"deletes": [
[
44
],
[
45
],
[
46
]
]
},
"org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java": {
"inserts": [
[
267
],
[
269
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/Weight.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/Weight.java\n@@ -40,10 +40,7 @@\n */\n public Weight(double[] weight) {\n final int dim = weight.length;\n- weightMatrix = org.apache.commons.math3.linear.MatrixUtils.createRealMatrix(dim, dim);\n- for (int i = 0; i < dim; i++) {\n- weightMatrix.setEntry(i, i, weight[i]);\n- }\n+ weightMatrix = new DiagonalMatrix(weight);\n }\n \n /**\n--- a/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optim/nonlinear/vector/jacobian/AbstractLeastSquaresOptimizer.java\n@@ -264,7 +264,16 @@ private void parseOptimizationData(OptimizationData... optData) {\n * @return the square-root of the weight matrix.\n */\n private RealMatrix squareRoot(RealMatrix m) {\n+ if (m instanceof DiagonalMatrix) {\n+ final int dim = m.getRowDimension();\n+ final RealMatrix sqrtM = new DiagonalMatrix(dim);\n+ for (int i = 0; i < dim; i++) {\n+ sqrtM.setEntry(i, i, FastMath.sqrt(m.getEntry(i, i)));\n+ }\n+ return sqrtM;\n+ } else {\n final EigenDecomposition dec = new EigenDecomposition(m);\n return dec.getSquareRoot();\n+ }\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.fitting.PolynomialFitterTest",
"error": "java.lang.OutOfMemoryError",
"message": "Java heap space",
"methodName": "testLargeSample"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 9,
"linesMod": 1,
"linesRem": 3,
"methods": 2,
"sizeInLines": 13,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfElseAdd",
"loopAdd",
"loopRem",
"mcAdd",
"mcRem",
"objInstAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"blockRemove",
"missComp",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "a6b2e992e17cee0d4cb5a2da8242a20b8e5a8fc3"
},
{
"bugId": 15,
"changedFiles": {
"org/apache/commons/math3/util/FastMath.java": {
"changes": [
[
1541
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/util/FastMath.java\n+++ b/src/main/java/org/apache/commons/math3/util/FastMath.java\n@@ -310,6 +310,7 @@\n /** 2^52 - double numbers this large must be integral (no fraction) or NaN or Infinite */\n private static final double TWO_POWER_52 = 4503599627370496.0;\n /** 2^53 - double numbers this large must be even. */\n+ private static final double TWO_POWER_53 = 2 * TWO_POWER_52;\n \n /** Constant: {@value}. */\n private static final double F_1_3 = 1d / 3d;\n@@ -1538,7 +1539,7 @@ public static double pow(double x, double y) {\n /* Handle special case x<0 */\n if (x < 0) {\n // y is an even integer in this case\n- if (y >= TWO_POWER_52 || y <= -TWO_POWER_52) {\n+ if (y >= TWO_POWER_53 || y <= -TWO_POWER_53) {\n return pow(-x, y);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.util.FastMathTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1.0> but was:<1.0>",
"methodName": "testMath904"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1228,
"spreadCodeOnly": 742
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condExpMod",
"varAdd"
],
"repairPatterns": [
"expLogicMod",
"initFix"
],
"repairTools": [],
"revisionId": "b221a7342856a2a548f5d9817055defc0ec4dea6"
},
{
"bugId": 17,
"changedFiles": {
"org/apache/commons/math3/dfp/Dfp.java": {
"inserts": [
[
1603
],
[
1604
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/dfp/Dfp.java\n+++ b/src/main/java/org/apache/commons/math3/dfp/Dfp.java\n@@ -1600,7 +1600,11 @@ public Dfp multiply(final Dfp x) {\n * @return product of this and x\n */\n public Dfp multiply(final int x) {\n+ if (x >= 0 && x < RADIX) {\n return multiplyFast(x);\n+ } else {\n+ return multiply(newInstance(x));\n+ }\n }\n \n /** Multiply this by a single digit 0&lt;=x&lt;radix.\n",
"failingTests": [
{
"className": " org.apache.commons.math3.dfp.DfpTest",
"error": "junit.framework.AssertionFailedError",
"message": "assersion failed Multiply #37 x = NaN flags = 1",
"methodName": "testMultiply"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "621806b796bc416f00341feca894ebae07be5ed0"
},
{
"bugId": 22,
"changedFiles": {
"org/apache/commons/math3/distribution/FDistribution.java": {
"changes": [
[
275
]
]
},
"org/apache/commons/math3/distribution/UniformRealDistribution.java": {
"changes": [
[
184
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/distribution/FDistribution.java\n+++ b/src/main/java/org/apache/commons/math3/distribution/FDistribution.java\n@@ -272,7 +272,7 @@ public double getSupportUpperBound() {\n \n /** {@inheritDoc} */\n public boolean isSupportLowerBoundInclusive() {\n- return true;\n+ return false;\n }\n \n /** {@inheritDoc} */\n--- a/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java\n+++ b/src/main/java/org/apache/commons/math3/distribution/UniformRealDistribution.java\n@@ -181,7 +181,7 @@ public boolean isSupportLowerBoundInclusive() {\n \n /** {@inheritDoc} */\n public boolean isSupportUpperBoundInclusive() {\n- return false;\n+ return true;\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.FDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<false> but was:<true>",
"methodName": "testIsSupportLowerBoundInclusive"
},
{
"className": " org.apache.commons.math3.distribution.UniformRealDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<true> but was:<false>",
"methodName": "testIsSupportUpperBoundInclusive"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"retExpChange"
],
"repairPatterns": [
"constChange"
],
"repairTools": [
"rtDeepRepair",
"rtHDRepair"
],
"revisionId": "b0cba9a79ee99b09958dec8e40c75bed47b7f780"
},
{
"bugId": 16,
"changedFiles": {
"org/apache/commons/math3/util/FastMath.java": {
"changes": [
[
397
],
[
458
]
],
"inserts": [
[
-1
],
[
394,
395
],
[
396
],
[
398,
399
],
[
400
],
[
455,
456
],
[
457
],
[
459,
460
],
[
461
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/util/FastMath.java\n+++ b/src/main/java/org/apache/commons/math3/util/FastMath.java\n@@ -79,6 +79,7 @@\n */\n public class FastMath {\n /** StrictMath.log(Double.MAX_VALUE): {@value} */\n+ private static final double LOG_MAX_VALUE = StrictMath.log(Double.MAX_VALUE);\n \n /** Archimede's constant PI, ratio of circle circumference to diameter. */\n public static final double PI = 105414357.0 / 33554432.0 + 1.984187159361080883e-9;\n@@ -391,12 +392,21 @@ public static double cosh(double x) {\n // exp(-z) can be ignored in comparison with exp(z)\n \n if (x > 20) {\n+ if (x >= LOG_MAX_VALUE) {\n // Avoid overflow (MATH-905).\n+ final double t = exp(0.5 * x);\n+ return (0.5 * t) * t;\n+ } else {\n return 0.5 * exp(x);\n }\n- if (x < -20) {\n+ } else if (x < -20) {\n+ if (x <= -LOG_MAX_VALUE) {\n // Avoid overflow (MATH-905).\n+ final double t = exp(-0.5 * x);\n+ return (0.5 * t) * t;\n+ } else {\n return 0.5 * exp(-x);\n+ }\n }\n \n final double hiPrec[] = new double[2];\n@@ -452,12 +462,21 @@ public static double sinh(double x) {\n // exp(-z) can be ignored in comparison with exp(z)\n \n if (x > 20) {\n+ if (x >= LOG_MAX_VALUE) {\n // Avoid overflow (MATH-905).\n+ final double t = exp(0.5 * x);\n+ return (0.5 * t) * t;\n+ } else {\n return 0.5 * exp(x);\n }\n- if (x < -20) {\n+ } else if (x < -20) {\n+ if (x <= -LOG_MAX_VALUE) {\n // Avoid overflow (MATH-905).\n+ final double t = exp(-0.5 * x);\n+ return (-0.5 * t) * t;\n+ } else {\n return -0.5 * exp(-x);\n+ }\n }\n \n if (x == 0) {\n",
"failingTests": [
{
"className": " org.apache.commons.math3.util.FastMathTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<Infinity>",
"methodName": "testMath905LargePositive"
},
{
"className": " org.apache.commons.math3.util.FastMathTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<Infinity>",
"methodName": "testMath905LargeNegative"
}
],
"metrics": {
"chunks": 11,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 21,
"spreadAllLines": 377,
"spreadCodeOnly": 235
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"copyPaste",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "875ed1f4d90d1457c0ab40dafc79be5a0c6f9bf6"
},
{
"bugId": 18,
"changedFiles": {
"org/apache/commons/math3/optimization/direct/CMAESOptimizer.java": {
"changes": [
[
932
],
[
958
],
[
992
],
[
995
]
],
"inserts": [
[
989,
990,
991
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n@@ -929,7 +929,7 @@ public FitnessFunction() {\n double[] res = new double[x.length];\n for (int i = 0; i < x.length; i++) {\n double diff = boundaries[1][i] - boundaries[0][i];\n- res[i] = (x[i] - boundaries[0][i]) / diff;\n+ res[i] = x[i] / diff;\n }\n return res;\n }\n@@ -955,7 +955,7 @@ public FitnessFunction() {\n double[] res = new double[x.length];\n for (int i = 0; i < x.length; i++) {\n double diff = boundaries[1][i] - boundaries[0][i];\n- res[i] = diff * x[i] + boundaries[0][i];\n+ res[i] = diff * x[i];\n }\n return res;\n }\n@@ -987,12 +987,14 @@ public boolean isFeasible(final double[] x) {\n return true;\n }\n \n+ final double[] bLoEnc = encode(boundaries[0]);\n+ final double[] bHiEnc = encode(boundaries[1]);\n \n for (int i = 0; i < x.length; i++) {\n- if (x[i] < 0) {\n+ if (x[i] < bLoEnc[i]) {\n return false;\n }\n- if (x[i] > 1.0) {\n+ if (x[i] > bHiEnc[i]) {\n return false;\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.direct.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<11.100000000386425> but was:<8.0>",
"methodName": "testFitAccuracyDependsOnBoundary"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 4,
"linesRem": 0,
"methods": 3,
"sizeInLines": 6,
"spreadAllLines": 60,
"spreadCodeOnly": 38
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"condExpMod",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"expArithMod",
"expLogicMod",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair"
],
"revisionId": "7c7d7e8f103582e753c39a2baf14a483e991fefb"
},
{
"bugId": 20,
"changedFiles": {
"org/apache/commons/math3/optimization/direct/CMAESOptimizer.java": {
"changes": [
[
921
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n@@ -918,7 +918,8 @@ public FitnessFunction() {\n * @return the original objective variables, possibly repaired.\n */\n public double[] repairAndDecode(final double[] x) {\n- return\n+ return boundaries != null && isRepairMode ?\n+ decode(repair(x)) :\n decode(x);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.direct.CMAESOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "Out of bounds (0.7651312169618905 > 0.5)",
"methodName": "testMath864"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Adds a new return output alternative through conditional expression of the form \"exp?a:b\". Something to think: \"Is it a change in return expression, a return branch adding or both?\". For now, it is considered as both.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"retExpChange"
],
"repairPatterns": [
"missNullCheckN",
"singleLine",
"wrapsIfElse"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL"
],
"revisionId": "efa9de05114492ca38cf4739a07339f5ad6faddc"
},
{
"bugId": 19,
"changedFiles": {
"org/apache/commons/math3/optimization/direct/CMAESOptimizer.java": {
"inserts": [
[
538,
539,
540
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/direct/CMAESOptimizer.java\n@@ -537,6 +537,19 @@ private void checkParameters() {\n boundaries[1] = uB;\n \n // Abort early if the normalization will overflow (cf. \"encode\" method).\n+ for (int i = 0; i < lB.length; i++) {\n+ if (Double.isInfinite(boundaries[1][i] - boundaries[0][i])) {\n+ final double max = Double.MAX_VALUE + boundaries[0][i];\n+ final NumberIsTooLargeException e\n+ = new NumberIsTooLargeException(boundaries[1][i],\n+ max,\n+ true);\n+ e.getContext().addMessage(LocalizedFormats.OVERFLOW);\n+ e.getContext().addMessage(LocalizedFormats.INDEX, i);\n+\n+ throw e;\n+ }\n+ }\n }\n } else {\n // Convert API to internal handling of boundaries.\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.direct.CMAESOptimizerTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.apache.commons.math3.exception.NumberIsTooLargeException> but was<org.apache.commons.math3.exception.MathIllegalStateException>",
"methodName": "testBoundaryRangeTooLarge"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 13,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 13,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"loopAdd",
"mcAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"missComp"
],
"repairTools": [],
"revisionId": "c73fad0a0d42103b5e13a68317ea95b1090263ba"
},
{
"bugId": 23,
"changedFiles": {
"org/apache/commons/math3/optimization/univariate/BrentOptimizer.java": {
"changes": [
[
237
],
[
274
],
[
275
],
[
276
],
[
277
]
],
"inserts": [
[
150,
151,
152,
153
],
[
234,
235
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/univariate/BrentOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/univariate/BrentOptimizer.java\n@@ -148,6 +148,7 @@ protected UnivariatePointValuePair doOptimize() {\n UnivariatePointValuePair current\n = new UnivariatePointValuePair(x, isMinim ? fx : -fx);\n // Best point encountered so far (which is the initial guess).\n+ UnivariatePointValuePair best = current;\n \n int iter = 0;\n while (true) {\n@@ -231,10 +232,15 @@ protected UnivariatePointValuePair doOptimize() {\n // User-defined convergence checker.\n previous = current;\n current = new UnivariatePointValuePair(u, isMinim ? fu : -fu);\n+ best = best(best,\n+ best(current,\n+ previous,\n+ isMinim),\n+ isMinim);\n \n if (checker != null) {\n if (checker.converged(iter, previous, current)) {\n- return best(current, previous, isMinim);\n+ return best;\n }\n }\n \n@@ -271,9 +277,10 @@ protected UnivariatePointValuePair doOptimize() {\n }\n }\n } else { // Default termination (Brent's criterion).\n- return\n+ return best(best,\n best(current,\n previous,\n+ isMinim),\n isMinim);\n }\n ++iter;\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.univariate.BrentOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "Best point not reported",
"methodName": "testKeepInitIfBest"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 124,
"spreadCodeOnly": 104
},
"observations": "Call overloaded method with extra params. New variable is added with its initialization.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"mcAdd",
"mcRepl",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"wrapsMethod"
],
"repairTools": [],
"revisionId": "f1b04e990f4fc86544b6230fab1aa8ecfb74fbb1"
},
{
"bugId": 21,
"changedFiles": {
"org/apache/commons/math3/linear/RectangularCholeskyDecomposition.java": {
"changes": [
[
79
],
[
82
],
[
83
],
[
84
],
[
90
],
[
91
],
[
92
],
[
93
],
[
128
]
],
"deletes": [
[
69
]
],
"inserts": [
[
94
],
[
119,
120,
121,
122,
123,
124
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/linear/RectangularCholeskyDecomposition.java\n+++ b/src/main/java/org/apache/commons/math3/linear/RectangularCholeskyDecomposition.java\n@@ -66,7 +66,6 @@ public RectangularCholeskyDecomposition(RealMatrix matrix, double small)\n final double[][] c = matrix.getData();\n final double[][] b = new double[order][order];\n \n- int[] swap = new int[order];\n int[] index = new int[order];\n for (int i = 0; i < order; ++i) {\n index[i] = i;\n@@ -76,21 +75,24 @@ public RectangularCholeskyDecomposition(RealMatrix matrix, double small)\n for (boolean loop = true; loop;) {\n \n // find maximal diagonal element\n- swap[r] = r;\n+ int swapR = r;\n for (int i = r + 1; i < order; ++i) {\n int ii = index[i];\n- int isi = index[swap[i]];\n- if (c[ii][ii] > c[isi][isi]) {\n- swap[r] = i;\n+ int isr = index[swapR];\n+ if (c[ii][ii] > c[isr][isr]) {\n+ swapR = i;\n }\n }\n \n \n // swap elements\n- if (swap[r] != r) {\n- int tmp = index[r];\n- index[r] = index[swap[r]];\n- index[swap[r]] = tmp;\n+ if (swapR != r) {\n+ final int tmpIndex = index[r];\n+ index[r] = index[swapR];\n+ index[swapR] = tmpIndex;\n+ final double[] tmpRow = b[r];\n+ b[r] = b[swapR];\n+ b[swapR] = tmpRow;\n }\n \n // check diagonal element\n@@ -121,11 +123,12 @@ public RectangularCholeskyDecomposition(RealMatrix matrix, double small)\n final double sqrt = FastMath.sqrt(c[ir][ir]);\n b[r][r] = sqrt;\n final double inverse = 1 / sqrt;\n+ final double inverse2 = 1 / c[ir][ir];\n for (int i = r + 1; i < order; ++i) {\n final int ii = index[i];\n final double e = inverse * c[ii][ir];\n b[i][r] = e;\n- c[ii][ii] -= e * e;\n+ c[ii][ii] -= c[ii][ir] * c[ii][ir] * inverse2;\n for (int j = r + 1; j < i; ++j) {\n final int ij = index[j];\n final double f = c[ii][ij] - e * b[j][r];\n",
"failingTests": [
{
"className": " org.apache.commons.math3.linear.RectangularCholeskyDecompositionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<0.0180652917341963>",
"methodName": "testMath789"
},
{
"className": " org.apache.commons.math3.linear.RectangularCholeskyDecompositionTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testFullRank"
}
],
"metrics": {
"chunks": 6,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 9,
"linesRem": 1,
"methods": 1,
"sizeInLines": 14,
"spreadAllLines": 50,
"spreadCodeOnly": 31
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfAdd",
"varAdd",
"varRem",
"varReplVar"
],
"repairPatterns": [
"expArithMod",
"expLogicMod",
"wrongComp",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "468ed8550b7759858a4dc59d694859a8ae7d35f0"
},
{
"bugId": 24,
"changedFiles": {
"org/apache/commons/math3/optimization/univariate/BrentOptimizer.java": {
"changes": [
[
230
],
[
267
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/univariate/BrentOptimizer.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/univariate/BrentOptimizer.java\n@@ -227,7 +227,7 @@ protected UnivariatePointValuePair doOptimize() {\n \n if (checker != null) {\n if (checker.converged(iter, previous, current)) {\n- return current;\n+ return best(current, previous, isMinim);\n }\n }\n \n@@ -264,7 +264,7 @@ protected UnivariatePointValuePair doOptimize() {\n }\n }\n } else { // Default termination (Brent's criterion).\n- return current;\n+ return best(current, previous, isMinim);\n }\n ++iter;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.univariate.BrentOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "Best point not reported",
"methodName": "testMath855"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 36,
"spreadCodeOnly": 34
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"copyPaste",
"wrapsMethod"
],
"repairTools": [
"rtDeepRepair",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "d5ff460ba69e4261f066d7856e2f90b886924513"
},
{
"bugId": 30,
"changedFiles": {
"org/apache/commons/math3/stat/inference/MannWhitneyUTest.java": {
"changes": [
[
173
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java\n+++ b/src/main/java/org/apache/commons/math3/stat/inference/MannWhitneyUTest.java\n@@ -170,7 +170,7 @@ private double calculateAsymptoticPValue(final double Umin,\n final int n2)\n throws ConvergenceException, MaxCountExceededException {\n \n- final int n1n2prod = n1 * n2;\n+ final double n1n2prod = n1 * n2;\n \n // http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U#Normal_approximation\n final double EU = n1n2prod / 2.0;\n",
"failingTests": [
{
"className": " org.apache.commons.math3.stat.inference.MannWhitneyUTestTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testBigDataSet"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"varTyChange"
],
"repairPatterns": [
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtElixir"
],
"revisionId": "a25e7f7abe7f6b3f4147febee4a917ce92241aab"
},
{
"bugId": 25,
"changedFiles": {
"org/apache/commons/math3/optimization/fitting/HarmonicFitter.java": {
"inserts": [
[
323,
324,
325,
326
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/fitting/HarmonicFitter.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/fitting/HarmonicFitter.java\n@@ -320,8 +320,11 @@ private void guessAOmega() {\n }\n a = 0.5 * (yMax - yMin);\n } else {\n+ if (c2 == 0) {\n // In some ill-conditioned cases (cf. MATH-844), the guesser\n // procedure cannot produce sensible results.\n+ throw new MathIllegalStateException(LocalizedFormats.ZERO_DENOMINATOR);\n+ }\n \n a = FastMath.sqrt(c1 / c2);\n omega = FastMath.sqrt(c2 / c3);\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.fitting.HarmonicFitterTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math3.exception.MathIllegalStateException",
"methodName": "testMath844"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 2,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [
"rtAcs"
],
"revisionId": "996dd998e3081e4a842017b8ebcdae9b6059b530"
},
{
"bugId": 26,
"changedFiles": {
"org/apache/commons/math3/fraction/Fraction.java": {
"changes": [
[
181
],
[
209
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n+++ b/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n@@ -178,7 +178,7 @@ private Fraction(double value, double epsilon, int maxDenominator, int maxIterat\n long overflow = Integer.MAX_VALUE;\n double r0 = value;\n long a0 = (long)FastMath.floor(r0);\n- if (a0 > overflow) {\n+ if (FastMath.abs(a0) > overflow) {\n throw new FractionConversionException(value, a0, 1l);\n }\n \n@@ -206,7 +206,7 @@ private Fraction(double value, double epsilon, int maxDenominator, int maxIterat\n long a1 = (long)FastMath.floor(r1);\n p2 = (a1 * p1) + p0;\n q2 = (a1 * q1) + q0;\n- if ((p2 > overflow) || (q2 > overflow)) {\n+ if ((FastMath.abs(p2) > overflow) || (FastMath.abs(q2) > overflow)) {\n throw new FractionConversionException(value, p2, q2);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.fraction.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "an exception should have been thrown",
"methodName": "testIntegerOverflow"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 27,
"spreadCodeOnly": 21
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpMod",
"mcAdd"
],
"repairPatterns": [
"expLogicMod",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "1566dd339f6efc2347b0962fac7fce22adbc31ff"
},
{
"bugId": 27,
"changedFiles": {
"org/apache/commons/math3/fraction/Fraction.java": {
"changes": [
[
597
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n+++ b/src/main/java/org/apache/commons/math3/fraction/Fraction.java\n@@ -594,7 +594,7 @@ public Fraction divide(final int i) {\n * @return the fraction percentage as a <tt>double</tt>.\n */\n public double percentageValue() {\n- return multiply(100).doubleValue();\n+ return 100 * doubleValue();\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math3.fraction.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2.1691754E9> but was:<-2.125791896E9>",
"methodName": "testMath835"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcRem",
"retExpChange"
],
"repairPatterns": [
"expArithMod",
"singleLine",
"unwrapMethod"
],
"repairTools": [],
"revisionId": "5f2077bb774d283e7984a2d5dc0c2759f2954963"
},
{
"bugId": 29,
"changedFiles": {
"org/apache/commons/math3/linear/OpenMapRealVector.java": {
"changes": [
[
349
],
[
350
],
[
351
],
[
352
]
],
"inserts": [
[
367,
368,
369,
370,
371,
372,
373,
374
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java\n+++ b/src/main/java/org/apache/commons/math3/linear/OpenMapRealVector.java\n@@ -346,10 +346,9 @@ public OpenMapRealVector ebeDivide(RealVector v) {\n * this only. Indeed, if this[i] = 0d and v[i] = 0d, then\n * this[i] / v[i] = NaN, and not 0d.\n */\n- Iterator iter = entries.iterator();\n- while (iter.hasNext()) {\n- iter.advance();\n- res.setEntry(iter.key(), iter.value() / v.getEntry(iter.key()));\n+ final int n = getDimension();\n+ for (int i = 0; i < n; i++) {\n+ res.setEntry(i, this.getEntry(i) / v.getEntry(i));\n }\n return res;\n }\n@@ -371,6 +370,18 @@ public OpenMapRealVector ebeMultiply(RealVector v) {\n *\n * These special cases are handled below.\n */\n+ if (v.isNaN() || v.isInfinite()) {\n+ final int n = getDimension();\n+ for (int i = 0; i < n; i++) {\n+ final double y = v.getEntry(i);\n+ if (Double.isNaN(y)) {\n+ res.setEntry(i, Double.NaN);\n+ } else if (Double.isInfinite(y)) {\n+ final double x = this.getEntry(i);\n+ res.setEntry(i, x * y);\n+ }\n+ }\n+ }\n return res;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.linear.SparseRealVectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "entry #0, left = 0.0, right = 0.0 expected:<NaN> but was:<0.0>",
"methodName": "testEbeDivideMixedTypes"
},
{
"className": " org.apache.commons.math3.linear.SparseRealVectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "entry #5, left = 0.0, right = Infinity expected:<NaN> but was:<0.0>",
"methodName": "testEbeMultiplyMixedTypes"
},
{
"className": " org.apache.commons.math3.linear.SparseRealVectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "entry #5, left = 0.0, right = Infinity expected:<NaN> but was:<0.0>",
"methodName": "testEbeMultiplySameType"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 3,
"linesRem": 1,
"methods": 2,
"sizeInLines": 16,
"spreadAllLines": 21,
"spreadCodeOnly": 12
},
"observations": "Changed a while loop to a for lor loop.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfAdd",
"condBranIfElseAdd",
"loopAdd",
"loopRem",
"mcAdd",
"mcRem",
"varAdd",
"varRem"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"wrongComp"
],
"repairTools": [],
"revisionId": "7bbddc2203bed78fafe7739a97df1f53e767341a"
},
{
"bugId": 28,
"changedFiles": {
"org/apache/commons/math3/optimization/linear/SimplexSolver.java": {
"inserts": [
[
116,
117,
118,
119
],
[
128,
129,
130,
131,
132,
133,
134,
135,
136,
137,
138
],
[
128,
129,
130,
131,
132,
133,
134,
135,
136,
137,
138
],
[
152
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexSolver.java\n@@ -116,6 +116,7 @@ private Integer getPivotRow(SimplexTableau tableau, final int col) {\n // there's a degeneracy as indicated by a tie in the minimum ratio test\n \n // 1. check if there's an artificial variable that can be forced out of the basis\n+ if (tableau.getNumArtificialVariables() > 0) {\n for (Integer row : minRatioPositions) {\n for (int i = 0; i < tableau.getNumArtificialVariables(); i++) {\n int column = i + tableau.getArtificialVariableOffset();\n@@ -125,6 +126,7 @@ private Integer getPivotRow(SimplexTableau tableau, final int col) {\n }\n }\n }\n+ }\n \n // 2. apply Bland's rule to prevent cycling:\n // take the row for which the corresponding basic variable has the smallest index\n@@ -135,6 +137,7 @@ private Integer getPivotRow(SimplexTableau tableau, final int col) {\n // Additional heuristic: if we did not get a solution after half of maxIterations\n // revert to the simple case of just returning the top-most row\n // This heuristic is based on empirical data gathered while investigating MATH-828.\n+ if (getIterations() < getMaxIterations() / 2) {\n Integer minRow = null;\n int minIndex = tableau.getWidth();\n for (Integer row : minRatioPositions) {\n@@ -149,6 +152,7 @@ private Integer getPivotRow(SimplexTableau tableau, final int col) {\n }\n }\n return minRow;\n+ }\n }\n return minRatioPositions.get(0);\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.linear.SimplexSolverTest",
"error": "org.apache.commons.math3.exception.MaxCountExceededException",
"message": "illegal state: maximal count (100) exceeded",
"methodName": "testMath828Cycle"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 33,
"spreadCodeOnly": 23
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"mcAdd"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "d3fc5af31eb696af03cfbe2e18584c7e1d307d54"
},
{
"bugId": 31,
"changedFiles": {
"org/apache/commons/math3/util/ContinuedFraction.java": {
"changes": [
[
169
],
[
170
],
[
185
],
[
188
],
[
189
]
],
"deletes": [
[
134
],
[
135
],
[
143
],
[
144
],
[
145
],
[
146
],
[
147
],
[
148
],
[
149
],
[
150
],
[
151
],
[
152
],
[
153
],
[
154
],
[
155
],
[
156
],
[
157
],
[
158
],
[
159
],
[
160
],
[
161
],
[
162
],
[
163
],
[
164
],
[
165
],
[
166
],
[
167
],
[
186
],
[
187
],
[
188
],
[
189
]
],
"inserts": [
[
142,
143,
144,
145,
146,
147,
148,
149,
150,
151,
152,
153,
154,
155,
156,
157,
158,
159,
160,
161,
162,
163,
164,
165,
166,
167,
168,
169
],
[
184,
185,
186,
187,
188,
189,
190,
191
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java\n+++ b/src/main/java/org/apache/commons/math3/util/ContinuedFraction.java\n@@ -131,8 +131,6 @@ public double evaluate(double x, double epsilon, int maxIterations) {\n \n int n = 1;\n double dPrev = 0.0;\n- double p0 = 1.0;\n- double q1 = 1.0;\n double cPrev = hPrev;\n double hN = hPrev;\n \n@@ -140,34 +138,18 @@ public double evaluate(double x, double epsilon, int maxIterations) {\n final double a = getA(n, x);\n final double b = getB(n, x);\n \n- double cN = a * hPrev + b * p0;\n- double q2 = a * q1 + b * dPrev;\n- if (Double.isInfinite(cN) || Double.isInfinite(q2)) {\n- double scaleFactor = 1d;\n- double lastScaleFactor = 1d;\n- final int maxPower = 5;\n- final double scale = FastMath.max(a,b);\n- if (scale <= 0) { // Can't scale\n- throw new ConvergenceException(LocalizedFormats.CONTINUED_FRACTION_INFINITY_DIVERGENCE, x);\n- }\n- for (int i = 0; i < maxPower; i++) {\n- lastScaleFactor = scaleFactor;\n- scaleFactor *= scale;\n- if (a != 0.0 && a > b) {\n- cN = hPrev / lastScaleFactor + (b / scaleFactor * p0);\n- q2 = q1 / lastScaleFactor + (b / scaleFactor * dPrev);\n- } else if (b != 0) {\n- cN = (a / scaleFactor * hPrev) + p0 / lastScaleFactor;\n- q2 = (a / scaleFactor * q1) + dPrev / lastScaleFactor;\n- }\n- if (!(Double.isInfinite(cN) || Double.isInfinite(q2))) {\n- break;\n- }\n- }\n+ double dN = a + b * dPrev;\n+ if (Precision.equals(dN, 0.0, small)) {\n+ dN = small;\n+ }\n+ double cN = a + b / cPrev;\n+ if (Precision.equals(cN, 0.0, small)) {\n+ cN = small;\n }\n \n- final double deltaN = cN / q2 / cPrev;\n- hN = cPrev * deltaN;\n+ dN = 1 / dN;\n+ final double deltaN = cN * dN;\n+ hN = hPrev * deltaN;\n \n if (Double.isInfinite(hN)) {\n throw new ConvergenceException(LocalizedFormats.CONTINUED_FRACTION_INFINITY_DIVERGENCE,\n@@ -182,11 +164,9 @@ public double evaluate(double x, double epsilon, int maxIterations) {\n break;\n }\n \n- dPrev = q1;\n- cPrev = cN / q2;\n- p0 = hPrev;\n- hPrev = cN;\n- q1 = q2;\n+ dPrev = dN;\n+ cPrev = cN;\n+ hPrev = hN;\n n++;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math3.distribution.BinomialDistributionTest",
"error": "org.apache.commons.math3.exception.ConvergenceException",
"message": "illegal state: Continued fraction diverged to NaN for value 0.5",
"methodName": "testMath718"
},
{
"className": " org.apache.commons.math3.distribution.FDistributionTest",
"error": "junit.framework.AssertionFailedError",
"message": "Failing to calculate inverse cumulative probability",
"methodName": "testMath785"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 12,
"linesRem": 21,
"methods": 1,
"sizeInLines": 34,
"spreadAllLines": 23,
"spreadCodeOnly": 17
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"condBranRem",
"exThrowsRem",
"loopRem",
"mcAdd",
"mcRem",
"objInstRem",
"varAdd",
"varRem",
"varReplVar"
],
"repairPatterns": [
"blockRemove",
"condBlockOthersAdd",
"condBlockRem",
"expArithMod",
"wrongComp",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "2d846db3aec18dd081e680be05f6e0faad1cb186"
},
{
"bugId": 32,
"changedFiles": {
"org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java": {
"changes": [
[
136
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java\n+++ b/src/main/java/org/apache/commons/math3/geometry/euclidean/twod/PolygonsSet.java\n@@ -133,7 +133,7 @@ protected void computeGeometricalProperties() {\n \n if (v.length == 0) {\n final BSPTree<Euclidean2D> tree = getTree(false);\n- if ((Boolean) tree.getAttribute()) {\n+ if (tree.getCut() == null && (Boolean) tree.getAttribute()) {\n // the instance covers the whole space\n setSize(Double.POSITIVE_INFINITY);\n setBarycenter(Vector2D.NaN);\n",
"failingTests": [
{
"className": " org.apache.commons.math3.geometry.euclidean.threed.PolyhedronsSetTest",
"error": "java.lang.ClassCastException",
"message": "org.apache.commons.math3.geometry.partitioning.BoundaryAttribute cannot be cast to java.lang.Boolean",
"methodName": "testIssue780"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"missNullCheckP",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtJAID",
"rtKali"
],
"revisionId": "f81847d8079753ce45b049813730055188a22efb"
},
{
"bugId": 35,
"changedFiles": {
"org/apache/commons/math3/genetics/ElitisticListPopulation.java": {
"changes": [
[
51
],
[
65
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java\n+++ b/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java\n@@ -48,7 +48,7 @@ public ElitisticListPopulation(final List<Chromosome> chromosomes,\n final int populationLimit,\n final double elitismRate) {\n super(chromosomes, populationLimit);\n- this.elitismRate = elitismRate;\n+ setElitismRate(elitismRate);\n }\n \n /**\n@@ -62,7 +62,7 @@ public ElitisticListPopulation(final List<Chromosome> chromosomes,\n */\n public ElitisticListPopulation(final int populationLimit, final double elitismRate) {\n super(populationLimit);\n- this.elitismRate = elitismRate;\n+ setElitismRate(elitismRate);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math3.genetics.ElitisticListPopulationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math3.exception.OutOfRangeException",
"methodName": "testChromosomeListConstructorTooLow"
},
{
"className": " org.apache.commons.math3.genetics.ElitisticListPopulationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math3.exception.OutOfRangeException",
"methodName": "testConstructorTooHigh"
},
{
"className": " org.apache.commons.math3.genetics.ElitisticListPopulationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math3.exception.OutOfRangeException",
"methodName": "testConstructorTooLow"
},
{
"className": " org.apache.commons.math3.genetics.ElitisticListPopulationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math3.exception.OutOfRangeException",
"methodName": "testChromosomeListConstructorTooHigh"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 13,
"spreadCodeOnly": 3
},
"observations": "Similar to Math-34",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignRem",
"mcAdd",
"varReplMc"
],
"repairPatterns": [
"copyPaste",
"wrapsMethod",
"wrongVarRef"
],
"repairTools": [
"rtAcs"
],
"revisionId": "a5d8d115cb85149c62059a23e8f4d318cac0e903"
},
{
"bugId": 33,
"changedFiles": {
"org/apache/commons/math3/optimization/linear/SimplexTableau.java": {
"changes": [
[
338
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java\n+++ b/src/main/java/org/apache/commons/math3/optimization/linear/SimplexTableau.java\n@@ -335,7 +335,7 @@ protected void dropPhase1Objective() {\n // positive cost non-artificial variables\n for (int i = getNumObjectiveFunctions(); i < getArtificialVariableOffset(); i++) {\n final double entry = tableau.getEntry(0, i);\n- if (Precision.compareTo(entry, 0d, maxUlps) > 0) {\n+ if (Precision.compareTo(entry, 0d, epsilon) > 0) {\n columnsToDrop.add(i);\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMath781"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "A variable used in a method call is replaced by another one.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"expLogicMod",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtElixir",
"rtNopol",
"rtssFix"
],
"revisionId": "3ef79313597d7d49067c48d65a09042d8d94822d"
},
{
"bugId": 37,
"changedFiles": {
"org/apache/commons/math/complex/Complex.java": {
"changes": [
[
1018
],
[
1063
]
],
"inserts": [
[
1021,
1022
],
[
1066
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/complex/Complex.java\n+++ b/src/main/java/org/apache/commons/math/complex/Complex.java\n@@ -1015,9 +1015,15 @@ public Complex sqrt1z() {\n * @since 1.2\n */\n public Complex tan() {\n- if (isNaN) {\n+ if (isNaN || Double.isInfinite(real)) {\n return NaN;\n }\n+ if (imaginary > 20.0) {\n+ return createComplex(0.0, 1.0);\n+ }\n+ if (imaginary < -20.0) {\n+ return createComplex(0.0, -1.0);\n+ }\n \n double real2 = 2.0 * real;\n double imaginary2 = 2.0 * imaginary;\n@@ -1060,9 +1066,15 @@ public Complex tan() {\n * @since 1.2\n */\n public Complex tanh() {\n- if (isNaN) {\n+ if (isNaN || Double.isInfinite(imaginary)) {\n return NaN;\n }\n+ if (real > 20.0) {\n+ return createComplex(1.0, 0.0);\n+ }\n+ if (real < -20.0) {\n+ return createComplex(-1.0, 0.0);\n+ }\n double real2 = 2.0 * real;\n double imaginary2 = 2.0 * imaginary;\n double d = FastMath.cosh(real2) + FastMath.cos(imaginary2);\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<NaN>",
"methodName": "testTanhInf"
},
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<NaN>",
"methodName": "testTan"
},
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<NaN>",
"methodName": "testTanh"
},
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<NaN>",
"methodName": "testTanInf"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 14,
"spreadAllLines": 46,
"spreadCodeOnly": 11
},
"observations": "The changes are almost the same in two different places... same structure, but with variattions in the parameters/arguments.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"condExpExpand",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"expLogicExpand",
"missComp"
],
"repairTools": [],
"revisionId": "65ed08e15af15617e967d3ea9d635dc55a0ef866"
},
{
"bugId": 34,
"changedFiles": {
"org/apache/commons/math3/genetics/ListPopulation.java": {
"changes": [
[
209
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java\n+++ b/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java\n@@ -206,6 +206,6 @@ public String toString() {\n * @return chromosome iterator\n */\n public Iterator<Chromosome> iterator() {\n- return chromosomes.iterator();\n+ return getChromosomes().iterator();\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math3.genetics.ListPopulationTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: java.lang.UnsupportedOperationException",
"methodName": "testIterator"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "A direct class attribute access was replaced by a method call that gives indirect access to the object.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcAdd",
"varReplMc"
],
"repairPatterns": [
"missComp",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtElixir",
"rtHDRepair"
],
"revisionId": "520f36b43a13681db338a07ac6c251cbe1a7a6e5"
},
{
"bugId": 40,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BracketingNthOrderBrentSolver.java": {
"changes": [
[
235
],
[
238
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BracketingNthOrderBrentSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BracketingNthOrderBrentSolver.java\n@@ -232,10 +232,16 @@ protected double doSolve() {\n double targetY;\n if (agingA >= MAXIMAL_AGING) {\n // we keep updating the high bracket, try to compensate this\n- targetY = -REDUCTION_FACTOR * yB;\n+ final int p = agingA - MAXIMAL_AGING;\n+ final double weightA = (1 << p) - 1;\n+ final double weightB = p + 1;\n+ targetY = (weightA * yA - weightB * REDUCTION_FACTOR * yB) / (weightA + weightB);\n } else if (agingB >= MAXIMAL_AGING) {\n // we keep updating the low bracket, try to compensate this\n- targetY = -REDUCTION_FACTOR * yA;\n+ final int p = agingB - MAXIMAL_AGING;\n+ final double weightA = p + 1;\n+ final double weightB = (1 << p) - 1;\n+ targetY = (weightB * yB - weightA * REDUCTION_FACTOR * yA) / (weightA + weightB);\n } else {\n // bracketing is balanced, try to find the root itself\n targetY = 0;\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.BracketingNthOrderBrentSolverTest",
"error": "org.apache.commons.math.exception.TooManyEvaluationsException",
"message": "illegal state: maximal count (100) exceeded: evaluations",
"methodName": "testIssue716"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 2,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"varAdd"
],
"repairPatterns": [
"copyPaste",
"expArithMod",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "c8becc7c47963bcdc1578298846ad6fbf08f64ef"
},
{
"bugId": 38,
"changedFiles": {
"org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java": {
"changes": [
[
1662
],
[
1663
]
],
"deletes": [
[
1660
],
[
1752
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/direct/BOBYQAOptimizer.java\n@@ -1657,10 +1657,10 @@ private void prelim(double[] lowerBound,\n final int tmp2 = jpt;\n jpt = ipt - n;\n ipt = tmp2;\n- throw new PathIsExploredException(); // XXX\n+// throw new PathIsExploredException(); // XXX\n }\n- final int iptMinus1 = ipt;\n- final int jptMinus1 = jpt;\n+ final int iptMinus1 = ipt - 1;\n+ final int jptMinus1 = jpt - 1;\n interpolationPoints.setEntry(nfm, iptMinus1, interpolationPoints.getEntry(ipt, iptMinus1));\n interpolationPoints.setEntry(nfm, jptMinus1, interpolationPoints.getEntry(jpt, jptMinus1));\n }\n@@ -1749,7 +1749,7 @@ private void prelim(double[] lowerBound,\n final int ih = ipt * (ipt - 1) / 2 + jpt - 1;\n final double tmp = interpolationPoints.getEntry(nfm, ipt - 1) * interpolationPoints.getEntry(nfm, jpt - 1);\n modelSecondDerivativesValues.setEntry(ih, (fbeg - fAtInterpolationPoints.getEntry(ipt) - fAtInterpolationPoints.getEntry(jpt) + f) / tmp);\n- throw new PathIsExploredException(); // XXX\n+// throw new PathIsExploredException(); // XXX\n }\n } while (getEvaluations() < npt);\n } // prelim\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.direct.BOBYQAOptimizerTest",
"error": "org.apache.commons.math.optimization.direct.BOBYQAOptimizer$PathIsExploredException",
"message": "If this exception is thrown, just remove it from the code prelim (at line 1752)",
"methodName": "testConstrainedRosenWithMoreInterpolationPoints"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 89,
"spreadCodeOnly": 70
},
"observations": "Removes Exception Thrown. The throws line is commented in code... maybe the change isn't a final one.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"exThrowsRem",
"objInstRem"
],
"repairPatterns": [
"copyPaste",
"expArithMod",
"initFix",
"wrongComp"
],
"repairTools": [
"rtNopol"
],
"revisionId": "91cc42ba0493938aa53585720b315b62c5784a96"
},
{
"bugId": 39,
"changedFiles": {
"org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java": {
"inserts": [
[
250,
251,
252
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n+++ b/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n@@ -247,6 +247,15 @@ public void integrate(final ExpandableStatefulODE equations, final double t)\n }\n \n stepSize = hNew;\n+ if (forward) {\n+ if (stepStart + stepSize >= t) {\n+ stepSize = t - stepStart;\n+ }\n+ } else {\n+ if (stepStart + stepSize <= t) {\n+ stepSize = t - stepStart;\n+ }\n+ }\n \n // next stages\n for (int k = 1; k < stages; ++k) {\n",
"failingTests": [
{
"className": " org.apache.commons.math.ode.nonstiff.DormandPrince853IntegratorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testTooLargeFirstStep"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [
"rtNopol"
],
"revisionId": "74e00296574dc3ac0bc064fc3258faabaf732d6c"
},
{
"bugId": 36,
"changedFiles": {
"org/apache/commons/math/fraction/BigFraction.java": {
"inserts": [
[
686,
687,
688
],
[
733,
734,
735
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/fraction/BigFraction.java\n+++ b/src/main/java/org/apache/commons/math/fraction/BigFraction.java\n@@ -683,8 +683,14 @@ public BigFraction divide(final BigFraction fraction) {\n @Override\n public double doubleValue() {\n double result = numerator.doubleValue() / denominator.doubleValue();\n+ if (Double.isNaN(result)) {\n // Numerator and/or denominator must be out of range:\n // Calculate how far to shift them to put them in range.\n+ int shift = Math.max(numerator.bitLength(),\n+ denominator.bitLength()) - Double.MAX_EXPONENT;\n+ result = numerator.shiftRight(shift).doubleValue() /\n+ denominator.shiftRight(shift).doubleValue();\n+ }\n return result;\n }\n \n@@ -730,8 +736,14 @@ public boolean equals(final Object other) {\n @Override\n public float floatValue() {\n float result = numerator.floatValue() / denominator.floatValue();\n+ if (Double.isNaN(result)) {\n // Numerator and/or denominator must be out of range:\n // Calculate how far to shift them to put them in range.\n+ int shift = Math.max(numerator.bitLength(),\n+ denominator.bitLength()) - Float.MAX_EXPONENT;\n+ result = numerator.shiftRight(shift).floatValue() /\n+ denominator.shiftRight(shift).floatValue();\n+ }\n return result;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.fraction.BigFractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<5.0> but was:<NaN>",
"methodName": "testFloatValueForLargeNumeratorAndDenominator"
},
{
"className": " org.apache.commons.math.fraction.BigFractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<5.0> but was:<NaN>",
"methodName": "testDoubleValueForLargeNumeratorAndDenominator"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 12,
"spreadAllLines": 49,
"spreadCodeOnly": 17
},
"observations": "The change is almost the same in two different places. The only difference between changes is the use of the call \"doubleValue()\" in place of \"floatValue()\" in correspondent methods.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"copyPaste",
"missComp"
],
"repairTools": [],
"revisionId": "1a15d5f4c13eca0435b0ed7e6a624064e7f7e07f"
},
{
"bugId": 42,
"changedFiles": {
"org/apache/commons/math/optimization/linear/SimplexTableau.java": {
"inserts": [
[
410,
411,
412,
413
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n+++ b/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n@@ -407,10 +407,12 @@ protected RealPointValuePair getSolution() {\n continue;\n }\n Integer basicRow = getBasicRow(colIndex);\n+ if (basicRow != null && basicRow == 0) {\n // if the basic row is found to be the objective function row\n // set the coefficient to 0 -> this case handles unconstrained \n // variables that are still part of the objective function\n- if (basicRows.contains(basicRow)) {\n+ coefficients[i] = 0;\n+ } else if (basicRows.contains(basicRow)) {\n // if multiple variables can take a given value\n // then we choose the first and set the rest equal to 0\n coefficients[i] = 0 - (restrictToNonNegative ? 0 : mostNegative);\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMath713NegativeVariable"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 3,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd"
],
"repairPatterns": [
"missNullCheckN",
"wrapsIfElse",
"wrongComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "e98a5000cd211539bf4ba65f62cc7f81395e1726"
},
{
"bugId": 41,
"changedFiles": {
"org/apache/commons/math/stat/descriptive/moment/Variance.java": {
"changes": [
[
520
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java\n+++ b/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java\n@@ -517,7 +517,7 @@ public double evaluate(final double[] values, final double[] weights,\n }\n \n double sumWts = 0;\n- for (int i = 0; i < weights.length; i++) {\n+ for (int i = begin; i < begin + length; i++) {\n sumWts += weights[i];\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.descriptive.moment.VarianceTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.6644508338125354> but was:<0.31909161062727365>",
"methodName": "testEvaluateArraySegmentWeighted"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "The changes were made only inside the for loop.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"loopCondChange",
"loopInitChange",
"varReplVar"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "882556eabbeb2f62939aee29afdec2a01ce4bbe1"
},
{
"bugId": 44,
"changedFiles": {
"org/apache/commons/math/ode/AbstractIntegrator.java": {
"deletes": [
[
280
]
],
"inserts": [
[
334
],
[
343
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java\n+++ b/src/main/java/org/apache/commons/math/ode/AbstractIntegrator.java\n@@ -277,7 +277,6 @@ protected double acceptStep(final AbstractStepInterpolator interpolator,\n \n double previousT = interpolator.getGlobalPreviousTime();\n final double currentT = interpolator.getGlobalCurrentTime();\n- resetOccurred = false;\n \n // initialize the events states if needed\n if (! statesInitialized) {\n@@ -331,6 +330,9 @@ public int compare(EventState es0, EventState es1) {\n if (isLastStep) {\n // the event asked to stop integration\n System.arraycopy(eventY, 0, y, 0, y.length);\n+ for (final EventState remaining : occuringEvents) {\n+ remaining.stepAccepted(eventT, eventY);\n+ }\n return eventT;\n }\n \n@@ -340,6 +342,9 @@ public int compare(EventState es0, EventState es1) {\n System.arraycopy(eventY, 0, y, 0, y.length);\n computeDerivatives(eventT, y, yDot);\n resetOccurred = true;\n+ for (final EventState remaining : occuringEvents) {\n+ remaining.stepAccepted(eventT, eventY);\n+ }\n return eventT;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.ode.events.EventStateTest",
"error": "junit.framework.AssertionFailedError",
"message": "going backard in time! (7.796578226186635 < 10.99)",
"methodName": "testIssue695"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 0,
"linesRem": 1,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 62,
"spreadCodeOnly": 39
},
"observations": "The variable and assignment adding are part of the for loop.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"copyPaste",
"missComp"
],
"repairTools": [
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtNopol"
],
"revisionId": "53c8cec5ceb4cd81e3f9b8858814accac83a324e"
},
{
"bugId": 43,
"changedFiles": {
"org/apache/commons/math/stat/descriptive/SummaryStatistics.java": {
"changes": [
[
158
],
[
161
],
[
164
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java\n+++ b/src/main/java/org/apache/commons/math/stat/descriptive/SummaryStatistics.java\n@@ -155,13 +155,13 @@ public void addValue(double value) {\n secondMoment.increment(value);\n // If mean, variance or geomean have been overridden,\n // need to increment these\n- if (!(meanImpl instanceof Mean)) {\n+ if (meanImpl != mean) {\n meanImpl.increment(value);\n }\n- if (!(varianceImpl instanceof Variance)) {\n+ if (varianceImpl != variance) {\n varianceImpl.increment(value);\n }\n- if (!(geoMeanImpl instanceof GeometricMean)) {\n+ if (geoMeanImpl != geoMean) {\n geoMeanImpl.increment(value);\n }\n n++;\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.descriptive.SummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2.5> but was:<NaN>",
"methodName": "testOverrideMeanWithMathClass"
},
{
"className": " org.apache.commons.math.stat.descriptive.SummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2.213363839400643> but was:<NaN>",
"methodName": "testOverrideGeoMeanWithMathClass"
},
{
"className": " org.apache.commons.math.stat.descriptive.SummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.25> but was:<NaN>",
"methodName": "testOverrideVarianceWithMathClass"
},
{
"className": " org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2.5> but was:<NaN>",
"methodName": "testOverrideMeanWithMathClass"
},
{
"className": " org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2.213363839400643> but was:<NaN>",
"methodName": "testOverrideGeoMeanWithMathClass"
},
{
"className": " org.apache.commons.math.stat.descriptive.SynchronizedSummaryStatisticsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.25> but was:<NaN>",
"methodName": "testOverrideVarianceWithMathClass"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 4,
"spreadCodeOnly": 4
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod"
],
"repairTools": [],
"revisionId": "dcae84b2e8f025e93340307d8bc04d406202c323"
},
{
"bugId": 47,
"changedFiles": {
"org/apache/commons/math/complex/Complex.java": {
"changes": [
[
256
],
[
257
],
[
293
]
],
"inserts": [
[
-1
],
[
99,
100,
101,
102,
103,
104,
105
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/complex/Complex.java\n+++ b/src/main/java/org/apache/commons/math/complex/Complex.java\n@@ -1,87 +1,88 @@\n /*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n \n package org.apache.commons.math.complex;\n \n import java.io.Serializable;\n import java.util.ArrayList;\n import java.util.List;\n \n import org.apache.commons.math.FieldElement;\n import org.apache.commons.math.exception.NullArgumentException;\n import org.apache.commons.math.exception.NotPositiveException;\n import org.apache.commons.math.exception.util.LocalizedFormats;\n import org.apache.commons.math.util.MathUtils;\n import org.apache.commons.math.util.FastMath;\n \n /**\n * Representation of a Complex number, i.e. a number which has both a\n * real and imaginary part.\n * <br/>\n * Implementations of arithmetic operations handle {@code NaN} and\n * infinite values according to the rules for {@link java.lang.Double}, i.e.\n * {@link #equals} is an equivalence relation for all instances that have\n * a {@code NaN} in either real or imaginary part, e.g. the following are\n * considered equal:\n * <ul>\n * <li>{@code 1 + NaNi}</li>\n * <li>{@code NaN + i}</li>\n * <li>{@code NaN + NaNi}</li>\n * </ul>\n * Note that this is in contradiction with the IEEE-754 standard for floating\n * point numbers (according to which the test {@code x == x} must fail if\n * {@code x} is {@code NaN}). The method\n * {@link MathUtils#equals(double,double,int) equals for primitive double} in\n * {@link MathUtils} conforms with IEEE-754 while this class conforms with\n * the standard behavior for Java object types.\n * <br/>\n * Implements Serializable since 2.0\n *\n * @version $Id$\n */\n public class Complex implements FieldElement<Complex>, Serializable {\n /** The square root of -1. A number representing \"0.0 + 1.0i\" */\n public static final Complex I = new Complex(0.0, 1.0);\n // CHECKSTYLE: stop ConstantName\n /** A complex number representing \"NaN + NaNi\" */\n public static final Complex NaN = new Complex(Double.NaN, Double.NaN);\n // CHECKSTYLE: resume ConstantName\n /** A complex number representing \"+INF + INFi\" */\n public static final Complex INF = new Complex(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);\n /** A complex number representing \"1.0 + 0.0i\" */\n public static final Complex ONE = new Complex(1.0, 0.0);\n /** A complex number representing \"0.0 + 0.0i\" */\n public static final Complex ZERO = new Complex(0.0, 0.0);\n \n /** Serializable version identifier */\n private static final long serialVersionUID = -6195664516687396620L;\n \n /** The imaginary part. */\n private final double imaginary;\n /** The real part. */\n private final double real;\n /** Record whether this complex number is equal to NaN. */\n private final transient boolean isNaN;\n /** Record whether this complex number is infinite. */\n private final transient boolean isInfinite;\n /** Record whether this complex number is zero. */\n+ private final transient boolean isZero;\n \n /**\n * Create a complex number given only the real part.\n *\n * @param real Real part.\n */\n@@ -98,17 +99,18 @@ public Complex(double real) {\n public Complex(double real, double imaginary) {\n this.real = real;\n this.imaginary = imaginary;\n \n isNaN = Double.isNaN(real) || Double.isNaN(imaginary);\n isInfinite = !isNaN &&\n (Double.isInfinite(real) || Double.isInfinite(imaginary));\n+ isZero = real == 0 && imaginary == 0;\n }\n \n /**\n * Return the absolute value of this complex number.\n * Returns {@code NaN} if either real or imaginary part is {@code NaN}\n * and {@code Double.POSITIVE_INFINITY} if neither part is {@code NaN},\n * but at least one part is infinite.\n *\n * @return the absolute value.\n */\n@@ -249,60 +251,60 @@ public Complex conjugate() {\n public Complex divide(Complex divisor)\n throws NullArgumentException {\n MathUtils.checkNotNull(divisor);\n if (isNaN || divisor.isNaN) {\n return NaN;\n }\n \n- if (divisor.getReal() == 0.0 && divisor.getImaginary() == 0.0) {\n- return NaN;\n+ if (divisor.isZero) {\n+ return isZero ? NaN : INF;\n }\n \n if (divisor.isInfinite() && !isInfinite()) {\n return ZERO;\n }\n \n final double c = divisor.getReal();\n final double d = divisor.getImaginary();\n \n if (FastMath.abs(c) < FastMath.abs(d)) {\n double q = c / d;\n double denominator = c * q + d;\n return createComplex((real * q + imaginary) / denominator,\n (imaginary * q - real) / denominator);\n } else {\n double q = d / c;\n double denominator = d * q + c;\n return createComplex((imaginary * q + real) / denominator,\n (imaginary - real * q) / denominator);\n }\n }\n \n /**\n * Returns a {@code Complex} whose value is {@code (this / divisor)},\n * with {@code divisor} interpreted as a real number.\n *\n * @param divisor Value by which this {@code Complex} is to be divided.\n * @return {@code this / divisor}.\n * @see #divide(Complex)\n */\n public Complex divide(double divisor) {\n if (isNaN || Double.isNaN(divisor)) {\n return NaN;\n }\n if (divisor == 0d) {\n- return NaN;\n+ return isZero ? NaN : INF;\n }\n if (Double.isInfinite(divisor)) {\n return !isInfinite() ? ZERO : NaN;\n }\n return createComplex(real / divisor,\n imaginary / divisor);\n }\n \n /**\n * Test for the equality of two Complex objects.\n * If both the real and imaginary parts of two complex numbers\n * are exactly the same, and neither is {@code Double.NaN}, the two\n * Complex objects are considered to be equal.\n * All {@code NaN} values are considered to be equal - i.e, if either\n * (or both) real and imaginary parts of the complex number are equal\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAtanI"
},
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<(NaN, NaN)> but was:<(Infinity, Infinity)>",
"methodName": "testDivideZero"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 209,
"spreadCodeOnly": 80
},
"observations": "The \"WrapWith\" condition is in the form \"exp?a:b\". The added variable is a class attribute.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"condExpMod",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"copyPaste",
"expLogicMod",
"wrapsIfElse",
"wrongComp"
],
"repairTools": [],
"revisionId": "330f3fe17d132bd4e2a91ff812ccf489e77f390f"
},
{
"bugId": 48,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BaseSecantSolver.java": {
"inserts": [
[
187,
188,
189
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n@@ -186,6 +186,9 @@ protected final double doSolve() {\n case REGULA_FALSI:\n // Detect early that algorithm is stuck, instead of waiting\n // for the maximum number of iterations to be exceeded.\n+ if (x == x1) {\n+ throw new ConvergenceException();\n+ }\n break;\n default:\n // Should never happen.\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.RegulaFalsiSolverTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.apache.commons.math.exception.ConvergenceException> but was<org.apache.commons.math.exception.TooManyEvaluationsException>",
"methodName": "testIssue631"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [],
"revisionId": "13d22f45624470ce5c07c085cf8b1ec0251eaee6"
},
{
"bugId": 50,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BaseSecantSolver.java": {
"deletes": [
[
187
],
[
188
],
[
189
],
[
190
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n@@ -184,10 +184,6 @@ protected final double doSolve() {\n break;\n case REGULA_FALSI:\n // Nothing.\n- if (x == x1) {\n- x0 = 0.5 * (x0 + x1 - FastMath.max(rtol * FastMath.abs(x1), atol));\n- f0 = computeObjectiveValue(x0);\n- }\n break;\n default:\n // Should never happen.\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.RegulaFalsiSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math.exception.TooManyEvaluationsException",
"methodName": "testIssue631"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 0,
"linesRem": 4,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignRem",
"condBranRem",
"mcRem"
],
"repairPatterns": [
"condBlockRem"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtJAID",
"rtKali",
"rtNopol",
"rtssFix"
],
"revisionId": "39cf5e69259d7560d50553caf028f9229b721013"
},
{
"bugId": 49,
"changedFiles": {
"org/apache/commons/math/linear/OpenMapRealVector.java": {
"changes": [
[
345
],
[
358
],
[
370
],
[
383
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java\n+++ b/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java\n@@ -342,7 +342,7 @@ public double dotProduct(RealVector v) {\n public OpenMapRealVector ebeDivide(RealVector v) {\n checkVectorDimensions(v.getDimension());\n OpenMapRealVector res = new OpenMapRealVector(this);\n- Iterator iter = res.entries.iterator();\n+ Iterator iter = entries.iterator();\n while (iter.hasNext()) {\n iter.advance();\n res.setEntry(iter.key(), iter.value() / v.getEntry(iter.key()));\n@@ -355,7 +355,7 @@ public OpenMapRealVector ebeDivide(RealVector v) {\n public OpenMapRealVector ebeDivide(double[] v) {\n checkVectorDimensions(v.length);\n OpenMapRealVector res = new OpenMapRealVector(this);\n- Iterator iter = res.entries.iterator();\n+ Iterator iter = entries.iterator();\n while (iter.hasNext()) {\n iter.advance();\n res.setEntry(iter.key(), iter.value() / v[iter.key()]);\n@@ -367,7 +367,7 @@ public OpenMapRealVector ebeDivide(double[] v) {\n public OpenMapRealVector ebeMultiply(RealVector v) {\n checkVectorDimensions(v.getDimension());\n OpenMapRealVector res = new OpenMapRealVector(this);\n- Iterator iter = res.entries.iterator();\n+ Iterator iter = entries.iterator();\n while (iter.hasNext()) {\n iter.advance();\n res.setEntry(iter.key(), iter.value() * v.getEntry(iter.key()));\n@@ -380,7 +380,7 @@ public OpenMapRealVector ebeMultiply(RealVector v) {\n public OpenMapRealVector ebeMultiply(double[] v) {\n checkVectorDimensions(v.length);\n OpenMapRealVector res = new OpenMapRealVector(this);\n- Iterator iter = res.entries.iterator();\n+ Iterator iter = entries.iterator();\n while (iter.hasNext()) {\n iter.advance();\n res.setEntry(iter.key(), iter.value() * v[iter.key()]);\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.SparseRealVectorTest",
"error": "org.apache.commons.math.MathRuntimeException$6",
"message": "map has been modified while iterating",
"methodName": "testConcurrentModification"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 4,
"linesRem": 0,
"methods": 4,
"sizeInLines": 4,
"spreadAllLines": 35,
"spreadCodeOnly": 29
},
"observations": "Changed the target of a iterator access.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"varReplVar"
],
"repairPatterns": [
"copyPaste",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "09e35881f1ad74335707e70aa78fd347e37d1066"
},
{
"bugId": 46,
"changedFiles": {
"org/apache/commons/math/complex/Complex.java": {
"changes": [
[
260
],
[
297
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/complex/Complex.java\n+++ b/src/main/java/org/apache/commons/math/complex/Complex.java\n@@ -257,7 +257,7 @@ public Complex divide(Complex divisor)\n \n if (divisor.isZero) {\n // return isZero ? NaN : INF; // See MATH-657\n- return isZero ? NaN : INF;\n+ return NaN;\n }\n \n if (divisor.isInfinite() && !isInfinite()) {\n@@ -294,7 +294,7 @@ public Complex divide(double divisor) {\n }\n if (divisor == 0d) {\n // return isZero ? NaN : INF; // See MATH-657\n- return isZero ? NaN : INF;\n+ return NaN;\n }\n if (Double.isInfinite(divisor)) {\n return !isInfinite() ? ZERO : NaN;\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAtanI"
},
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<(Infinity, Infinity)> but was:<(NaN, NaN)>",
"methodName": "testDivideZero"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 36,
"spreadCodeOnly": 23
},
"observations": "The removed if-else condition is in the form \"exp?a:b\".",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranRem",
"retExpChange"
],
"repairPatterns": [
"copyPaste",
"unwrapIfElse"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth"
],
"revisionId": "e6f27ebcb9ee0a344308382b99a3894bb61b225d"
},
{
"bugId": 45,
"changedFiles": {
"org/apache/commons/math/linear/OpenMapRealMatrix.java": {
"inserts": [
[
50
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java\n+++ b/src/main/java/org/apache/commons/math/linear/OpenMapRealMatrix.java\n@@ -47,6 +47,11 @@\n */\n public OpenMapRealMatrix(int rowDimension, int columnDimension) {\n super(rowDimension, columnDimension);\n+ long lRow = (long) rowDimension;\n+ long lCol = (long) columnDimension;\n+ if (lRow * lCol >= (long) Integer.MAX_VALUE) {\n+ throw new NumberIsTooLargeException(lRow * lCol, Integer.MAX_VALUE, false);\n+ }\n this.rows = rowDimension;\n this.columns = columnDimension;\n this.entries = new OpenIntToDoubleHashMap(0.0);\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.OpenMapRealMatrixTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math.exception.NumberIsTooLargeException",
"methodName": "testMath679"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [],
"revisionId": "bc4e9db01c2a03062965fa4bac65782376ab2287"
},
{
"bugId": 51,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BaseSecantSolver.java": {
"inserts": [
[
179,
182,
185,
186,
187
],
[
188,
189
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BaseSecantSolver.java\n@@ -182,10 +182,19 @@ protected final double doSolve() {\n case PEGASUS:\n f0 *= f1 / (f1 + fx);\n break;\n+ case REGULA_FALSI:\n+ if (x == x1) {\n+ final double delta = FastMath.max(rtol * FastMath.abs(x1),\n+ atol);\n // Update formula cannot make any progress: Update the\n // search interval.\n+ x0 = 0.5 * (x0 + x1 - delta);\n+ f0 = computeObjectiveValue(x0);\n+ }\n+ break;\n default:\n // Should never happen.\n+ throw new MathInternalError();\n }\n }\n // Update from [x0, x1] to [x0, x].\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.RegulaFalsiSolverTest",
"error": "org.apache.commons.math.exception.TooManyEvaluationsException",
"message": "illegal state: maximal count (3,624) exceeded: evaluations",
"methodName": "testIssue631"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 4,
"spreadCodeOnly": 1
},
"observations": "Adds an exception throw in default clause of switch-case.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranCaseAdd",
"condBranIfAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "2f066a5b2d2fe8a00a251a3220b0d52446fe392d"
},
{
"bugId": 58,
"changedFiles": {
"org/apache/commons/math/optimization/fitting/GaussianFitter.java": {
"changes": [
[
121
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java\n+++ b/src/main/java/org/apache/commons/math/optimization/fitting/GaussianFitter.java\n@@ -118,7 +118,7 @@ public double value(double x, double[] p) {\n */\n public double[] fit() {\n final double[] guess = (new ParameterGuesser(getObservations())).guess();\n- return fit(new Gaussian.Parametric(), guess);\n+ return fit(guess);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.fitting.GaussianFitterTest",
"error": "org.apache.commons.math.exception.NotStrictlyPositiveException",
"message": "-1.277 is smaller than, or equal to, the minimum (0)",
"methodName": "testMath519"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Call overloaded method without one parameter.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcParRem",
"mcRepl",
"objInstRem",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtNopol",
"rtssFix"
],
"revisionId": "45add3a0e7e2e94bfc29e85c9ef0856e2e473a33"
},
{
"bugId": 59,
"changedFiles": {
"org/apache/commons/math/util/FastMath.java": {
"changes": [
[
3482
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/util/FastMath.java\n+++ b/src/main/java/org/apache/commons/math/util/FastMath.java\n@@ -3479,7 +3479,7 @@ public static long max(final long a, final long b) {\n * @return b if a is lesser or equal to b, a otherwise\n */\n public static float max(final float a, final float b) {\n- return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : b);\n+ return (a <= b) ? b : (Float.isNaN(a + b) ? Float.NaN : a);\n }\n \n /** Compute the maximum of two values\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.FastMathTest",
"error": "junit.framework.AssertionFailedError",
"message": "max(50.0, -50.0) expected:<50.0> but was:<-50.0>",
"methodName": "testMinMaxFloat"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"retExpChange",
"varReplVar"
],
"repairPatterns": [
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtElixir"
],
"revisionId": "5dcca48038fb6274cc155251d09db12746ccce71"
},
{
"bugId": 57,
"changedFiles": {
"org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java": {
"changes": [
[
175
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java\n+++ b/src/main/java/org/apache/commons/math/stat/clustering/KMeansPlusPlusClusterer.java\n@@ -172,7 +172,7 @@ public KMeansPlusPlusClusterer(final Random random, final EmptyClusterStrategy e\n while (resultSet.size() < k) {\n // For each data point x, compute D(x), the distance between x and\n // the nearest center that has already been chosen.\n- int sum = 0;\n+ double sum = 0;\n for (int i = 0; i < pointSet.size(); i++) {\n final T p = pointSet.get(i);\n final Cluster<T> nearest = getNearestCluster(resultSet, p);\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.clustering.KMeansPlusPlusClustererTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSmallDistances"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Just changed the declared type of a primitive variable.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"varTyChange"
],
"repairPatterns": [
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtNopol",
"rtssFix"
],
"revisionId": "00fea9d8078d487e31cec8292dbd9bd69bc9c216"
},
{
"bugId": 53,
"changedFiles": {
"org/apache/commons/math/complex/Complex.java": {
"inserts": [
[
153
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/complex/Complex.java\n+++ b/src/main/java/org/apache/commons/math/complex/Complex.java\n@@ -150,6 +150,9 @@ public double abs() {\n public Complex add(Complex rhs)\n throws NullArgumentException {\n MathUtils.checkNotNull(rhs);\n+ if (isNaN || rhs.isNaN) {\n+ return NaN;\n+ }\n return createComplex(real + rhs.getReal(),\n imaginary + rhs.getImaginary());\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testAddNaN"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [
"rtDeepRepair",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtJAID",
"rtssFix"
],
"revisionId": "7707b0bb80be05bbf6533a36bb0c646cbfd1026d"
},
{
"bugId": 61,
"changedFiles": {
"org/apache/commons/math/distribution/PoissonDistributionImpl.java": {
"changes": [
[
22
],
[
94
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java\n+++ b/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java\n@@ -19,7 +19,7 @@\n import java.io.Serializable;\n \n import org.apache.commons.math.MathException;\n-import org.apache.commons.math.MathRuntimeException;\n+import org.apache.commons.math.exception.NotStrictlyPositiveException;\n import org.apache.commons.math.exception.util.LocalizedFormats;\n import org.apache.commons.math.special.Gamma;\n import org.apache.commons.math.util.MathUtils;\n@@ -91,7 +91,7 @@ public PoissonDistributionImpl(double p) {\n */\n public PoissonDistributionImpl(double p, double epsilon, int maxIterations) {\n if (p <= 0) {\n- throw MathRuntimeException.createIllegalArgumentException(LocalizedFormats.NOT_POSITIVE_POISSON_MEAN, p);\n+ throw new NotStrictlyPositiveException(LocalizedFormats.MEAN, p);\n }\n mean = p;\n normal = new NormalDistributionImpl(p, FastMath.sqrt(p));\n",
"failingTests": [
{
"className": " org.apache.commons.math.distribution.PoissonDistributionTest",
"error": "org.apache.commons.math.MathRuntimeException$4",
"message": "the Poisson mean must be positive (-1)",
"methodName": "testMean"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 71,
"spreadCodeOnly": 18
},
"observations": "Replaces Exception Thrown. Changed the type of exception thrown. Changed the imported type.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcRem",
"objInstAdd"
],
"repairPatterns": [
"initFix",
"notClassified"
],
"repairTools": [
"rtAcs"
],
"revisionId": "f76efe5f4ef36fadc677c94269927076f2f42eb9"
},
{
"bugId": 55,
"changedFiles": {
"org/apache/commons/math/geometry/Vector3D.java": {
"changes": [
[
473
]
],
"inserts": [
[
458,
459,
460,
461,
462,
463,
464,
465,
466,
467,
468,
469,
470,
471,
472,
473
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/geometry/Vector3D.java\n+++ b/src/main/java/org/apache/commons/math/geometry/Vector3D.java\n@@ -456,9 +456,21 @@ public static double dotProduct(Vector3D v1, Vector3D v2) {\n */\n public static Vector3D crossProduct(final Vector3D v1, final Vector3D v2) {\n \n+ final double n1 = v1.getNormSq();\n+ final double n2 = v2.getNormSq();\n+ if ((n1 * n2) < MathUtils.SAFE_MIN) {\n+ return ZERO;\n+ }\n \n // rescale both vectors without losing precision,\n // to ensure their norm are the same order of magnitude\n+ final int deltaExp = (FastMath.getExponent(n1) - FastMath.getExponent(n2)) / 4;\n+ final double x1 = FastMath.scalb(v1.x, -deltaExp);\n+ final double y1 = FastMath.scalb(v1.y, -deltaExp);\n+ final double z1 = FastMath.scalb(v1.z, -deltaExp);\n+ final double x2 = FastMath.scalb(v2.x, deltaExp);\n+ final double y2 = FastMath.scalb(v2.y, deltaExp);\n+ final double z2 = FastMath.scalb(v2.z, deltaExp);\n \n // we reduce cancellation errors by preconditioning,\n // we replace v1 by v3 = v1 - rho v2 with rho chosen in order to compute\n@@ -467,10 +479,15 @@ public static Vector3D crossProduct(final Vector3D v1, final Vector3D v2) {\n // available at http://www.cs.berkeley.edu/~wkahan/MathH110/Cross.pdf\n \n // compute rho as an 8 bits approximation of v1.v2 / v2.v2\n+ final double ratio = (x1 * x2 + y1 * y2 + z1 * z2) / FastMath.scalb(n2, 2 * deltaExp);\n+ final double rho = FastMath.rint(256 * ratio) / 256;\n \n+ final double x3 = x1 - rho * x2;\n+ final double y3 = y1 - rho * y2;\n+ final double z3 = z1 - rho * z2;\n \n // compute cross product from v3 and v2 instead of v1 and v2\n- return new Vector3D(v1.y * v2.z - v1.z * v2.y, v1.z * v2.x - v1.x * v2.z, v1.x * v2.y - v1.y * v2.x);\n+ return new Vector3D(y3 * z2 - z3 * y2, z3 * x2 - x3 * z2, x3 * y2 - y3 * x2);\n \n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.geometry.Vector3DTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<0.0>",
"methodName": "testCrossProductCancellation"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 17,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 18,
"spreadAllLines": 14,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"mcParValChange",
"objInstMod",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"expArithMod",
"initFix",
"wrongComp"
],
"repairTools": [],
"revisionId": "0c38504ffa3ef520ce78e260538d7b8742c895e8"
},
{
"bugId": 60,
"changedFiles": {
"org/apache/commons/math/distribution/NormalDistributionImpl.java": {
"deletes": [
[
126
],
[
129
],
[
130
],
[
131
],
[
132
],
[
133
],
[
134
],
[
135
],
[
136
],
[
137
]
],
"inserts": [
[
126,
127
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java\n+++ b/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java\n@@ -123,18 +123,11 @@ public double density(double x) {\n */\n public double cumulativeProbability(double x) throws MathException {\n final double dev = x - mean;\n- try {\n+ if (FastMath.abs(dev) > 40 * standardDeviation) { \n+ return dev < 0 ? 0.0d : 1.0d;\n+ }\n return 0.5 * (1.0 + Erf.erf((dev) /\n (standardDeviation * FastMath.sqrt(2.0))));\n- } catch (MaxIterationsExceededException ex) {\n- if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38\n- return 0;\n- } else if (x > (mean + 20 * standardDeviation)) {\n- return 1;\n- } else {\n- throw ex;\n- }\n- }\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.distribution.NormalDistributionTest",
"error": "org.apache.commons.math.ConvergenceException",
"message": "Continued fraction diverged to NaN for value ∞",
"methodName": "testExtremeValues"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 9,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "Unwraps try-catch.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"condBranIfElseAdd",
"condBranRem",
"exThrowsRem",
"exTryCatchRem",
"mcAdd",
"retBranchAdd",
"retRem"
],
"repairPatterns": [
"blockRemove",
"condBlockRem",
"condBlockRetAdd",
"unwrapTryCatch"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGenProg"
],
"revisionId": "9054aac4b948117b838d6a5b15be1f50965d805a"
},
{
"bugId": 54,
"changedFiles": {
"org/apache/commons/math/dfp/Dfp.java": {
"changes": [
[
2319
]
],
"inserts": [
[
272,
273
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/dfp/Dfp.java\n+++ b/src/main/java/org/apache/commons/math/dfp/Dfp.java\n@@ -270,6 +270,9 @@ protected Dfp(final DfpField field, double x) {\n // Zero or sub-normal\n if (x == 0) {\n // make sure 0 has the right sign\n+ if ((bits & 0x8000000000000000L) != 0) {\n+ sign = -1;\n+ }\n return;\n }\n \n@@ -2316,7 +2319,10 @@ public double toDouble() {\n \n Dfp y = this;\n boolean negate = false;\n- if (lessThan(getZero())) {\n+ int cmp0 = compare(this, getZero());\n+ if (cmp0 == 0) {\n+ return sign < 0 ? -0.0 : +0.0;\n+ } else if (cmp0 < 0) {\n y = negate();\n negate = true;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.dfp.DfpTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<-Infinity>",
"methodName": "testIssue567"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 2046,
"spreadCodeOnly": 1332
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpMod",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "c00ac8120a4215125e49775cd9351e689586b467"
},
{
"bugId": 56,
"changedFiles": {
"org/apache/commons/math/util/MultidimensionalCounter.java": {
"changes": [
[
243
]
],
"deletes": [
[
237
],
[
238
],
[
239
],
[
240
],
[
241
],
[
242
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java\n+++ b/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java\n@@ -234,13 +234,7 @@ public int getDimension() {\n indices[i] = idx;\n }\n \n- int idx = 1;\n- while (count < index) {\n- count += idx;\n- ++idx;\n- }\n- --idx;\n- indices[last] = idx;\n+ indices[last] = index - count;\n \n return indices;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MultidimensionalCounterTest",
"error": "junit.framework.AssertionFailedError",
"message": "Wrong multidimensional index for [3][2] expected:<3> but was:<2>",
"methodName": "testIterationConsistency"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 6,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaces a wrong and more complex calculation by the correct and simpler one.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"assignRem",
"loopRem",
"varRem"
],
"repairPatterns": [
"blockRemove",
"expArithMod",
"wrongComp"
],
"repairTools": [
"rtDeepRepair",
"rtGPFL"
],
"revisionId": "e06fe05e2dd68936e770ba67caa7b9924568170d"
},
{
"bugId": 52,
"changedFiles": {
"org/apache/commons/math/geometry/euclidean/threed/Rotation.java": {
"changes": [
[
344
],
[
353
],
[
359
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Rotation.java\n+++ b/src/main/java/org/apache/commons/math/geometry/euclidean/threed/Rotation.java\n@@ -341,7 +341,8 @@ public Rotation(Vector3D u1, Vector3D u2, Vector3D v1, Vector3D v2) {\n Vector3D k = v1Su1.crossProduct(v2Su2);\n Vector3D u3 = u1.crossProduct(u2);\n double c = k.dotProduct(u3);\n- if (c == 0) {\n+ final double inPlaneThreshold = 0.001;\n+ if (c <= inPlaneThreshold * k.getNorm() * u3.getNorm()) {\n // the (q1, q2, q3) vector is close to the (u1, u2) plane\n // we try other vectors\n Vector3D v3 = Vector3D.crossProduct(v1, v2);\n@@ -350,13 +351,13 @@ public Rotation(Vector3D u1, Vector3D u2, Vector3D v1, Vector3D v2) {\n Vector3D u2Prime = u1.crossProduct(u3);\n c = k.dotProduct(u2Prime);\n \n- if (c == 0) {\n+ if (c <= inPlaneThreshold * k.getNorm() * u2Prime.getNorm()) {\n // the (q1, q2, q3) vector is also close to the (u1, u3) plane,\n // it is almost aligned with u1: we try (u2, u3) and (v2, v3)\n k = v2Su2.crossProduct(v3Su3);;\n c = k.dotProduct(u2.crossProduct(u3));;\n \n- if (c == 0) {\n+ if (c <= 0) {\n // the (q1, q2, q3) vector is aligned with everything\n // this is really the identity rotation\n q0 = 1.0;\n",
"failingTests": [
{
"className": " org.apache.commons.math.geometry.euclidean.threed.RotationTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.6228370359608201> but was:<NaN>",
"methodName": "testIssue639"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 3,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 13,
"spreadCodeOnly": 7
},
"observations": "New variable is added with its initialization.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condExpMod",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"expLogicMod",
"initFix"
],
"repairTools": [],
"revisionId": "3c319db494928e9d51ea6091b301302c65f4eceb"
},
{
"bugId": 63,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"changes": [
[
417
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/main/java/org/apache/commons/math/util/MathUtils.java\n@@ -414,7 +414,7 @@ public static double cosh(double x) {\n * @return {@code true} if the values are equal.\n */\n public static boolean equals(double x, double y) {\n- return (Double.isNaN(x) && Double.isNaN(y)) || x == y;\n+ return equals(x, y, 1);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testArrayEquals"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcAdd",
"mcRem",
"retExpChange"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir"
],
"revisionId": "d2a5bc02c002acfa220ce8bad23b9e8af137f47d"
},
{
"bugId": 62,
"changedFiles": {
"org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java": {
"changes": [
[
146
],
[
160
],
[
161
],
[
162
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/univariate/MultiStartUnivariateRealOptimizer.java\n@@ -143,7 +143,7 @@ public UnivariateRealPointValuePair optimize(final FUNC f,\n final GoalType goal,\n final double min, final double max)\n throws FunctionEvaluationException {\n- return optimize(f, goal, min, max, 0);\n+ return optimize(f, goal, min, max, min + 0.5 * (max - min));\n }\n \n /** {@inheritDoc} */\n@@ -157,9 +157,8 @@ public UnivariateRealPointValuePair optimize(final FUNC f, final GoalType goal,\n // Multi-start loop.\n for (int i = 0; i < starts; ++i) {\n try {\n- final double bound1 = (i == 0) ? min : min + generator.nextDouble() * (max - min);\n- final double bound2 = (i == 0) ? max : min + generator.nextDouble() * (max - min);\n- optima[i] = optimizer.optimize(f, goal, FastMath.min(bound1, bound2), FastMath.max(bound1, bound2));\n+ final double s = (i == 0) ? startValue : min + generator.nextDouble() * (max - min);\n+ optima[i] = optimizer.optimize(f, goal, min, max, s);\n } catch (FunctionEvaluationException fee) {\n optima[i] = null;\n } catch (ConvergenceException ce) {\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.univariate.MultiStartUnivariateRealOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0.2719561293> but was:<-0.2719561278056452>",
"methodName": "testQuinticMin"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 1,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 13,
"spreadCodeOnly": 9
},
"observations": "Changes the way to compute \"optima[i]\", changing params for call to \"optimize\". Removed if-branch is in the form \"exp?a:b\".",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"assignRem",
"condBranIfElseAdd",
"condBranRem",
"mcAdd",
"mcParAdd",
"mcParValChange",
"mcRem",
"mcRepl",
"retExpChange",
"varAdd",
"varRem"
],
"repairPatterns": [
"expArithMod",
"wrongComp",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen"
],
"revisionId": "8de3eb542b2be80ba309b2c91ae1dba75bdb5063"
},
{
"bugId": 66,
"changedFiles": {
"org/apache/commons/math/optimization/univariate/BrentOptimizer.java": {
"changes": [
[
44
],
[
46
],
[
47
],
[
57
],
[
93
],
[
94
],
[
95
],
[
96
],
[
97
],
[
119
],
[
120
],
[
126
],
[
127
],
[
200
],
[
201
],
[
238
],
[
241
]
],
"deletes": [
[
59
],
[
60
],
[
61
],
[
62
],
[
63
],
[
64
],
[
65
],
[
66
],
[
67
],
[
243
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java\n@@ -41,10 +41,10 @@\n * Construct a solver.\n */\n public BrentOptimizer() {\n- setMaxEvaluations(Integer.MAX_VALUE);\n+ setMaxEvaluations(1000);\n setMaximalIterationCount(100);\n- setAbsoluteAccuracy(1E-10);\n- setRelativeAccuracy(1.0e-14);\n+ setAbsoluteAccuracy(1e-11);\n+ setRelativeAccuracy(1e-9);\n }\n \n /**\n@@ -54,17 +54,10 @@ public BrentOptimizer() {\n */\n protected double doOptimize()\n throws MaxIterationsExceededException, FunctionEvaluationException {\n- throw new UnsupportedOperationException();\n- }\n- public double optimize(final UnivariateRealFunction f, final GoalType goalType, final double min, final double max, final double startValue) throws MaxIterationsExceededException, FunctionEvaluationException {\n- clearResult();\n return localMin(getGoalType() == GoalType.MINIMIZE,\n- f, goalType, min, startValue, max,\n+ getMin(), getStartValue(), getMax(),\n getRelativeAccuracy(), getAbsoluteAccuracy());\n }\n- public double optimize(final UnivariateRealFunction f, final GoalType goalType, final double min, final double max) throws MaxIterationsExceededException, FunctionEvaluationException {\n- return optimize(f, goalType, min, max, min + GOLDEN_SECTION * (max - min));\n- }\n \n /**\n * Find the minimum of the function within the interval {@code (lo, hi)}.\n@@ -91,8 +84,6 @@ public double optimize(final UnivariateRealFunction f, final GoalType goalType,\n * the function.\n */\n private double localMin(boolean isMinim,\n- UnivariateRealFunction f,\n- GoalType goalType,\n double lo, double mid, double hi,\n double eps, double t)\n throws MaxIterationsExceededException, FunctionEvaluationException {\n@@ -116,15 +107,14 @@ private double localMin(boolean isMinim,\n double w = x;\n double d = 0;\n double e = 0;\n- double fx = computeObjectiveValue(f, x);\n- if (goalType == GoalType.MAXIMIZE) {\n+ double fx = computeObjectiveValue(x);\n+ if (!isMinim) {\n fx = -fx;\n }\n double fv = fx;\n double fw = fx;\n \n- int count = 0;\n- while (count < maximalIterationCount) {\n+ while (true) {\n double m = 0.5 * (a + b);\n final double tol1 = eps * Math.abs(x) + t;\n final double tol2 = 2 * tol1;\n@@ -197,8 +187,8 @@ private double localMin(boolean isMinim,\n u = x + d;\n }\n \n- double fu = computeObjectiveValue(f, u);\n- if (goalType == GoalType.MAXIMIZE) {\n+ double fu = computeObjectiveValue(u);\n+ if (!isMinim) {\n fu = -fu;\n }\n \n@@ -235,11 +225,10 @@ private double localMin(boolean isMinim,\n }\n }\n } else { // termination\n- setResult(x, (goalType == GoalType.MAXIMIZE) ? -fx : fx, count);\n+ setFunctionValue(isMinim ? fx : -fx);\n return x;\n }\n- ++count;\n+ incrementIterationsCounter();\n }\n- throw new MaxIterationsExceededException(maximalIterationCount);\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.MultiStartUnivariateRealOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0.2719561270319131> but was:<-0.2719561299044896>",
"methodName": "testQuinticMin"
},
{
"className": " org.apache.commons.math.optimization.MultiStartUnivariateRealOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSinMin"
},
{
"className": " org.apache.commons.math.optimization.univariate.BrentOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1880.5> but was:<18.0>",
"methodName": "testQuinticMinStatistics"
},
{
"className": " org.apache.commons.math.optimization.univariate.BrentOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<4.71238898038469> but was:<4.71238897901431>",
"methodName": "testSinMin"
}
],
"metrics": {
"chunks": 12,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 11,
"linesRem": 11,
"methods": 4,
"sizeInLines": 22,
"spreadAllLines": 178,
"spreadCodeOnly": 129
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"condExpMod",
"exThrowsRem",
"loopCondChange",
"mcAdd",
"mcParRem",
"mcParValChange",
"mcRem",
"mcRepl",
"mdOverride",
"mdParRem",
"mdRem",
"objInstRem",
"retExpChange",
"retRem",
"varAdd",
"varRem",
"varReplMc"
],
"repairPatterns": [
"constChange",
"expLogicMod",
"initFix",
"wrongComp",
"wrongMethodRef",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "76fcbc838c0f27d9b029c1f283390cb4f47f8895"
},
{
"bugId": 65,
"changedFiles": {
"org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java": {
"changes": [
[
245
],
[
258
]
],
"deletes": [
[
240
],
[
241
],
[
242
],
[
243
],
[
244
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java\n@@ -239,30 +239,25 @@ protected void updateResidualsAndCost()\n public double getRMS() {\n- double criterion = 0;\n- for (int i = 0; i < rows; ++i) {\n- final double residual = residuals[i];\n- criterion += residual * residual * residualsWeights[i];\n- }\n- return Math.sqrt(criterion / rows);\n+ return Math.sqrt(getChiSquare() / rows);\n }\n \n /**\n * Get a Chi-Square-like value assuming the N residuals follow N\n * distinct normal distributions centered on 0 and whose variances are\n * the reciprocal of the weights.\n * @return chi-square value\n */\n public double getChiSquare() {\n double chiSquare = 0;\n for (int i = 0; i < rows; ++i) {\n final double residual = residuals[i];\n- chiSquare += residual * residual / residualsWeights[i];\n+ chiSquare += residual * residual * residualsWeights[i];\n }\n return chiSquare;\n }\n \n /**\n * Get the covariance matrix of optimized parameters.\n * @return covariance matrix\n * @exception FunctionEvaluationException if the function jacobian cannot\n * be evaluated\n * @exception OptimizationException if the covariance matrix\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.004> but was:<0.0019737107108948474>",
"methodName": "testCircleFitting"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 5,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 12,
"spreadCodeOnly": 5
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"assignRem",
"loopRem",
"mcAdd",
"mcParValChange",
"varRem",
"varReplMc"
],
"repairPatterns": [
"blockRemove",
"expArithMod",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "a4f9188a55e6935d4d38ae97806af4d59e671588"
},
{
"bugId": 64,
"changedFiles": {
"org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java": {
"changes": [
[
278
],
[
316
],
[
346
]
],
"deletes": [
[
365
],
[
442
],
[
443
],
[
444
],
[
445
]
],
"inserts": [
[
243,
244,
245,
246,
247,
248,
249,
250,
251,
252,
253,
254,
255,
256,
257,
258,
259,
260,
261,
262,
263
],
[
270
],
[
323,
324
],
[
344,
345,
346
],
[
421,
422,
423,
424
],
[
434
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java\n@@ -255,6 +255,8 @@ protected VectorialPointValuePair doOptimize()\n double[] diag = new double[cols];\n double[] oldX = new double[cols];\n double[] oldRes = new double[rows];\n+ double[] oldObj = new double[rows];\n+ double[] qtf = new double[rows];\n double[] work1 = new double[cols];\n double[] work2 = new double[cols];\n double[] work3 = new double[cols];\n@@ -267,6 +269,9 @@ protected VectorialPointValuePair doOptimize()\n boolean firstIteration = true;\n VectorialPointValuePair current = new VectorialPointValuePair(point, objective);\n while (true) {\n+ for (int i=0;i<rows;i++) {\n+ qtf[i]=residuals[i];\n+ }\n incrementIterationsCounter();\n \n // compute the Q.R. decomposition of the jacobian matrix\n@@ -275,7 +280,7 @@ protected VectorialPointValuePair doOptimize()\n qrDecomposition();\n \n // compute Qt.res\n- qTy(residuals);\n+ qTy(qtf);\n // now we don't need Q anymore,\n // so let jacobian contain the R matrix with its diagonal elements\n for (int k = 0; k < solvedCols; ++k) {\n@@ -313,7 +318,7 @@ protected VectorialPointValuePair doOptimize()\n if (s != 0) {\n double sum = 0;\n for (int i = 0; i <= j; ++i) {\n- sum += jacobian[i][pj] * residuals[i];\n+ sum += jacobian[i][pj] * qtf[i];\n }\n maxCosine = Math.max(maxCosine, Math.abs(sum) / (s * cost));\n }\n@@ -321,6 +326,8 @@ protected VectorialPointValuePair doOptimize()\n }\n if (maxCosine <= orthoTolerance) {\n // convergence has been reached\n+ \tupdateResidualsAndCost();\n+ \tcurrent = new VectorialPointValuePair(point, objective);\n return current;\n }\n \n@@ -341,9 +348,12 @@ protected VectorialPointValuePair doOptimize()\n double[] tmpVec = residuals;\n residuals = oldRes;\n oldRes = tmpVec;\n+ tmpVec = objective;\n+ objective = oldObj;\n+ oldObj = tmpVec;\n \n // determine the Levenberg-Marquardt parameter\n- determineLMParameter(oldRes, delta, diag, work1, work2, work3);\n+ determineLMParameter(qtf, delta, diag, work1, work2, work3);\n \n // compute the new point and the norm of the evolution direction\n double lmNorm = 0;\n@@ -362,7 +372,6 @@ protected VectorialPointValuePair doOptimize()\n \n // evaluate the function at x + p and calculate its norm\n updateResidualsAndCost();\n- current = new VectorialPointValuePair(point, objective);\n \n // compute the scaled actual reduction\n double actRed = -1.0;\n@@ -418,9 +427,15 @@ protected VectorialPointValuePair doOptimize()\n xNorm += xK * xK;\n }\n xNorm = Math.sqrt(xNorm);\n+ current = new VectorialPointValuePair(point, objective);\n \n // tests for convergence.\n+ if (checker != null) {\n // we use the vectorial convergence checker\n+ \tif (checker.converged(getIterations(), previous, current)) {\n+ \t\treturn current;\n+ \t}\n+ }\n } else {\n // failed iteration, reset the previous values\n cost = previousCost;\n@@ -431,6 +446,9 @@ protected VectorialPointValuePair doOptimize()\n tmpVec = residuals;\n residuals = oldRes;\n oldRes = tmpVec;\n+ tmpVec = objective;\n+ objective = oldObj;\n+ oldObj = tmpVec;\n }\n if (checker==null) {\n \tif (((Math.abs(actRed) <= costRelativeTolerance) &&\n@@ -439,10 +457,6 @@ protected VectorialPointValuePair doOptimize()\n (delta <= parRelativeTolerance * xNorm)) {\n return current;\n }\n- } else {\n- if (checker.converged(getIterations(), previous, current)) {\n- return current;\n- }\n }\n // tests for termination and stringent tolerances\n // (2.2204e-16 is the machine epsilon for IEEE754)\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.general.MinpackTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.2578199266368004> but was:<0.2578330049004441>",
"methodName": "testMinpackJennrichSampson"
},
{
"className": " org.apache.commons.math.optimization.general.MinpackTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<11.41300466147456> but was:<11.4121122022341>",
"methodName": "testMinpackFreudensteinRoth"
}
],
"metrics": {
"chunks": 13,
"classes": 1,
"files": 1,
"linesAdd": 19,
"linesMod": 3,
"linesRem": 5,
"methods": 1,
"sizeInLines": 27,
"spreadAllLines": 180,
"spreadCodeOnly": 131
},
"observations": "Moved instantiation of object of type VectorialPointValuePair to another place (lines ahead).",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranRem",
"loopAdd",
"mcAdd",
"mcMove",
"mcParValChange",
"mcRem",
"objInstAdd",
"objInstRem",
"retBranchAdd",
"retRem",
"varAdd",
"varReplVar"
],
"repairPatterns": [
"blockRemove",
"codeMove",
"condBlockOthersAdd",
"condBlockRem",
"condBlockRetAdd",
"expArithMod",
"missNullCheckN",
"wrongComp",
"wrongVarRef"
],
"repairTools": [
"rtDeepRepair"
],
"revisionId": "7dadc2ab019f066a7a287376ad4c63193e8a0a9a"
},
{
"bugId": 70,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BisectionSolver.java": {
"changes": [
[
72
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BisectionSolver.java\n@@ -69,7 +69,7 @@ public double solve(double min, double max)\n /** {@inheritDoc} */\n public double solve(final UnivariateRealFunction f, double min, double max, double initial)\n throws MaxIterationsExceededException, FunctionEvaluationException {\n- return solve(min, max);\n+ return solve(f, min, max);\n }\n \n /** {@inheritDoc} */\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.BisectionSolverTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testMath369"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Call overloaded method without one parameter.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcParAdd",
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtssFix"
],
"revisionId": "f41fcd85ca62a2109a6e550be0353d292d351213"
},
{
"bugId": 68,
"changedFiles": {
"org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java": {
"changes": [
[
303
],
[
419
]
],
"inserts": [
[
164,
165,
166,
167,
168,
169,
170,
171
],
[
243,
244,
245,
246,
247
],
[
250,
251,
252
],
[
345,
346,
347,
348
],
[
411,
412,
413,
414,
415
],
[
421,
422,
423,
424
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizer.java\n@@ -163,6 +163,7 @@ public LevenbergMarquardtOptimizer() {\n setMaxIterations(1000);\n \n // default values for the tuning parameters\n+ setConvergenceChecker(null);\n setInitialStepBoundFactor(100.0);\n setCostRelativeTolerance(1.0e-10);\n setParRelativeTolerance(1.0e-10);\n@@ -244,11 +245,13 @@ protected VectorialPointValuePair doOptimize()\n // outer loop\n lmPar = 0;\n boolean firstIteration = true;\n+ VectorialPointValuePair current = new VectorialPointValuePair(point, objective);\n while (true) {\n \n incrementIterationsCounter();\n \n // compute the Q.R. decomposition of the jacobian matrix\n+ VectorialPointValuePair previous = current;\n updateJacobian();\n qrDecomposition();\n \n@@ -300,7 +303,7 @@ protected VectorialPointValuePair doOptimize()\n }\n if (maxCosine <= orthoTolerance) {\n // convergence has been reached\n- return new VectorialPointValuePair(point, objective);\n+ return current;\n }\n \n // rescale if necessary\n@@ -342,6 +345,7 @@ protected VectorialPointValuePair doOptimize()\n \n // evaluate the function at x + p and calculate its norm\n updateResidualsAndCost();\n+ current = new VectorialPointValuePair(point, objective);\n \n // compute the scaled actual reduction\n double actRed = -1.0;\n@@ -410,14 +414,20 @@ protected VectorialPointValuePair doOptimize()\n }\n \n // tests for convergence.\n+ if (checker != null) {\n // we use the vectorial convergence checker\n+ if (checker.converged(getIterations(), previous, current)) {\n+ return current; \n+ }\n+ } else {\n // we use the Levenberg-Marquardt specific convergence parameters\n if (((Math.abs(actRed) <= costRelativeTolerance) &&\n (preRed <= costRelativeTolerance) &&\n (ratio <= 2.0)) ||\n (delta <= parRelativeTolerance * xNorm)) {\n- return new VectorialPointValuePair(point, objective);\n+ return current;\n }\n+ }\n \n // tests for termination and stringent tolerances\n // (2.2204e-16 is the machine epsilon for IEEE754)\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.general.MinpackTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.2578330049> but was:<0.257819926636807>",
"methodName": "testMinpackJennrichSampson"
},
{
"className": " org.apache.commons.math.optimization.general.MinpackTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<11.4121122022341> but was:<11.41300466147456>",
"methodName": "testMinpackFreudensteinRoth"
}
],
"metrics": {
"chunks": 9,
"classes": 1,
"files": 1,
"linesAdd": 10,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 253,
"spreadCodeOnly": 160
},
"observations": "New objects were instantiated. Objects instantiated before were removed too (line 419).",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"objInstAdd",
"objInstRem",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missNullCheckN",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "615ca9a000c253575e6f62bed87db6110b750834"
},
{
"bugId": 69,
"changedFiles": {
"org/apache/commons/math/stat/correlation/PearsonsCorrelation.java": {
"changes": [
[
171
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java\n+++ b/src/main/java/org/apache/commons/math/stat/correlation/PearsonsCorrelation.java\n@@ -168,7 +168,7 @@ public RealMatrix getCorrelationPValues() throws MathException {\n } else {\n double r = correlationMatrix.getEntry(i, j);\n double t = Math.abs(r * Math.sqrt((nObs - 2)/(1 - r * r)));\n- out[i][j] = 2 * (1 - tDistribution.cumulativeProbability(t));\n+ out[i][j] = 2 * tDistribution.cumulativeProbability(-t);\n }\n }\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.correlation.PearsonsCorrelationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testPValueNearZero"
},
{
"className": " org.apache.commons.math.stat.correlation.SpearmansRankCorrelationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testPValueNearZero"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Fix assignment operation.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"mcParValChange"
],
"repairPatterns": [
"expArithMod",
"singleLine",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "a2711c189d9754c22e3aba2de1c6c125e52626aa"
},
{
"bugId": 71,
"changedFiles": {
"org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java": {
"inserts": [
[
295,
296,
297,
298,
299,
300,
301
]
]
},
"org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java": {
"inserts": [
[
175,
176,
177,
178,
179,
180,
181
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n+++ b/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n@@ -297,6 +297,10 @@ public double integrate(final FirstOrderDifferentialEquations equations,\n // it is so small (much probably exactly 0 due to limited accuracy)\n // that the code above would fail handling it.\n // So we set up an artificial 0 size step by copying states\n+ interpolator.storeTime(stepStart);\n+ System.arraycopy(y, 0, yTmp, 0, y0.length);\n+ hNew = 0;\n+ stepSize = 0;\n loop = false;\n } else {\n // reject the step to match exactly the next switch time\n--- a/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java\n+++ b/src/main/java/org/apache/commons/math/ode/nonstiff/RungeKuttaIntegrator.java\n@@ -177,6 +177,9 @@ public double integrate(final FirstOrderDifferentialEquations equations,\n // it is so small (much probably exactly 0 due to limited accuracy)\n // that the code above would fail handling it.\n // So we set up an artificial 0 size step by copying states\n+ interpolator.storeTime(stepStart);\n+ System.arraycopy(y, 0, yTmp, 0, y0.length);\n+ stepSize = 0;\n loop = false;\n } else {\n // reject the step to match exactly the next switch time\n",
"failingTests": [
{
"className": " org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegratorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.8782503799999986E9> but was:<1.878250439999994E9>",
"methodName": "testMissedEndEvent"
},
{
"className": " org.apache.commons.math.ode.nonstiff.DormandPrince853IntegratorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.8782503799999986E9> but was:<1.878250479999994E9>",
"methodName": "testMissedEndEvent"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 7,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Three lines equal lines are added in two different places. Just line 302 is different.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"mcAdd"
],
"repairPatterns": [
"copyPaste"
],
"repairTools": [
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg"
],
"revisionId": "6537e18ad189603e19615226e6aa1a9cdd154b8f"
},
{
"bugId": 72,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BrentSolver.java": {
"changes": [
[
115
],
[
127
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java\n@@ -112,7 +112,7 @@ public double solve(final UnivariateRealFunction f,\n // return the first endpoint if it is good enough\n double yMin = f.value(min);\n if (Math.abs(yMin) <= functionValueAccuracy) {\n- setResult(yMin, 0);\n+ setResult(min, 0);\n return result;\n }\n \n@@ -124,7 +124,7 @@ public double solve(final UnivariateRealFunction f,\n // return the second endpoint if it is good enough\n double yMax = f.value(max);\n if (Math.abs(yMax) <= functionValueAccuracy) {\n- setResult(yMax, 0);\n+ setResult(max, 0);\n return result;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.BrentSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<3.141592653589793> but was:<1.2246467991473532E-16>",
"methodName": "testRootEndpoints"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 11,
"spreadCodeOnly": 7
},
"observations": "Similar changes in two different places, the same melhod is targeted, the same argument is changed, only the new values applied are different.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"wrongComp",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "aa09ac7ca6e01a2ba41470ca590f07f2ada8af6f"
},
{
"bugId": 67,
"changedFiles": {
"org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java": {
"changes": [
[
92
],
[
97
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java\n+++ b/src/main/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizer.java\n@@ -89,12 +89,12 @@ public MultiStartUnivariateRealOptimizer(final UnivariateRealOptimizer optimizer\n \n /** {@inheritDoc} */\n public double getFunctionValue() {\n- return optimizer.getFunctionValue();\n+ return optimaValues[0];\n }\n \n /** {@inheritDoc} */\n public double getResult() {\n- return optimizer.getResult();\n+ return optima[0];\n }\n \n /** {@inheritDoc} */\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.MultiStartUnivariateRealOptimizerTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0.27195612846834> but was:<-0.27194301946870036>",
"methodName": "testQuinticMin"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 4,
"spreadCodeOnly": 2
},
"observations": "A direct access to a vector was added in place of a value returned from a call to an object method. The change was similar in structure in two different places.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcRem",
"retExpChange"
],
"repairPatterns": [
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "fc505bba569dede0d29a401798fa9f55df9e27f1"
},
{
"bugId": 73,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/BrentSolver.java": {
"inserts": [
[
135,
136,
137,
138
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java\n+++ b/src/main/java/org/apache/commons/math/analysis/solvers/BrentSolver.java\n@@ -133,6 +133,10 @@ public double solve(final UnivariateRealFunction f,\n return solve(f, initial, yInitial, max, yMax, initial, yInitial);\n }\n \n+ if (yMin * yMax > 0) {\n+ throw MathRuntimeException.createIllegalArgumentException(\n+ NON_BRACKETING_MESSAGE, min, max, yMin, yMax);\n+ }\n \n // full Brent algorithm starting with provided initial guess\n return solve(f, min, yMin, max, yMax, initial, yInitial);\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.solvers.BrentSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expecting IllegalArgumentException - non-bracketing",
"methodName": "testBadEndpoints"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtNopol"
],
"revisionId": "29c3b75e2d5120771ca85ffcbffc9b7cb5d45c58"
},
{
"bugId": 74,
"changedFiles": {
"org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java": {
"changes": [
[
245
],
[
247
],
[
248
],
[
250
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n+++ b/src/main/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java\n@@ -242,12 +242,15 @@ public double integrate(final FirstOrderDifferentialEquations equations,\n }\n \n if (firstTime) {\n- final double[] scale;\n+ final double[] scale = new double[y0.length];\n if (vecAbsoluteTolerance == null) {\n- scale = new double[y0.length];\n- java.util.Arrays.fill(scale, scalAbsoluteTolerance);\n+ for (int i = 0; i < scale.length; ++i) {\n+ scale[i] = scalAbsoluteTolerance + scalRelativeTolerance * Math.abs(y[i]);\n+ }\n } else {\n- scale = vecAbsoluteTolerance;\n+ for (int i = 0; i < scale.length; ++i) {\n+ scale[i] = vecAbsoluteTolerance[i] + vecRelativeTolerance[i] * Math.abs(y[i]);\n+ }\n }\n hNew = initializeStep(equations, forward, getOrder(), scale,\n stepStart, y, yDotK[0], yTmp, yDotK[1]);\n",
"failingTests": [
{
"className": " org.apache.commons.math.ode.nonstiff.AdamsMoultonIntegratorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "polynomial"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 7,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "A vector/object was instantiated.The way to initialize values was changed.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"loopAdd",
"mcAdd",
"mcRem"
],
"repairPatterns": [
"initFix",
"notClassified",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair"
],
"revisionId": "d06e7b7c8e646ff489a5dfba47dfcb283a194e9b"
},
{
"bugId": 75,
"changedFiles": {
"org/apache/commons/math/stat/Frequency.java": {
"changes": [
[
303
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/stat/Frequency.java\n+++ b/src/main/java/org/apache/commons/math/stat/Frequency.java\n@@ -300,7 +300,7 @@ public long getCount(char v) {\n */\n @Deprecated\n public double getPct(Object v) {\n- return getCumPct((Comparable<?>) v);\n+ return getPct((Comparable<?>) v);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.FrequencyTest",
"error": "junit.framework.AssertionFailedError",
"message": "three (Object) pct expected:<0.5> but was:<1.0>",
"methodName": "testPcts"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrongMethodRef"
],
"repairTools": [
"rtElixir"
],
"revisionId": "523df0c13719150b1397a6094f410274bfaf1475"
},
{
"bugId": 77,
"changedFiles": {
"org/apache/commons/math/linear/ArrayRealVector.java": {
"changes": [
[
721
]
]
},
"org/apache/commons/math/linear/OpenMapRealVector.java": {
"deletes": [
[
498
],
[
499
],
[
500
],
[
501
],
[
502
],
[
503
],
[
504
],
[
505
],
[
506
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/ArrayRealVector.java\n+++ b/src/main/java/org/apache/commons/math/linear/ArrayRealVector.java\n@@ -718,7 +718,7 @@ public double getL1Norm() {\n public double getLInfNorm() {\n double max = 0;\n for (double a : data) {\n- max += Math.max(max, Math.abs(a));\n+ max = Math.max(max, Math.abs(a));\n }\n return max;\n }\n--- a/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java\n+++ b/src/main/java/org/apache/commons/math/linear/OpenMapRealVector.java\n@@ -495,15 +495,6 @@ public double getL1Distance(double[] v) throws IllegalArgumentException {\n return max;\n }\n \n- public double getLInfNorm() {\n- double max = 0;\n- Iterator iter = entries.iterator();\n- while (iter.hasNext()) {\n- iter.advance();\n- max += iter.value();\n- }\n- return max;\n- }\n /**\n * Optimized method to compute LInfDistance.\n * @param v The vector to compute from\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.ArrayRealVectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "compare values expected:<6.0> but was:<128.0>",
"methodName": "testBasicFunctions"
},
{
"className": " org.apache.commons.math.linear.SparseRealVectorTest",
"error": "junit.framework.AssertionFailedError",
"message": "compare values expected:<6.0> but was:<-3.0>",
"methodName": "testBasicFunctions"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 9,
"methods": 2,
"sizeInLines": 10,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Fix a assignment. Removes a method (aparently, unrelated changes).",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"assignRem",
"loopRem",
"mcRem",
"mdOverride",
"mdRem",
"retRem",
"varRem"
],
"repairPatterns": [
"blockRemove",
"expArithMod",
"wrongComp"
],
"repairTools": [
"rtDeepRepair"
],
"revisionId": "d6555de715889237b7be11639d164e7098862003"
},
{
"bugId": 82,
"changedFiles": {
"org/apache/commons/math/optimization/linear/SimplexSolver.java": {
"changes": [
[
82
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java\n+++ b/src/main/java/org/apache/commons/math/optimization/linear/SimplexSolver.java\n@@ -79,7 +79,7 @@ private Integer getPivotRow(final int col, final SimplexTableau tableau) {\n for (int i = tableau.getNumObjectiveFunctions(); i < tableau.getHeight(); i++) {\n final double rhs = tableau.getEntry(i, tableau.getWidth() - 1);\n final double entry = tableau.getEntry(i, col);\n- if (MathUtils.compareTo(entry, 0, epsilon) >= 0) {\n+ if (MathUtils.compareTo(entry, 0, epsilon) > 0) {\n final double ratio = rhs / entry;\n if (ratio < minRatio) {\n minRatio = ratio;\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10.0> but was:<11.5>",
"methodName": "testMath288"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes operator in condition.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtAcs",
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtJAID",
"rtKali"
],
"revisionId": "4ece1884cc408e15c8f1db9010fec5cac43937b9"
},
{
"bugId": 76,
"changedFiles": {
"org/apache/commons/math/linear/SingularValueDecompositionImpl.java": {
"changes": [
[
162
],
[
166
],
[
178
],
[
248
],
[
252
],
[
263
]
],
"deletes": [
[
176
],
[
261
]
],
"inserts": [
[
171
],
[
177
],
[
180,
181
],
[
180,
181
],
[
256
],
[
262
],
[
265
],
[
265
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java\n+++ b/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java\n@@ -159,24 +159,27 @@ public RealMatrix getU()\n if (m >= n) {\n // the tridiagonal matrix is Bt.B, where B is upper bidiagonal\n final RealMatrix e =\n- eigenDecomposition.getV().getSubMatrix(0, p - 1, 0, p - 1);\n+ eigenDecomposition.getV().getSubMatrix(0, n - 1, 0, p - 1);\n final double[][] eData = e.getData();\n final double[][] wData = new double[m][p];\n double[] ei1 = eData[0];\n- for (int i = 0; i < p - 1; ++i) {\n+ for (int i = 0; i < p; ++i) {\n // compute W = B.E.S^(-1) where E is the eigenvectors matrix\n final double mi = mainBidiagonal[i];\n final double[] ei0 = ei1;\n final double[] wi = wData[i];\n+ if (i < n - 1) {\n ei1 = eData[i + 1];\n final double si = secondaryBidiagonal[i];\n for (int j = 0; j < p; ++j) {\n wi[j] = (mi * ei0[j] + si * ei1[j]) / singularValues[j];\n }\n- }\n+ } else {\n for (int j = 0; j < p; ++j) {\n- wData[p - 1][j] = ei1[j] * mainBidiagonal[p - 1] / singularValues[j];\n+ wi[j] = mi * ei0[j] / singularValues[j];\n }\n+ }\n+ }\n \n for (int i = p; i < m; ++i) {\n wData[i] = new double[p];\n@@ -245,23 +248,26 @@ public RealMatrix getV()\n // the tridiagonal matrix is B.Bt, where B is lower bidiagonal\n // compute W = Bt.E.S^(-1) where E is the eigenvectors matrix\n final RealMatrix e =\n- eigenDecomposition.getV().getSubMatrix(0, p - 1, 0, p - 1);\n+ eigenDecomposition.getV().getSubMatrix(0, m - 1, 0, p - 1);\n final double[][] eData = e.getData();\n final double[][] wData = new double[n][p];\n double[] ei1 = eData[0];\n- for (int i = 0; i < p - 1; ++i) {\n+ for (int i = 0; i < p; ++i) {\n final double mi = mainBidiagonal[i];\n final double[] ei0 = ei1;\n final double[] wi = wData[i];\n+ if (i < m - 1) {\n ei1 = eData[i + 1];\n final double si = secondaryBidiagonal[i];\n for (int j = 0; j < p; ++j) {\n wi[j] = (mi * ei0[j] + si * ei1[j]) / singularValues[j];\n }\n- }\n+ } else {\n for (int j = 0; j < p; ++j) {\n- wData[p - 1][j] = ei1[j] * mainBidiagonal[p - 1] / singularValues[j];\n+ wi[j] = mi * ei0[j] / singularValues[j];\n }\n+ }\n+ }\n for (int i = p; i < n; ++i) {\n wData[i] = new double[p];\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.SingularValueSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<0.09336767546650937>",
"methodName": "testMath320A"
},
{
"className": " org.apache.commons.math.linear.SingularValueSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.0> but was:<3.2>",
"methodName": "testMath320B"
}
],
"metrics": {
"chunks": 12,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 8,
"linesRem": 0,
"methods": 1,
"sizeInLines": 14,
"spreadAllLines": 95,
"spreadCodeOnly": 67
},
"observations": "The structure of the changes are similar and applied in two different methods.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"assignRem",
"condBranIfElseAdd",
"loopCondChange",
"mcParValChange",
"varReplVar"
],
"repairPatterns": [
"copyPaste",
"expArithMod",
"expLogicMod",
"wrapsIfElse",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "39e2ad8af8fdedac51144158061cb31e7863c3a1"
},
{
"bugId": 84,
"changedFiles": {
"org/apache/commons/math/optimization/direct/MultiDirectional.java": {
"inserts": [
[
63,
64
],
[
92,
93,
94,
95,
96,
97
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java\n+++ b/src/main/java/org/apache/commons/math/optimization/direct/MultiDirectional.java\n@@ -61,6 +61,7 @@ public MultiDirectional(final double khi, final double gamma) {\n protected void iterateSimplex(final Comparator<RealPointValuePair> comparator)\n throws FunctionEvaluationException, OptimizationException, IllegalArgumentException {\n \n+ final RealConvergenceChecker checker = getConvergenceChecker();\n while (true) {\n \n incrementIterationsCounter();\n@@ -89,8 +90,16 @@ protected void iterateSimplex(final Comparator<RealPointValuePair> comparator)\n final RealPointValuePair contracted = evaluateNewSimplex(original, gamma, comparator);\n if (comparator.compare(contracted, best) < 0) {\n // accept the contracted simplex\n+ return;\n+ }\n \n // check convergence\n+ final int iter = getIterations();\n+ boolean converged = true;\n+ for (int i = 0; i < simplex.length; ++i) {\n+ converged &= checker.converged(iter, original[i], simplex[i]);\n+ }\n+ if (converged) {\n return;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.direct.MultiDirectionalTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testMinimizeMaximize"
},
{
"className": " org.apache.commons.math.optimization.direct.MultiDirectionalTest",
"error": "org.apache.commons.math.optimization.OptimizationException",
"message": "org.apache.commons.math.MaxIterationsExceededException: Maximal number of iterations (100) exceeded",
"methodName": "testMath283"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 30,
"spreadCodeOnly": 15
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL",
"rtGenProg",
"rtKali"
],
"revisionId": "317793eeff84dc9b260301adbe4aa8f5c79f703a"
},
{
"bugId": 81,
"changedFiles": {
"org/apache/commons/math/linear/EigenDecompositionImpl.java": {
"changes": [
[
905
],
[
906
],
[
1543
]
],
"inserts": [
[
603,
604,
605
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java\n+++ b/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java\n@@ -600,6 +600,7 @@ private void computeGershgorinCircles() {\n lowerSpectra = Math.min(lowerSpectra, lower);\n final double upper = dCurrent + eCurrent;\n work[upperStart + m - 1] = upper;\n+ upperSpectra = Math.max(upperSpectra, upper);\n minPivot = MathUtils.SAFE_MIN * Math.max(1.0, eMax * eMax);\n \n }\n@@ -902,8 +903,8 @@ private void processGeneralBlock(final int n)\n diagMax = work[4 * i0];\n offDiagMin = work[4 * i0 + 2];\n double previousEMin = work[4 * i0 + 3];\n- for (int i = 4 * i0; i < 4 * n0 - 11; i += 4) {\n- if ((work[i + 3] <= TOLERANCE_2 * work[i]) &&\n+ for (int i = 4 * i0; i < 4 * n0 - 16; i += 4) {\n+ if ((work[i + 3] <= TOLERANCE_2 * work[i]) ||\n (work[i + 2] <= TOLERANCE_2 * sigma)) {\n // insert a split\n work[i + 2] = -sigma;\n@@ -1540,7 +1541,7 @@ private void computeShiftIncrement(final int start, final int end, final int def\n double a2 = (work[np - 8] / b2) * (1 + work[np - 4] / b1);\n \n // approximate contribution to norm squared from i < nn-2.\n- if (end - start > 2) {\n+ if (end - start > 3) {\n b2 = work[nn - 13] / work[nn - 15];\n a2 = a2 + b2;\n for (int i4 = nn - 17; i4 >= 4 * start + 2 + pingPong; i4 -= 4) {\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.EigenDecompositionImplTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "-1",
"methodName": "testMath308"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 3,
"linesRem": 0,
"methods": 3,
"sizeInLines": 4,
"spreadAllLines": 938,
"spreadCodeOnly": 643
},
"observations": "Fix/updates assignment to var upperSpectra.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condExpMod",
"loopCondChange",
"mcAdd"
],
"repairPatterns": [
"constChange",
"expArithMod",
"expLogicMod",
"missComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "7d903ca533833e5db8d2fe150f1e31b54ddda700"
},
{
"bugId": 80,
"changedFiles": {
"org/apache/commons/math/linear/EigenDecompositionImpl.java": {
"changes": [
[
1135
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java\n+++ b/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java\n@@ -1132,7 +1132,7 @@ private int goodStep(final int start, final int end) {\n private boolean flipIfWarranted(final int n, final int step) {\n if (1.5 * work[pingPong] < work[4 * (n - 1) + pingPong]) {\n // flip array\n- int j = 4 * n - 1;\n+ int j = 4 * (n - 1);\n for (int i = 0; i < j; i += 4) {\n for (int k = 0; k < 4; k += step) {\n final double tmp = work[i + k];\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.EigenDecompositionImplTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<16828.208208485466> but was:<20654.74511575945>",
"methodName": "testMathpbx02"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Fix expression in assignment (added parathesis).",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange"
],
"repairPatterns": [
"expArithMod",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtJAID",
"rtKali",
"rtNopol"
],
"revisionId": "3ced4f2a4e2546f0d7c309bd8f6305edee0dee8f"
},
{
"bugId": 78,
"changedFiles": {
"org/apache/commons/math/ode/events/EventState.java": {
"inserts": [
[
189,
190,
191,
192,
193,
194,
195,
196,
197,
198,
199,
200,
201
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/ode/events/EventState.java\n+++ b/src/main/java/org/apache/commons/math/ode/events/EventState.java\n@@ -188,6 +188,7 @@ public boolean evaluateStep(final StepInterpolator interpolator)\n if (g0Positive ^ (gb >= 0)) {\n // there is a sign change: an event is expected during this step\n \n+ if (ga * gb > 0) {\n // this is a corner case:\n // - there was an event near ta,\n // - there is another event between ta and tb\n@@ -195,7 +196,17 @@ public boolean evaluateStep(final StepInterpolator interpolator)\n // this implies that the real sign of ga is the same as gb, so we need to slightly\n // shift ta to make sure ga and gb get opposite signs and the solver won't complain\n // about bracketing\n+ final double epsilon = (forward ? 0.25 : -0.25) * convergence;\n+ for (int k = 0; (k < 4) && (ga * gb > 0); ++k) {\n+ ta += epsilon;\n+ interpolator.setInterpolatedTime(ta);\n+ ga = handler.g(ta, interpolator.getInterpolatedState());\n+ }\n+ if (ga * gb > 0) {\n // this should never happen\n+ throw MathRuntimeException.createInternalError(null);\n+ }\n+ }\n \n // variation direction, with respect to the integration direction\n increasing = gb >= ga;\n",
"failingTests": [
{
"className": " org.apache.commons.math.ode.events.EventStateTest",
"error": "org.apache.commons.math.MathRuntimeException$4",
"message": "function values at endpoints do not have different signs. Endpoints: [89.999, 153.1], Values: [-0.066, -1,142.11]",
"methodName": "closeEvents"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 11,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 11,
"spreadAllLines": 8,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"missComp"
],
"repairTools": [
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "b3ed2415fc58b34667d99f077bae6c8e38b7aced"
},
{
"bugId": 83,
"changedFiles": {
"org/apache/commons/math/optimization/linear/SimplexTableau.java": {
"changes": [
[
292
],
[
341
],
[
345
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n+++ b/src/main/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n@@ -289,7 +289,7 @@ private Integer getBasicRowForSolution(final int col) {\n */\n private Integer getBasicRow(final int col, boolean ignoreObjectiveRows) {\n Integer row = null;\n- int start = getNumObjectiveFunctions();\n+ int start = ignoreObjectiveRows ? getNumObjectiveFunctions() : 0;\n for (int i = start; i < getHeight(); i++) {\n if (MathUtils.equals(getEntry(i, col), 1.0, epsilon) && (row == null)) {\n row = i;\n@@ -338,11 +338,11 @@ private void copyArray(final double[] src, final double[] dest,\n */\n protected RealPointValuePair getSolution() {\n double[] coefficients = new double[getOriginalNumDecisionVariables()];\n- Integer negativeVarBasicRow = getBasicRow(getNegativeDecisionVariableOffset());\n+ Integer negativeVarBasicRow = getBasicRowForSolution(getNegativeDecisionVariableOffset());\n double mostNegative = negativeVarBasicRow == null ? 0 : getEntry(negativeVarBasicRow, getRhsOffset());\n Set<Integer> basicRows = new HashSet<Integer>();\n for (int i = 0; i < coefficients.length; i++) {\n- Integer basicRow = getBasicRow(getNumObjectiveFunctions() + i);\n+ Integer basicRow = getBasicRowForSolution(getNumObjectiveFunctions() + i);\n if (basicRows.contains(basicRow)) {\n // if multiple variables can take a given value \n // then we choose the first and set the rest equal to 0\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<6.9> but was:<4.6000000000000005>",
"methodName": "testMath286"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 51,
"spreadCodeOnly": 34
},
"observations": "The added \"WrapWith\" uses \"exp?a:b\" format.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"condBranIfElseAdd",
"mcRepl"
],
"repairPatterns": [
"wrapsIfElse",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "f36be8e8b7371fb8814456b6c095866aa802de78"
},
{
"bugId": 79,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"changes": [
[
1624
],
[
1626
]
]
}
},
"diff": "--- a/src/main/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/main/java/org/apache/commons/math/util/MathUtils.java\n@@ -1621,9 +1621,9 @@ public static double distance(double[] p1, double[] p2) {\n * @return the L<sub>2</sub> distance between the two points\n */\n public static double distance(int[] p1, int[] p2) {\n- int sum = 0;\n+ double sum = 0;\n for (int i = 0; i < p1.length; i++) {\n- final int dp = p1[i] - p2[i];\n+ final double dp = p1[i] - p2[i];\n sum += dp * dp;\n }\n return Math.sqrt(sum);\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.clustering.KMeansPlusPlusClustererTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "testPerformClusterAnalysisDegenerate"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"varTyChange"
],
"repairPatterns": [
"notClassified"
],
"repairTools": [
"rtCardumen",
"rtssFix"
],
"revisionId": "138baec1c778c2ea1dc1a6efe6d5e76a3b072b1d"
},
{
"bugId": 85,
"changedFiles": {
"org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java": {
"changes": [
[
198
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java\n+++ b/src/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtils.java\n@@ -195,7 +195,7 @@ public static double solve(UnivariateRealFunction f, double x0, double x1,\n } while ((fa * fb > 0.0) && (numIterations < maximumIterations) && \n ((a > lowerBound) || (b < upperBound)));\n \n- if (fa * fb >= 0.0 ) {\n+ if (fa * fb > 0.0 ) {\n throw new ConvergenceException(\n \"number of iterations={0}, maximum iterations={1}, \" +\n \"initial={2}, lower bound={3}, upper bound={4}, final a value={5}, \" +\n",
"failingTests": [
{
"className": " org.apache.commons.math.distribution.NormalDistributionTest",
"error": "org.apache.commons.math.MathException",
"message": "org.apache.commons.math.ConvergenceException: number of iterations=1, maximum iterations=2,147,483,647, initial=1, lower bound=0, upper bound=179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000, final a value=0, final b value=2, f(a)=-0.477, f(b)=0",
"methodName": "testMath280"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes operator in condition.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtAcs",
"rtCardumen",
"rtDeepRepair",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtHDRepair",
"rtJAID",
"rtKali",
"rtNopol"
],
"revisionId": "9be86f674f91fa3fe0a8694e7b98472dabe6886d"
},
{
"bugId": 89,
"changedFiles": {
"org/apache/commons/math/stat/Frequency.java": {
"inserts": [
[
110
],
[
111
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/stat/Frequency.java\n+++ b/src/java/org/apache/commons/math/stat/Frequency.java\n@@ -107,7 +107,11 @@ public String toString() {\n */\n @Deprecated\n public void addValue(Object v) {\n+ if (v instanceof Comparable<?>){\n addValue((Comparable<?>) v); \n+ } else {\n+ throw new IllegalArgumentException(\"Object must implement Comparable\");\n+ }\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.FrequencyTest",
"error": "java.lang.ClassCastException",
"message": "java.lang.Object cannot be cast to java.lang.Comparable",
"methodName": "testAddNonComparable"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [
"rtAcs"
],
"revisionId": "62b3877f953dd47c4d301be35c77446e2cf55311"
},
{
"bugId": 87,
"changedFiles": {
"org/apache/commons/math/optimization/linear/SimplexTableau.java": {
"changes": [
[
275
]
],
"deletes": [
[
276
],
[
278
],
[
280
]
],
"inserts": [
[
279
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n+++ b/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n@@ -272,12 +272,10 @@ protected static double getInvertedCoeffiecientSum(final RealVector coefficients\n private Integer getBasicRow(final int col) {\n Integer row = null;\n for (int i = getNumObjectiveFunctions(); i < getHeight(); i++) {\n- if (!MathUtils.equals(getEntry(i, col), 0.0, epsilon)) {\n- if (row == null) {\n+ if (MathUtils.equals(getEntry(i, col), 1.0, epsilon) && (row == null)) {\n row = i;\n- } else {\n+ } else if (!MathUtils.equals(getEntry(i, col), 0.0, epsilon)) {\n return null;\n- }\n }\n }\n return row;\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<10.0> but was:<0.0>",
"methodName": "testSingleVariableAndConstraint"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 2,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd",
"mcAdd"
],
"repairPatterns": [
"wrapsIfElse",
"wrongComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "75f5c92aeb47e264c196a8c38a495adac89f493c"
},
{
"bugId": 86,
"changedFiles": {
"org/apache/commons/math/linear/CholeskyDecompositionImpl.java": {
"deletes": [
[
114
],
[
115
],
[
116
]
],
"inserts": [
[
135,
136,
137,
138
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java\n+++ b/src/java/org/apache/commons/math/linear/CholeskyDecompositionImpl.java\n@@ -111,9 +111,6 @@ public CholeskyDecompositionImpl(final RealMatrix matrix,\n \n final double[] lI = lTData[i];\n \n- if (lTData[i][i] < absolutePositivityThreshold) {\n- throw new NotPositiveDefiniteMatrixException();\n- }\n // check off-diagonal elements (and reset them to 0)\n for (int j = i + 1; j < order; ++j) {\n final double[] lJ = lTData[j];\n@@ -134,6 +131,9 @@ public CholeskyDecompositionImpl(final RealMatrix matrix,\n final double[] ltI = lTData[i];\n \n // check diagonal element\n+ if (ltI[i] < absolutePositivityThreshold) {\n+ throw new NotPositiveDefiniteMatrixException();\n+ }\n \n ltI[i] = Math.sqrt(ltI[i]);\n final double inverse = 1.0 / ltI[i];\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.CholeskyDecompositionImplTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math.linear.NotPositiveDefiniteMatrixException",
"methodName": "testMath274"
},
{
"className": " org.apache.commons.math.linear.CholeskyDecompositionImplTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected exception: org.apache.commons.math.linear.NotPositiveDefiniteMatrixException",
"methodName": "testNotPositiveDefinite"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 3,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 20,
"spreadCodeOnly": 14
},
"observations": "The condition to throw the exception is moved from one place to another.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"condBranRem",
"exThrowsAdd",
"exThrowsRem",
"objInstAdd",
"objInstRem"
],
"repairPatterns": [
"codeMove"
],
"repairTools": [],
"revisionId": "bd8f05c4dda4b5b00e525e08fd6c95d256423c97"
},
{
"bugId": 88,
"changedFiles": {
"org/apache/commons/math/optimization/linear/SimplexTableau.java": {
"deletes": [
[
336
],
[
337
],
[
338
],
[
339
],
[
340
],
[
341
],
[
342
]
],
"inserts": [
[
325,
326,
327,
328,
329
],
[
331,
332,
333
],
[
343
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n+++ b/src/java/org/apache/commons/math/optimization/linear/SimplexTableau.java\n@@ -326,19 +326,18 @@ protected RealPointValuePair getSolution() {\n Integer basicRow =\n getBasicRow(getNumObjectiveFunctions() + getOriginalNumDecisionVariables());\n double mostNegative = basicRow == null ? 0 : getEntry(basicRow, getRhsOffset());\n+ Set<Integer> basicRows = new HashSet<Integer>();\n for (int i = 0; i < coefficients.length; i++) {\n basicRow = getBasicRow(getNumObjectiveFunctions() + i);\n+ if (basicRows.contains(basicRow)) {\n // if multiple variables can take a given value \n // then we choose the first and set the rest equal to 0\n+ coefficients[i] = 0;\n+ } else {\n+ basicRows.add(basicRow);\n coefficients[i] =\n (basicRow == null ? 0 : getEntry(basicRow, getRhsOffset())) -\n (restrictToNonNegative ? 0 : mostNegative);\n- if (basicRow != null) {\n- for (int j = getNumObjectiveFunctions(); j < getNumObjectiveFunctions() + i; j++) {\n- if (tableau.getEntry(basicRow, j) == 1) {\n- coefficients[i] = 0;\n- }\n- }\n }\n }\n return new RealPointValuePair(coefficients, f.getValue(coefficients));\n",
"failingTests": [
{
"className": " org.apache.commons.math.optimization.linear.SimplexSolverTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1.0> but was:<0.0>",
"methodName": "testMath272"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 6,
"methods": 1,
"sizeInLines": 11,
"spreadAllLines": 7,
"spreadCodeOnly": 5
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfElseAdd",
"condBranRem",
"loopRem",
"mcAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"blockRemove",
"condBlockRem",
"wrapsIfElse",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "24a6a2692e942969f5c39bd88d3d12ac0f0bf0d9"
},
{
"bugId": 91,
"changedFiles": {
"org/apache/commons/math/fraction/Fraction.java": {
"changes": [
[
259
],
[
260
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/fraction/Fraction.java\n+++ b/src/java/org/apache/commons/math/fraction/Fraction.java\n@@ -256,8 +256,8 @@ public Fraction abs() {\n * than <tt>object</tt>, 0 if they are equal.\n */\n public int compareTo(Fraction object) {\n- double nOd = doubleValue();\n- double dOn = object.doubleValue();\n+ long nOd = ((long) numerator) * object.denominator;\n+ long dOn = ((long) denominator) * object.numerator;\n return (nOd < dOn) ? -1 : ((nOd > dOn) ? +1 : 0);\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.fraction.FractionTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-1> but was:<0>",
"methodName": "testCompareTo"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "The value of a class attribute is accessed in place of a method to do the assignment.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"mcRem",
"varTyChange"
],
"repairPatterns": [
"expArithMod",
"initFix",
"wrongComp"
],
"repairTools": [],
"revisionId": "e1df5f5486f10ac521dfc3dc20d1bfe508e67aa8"
},
{
"bugId": 93,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"changes": [
[
346
]
],
"deletes": [
[
345
]
],
"inserts": [
[
346
],
[
377
],
[
397
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/java/org/apache/commons/math/util/MathUtils.java\n@@ -342,8 +342,10 @@ public static boolean equals(double[] x, double[] y) {\n * @throws IllegalArgumentException if n < 0\n */\n public static long factorial(final int n) {\n- long result = Math.round(factorialDouble(n));\n- if (result == Long.MAX_VALUE) {\n+ if (n < 0) {\n+ throw new IllegalArgumentException(\"must have n >= 0 for n!\");\n+ }\n+ if (n > 20) {\n throw new ArithmeticException(\n \"factorial value is too large to fit in a long\");\n }\n@@ -374,6 +376,9 @@ public static double factorialDouble(final int n) {\n if (n < 0) {\n throw new IllegalArgumentException(\"must have n >= 0 for n!\");\n }\n+ if (n < 21) {\n+ return factorial(n);\n+ }\n return Math.floor(Math.exp(factorialLog(n)) + 0.5);\n }\n \n@@ -394,6 +399,9 @@ public static double factorialLog(final int n) {\n if (n < 0) {\n throw new IllegalArgumentException(\"must have n > 0 for n!\");\n }\n+ if (n < 21) {\n+ return Math.log(factorial(n));\n+ }\n double logSum = 0;\n for (int i = 2; i <= n; i++) {\n logSum += Math.log((double)i);\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "17! expected:<3.55687428096E14> but was:<3.55687428096001E14>",
"methodName": "testFactorial"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 10,
"spreadAllLines": 50,
"spreadCodeOnly": 15
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"condExpMod",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd",
"varRem"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockRetAdd",
"expLogicMod",
"missComp",
"wrongComp"
],
"repairTools": [
"rtAcs"
],
"revisionId": "7cd3d822b65b7acdd1f6e1c82b291cd994f4fe05"
},
{
"bugId": 95,
"changedFiles": {
"org/apache/commons/math/distribution/FDistributionImpl.java": {
"changes": [
[
144
]
],
"inserts": [
[
146,
147
],
[
148
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/distribution/FDistributionImpl.java\n+++ b/src/java/org/apache/commons/math/distribution/FDistributionImpl.java\n@@ -141,10 +141,12 @@ protected double getDomainUpperBound(double p) {\n * @return initial domain value\n */\n protected double getInitialDomain(double p) {\n- double ret;\n+ double ret = 1.0;\n double d = getDenominatorDegreesOfFreedom();\n+ if (d > 2.0) {\n // use mean\n ret = d / (d - 2.0);\n+ }\n return ret;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.distribution.FDistributionTest",
"error": "java.lang.IllegalArgumentException",
"message": "Invalid endpoint parameters: lowerBound=0.0 initial=-1.0 upperBound=1.7976931348623157E308",
"methodName": "testSmallDegreesOfFreedom"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 3,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd"
],
"repairPatterns": [
"initFix",
"wrapsIf"
],
"repairTools": [
"rtCardumen",
"rtGPFL",
"rtGenProg",
"rtKali"
],
"revisionId": "fbf87122e0f7229892b6dbbf2e211cc46acea008"
},
{
"bugId": 94,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"changes": [
[
412
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/java/org/apache/commons/math/util/MathUtils.java\n@@ -409,7 +409,7 @@ public static double factorialLog(final int n) {\n * @since 1.1\n */\n public static int gcd(int u, int v) {\n- if (u * v == 0) {\n+ if ((u == 0) || (v == 0)) {\n return (Math.abs(u) + Math.abs(v));\n }\n // keep u and v negative, as negative integers range down to\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<98304> but was:<3440640>",
"methodName": "testGcd"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpExpand"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtssFix"
],
"revisionId": "a96e597894562c2cf01fc678f6c435d65ccc31c5"
},
{
"bugId": 90,
"changedFiles": {
"org/apache/commons/math/stat/Frequency.java": {
"changes": [
[
109
],
[
110
],
[
111
],
[
112
],
[
113
],
[
114
],
[
115
],
[
116
],
[
117
],
[
118
],
[
119
],
[
120
],
[
121
],
[
122
],
[
123
],
[
124
],
[
125
],
[
126
],
[
127
],
[
128
],
[
129
],
[
130
],
[
131
],
[
132
],
[
133
],
[
134
],
[
135
],
[
136
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/stat/Frequency.java\n+++ b/src/java/org/apache/commons/math/stat/Frequency.java\n@@ -107,6 +107,8 @@ public String toString() {\n */\n @Deprecated\n public void addValue(Object v) {\n+ addValue((Comparable<?>) v);\n+ }\n \n /**\n * Adds 1 to the frequency count for v.\n@@ -118,6 +120,7 @@ public void addValue(Object v) {\n * @param v the value to add.\n * @throws IllegalArgumentException if <code>v</code> is not comparable with previous entries\n */\n+ public void addValue(Comparable<?>v){\n Object obj = v;\n if (v instanceof Integer) {\n obj = Long.valueOf(((Integer) v).longValue());\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.FrequencyTest",
"error": "java.lang.IllegalArgumentException",
"message": "Value not comparable to existing values.",
"methodName": "testAddNonComparable"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 11,
"spreadCodeOnly": 0
},
"observations": "Added a new overloaded method reusing part of the implementation of an existing one. The old method just call the new one.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcAdd",
"mdAdd"
],
"repairPatterns": [
"notClassified"
],
"repairTools": [
"rtAcs"
],
"revisionId": "0c84b28c3542f3340f7ec0dffc34c60dff66604e"
},
{
"bugId": 96,
"changedFiles": {
"org/apache/commons/math/complex/Complex.java": {
"changes": [
[
258
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/complex/Complex.java\n+++ b/src/java/org/apache/commons/math/complex/Complex.java\n@@ -255,7 +255,7 @@ public boolean equals(Object other) {\n if (rhs.isNaN()) {\n ret = this.isNaN();\n } else {\n- ret = (Double.doubleToRawLongBits(real) == Double.doubleToRawLongBits(rhs.getReal())) && (Double.doubleToRawLongBits(imaginary) == Double.doubleToRawLongBits(rhs.getImaginary())); \n+ ret = (real == rhs.real) && (imaginary == rhs.imaginary); \n }\n } catch (ClassCastException ex) {\n // ignore exception\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<org.apache.commons.math.complex.Complex@98b00000> but was:<org.apache.commons.math.complex.Complex@18b00000>",
"methodName": "testMath221"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes logical expression in assignment",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"mcRem"
],
"repairPatterns": [
"expLogicMod",
"singleLine",
"unwrapMethod"
],
"repairTools": [],
"revisionId": "e6449cccdeaba96ffba4c27db322c5c3d5c18662"
},
{
"bugId": 92,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"changes": [
[
236
]
],
"deletes": [
[
184
],
[
185
],
[
186
],
[
187
],
[
188
]
],
"inserts": [
[
184,
185,
186,
187,
188,
189,
190,
191,
192,
193,
194,
195,
196,
197,
198,
199,
200,
201,
202,
203,
204,
205,
206,
207,
208
],
[
234,
235,
236
],
[
272,
273,
274,
275,
276,
277,
278,
279,
280,
281,
282,
283,
284,
285,
286,
287,
288,
289
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/java/org/apache/commons/math/util/MathUtils.java\n@@ -181,30 +181,43 @@ public static long binomialCoefficient(final int n, final int k) {\n if ((k == 1) || (k == n - 1)) {\n return n;\n }\n- long result = Math.round(binomialCoefficientDouble(n, k));\n- if (result == Long.MAX_VALUE) {\n- throw new ArithmeticException(\n- \"result too large to represent in a long integer\");\n- }\n // Use symmetry for large k\n+ if (k > n / 2)\n+ return binomialCoefficient(n, n - k);\n \n // We use the formula\n // (n choose k) = n! / (n-k)! / k!\n // (n choose k) == ((n-k+1)*...*n) / (1*...*k)\n // which could be written\n // (n choose k) == (n-1 choose k-1) * n / k\n+ long result = 1;\n+ if (n <= 61) {\n // For n <= 61, the naive implementation cannot overflow.\n+ for (int j = 1, i = n - k + 1; j <= k; i++, j++) {\n+ result = result * i / j;\n+ }\n+ } else if (n <= 66) {\n // For n > 61 but n <= 66, the result cannot overflow,\n // but we must take care not to overflow intermediate values.\n+ for (int j = 1, i = n - k + 1; j <= k; i++, j++) {\n // We know that (result * i) is divisible by j,\n // but (result * i) may overflow, so we split j:\n // Filter out the gcd, d, so j/d and i/d are integer.\n // result is divisible by (j/d) because (j/d)\n // is relative prime to (i/d) and is a divisor of\n // result * (i/d).\n+ long d = gcd(i, j);\n+ result = (result / (j / d)) * (i / d);\n+ }\n+ } else {\n // For n > 66, a result overflow might occur, so we check\n // the multiplication, taking care to not overflow\n // unnecessary.\n+ for (int j = 1, i = n - k + 1; j <= k; i++, j++) {\n+ long d = gcd(i, j);\n+ result = mulAndCheck((result / (j / d)), (i / d));\n+ }\n+ }\n return result;\n }\n \n@@ -231,9 +244,33 @@ public static long binomialCoefficient(final int n, final int k) {\n * @throws IllegalArgumentException if preconditions are not met.\n */\n public static double binomialCoefficientDouble(final int n, final int k) {\n+ if (n < k) {\n+ throw new IllegalArgumentException(\n+ \"must have n >= k for binomial coefficient (n,k)\");\n+ }\n+ if (n < 0) {\n+ throw new IllegalArgumentException(\n+ \"must have n >= 0 for binomial coefficient (n,k)\");\n+ }\n+ if ((n == k) || (k == 0)) {\n+ return 1d;\n+ }\n+ if ((k == 1) || (k == n - 1)) {\n+ return n;\n+ }\n+ if (k > n/2) {\n+ return binomialCoefficientDouble(n, n - k);\n+ }\n+ if (n < 67) {\n+ return binomialCoefficient(n,k);\n+ }\n \n+ double result = 1d;\n+ for (int i = 1; i <= k; i++) {\n+ result *= (double)(n - k + i) / (double)i;\n+ }\n \n- return Math.floor(Math.exp(binomialCoefficientLog(n, k)) + 0.5);\n+ return Math.floor(result + 0.5);\n }\n \n /**\n@@ -274,11 +311,17 @@ public static double binomialCoefficientLog(final int n, final int k) {\n * For values small enough to do exact integer computation,\n * return the log of the exact value \n */\n+ if (n < 67) { \n+ return Math.log(binomialCoefficient(n,k));\n+ }\n \n /*\n * Return the log of binomialCoefficientDouble for values that will not\n * overflow binomialCoefficientDouble\n */\n+ if (n < 1030) { \n+ return Math.log(binomialCoefficientDouble(n, k));\n+ } \n \n /*\n * Sum logs for values that could overflow\n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "48,22 expected:<27385657281648> but was:<27385657281647>",
"methodName": "testBinomialCoefficientLarge"
}
],
"metrics": {
"chunks": 12,
"classes": 1,
"files": 1,
"linesAdd": 48,
"linesMod": 1,
"linesRem": 5,
"methods": 2,
"sizeInLines": 54,
"spreadAllLines": 92,
"spreadCodeOnly": 19
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranIfElseAdd",
"condBranRem",
"exThrowsAdd",
"exThrowsRem",
"loopAdd",
"mcAdd",
"mcParValChange",
"mcRem",
"objInstAdd",
"objInstRem",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"blockRemove",
"condBlockExcAdd",
"condBlockOthersAdd",
"condBlockRem",
"condBlockRetAdd",
"expArithMod",
"missComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "85a8ab2dcfc26e83be1514acdb11d3feaac3e73d"
},
{
"bugId": 98,
"changedFiles": {
"org/apache/commons/math/linear/BigMatrixImpl.java": {
"changes": [
[
991
]
]
},
"org/apache/commons/math/linear/RealMatrixImpl.java": {
"changes": [
[
779
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/linear/BigMatrixImpl.java\n+++ b/src/java/org/apache/commons/math/linear/BigMatrixImpl.java\n@@ -988,7 +988,7 @@ public BigDecimal getTrace() throws IllegalArgumentException {\n }\n final int nRows = this.getRowDimension();\n final int nCols = this.getColumnDimension();\n- final BigDecimal[] out = new BigDecimal[v.length];\n+ final BigDecimal[] out = new BigDecimal[nRows];\n for (int row = 0; row < nRows; row++) {\n BigDecimal sum = ZERO;\n for (int i = 0; i < nCols; i++) {\n--- a/src/java/org/apache/commons/math/linear/RealMatrixImpl.java\n+++ b/src/java/org/apache/commons/math/linear/RealMatrixImpl.java\n@@ -776,7 +776,7 @@ public double getTrace() throws IllegalArgumentException {\n if (v.length != nCols) {\n throw new IllegalArgumentException(\"vector has wrong length\");\n }\n- final double[] out = new double[v.length];\n+ final double[] out = new double[nRows];\n for (int row = 0; row < nRows; row++) {\n final double[] dataRow = data[row];\n double sum = 0;\n",
"failingTests": [
{
"className": " org.apache.commons.math.linear.BigMatrixImplTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "2",
"methodName": "testMath209"
},
{
"className": " org.apache.commons.math.linear.RealMatrixImplTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "2",
"methodName": "testMath209"
}
],
"metrics": {
"chunks": 2,
"classes": 2,
"files": 2,
"linesAdd": 0,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes dimension of two vectors.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"varReplVar"
],
"repairPatterns": [
"copyPaste",
"initFix",
"wrongVarRef"
],
"repairTools": [
"rtDeepRepair"
],
"revisionId": "a0f3e0435c405ec842240413e2165863c9c76a16"
},
{
"bugId": 101,
"changedFiles": {
"org/apache/commons/math/complex/ComplexFormat.java": {
"changes": [
[
377
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/complex/ComplexFormat.java\n+++ b/src/java/org/apache/commons/math/complex/ComplexFormat.java\n@@ -374,7 +374,8 @@ public Complex parse(String source, ParsePosition pos) {\n int n = getImaginaryCharacter().length();\n startIndex = pos.getIndex();\n int endIndex = startIndex + n;\n- if (\n+ if ((startIndex >= source.length()) ||\n+ (endIndex > source.length()) ||\n source.substring(startIndex, endIndex).compareTo(\n getImaginaryCharacter()) != 0) {\n // set index back to initial, error index should be the start index\n",
"failingTests": [
{
"className": " org.apache.commons.math.complex.ComplexFormatTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 6",
"methodName": "testForgottenImaginaryCharacter"
},
{
"className": " org.apache.commons.math.complex.FrenchComplexFormatTest",
"error": "java.lang.StringIndexOutOfBoundsException",
"message": "String index out of range: 6",
"methodName": "testForgottenImaginaryCharacter"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth"
],
"revisionId": "32643d19538ad853a1280eb4060c4f15ac6dc3dd"
},
{
"bugId": 105,
"changedFiles": {
"org/apache/commons/math/stat/regression/SimpleRegression.java": {
"changes": [
[
264
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java\n+++ b/src/java/org/apache/commons/math/stat/regression/SimpleRegression.java\n@@ -261,7 +261,7 @@ public double getSlope() {\n * @return sum of squared errors associated with the regression model\n */\n public double getSumSquaredErrors() {\n- return sumYY - sumXY * sumXY / sumXX;\n+ return Math.max(0d, sumYY - sumXY * sumXY / sumXX);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.regression.SimpleRegressionTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSSENonNegative"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrapsMethod"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtJAID",
"rtNopol"
],
"revisionId": "fc21b26f84312e4f75e8b144238618c73a8b091f"
},
{
"bugId": 104,
"changedFiles": {
"org/apache/commons/math/special/Gamma.java": {
"changes": [
[
37
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/special/Gamma.java\n+++ b/src/java/org/apache/commons/math/special/Gamma.java\n@@ -34,7 +34,7 @@\n private static final long serialVersionUID = -6587513359895466954L;\n \n /** Maximum allowed numerical error. */\n- private static final double DEFAULT_EPSILON = 10e-9;\n+ private static final double DEFAULT_EPSILON = 10e-15;\n \n /** Lanczos coefficients */\n private static double[] lanczos =\n",
"failingTests": [
{
"className": " org.apache.commons.math.special.GammaTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0.632120558828558> but was:<0.6321205587649603>",
"methodName": "testRegularizedGammaPositivePositive"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 0,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange"
],
"repairPatterns": [
"constChange",
"initFix",
"singleLine"
],
"repairTools": [
"rtCardumen",
"rtElixir"
],
"revisionId": "e39a7750ef362679599b623b05bfadb150832515"
},
{
"bugId": 97,
"changedFiles": {
"org/apache/commons/math/analysis/BrentSolver.java": {
"changes": [
[
138
],
[
145
]
],
"inserts": [
[
139,
140,
141
],
[
145
],
[
148,
149
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/analysis/BrentSolver.java\n+++ b/src/java/org/apache/commons/math/analysis/BrentSolver.java\n@@ -135,17 +135,31 @@ public double solve(double min, double max) throws MaxIterationsExceededExceptio\n \n // Verify bracketing\n double sign = yMin * yMax;\n- if (sign >= 0) {\n+ if (sign > 0) {\n // check if either value is close to a zero\n+ if (Math.abs(yMin) <= functionValueAccuracy) {\n+ setResult(min, 0);\n+ ret = min;\n+ } else if (Math.abs(yMax) <= functionValueAccuracy) {\n+ setResult(max, 0);\n+ ret = max;\n+ } else {\n // neither value is close to zero and min and max do not bracket root.\n throw new IllegalArgumentException\n (\"Function values at endpoints do not have different signs.\" +\n \" Endpoints: [\" + min + \",\" + max + \"]\" + \n \" Values: [\" + yMin + \",\" + yMax + \"]\");\n- } else {\n+ }\n+ } else if (sign < 0){\n // solve using only the first endpoint as initial guess\n ret = solve(min, yMin, max, yMax, min, yMin);\n+ } else {\n // either min or max is a root\n+ if (yMin == 0.0) {\n+ ret = min;\n+ } else {\n+ ret = max;\n+ }\n }\n \n return ret;\n",
"failingTests": [
{
"className": " org.apache.commons.math.analysis.BrentSolverTest",
"error": "java.lang.IllegalArgumentException",
"message": "Function values at endpoints do not have different signs. Endpoints: [3.0,3.141592653589793] Values: [0.1411200080598672,1.2246467991473532E-16]",
"methodName": "testRootEndpoints"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 14,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 16,
"spreadAllLines": 9,
"spreadCodeOnly": 5
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"condExpMod",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicMod",
"wrapsIfElse"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth"
],
"revisionId": "ed492bd0c5c5c3a0258a65cb31cc8723d8f011fd"
},
{
"bugId": 100,
"changedFiles": {
"org/apache/commons/math/estimation/AbstractEstimator.java": {
"changes": [
[
166
],
[
202
],
[
207
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/estimation/AbstractEstimator.java\n+++ b/src/java/org/apache/commons/math/estimation/AbstractEstimator.java\n@@ -163,7 +163,7 @@ public double getChiSquare(EstimationProblem problem) {\n \n // compute transpose(J).J, avoiding building big intermediate matrices\n final int rows = problem.getMeasurements().length;\n- final int cols = problem.getAllParameters().length;\n+ final int cols = problem.getUnboundParameters().length;\n final int max = cols * rows;\n double[][] jTj = new double[cols][cols];\n for (int i = 0; i < cols; ++i) {\n@@ -199,12 +199,12 @@ public double getChiSquare(EstimationProblem problem) {\n public double[] guessParametersErrors(EstimationProblem problem)\n throws EstimationException {\n int m = problem.getMeasurements().length;\n- int p = problem.getAllParameters().length;\n+ int p = problem.getUnboundParameters().length;\n if (m <= p) {\n throw new EstimationException(\"no degrees of freedom ({0} measurements, {1} parameters)\",\n new Object[] { new Integer(m), new Integer(p)});\n }\n- double[] errors = new double[problem.getAllParameters().length];\n+ double[] errors = new double[problem.getUnboundParameters().length];\n final double c = Math.sqrt(getChiSquare(problem) / (m - p));\n double[][] covar = getCovariances(problem);\n for (int i = 0; i < errors.length; ++i) {\n",
"failingTests": [
{
"className": " org.apache.commons.math.estimation.GaussNewtonEstimatorTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "6",
"methodName": "testBoundParameters"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 39,
"spreadCodeOnly": 26
},
"observations": "Apply the same replace of methods in three different places.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignExpChange",
"mcRepl"
],
"repairPatterns": [
"copyPaste",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "876d133334e8dde309cc11f884c0dd4cc9ce530e"
},
{
"bugId": 103,
"changedFiles": {
"org/apache/commons/math/distribution/NormalDistributionImpl.java": {
"inserts": [
[
109
],
[
111
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/distribution/NormalDistributionImpl.java\n+++ b/src/java/org/apache/commons/math/distribution/NormalDistributionImpl.java\n@@ -106,8 +106,18 @@ public void setStandardDeviation(double sd) {\n * convergence exception is caught and 0 or 1 is returned.\n */\n public double cumulativeProbability(double x) throws MathException {\n+ try {\n return 0.5 * (1.0 + Erf.erf((x - mean) /\n (standardDeviation * Math.sqrt(2.0))));\n+ } catch (MaxIterationsExceededException ex) {\n+ if (x < (mean - 20 * standardDeviation)) { // JDK 1.5 blows at 38\n+ return 0.0d;\n+ } else if (x > (mean + 20 * standardDeviation)) {\n+ return 1.0d;\n+ } else {\n+ throw ex;\n+ }\n+ }\n }\n \n /**\n",
"failingTests": [
{
"className": " org.apache.commons.math.distribution.NormalDistributionTest",
"error": "org.apache.commons.math.MaxIterationsExceededException",
"message": "Maximal number of iterations (10,000) exceeded",
"methodName": "testExtremeValues"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 10,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 10,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfElseAdd",
"exThrowsAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockRetAdd",
"wrapsTryCatch",
"wrongComp"
],
"repairTools": [],
"revisionId": "4ce05bcd51ec956d789d20b59c743603d24a8ab7"
},
{
"bugId": 102,
"changedFiles": {
"org/apache/commons/math/stat/inference/ChiSquareTestImpl.java": {
"inserts": [
[
74,
75,
76
],
[
77
],
[
79
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java\n+++ b/src/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java\n@@ -71,11 +71,28 @@ public double chiSquare(double[] expected, long[] observed)\n throw new IllegalArgumentException(\n \"observed counts must be non-negative and expected counts must be postive\");\n }\n+ double sumExpected = 0d;\n+ double sumObserved = 0d;\n+ for (int i = 0; i < observed.length; i++) {\n+ sumExpected += expected[i];\n+ sumObserved += observed[i];\n+ }\n+ double ratio = 1.0d;\n+ boolean rescale = false;\n+ if (Math.abs(sumExpected - sumObserved) > 10E-6) {\n+ ratio = sumObserved / sumExpected;\n+ rescale = true;\n+ }\n double sumSq = 0.0d;\n double dev = 0.0d;\n for (int i = 0; i < observed.length; i++) {\n+ if (rescale) {\n+ dev = ((double) observed[i] - ratio * expected[i]);\n+ sumSq += dev * dev / (ratio * expected[i]);\n+ } else {\n dev = ((double) observed[i] - expected[i]);\n sumSq += dev * dev / expected[i];\n+ }\n }\n return sumSq;\n }\n",
"failingTests": [
{
"className": " org.apache.commons.math.stat.inference.ChiSquareFactoryTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<114875.90421929007> but was:<3624883.3429077636>",
"methodName": "testChiSquareLargeTestStatistic"
},
{
"className": " org.apache.commons.math.stat.inference.ChiSquareFactoryTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<9.023307936427388> but was:<16.413107036160778>",
"methodName": "testChiSquare"
},
{
"className": " org.apache.commons.math.stat.inference.ChiSquareTestTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<114875.90421929007> but was:<3624883.3429077636>",
"methodName": "testChiSquareLargeTestStatistic"
},
{
"className": " org.apache.commons.math.stat.inference.ChiSquareTestTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<9.023307936427388> but was:<16.413107036160778>",
"methodName": "testChiSquare"
},
{
"className": " org.apache.commons.math.stat.inference.TestUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<114875.90421929007> but was:<3624883.3429077636>",
"methodName": "testChiSquareLargeTestStatistic"
},
{
"className": " org.apache.commons.math.stat.inference.TestUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "chi-square test statistic expected:<9.023307936427388> but was:<16.413107036160778>",
"methodName": "testChiSquare"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 17,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 17,
"spreadAllLines": 5,
"spreadCodeOnly": 5
},
"observations": "",
"program": "commons-math",
"project": "Math",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"loopAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "a1bac127067c912b4a9f7a2957c427853a36c730"
},
{
"bugId": 99,
"changedFiles": {
"org/apache/commons/math/util/MathUtils.java": {
"inserts": [
[
543
],
[
714
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/util/MathUtils.java\n+++ b/src/java/org/apache/commons/math/util/MathUtils.java\n@@ -540,6 +540,11 @@ public static int gcd(final int p, final int q) {\n int u = p;\n int v = q;\n if ((u == 0) || (v == 0)) {\n+ if ((u == Integer.MIN_VALUE) || (v == Integer.MIN_VALUE)) {\n+ throw MathRuntimeException.createArithmeticException(\n+ \"overflow: gcd({0}, {1}) is 2^31\",\n+ new Object[] { p, q });\n+ }\n return (Math.abs(u) + Math.abs(v));\n }\n // keep u and v negative, as negative integers range down to\n@@ -711,6 +716,9 @@ public static int lcm(int a, int b) {\n return 0;\n }\n int lcm = Math.abs(mulAndCheck(a / gcd(a, b), b));\n+ if (lcm == Integer.MIN_VALUE){\n+ throw new ArithmeticException(\"overflow: lcm is 2^31\");\n+ }\n return lcm;\n }\n \n",
"failingTests": [
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expecting ArithmeticException",
"methodName": "testGcd"
},
{
"className": " org.apache.commons.math.util.MathUtilsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expecting ArithmeticException",
"methodName": "testLcm"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 171,
"spreadCodeOnly": 68
},
"observations": "Instantiates a vector object as part of the exception creation.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [
"rtAcs"
],
"revisionId": "58b5609fe8f99aabc990d885bf6c4d85631b7c79"
},
{
"bugId": 106,
"changedFiles": {
"org/apache/commons/math/fraction/ProperFractionFormat.java": {
"inserts": [
[
164,
165,
166,
167,
168
],
[
199,
200,
201,
202
]
]
}
},
"diff": "--- a/src/java/org/apache/commons/math/fraction/ProperFractionFormat.java\n+++ b/src/java/org/apache/commons/math/fraction/ProperFractionFormat.java\n@@ -162,7 +162,11 @@ public Fraction parse(String source, ParsePosition pos) {\n return null;\r\n }\r\n \r\n+ if (num.intValue() < 0) {\r\n // minus signs should be leading, invalid expression\r\n+ pos.setIndex(initialIndex);\r\n+ return null;\r\n+ }\r\n \r\n // parse '/'\r\n int startIndex = pos.getIndex();\r\n@@ -197,7 +201,11 @@ public Fraction parse(String source, ParsePosition pos) {\n return null;\r\n }\r\n \r\n+ if (den.intValue() < 0) {\r\n // minus signs must be leading, invalid\r\n+ pos.setIndex(initialIndex);\r\n+ return null;\r\n+ }\r\n \r\n int w = whole.intValue();\r\n int n = num.intValue();\r\n",
"failingTests": [
{
"className": " org.apache.commons.math.fraction.FractionFormatTest",
"error": "junit.framework.AssertionFailedError",
"message": "invalid minus in improper fraction.",
"methodName": "testParseProperInvalidMinus"
}
],
"metrics": {
"chunks": 4,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 36,
"spreadCodeOnly": 18
},
"observations": "Only one variable is different between the two blocks of code in patch.",
"program": "commons-math",
"project": "Math",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste"
],
"repairTools": [],
"revisionId": "41ba9e00e3bbde990f6821f67f0da2a5575b9ac3"
},
{
"bugId": 3,
"changedFiles": {
"org/mockito/internal/invocation/InvocationMatcher.java": {
"changes": [
[
127
],
[
128
],
[
129
],
[
130
],
[
131
],
[
132
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/invocation/InvocationMatcher.java\n+++ b/src/org/mockito/internal/invocation/InvocationMatcher.java\n@@ -124,10 +124,12 @@ public void captureArgumentsFrom(Invocation invocation) {\n ((CapturesArguments) m).captureFrom(invocation.getArgumentAt(position, Object.class));\n }\n }\n- for (int position = indexOfVararg; position < matchers.size(); position++) {\n- Matcher m = matchers.get(position);\n+ for (Matcher m : uniqueMatcherSet(indexOfVararg)) {\n if (m instanceof CapturesArguments) {\n- ((CapturesArguments) m).captureFrom(invocation.getRawArguments()[position - indexOfVararg]);\n+ Object rawArgument = invocation.getRawArguments()[indexOfVararg];\n+ for (int i = 0; i < Array.getLength(rawArgument); i++) {\n+ ((CapturesArguments) m).captureFrom(Array.get(rawArgument, i));\n+ }\n }\n }\n } else {\n@@ -140,6 +142,18 @@ public void captureArgumentsFrom(Invocation invocation) {\n }\n }\n \n+ private Set<Matcher> uniqueMatcherSet(int indexOfVararg) {\n+ HashSet<Matcher> set = new HashSet<Matcher>();\n+ for (int position = indexOfVararg; position < matchers.size(); position++) {\n+ Matcher matcher = matchers.get(position);\n+ if(matcher instanceof MatcherDecorator) {\n+ set.add(((MatcherDecorator) matcher).getActualMatcher());\n+ } else {\n+ set.add(matcher);\n+ }\n+ }\n+ return set;\n+ }\n \n public static List<InvocationMatcher> createFrom(List<Invocation> invocations) {\n LinkedList<InvocationMatcher> out = new LinkedList<InvocationMatcher>();\n",
"failingTests": [
{
"className": " org.mockito.internal.invocation.InvocationMatcherTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[['a', 'b']]> but was:<[[1]]>",
"methodName": "should_capture_varargs_as_vararg"
},
{
"className": " org.mockitousage.bugs.varargs.VarargsAndAnyObjectPicksUpExtraInvocationsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "2",
"methodName": "shouldVerifyCorrectlyNumberOfInvocationsWithVarargs"
},
{
"className": " org.mockitousage.bugs.varargs.VarargsNotPlayingWithAnyObjectTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "1",
"methodName": "shouldMatchAnyVararg"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[['a', 'b', 'c', 'again ?!']]> but was:<[[42, 42]]>",
"methodName": "should_capture_all_vararg"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "2",
"methodName": "captures_correctly_when_captor_used_multiple_times"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<[['a', 'b', 'c']]> but was:<[[42]]>",
"methodName": "should_capture_vararg"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "1",
"methodName": "captures_correctly_when_captor_used_on_pure_vararg_method"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "java.lang.ClassCastException",
"message": "[B cannot be cast to java.lang.Byte",
"methodName": "should_capture_byte_vararg_by_creating_captor_with_primitive_wrapper"
},
{
"className": " org.mockitousage.matchers.CapturingArgumentsTest",
"error": "java.lang.ClassCastException",
"message": "[B cannot be cast to java.lang.Byte",
"methodName": "should_capture_byte_vararg_by_creating_captor_with_primitive"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 15,
"linesMod": 2,
"linesRem": 1,
"methods": 2,
"sizeInLines": 18,
"spreadAllLines": 13,
"spreadCodeOnly": 12
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"condBranIfElseAdd",
"loopAdd",
"loopCondChange",
"mcAdd",
"mcRem",
"mdAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"wrongComp"
],
"repairTools": [],
"revisionId": "3eec7451d6c83c280743c39b39c77a179abb30f9"
},
{
"bugId": 2,
"changedFiles": {
"org/mockito/internal/util/Timer.java": {
"inserts": [
[
-1
],
[
10
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/Timer.java\n+++ b/src/org/mockito/internal/util/Timer.java\n@@ -1,5 +1,6 @@\n package org.mockito.internal.util;\n \n+import org.mockito.exceptions.Reporter;\n \n public class Timer {\n \n@@ -7,6 +8,7 @@\n private long startTime = -1;\n \n public Timer(long durationMillis) {\n+ validateInput(durationMillis);\n this.durationMillis = durationMillis;\n }\n \n@@ -25,4 +27,9 @@ public void start() {\n startTime = System.currentTimeMillis();\n }\n \n+ private void validateInput(long durationMillis) {\n+ if (durationMillis < 0) {\n+ new Reporter().cannotCreateTimerWithNegativeDurationTime(durationMillis);\n+ }\n+ }\n }\n",
"failingTests": [
{
"className": " org.mockito.internal.util.TimerTest",
"error": "junit.framework.AssertionFailedError",
"message": "It is forbidden to create timer with negative value of timer's duration.",
"methodName": "should_throw_friendly_reminder_exception_when_duration_is_negative"
},
{
"className": " org.mockito.verification.NegativeDurationTest",
"error": "junit.framework.AssertionFailedError",
"message": "It is forbidden to invoke Mockito.timeout() with negative value.",
"methodName": "should_throw_exception_when_duration_is_negative_for_timeout_method"
},
{
"className": " org.mockito.verification.NegativeDurationTest",
"error": "junit.framework.AssertionFailedError",
"message": "It is forbidden to invoke Mockito.after() with negative value.",
"methodName": "should_throw_exception_when_duration_is_negative_for_after_method"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 7,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 7,
"spreadAllLines": 25,
"spreadCodeOnly": 13
},
"observations": "import and instantiate a new Reporter object. It appears as an validation object/procedure.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"mdAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [],
"revisionId": "80452c7a42777513c35fd30c4e12bcd7ee438fb9"
},
{
"bugId": 1,
"changedFiles": {
"org/mockito/internal/invocation/InvocationMatcher.java": {
"deletes": [
[
123
]
],
"inserts": [
[
123,
124,
125
]
]
}
},
"diff": "--- a/src/org/mockito/internal/invocation/InvocationMatcher.java\n+++ b/src/org/mockito/internal/invocation/InvocationMatcher.java\n@@ -120,7 +120,18 @@ public Location getLocation() {\n public void captureArgumentsFrom(Invocation invocation) {\n if (invocation.getMethod().isVarArgs()) {\n int indexOfVararg = invocation.getRawArguments().length - 1;\n- throw new UnsupportedOperationException();\n+ for (int position = 0; position < indexOfVararg; position++) {\n+ Matcher m = matchers.get(position);\n+ if (m instanceof CapturesArguments) {\n+ ((CapturesArguments) m).captureFrom(invocation.getArgumentAt(position, Object.class));\n+ }\n+ }\n+ for (int position = indexOfVararg; position < matchers.size(); position++) {\n+ Matcher m = matchers.get(position);\n+ if (m instanceof CapturesArguments) {\n+ ((CapturesArguments) m).captureFrom(invocation.getRawArguments()[position - indexOfVararg]);\n+ }\n+ }\n \n } else {\n for (int position = 0; position < matchers.size(); position++) {\n",
"failingTests": [
{
"className": " org.mockito.internal.invocation.InvocationMatcherTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_capture_arguments_when_args_count_does_NOT_match"
},
{
"className": " org.mockito.internal.util.reflection.FieldInitializerTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "can_instantiate_class_with_parameterized_constructor"
},
{
"className": " org.mockito.internal.util.reflection.ParameterizedConstructorInstantiatorTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_report_failure_if_constructor_throws_exception"
},
{
"className": " org.mockito.internal.util.reflection.ParameterizedConstructorInstantiatorTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_fail_if_an_argument_instance_type_do_not_match_wanted_type"
},
{
"className": " org.mockito.internal.util.reflection.ParameterizedConstructorInstantiatorTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_instantiate_type_with_vararg_constructor"
},
{
"className": " org.mockito.internal.util.reflection.ParameterizedConstructorInstantiatorTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_instantiate_type_if_resolver_provide_matching_types"
},
{
"className": " org.mockitousage.basicapi.ResetTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldRemoveAllStubbing"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyWithNullVarArgArray"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyWithAnyObject"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldStubBooleanVarargs"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldMatchEasilyEmptyVararg"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyBooleanVarargs"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldStubCorrectlyWhenMixedVarargsUsed"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldStubStringVarargs"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldStubCorrectlyWhenDoubleStringAndMixedVarargsUsed"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyStringVarargs"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyObjectVarargs"
},
{
"className": " org.mockitousage.bugs.VarargsErrorWhenCallingRealMethodTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldNotThrowAnyException"
},
{
"className": " org.mockitousage.bugs.varargs.VarargsAndAnyObjectPicksUpExtraInvocationsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyCorrectlyWithAnyVarargs"
},
{
"className": " org.mockitousage.bugs.varargs.VarargsAndAnyObjectPicksUpExtraInvocationsTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyCorrectlyNumberOfInvocationsUsingAnyVarargAndEqualArgument"
},
{
"className": " org.mockitousage.bugs.varargs.VarargsNotPlayingWithAnyObjectTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldStubUsingAnyVarargs"
},
{
"className": " org.mockitousage.matchers.VerificationAndStubbingUsingMatchersTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldVerifyUsingMatchers"
},
{
"className": " org.mockitousage.stubbing.BasicStubbingTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "test_stub_only_not_verifiable"
},
{
"className": " org.mockitousage.stubbing.BasicStubbingTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "should_evaluate_latest_stubbing_first"
},
{
"className": " org.mockitousage.stubbing.DeprecatedStubbingTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldEvaluateLatestStubbingFirst"
},
{
"className": " org.mockitousage.verification.VerificationInOrderMixedWithOrdiraryVerificationTest",
"error": "java.lang.UnsupportedOperationException",
"message": "",
"methodName": "shouldUseEqualsToVerifyMethodVarargs"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 11,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsRem",
"loopAdd",
"objInstRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missComp"
],
"repairTools": [],
"revisionId": "4e9d7607825c3c668fd43f19507bfead566c528c"
},
{
"bugId": 7,
"changedFiles": {
"org/mockito/internal/util/reflection/GenericMetadataSupport.java": {
"inserts": [
[
379
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/reflection/GenericMetadataSupport.java\n+++ b/src/org/mockito/internal/util/reflection/GenericMetadataSupport.java\n@@ -376,6 +376,7 @@ private void readTypeVariables() {\n for (Type type : typeVariable.getBounds()) {\r\n registerTypeVariablesOn(type);\r\n }\r\n+ registerTypeParametersOn(new TypeVariable[] { typeVariable });\r\n registerTypeVariablesOn(getActualTypeArgumentFor(typeVariable));\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.deepstubs.DeepStubFailingWhenGenricNestedAsRawTypeTest",
"error": "org.mockito.exceptions.base.MockitoException",
"message": "Raw extraction not supported for : 'null'",
"methodName": "discoverDeepMockingOfGenerics"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Instantiates and initializes an TypeVariable vector.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"missComp",
"singleLine"
],
"repairTools": [],
"revisionId": "0aaa36ce6924ca87f88e3723771413b42b80dc5a"
},
{
"bugId": 4,
"changedFiles": {
"org/mockito/exceptions/Reporter.java": {
"changes": [
[
424
],
[
434
]
],
"inserts": [
[
677
]
]
}
},
"diff": "--- a/src/org/mockito/exceptions/Reporter.java\n+++ b/src/org/mockito/exceptions/Reporter.java\n@@ -421,7 +421,7 @@ public void noMoreInteractionsWanted(Invocation undesired, List<VerificationAwar\n throw new NoInteractionsWanted(join(\n \"No interactions wanted here:\",\n new LocationImpl(),\n- \"But found this interaction on mock '\" + undesired.getMock() + \"':\",\n+ \"But found this interaction on mock '\" + safelyGetMockName(undesired.getMock()) + \"':\",\n undesired.getLocation(),\n scenario\n ));\n@@ -431,7 +431,7 @@ public void noMoreInteractionsWantedInOrder(Invocation undesired) {\n throw new VerificationInOrderFailure(join(\n \"No interactions wanted here:\",\n new LocationImpl(),\n- \"But found this interaction on mock '\" + undesired.getMock() + \"':\",\n+ \"But found this interaction on mock '\" + safelyGetMockName(undesired.getMock()) + \"':\",\n undesired.getLocation()\n ));\n }\n@@ -674,6 +674,9 @@ public void cannotInjectDependency(Field field, Object matchingMock, Exception d\n }\n \n private String exceptionCauseMessageIfAvailable(Exception details) {\n+ if (details.getCause() == null) {\n+ return details.getMessage();\n+ }\n return details.getCause().getMessage();\n }\n \n",
"failingTests": [
{
"className": " org.mockito.exceptions.ReporterTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.mockito.exceptions.verification.VerificationInOrderFailure> but was<java.lang.ClassCastException>",
"methodName": "can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_no_more_interaction_wanted_in_order"
},
{
"className": " org.mockito.exceptions.ReporterTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.mockito.exceptions.base.MockitoException> but was<java.lang.NullPointerException>",
"methodName": "can_use_print_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_injection_failure"
},
{
"className": " org.mockito.exceptions.ReporterTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.mockito.exceptions.verification.NoInteractionsWanted> but was<java.lang.ClassCastException>",
"methodName": "can_use_mock_name_even_when_mock_bogus_default_answer_and_when_reporting_no_more_interaction_wanted"
},
{
"className": " org.mockitousage.bugs.ClassCastExOnVerifyZeroInteractionsTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<org.mockito.exceptions.verification.NoInteractionsWanted> but was<java.lang.ClassCastException>",
"methodName": "should_not_throw_a_ClassCastException"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 2,
"linesRem": 0,
"methods": 3,
"sizeInLines": 5,
"spreadAllLines": 251,
"spreadCodeOnly": 223
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missNullCheckP",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "42b391d4209024292b6101048389570e4ec36b2a"
},
{
"bugId": 11,
"changedFiles": {
"org/mockito/internal/creation/DelegatingMethod.java": {
"changes": [
[
60
]
],
"inserts": [
[
55
],
[
56
]
]
}
},
"diff": "--- a/src/org/mockito/internal/creation/DelegatingMethod.java\n+++ b/src/org/mockito/internal/creation/DelegatingMethod.java\n@@ -52,11 +52,19 @@ public boolean isAbstract() {\n */\n @Override\n public boolean equals(Object o) {\n+ if (this == o) {\n+ return true;\n+ }\n+ if (o instanceof DelegatingMethod) {\n+ DelegatingMethod that = (DelegatingMethod) o;\n+ return method.equals(that.method);\n+ } else {\n return method.equals(o);\n+ }\n }\n \n @Override\n public int hashCode() {\n- return 1;\n+ return method.hashCode();\n }\n }\n\\ No newline at end of file\n",
"failingTests": [
{
"className": " org.mockito.internal.creation.DelegatingMethodTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "equals_should_return_true_when_equal"
},
{
"className": " org.mockito.internal.creation.DelegatingMethodTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "equals_should_return_true_when_self"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 9,
"spreadAllLines": 5,
"spreadCodeOnly": 4
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "1802cf79c482f2df29abb3d6735bcf0b16cedb7d"
},
{
"bugId": 10,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java": {
"changes": [
[
71
],
[
87
],
[
90
],
[
94
],
[
99
]
],
"inserts": [
[
-1
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n@@ -14,6 +14,7 @@\n import org.mockito.internal.util.MockUtil;\r\n import org.mockito.internal.util.reflection.GenericMetadataSupport;\r\n import org.mockito.invocation.InvocationOnMock;\r\n+import org.mockito.mock.MockCreationSettings;\r\n import org.mockito.stubbing.Answer;\r\n \r\n import java.io.IOException;\r\n@@ -68,7 +69,7 @@ private Object deepStub(InvocationOnMock invocation, GenericMetadataSupport retu\n \r\n // record deep stub answer\r\n return recordDeepStubAnswer(\r\n- newDeepStubMock(returnTypeGenericMetadata),\r\n+ newDeepStubMock(returnTypeGenericMetadata, invocation.getMock()),\r\n container\r\n );\r\n }\r\n@@ -84,22 +85,26 @@ private Object deepStub(InvocationOnMock invocation, GenericMetadataSupport retu\n * @param parentMock The parent of the current deep stub mock.\r\n * @return The mock\r\n */\r\n- private Object newDeepStubMock(GenericMetadataSupport returnTypeGenericMetadata) {\r\n+ private Object newDeepStubMock(GenericMetadataSupport returnTypeGenericMetadata, Object parentMock) {\r\n+ MockCreationSettings parentMockSettings = new MockUtil().getMockSettings(parentMock);\r\n return mockitoCore().mock(\r\n returnTypeGenericMetadata.rawType(),\r\n- withSettingsUsing(returnTypeGenericMetadata)\r\n+ withSettingsUsing(returnTypeGenericMetadata, parentMockSettings)\r\n );\r\n }\r\n \r\n- private MockSettings withSettingsUsing(GenericMetadataSupport returnTypeGenericMetadata) {\r\n+ private MockSettings withSettingsUsing(GenericMetadataSupport returnTypeGenericMetadata, MockCreationSettings parentMockSettings) {\r\n MockSettings mockSettings = returnTypeGenericMetadata.hasRawExtraInterfaces() ?\r\n withSettings().extraInterfaces(returnTypeGenericMetadata.rawExtraInterfaces())\r\n : withSettings();\r\n \r\n- return mockSettings.serializable()\r\n+ return propagateSerializationSettings(mockSettings, parentMockSettings)\r\n .defaultAnswer(returnsDeepStubsAnswerUsing(returnTypeGenericMetadata));\r\n }\r\n \r\n+ private MockSettings propagateSerializationSettings(MockSettings mockSettings, MockCreationSettings parentMockSettings) {\r\n+ return mockSettings.serializable(parentMockSettings.getSerializableMode());\r\n+ }\r\n \r\n private ReturnsDeepStubs returnsDeepStubsAnswerUsing(final GenericMetadataSupport returnTypeGenericMetadata) {\r\n return new ReturnsDeepStubsSerializationFallback(returnTypeGenericMetadata);\r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.DeepStubsWronglyReportsSerializationProblemsTest",
"error": "org.mockito.exceptions.base.MockitoException",
"message": "",
"methodName": "should_not_raise_a_mockito_exception_about_serialization_when_accessing_deep_stub"
}
],
"metrics": {
"chunks": 7,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 5,
"linesRem": 0,
"methods": 4,
"sizeInLines": 10,
"spreadAllLines": 81,
"spreadCodeOnly": 36
},
"observations": "Changes signature of existent methods, adding new params.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcParAdd",
"mcRepl",
"mdAdd",
"mdParAdd",
"objInstAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"missComp",
"notClassified"
],
"repairTools": [],
"revisionId": "1beeae39ac9f79d6a0db285dec311b78025ac062"
},
{
"bugId": 5,
"changedFiles": {
"org/mockito/internal/verification/VerificationOverTimeImpl.java": {
"changes": [
[
91
]
]
}
},
"diff": "--- a/src/org/mockito/internal/verification/VerificationOverTimeImpl.java\n+++ b/src/org/mockito/internal/verification/VerificationOverTimeImpl.java\n@@ -88,7 +88,7 @@ public void verify(VerificationData data) {\n } catch (MockitoAssertionError e) {\n error = handleVerifyException(e);\n }\n- catch (org.mockito.exceptions.verification.junit.ArgumentsAreDifferent e) {\n+ catch (AssertionError e) {\n error = handleVerifyException(e);\n }\n }\n",
"failingTests": [
{
"className": " org.mockitointegration.NoJUnitDependenciesTest",
"error": "junit.framework.AssertionFailedError",
"message": "'org.mockito.internal.verification.VerificationOverTimeImpl' has some dependency to JUnit",
"methodName": "pure_mockito_should_not_depend_JUnit"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Change parameter type in catch command.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"varTyChange"
],
"repairPatterns": [
"singleLine"
],
"repairTools": [],
"revisionId": "42a24dde02923185db3f79ae57e7819f7d70af55"
},
{
"bugId": 6,
"changedFiles": {
"org/mockito/Matchers.java": {
"changes": [
[
122
],
[
137
],
[
152
],
[
167
],
[
182
],
[
197
],
[
212
],
[
227
],
[
244
],
[
292
],
[
309
],
[
324
],
[
339
],
[
358
],
[
373
],
[
392
],
[
407
],
[
427
],
[
442
],
[
461
]
]
}
},
"diff": "--- a/src/org/mockito/Matchers.java\n+++ b/src/org/mockito/Matchers.java\n@@ -119,7 +119,7 @@\n * @return <code>false</code>.\r\n */\r\n public static boolean anyBoolean() {\r\n- return reportMatcher(Any.ANY).returnFalse();\r\n+ return reportMatcher(new InstanceOf(Boolean.class)).returnFalse();\r\n }\r\n \r\n /**\r\n@@ -134,7 +134,7 @@ public static boolean anyBoolean() {\n * @return <code>0</code>.\r\n */\r\n public static byte anyByte() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Byte.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -149,7 +149,7 @@ public static byte anyByte() {\n * @return <code>0</code>.\r\n */\r\n public static char anyChar() {\r\n- return reportMatcher(Any.ANY).returnChar();\r\n+ return reportMatcher(new InstanceOf(Character.class)).returnChar();\r\n }\r\n \r\n /**\r\n@@ -164,7 +164,7 @@ public static char anyChar() {\n * @return <code>0</code>.\r\n */\r\n public static int anyInt() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Integer.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -179,7 +179,7 @@ public static int anyInt() {\n * @return <code>0</code>.\r\n */\r\n public static long anyLong() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Long.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -194,7 +194,7 @@ public static long anyLong() {\n * @return <code>0</code>.\r\n */\r\n public static float anyFloat() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Float.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -209,7 +209,7 @@ public static float anyFloat() {\n * @return <code>0</code>.\r\n */\r\n public static double anyDouble() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Double.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -224,7 +224,7 @@ public static double anyDouble() {\n * @return <code>0</code>.\r\n */\r\n public static short anyShort() {\r\n- return reportMatcher(Any.ANY).returnZero();\r\n+ return reportMatcher(new InstanceOf(Short.class)).returnZero();\r\n }\r\n \r\n /**\r\n@@ -241,7 +241,7 @@ public static short anyShort() {\n * @return <code>null</code>.\r\n */\r\n public static <T> T anyObject() {\r\n- return (T) reportMatcher(Any.ANY).returnNull();\r\n+ return (T) reportMatcher(new InstanceOf(Object.class)).returnNull();\r\n }\r\n \r\n /**\r\n@@ -289,7 +289,7 @@ public static short anyShort() {\n * @return <code>null</code>.\r\n */\r\n public static <T> T any(Class<T> clazz) {\r\n- return (T) reportMatcher(Any.ANY).returnFor(clazz);\r\n+ return (T) reportMatcher(new InstanceOf(clazz)).returnFor(clazz);\r\n }\r\n \r\n /**\r\n@@ -306,7 +306,7 @@ public static short anyShort() {\n * @return <code>null</code>.\r\n */\r\n public static <T> T any() {\r\n- return (T) anyObject();\r\n+ return (T) reportMatcher(Any.ANY).returnNull();\r\n }\r\n \r\n /**\r\n@@ -321,7 +321,7 @@ public static short anyShort() {\n * @return empty String (\"\")\r\n */\r\n public static String anyString() {\r\n- return reportMatcher(Any.ANY).returnString();\r\n+ return reportMatcher(new InstanceOf(String.class)).returnString();\r\n }\r\n \r\n /**\r\n@@ -336,7 +336,7 @@ public static String anyString() {\n * @return empty List.\r\n */\r\n public static List anyList() {\r\n- return reportMatcher(Any.ANY).returnList();\r\n+ return reportMatcher(new InstanceOf(List.class)).returnList();\r\n } \r\n \r\n /**\r\n@@ -355,7 +355,7 @@ public static List anyList() {\n * @return empty List.\r\n */\r\n public static <T> List<T> anyListOf(Class<T> clazz) {\r\n- return (List) reportMatcher(Any.ANY).returnList();\r\n+ return anyList();\r\n } \r\n \r\n /**\r\n@@ -370,7 +370,7 @@ public static List anyList() {\n * @return empty Set\r\n */\r\n public static Set anySet() {\r\n- return reportMatcher(Any.ANY).returnSet();\r\n+ return reportMatcher(new InstanceOf(Set.class)).returnSet();\r\n }\r\n \r\n /**\r\n@@ -389,7 +389,7 @@ public static Set anySet() {\n * @return empty Set\r\n */\r\n public static <T> Set<T> anySetOf(Class<T> clazz) {\r\n- return (Set) reportMatcher(Any.ANY).returnSet();\r\n+ return anySet();\r\n }\r\n \r\n /**\r\n@@ -404,7 +404,7 @@ public static Set anySet() {\n * @return empty Map.\r\n */\r\n public static Map anyMap() {\r\n- return reportMatcher(Any.ANY).returnMap();\r\n+ return reportMatcher(new InstanceOf(Map.class)).returnMap();\r\n }\r\n \r\n /**\r\n@@ -424,7 +424,7 @@ public static Map anyMap() {\n * @return empty Map.\r\n */\r\n public static <K, V> Map<K, V> anyMapOf(Class<K> keyClazz, Class<V> valueClazz) {\r\n- return reportMatcher(Any.ANY).returnMap();\r\n+ return anyMap();\r\n }\r\n \r\n /**\r\n@@ -439,7 +439,7 @@ public static Map anyMap() {\n * @return empty Collection.\r\n */\r\n public static Collection anyCollection() {\r\n- return reportMatcher(Any.ANY).returnList();\r\n+ return reportMatcher(new InstanceOf(Collection.class)).returnList();\r\n } \r\n \r\n /**\r\n@@ -458,7 +458,7 @@ public static Collection anyCollection() {\n * @return empty Collection.\r\n */\r\n public static <T> Collection<T> anyCollectionOf(Class<T> clazz) {\r\n- return (Collection) reportMatcher(Any.ANY).returnList();\r\n+ return anyCollection();\r\n } \r\n \r\n /**\r\n",
"failingTests": [
{
"className": " org.mockitousage.matchers.AnyXMatchersAcceptNullsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<0>",
"methodName": "shouldNotAcceptNullInAllAnyPrimitiveWrapperMatchers"
},
{
"className": " org.mockitousage.matchers.AnyXMatchersAcceptNullsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<0>",
"methodName": "shouldNotAcceptNullInAnyXMatchers"
},
{
"className": " org.mockitousage.matchers.MatchersTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<matched>",
"methodName": "anyStringMatcher"
},
{
"className": " org.mockitousage.matchers.NewMatchersTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<matched>",
"methodName": "shouldAllowAnyCollection"
},
{
"className": " org.mockitousage.matchers.NewMatchersTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<matched>",
"methodName": "shouldAllowAnyList"
},
{
"className": " org.mockitousage.matchers.NewMatchersTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<matched>",
"methodName": "shouldAllowAnyMap"
},
{
"className": " org.mockitousage.matchers.NewMatchersTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<null> but was:<matched>",
"methodName": "shouldAllowAnySet"
}
],
"metrics": {
"chunks": 20,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 20,
"linesRem": 0,
"methods": 20,
"sizeInLines": 20,
"spreadAllLines": 320,
"spreadCodeOnly": 41
},
"observations": "Instantiates specific objects in place of call do Any.ANY",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcParValChange",
"objInstAdd",
"varReplMc"
],
"repairPatterns": [
"copyPaste",
"wrongMethodRef",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "dc205824dbc289acbcde919e430176ad72da847f"
},
{
"bugId": 9,
"changedFiles": {
"org/mockito/internal/stubbing/answers/CallsRealMethods.java": {
"inserts": [
[
-1
],
[
-1
],
[
36
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/answers/CallsRealMethods.java\n+++ b/src/org/mockito/internal/stubbing/answers/CallsRealMethods.java\n@@ -5,7 +5,9 @@\n package org.mockito.internal.stubbing.answers;\r\n \r\n import java.io.Serializable;\n+import java.lang.reflect.Modifier;\n \n+import org.mockito.internal.stubbing.defaultanswers.GloballyConfiguredAnswer;\n import org.mockito.invocation.InvocationOnMock;\n import org.mockito.stubbing.Answer;\n \r\n@@ -33,6 +35,9 @@\n private static final long serialVersionUID = 9057165148930624087L;\r\n \r\n public Object answer(InvocationOnMock invocation) throws Throwable {\n+ \tif (Modifier.isAbstract(invocation.getMethod().getModifiers())) {\n+ \t\treturn new GloballyConfiguredAnswer().answer(invocation);\n+ \t}\n return invocation.callRealMethod();\r\n }\r\n }\n\\ No newline at end of file\n",
"failingTests": [
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "org.mockito.exceptions.base.MockitoException",
"message": "",
"methodName": "abstractMethodStubbed"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "org.mockito.exceptions.base.MockitoException",
"message": "",
"methodName": "testCallsRealInterfaceMethod"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "org.mockito.exceptions.base.MockitoException",
"message": "",
"methodName": "abstractMethodReturnsDefault"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 28,
"spreadCodeOnly": 5
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "31f908029b8cd9b1f32bed3a41651b30ebb47b9f"
},
{
"bugId": 8,
"changedFiles": {
"org/mockito/internal/util/reflection/GenericMetadataSupport.java": {
"changes": [
[
79
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/reflection/GenericMetadataSupport.java\n+++ b/src/org/mockito/internal/util/reflection/GenericMetadataSupport.java\n@@ -76,7 +76,7 @@ protected void registerTypeVariablesOn(Type classType) {\n \r\n if (actualTypeArgument instanceof WildcardType) {\r\n contextualActualTypeParameters.put(typeParameter, boundsOf((WildcardType) actualTypeArgument));\r\n- } else {\r\n+ } else if (typeParameter != actualTypeArgument) {\r\n contextualActualTypeParameters.put(typeParameter, actualTypeArgument);\r\n }\r\n // logger.log(\"For '\" + parameterizedType + \"' found type variable : { '\" + typeParameter + \"(\" + System.identityHashCode(typeParameter) + \")\" + \"' : '\" + actualTypeArgument + \"(\" + System.identityHashCode(typeParameter) + \")\" + \"' }\");\r\n",
"failingTests": [
{
"className": " org.mockito.internal.util.reflection.GenericMetadataSupportTest",
"error": "java.lang.StackOverflowError",
"message": "",
"methodName": "typeVariable_of_self_type"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Replaced and \"else\" with an \"else if\"",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"singleLine",
"wrapsIf"
],
"repairTools": [],
"revisionId": "5a03bf5d0c9aedac9cfbf074833167c1eca6439f"
},
{
"bugId": 16,
"changedFiles": {
"org/mockito/Mockito.java": {
"changes": [
[
827
],
[
899
]
]
},
"org/mockito/internal/MockitoCore.java": {
"changes": [
[
33
]
],
"deletes": [
[
32
]
],
"inserts": [
[
35
],
[
36
]
]
}
},
"diff": "--- a/src/org/mockito/Mockito.java\n+++ b/src/org/mockito/Mockito.java\n@@ -1,921 +1,921 @@\n /*\r\n * Copyright (c) 2007 Mockito contributors\r\n * This program is made available under the terms of the MIT License.\r\n */\r\n package org.mockito;\r\n \r\n import org.mockito.internal.MockitoCore;\r\n import org.mockito.internal.creation.MockSettingsImpl;\r\n import org.mockito.internal.debugging.MockitoDebuggerImpl;\r\n import org.mockito.internal.stubbing.answers.*;\r\n import org.mockito.internal.stubbing.defaultanswers.*;\r\n import org.mockito.internal.verification.VerificationModeFactory;\r\n import org.mockito.internal.verification.api.VerificationMode;\r\n import org.mockito.runners.MockitoJUnitRunner;\r\n import org.mockito.stubbing.*;\r\n \r\n /**\r\n * <p align=\"left\"><img src=\"logo.jpg\"/></p>\r\n * Mockito library enables mocks creation, verification and stubbing.\r\n * <p>\r\n * This javadoc content is also available on the <a href=\"http://mockito.org\">http://mockito.org</a> web page. \r\n * All documentation is kept in javadocs because it guarantees consistency between what's on the web and what's in the source code.\r\n * Also, it makes possible to access documentation straight from the IDE even if you work offline. \r\n * \r\n * <h1>Contents</h1>\r\n * \r\n * <b> \r\n * <a href=\"#1\">1. Let's verify some behaviour! </a><br/> \r\n * <a href=\"#2\">2. How about some stubbing? </a><br/>\r\n * <a href=\"#3\">3. Argument matchers </a><br/>\r\n * <a href=\"#4\">4. Verifying exact number of invocations / at least once / never </a><br/> \r\n * <a href=\"#5\">5. Stubbing void methods with exceptions </a><br/> \r\n * <a href=\"#6\">6. Verification in order </a><br/> \r\n * <a href=\"#7\">7. Making sure interaction(s) never happened on mock </a><br/> \r\n * <a href=\"#8\">8. Finding redundant invocations </a><br/> \r\n * <a href=\"#9\">9. Shorthand for mocks creation - &#064;Mock annotation </a><br/> \r\n * <a href=\"#10\">10. Stubbing consecutive calls (iterator-style stubbing) </a><br/> \r\n * <a href=\"#11\">11. Stubbing with callbacks </a><br/>\r\n * <a href=\"#12\">12. doThrow()|doAnswer()|doNothing()|doReturn() family of methods mostly for stubbing voids </a><br/>\r\n * <a href=\"#13\">13. Spying on real objects </a><br/>\r\n * <a href=\"#14\">14. Changing default return values of unstubbed invocations (Since 1.7) </a><br/>\r\n * <a href=\"#15\">15. Capturing arguments for further assertions (Since 1.8.0) </a><br/>\r\n * <a href=\"#16\">16. Real partial mocks (Since 1.8.0) </a><br/>\r\n * <a href=\"#17\">17. Resetting mocks (Since 1.8.0) </a><br/>\r\n * <a href=\"#18\">18. Troubleshooting & validating framework usage (Since 1.8.0) </a><br/>\r\n * <a href=\"#19\">19. Aliases for behavior driven development (Since 1.8.0) </a><br/>\r\n * <a href=\"#20\">20. (**New**) Serializable mocks (Since 1.8.1) </a><br/>\r\n * </b>\r\n * \r\n * <p>\r\n * Following examples mock a List, because everyone knows its interface (methods\r\n * like add(), get(), clear() will be used). <br>\r\n * You probably wouldn't mock List class 'in real'.\r\n * \r\n * <h3 id=\"1\">1. Let's verify some behaviour!</h3>\r\n * \r\n * <pre>\r\n * //Let's import Mockito statically so that the code looks clearer\r\n * import static org.mockito.Mockito.*;\r\n * \r\n * //mock creation\r\n * List mockedList = mock(List.class);\r\n *\r\n * //using mock object\r\n * mockedList.add(\"one\");\r\n * mockedList.clear();\r\n *\r\n * //verification\r\n * verify(mockedList).add(\"one\");\r\n * verify(mockedList).clear();\r\n * </pre>\r\n * \r\n * <p>\r\n * Once created, mock will remember all interactions. Then you can selectively\r\n * verify whatever interaction you are interested in.\r\n * \r\n * <h3 id=\"2\">2. How about some stubbing?</h3>\r\n * \r\n * <pre>\r\n * //You can mock concrete classes, not only interfaces\r\n * LinkedList mockedList = mock(LinkedList.class);\r\n * \r\n * //stubbing\r\n * when(mockedList.get(0)).thenReturn(\"first\");\r\n * when(mockedList.get(1)).thenThrow(new RuntimeException());\r\n * \r\n * //following prints \"first\"\r\n * System.out.println(mockedList.get(0));\r\n * \r\n * //following throws runtime exception\r\n * System.out.println(mockedList.get(1));\r\n * \r\n * //following prints \"null\" because get(999) was not stubbed\r\n * System.out.println(mockedList.get(999));\r\n * \r\n * //Although it is possible to verify a stubbed invocation, usually <b>it's just redundant</b>\r\n * //If your code cares what get(0) returns then something else breaks (often before even verify() gets executed).\r\n * //If your code doesn't care what get(0) returns then it should not be stubbed. Not convinced? See <a href=\"http://monkeyisland.pl/2008/04/26/asking-and-telling\">here</a>.\r\n * verify(mockedList).get(0);\r\n * </pre>\r\n * \r\n * <ul>\r\n * <li> By default, for all methods that return value, mock returns null, an\r\n * empty collection or appropriate primitive/primitive wrapper value (e.g: 0,\r\n * false, ... for int/Integer, boolean/Boolean, ...). </li>\r\n * \r\n * <li> Stubbing can be overridden: for example common stubbing can go to\r\n * fixture setup but the test methods can override it.\r\n * Please note that overridding stubbing is a potential code smell that points out too much stubbing</li>\r\n * \r\n * <li> Once stubbed, the method will always return stubbed value regardless\r\n * of how many times it is called. </li>\r\n * \r\n * <li> Last stubbing is more important - when you stubbed the same method with\r\n * the same arguments many times. </li>\r\n * \r\n * </ul>\r\n * \r\n * <h3 id=\"3\">3. Argument matchers</h3>\r\n * \r\n * Mockito verifies argument values in natural java style: by using an equals() method.\r\n * Sometimes, when extra flexibility is required then you might use argument matchers: \r\n * \r\n * <pre>\r\n * //stubbing using built-in anyInt() argument matcher\r\n * when(mockedList.get(anyInt())).thenReturn(\"element\");\r\n * \r\n * //stubbing using hamcrest (let's say isValid() returns your own hamcrest matcher):\r\n * when(mockedList.contains(argThat(isValid()))).thenReturn(\"element\");\r\n * \r\n * //following prints \"element\"\r\n * System.out.println(mockedList.get(999));\r\n * \r\n * //<b>you can also verify using an argument matcher</b>\r\n * verify(mockedList).get(anyInt());\r\n * </pre>\r\n * \r\n * <p>\r\n * Argument matchers allow flexible verification or stubbing. \r\n * {@link Matchers Click here to see} more built-in matchers \r\n * and examples of <b>custom argument matchers / hamcrest matchers</b>.\r\n * <p>\r\n * For information solely on <b>custom argument matchers</b> check out javadoc for {@link ArgumentMatcher} class.\r\n * <p>\r\n * Be reasonable with using complicated argument matching.\r\n * The natural matching style using equals() with occasional anyX() matchers tend to give clean & simple tests.\r\n * Sometimes it's just better to refactor the code to allow equals() matching or even implement equals() method to help out with testing.\r\n * <p>\r\n * Also, read <a href=\"#15\">section 15</a> or javadoc for {@link ArgumentCaptor} class.\r\n * {@link ArgumentCaptor} is a special implementation of an argument matcher that captures argument values for further assertions. \r\n * <p>\r\n * <b>Warning on argument matchers:</b>\r\n * <p>\r\n * If you are using argument matchers, <b>all arguments</b> have to be provided\r\n * by matchers.\r\n * <p>\r\n * E.g: (example shows verification but the same applies to stubbing):\r\n * \r\n * <pre>\r\n * verify(mock).someMethod(anyInt(), anyString(), <b>eq(\"third argument\")</b>);\r\n * //above is correct - eq() is also an argument matcher\r\n * \r\n * verify(mock).someMethod(anyInt(), anyString(), <b>\"third argument\"</b>);\r\n * //above is incorrect - exception will be thrown because third argument is given without an argument matcher.\r\n * </pre>\r\n * \r\n * <h3 id=\"4\">4. Verifying exact number of invocations / at least x / never</h3>\r\n * \r\n * <pre>\r\n * //using mock \r\n * mockedList.add(\"once\");\r\n * \r\n * mockedList.add(\"twice\");\r\n * mockedList.add(\"twice\");\r\n * \r\n * mockedList.add(\"three times\");\r\n * mockedList.add(\"three times\");\r\n * mockedList.add(\"three times\");\r\n * \r\n * //following two verifications work exactly the same - times(1) is used by default\r\n * verify(mockedList).add(\"once\");\r\n * verify(mockedList, times(1)).add(\"once\");\r\n * \r\n * //exact number of invocations verification\r\n * verify(mockedList, times(2)).add(\"twice\");\r\n * verify(mockedList, times(3)).add(\"three times\");\r\n * \r\n * //verification using never(). never() is an alias to times(0)\r\n * verify(mockedList, never()).add(\"never happened\");\r\n * \r\n * //verification using atLeast()/atMost()\r\n * verify(mockedList, atLeastOnce()).add(\"three times\");\r\n * verify(mockedList, atLeast(2)).add(\"five times\");\r\n * verify(mockedList, atMost(5)).add(\"three times\");\r\n * \r\n * </pre>\r\n * \r\n * <p>\r\n * <b>times(1) is the default.</b> Therefore using times(1) explicitly can be\r\n * omitted.\r\n * \r\n * <h3 id=\"5\">5. Stubbing void methods with exceptions</h3>\r\n * \r\n * <pre>\r\n * doThrow(new RuntimeException()).when(mockedList).clear();\r\n * \r\n * //following throws RuntimeException:\r\n * mockedList.clear();\r\n * </pre>\r\n * \r\n * Read more about doThrow|doAnswer family of methods in paragraph 12.\r\n * <p>\r\n * Initially, {@link Mockito#stubVoid(Object)} was used for stubbing voids.\r\n * Currently stubVoid() is deprecated in favor of {@link Mockito#doThrow(Throwable)}.\r\n * This is because of improved readability and consistency with the family of {@link Mockito#doAnswer(Answer)} methods. \r\n * \r\n * <h3 id=\"6\">6. Verification in order</h3>\r\n * \r\n * <pre>\r\n * List firstMock = mock(List.class);\r\n * List secondMock = mock(List.class);\r\n * \r\n * //using mocks\r\n * firstMock.add(\"was called first\");\r\n * secondMock.add(\"was called second\");\r\n * \r\n * //create inOrder object passing any mocks that need to be verified in order\r\n * InOrder inOrder = inOrder(firstMock, secondMock);\r\n * \r\n * //following will make sure that firstMock was called before secondMock\r\n * inOrder.verify(firstMock).add(\"was called first\");\r\n * inOrder.verify(secondMock).add(\"was called second\");\r\n * </pre>\r\n * \r\n * Verification in order is flexible - <b>you don't have to verify all\r\n * interactions</b> one-by-one but only those that you are interested in\r\n * testing in order.\r\n * <p>\r\n * Also, you can create InOrder object passing only mocks that are relevant for\r\n * in-order verification.\r\n * \r\n * <h3 id=\"7\">7. Making sure interaction(s) never happened on mock</h3>\r\n * \r\n * <pre>\r\n * //using mocks - only mockOne is interacted\r\n * mockOne.add(\"one\");\r\n * \r\n * //ordinary verification\r\n * verify(mockOne).add(\"one\");\r\n * \r\n * //verify that method was never called on a mock\r\n * verify(mockOne, never()).add(\"two\");\r\n * \r\n * //verify that other mocks were not interacted\r\n * verifyZeroInteractions(mockTwo, mockThree);\r\n * \r\n * </pre>\r\n * \r\n * <h3 id=\"8\">8. Finding redundant invocations</h3>\r\n * \r\n * <pre>\r\n * //using mocks\r\n * mockedList.add(\"one\");\r\n * mockedList.add(\"two\");\r\n * \r\n * verify(mockedList).add(\"one\");\r\n * \r\n * //following verification will fail \r\n * verifyNoMoreInteractions(mockedList);\r\n * </pre>\r\n * \r\n * A word of <b>warning</b>: \r\n * Some users who did a lot of classic, expect-run-verify mocking tend to use verifyNoMoreInteractions() very often, even in every test method. \r\n * verifyNoMoreInteractions() is not recommended to use in every test method. \r\n * verifyNoMoreInteractions() is a handy assertion from the interaction testing toolkit. Use it only when it's relevant.\r\n * Abusing it leads to overspecified, less maintainable tests. You can find further reading \r\n * <a href=\"http://monkeyisland.pl/2008/07/12/should-i-worry-about-the-unexpected/\">here</a>.\r\n * \r\n * <p> \r\n * See also {@link Mockito#never()} - it is more explicit and\r\n * communicates the intent well.\r\n * <p>\r\n * \r\n * <h3 id=\"9\">9. Shorthand for mocks creation - &#064;Mock annotation</h3>\r\n * \r\n * <ul>\r\n * <li>Minimizes repetitive mock creation code.</li>\r\n * <li>Makes the test class more readable.</li>\r\n * <li>Makes the verification error easier to read because the <b>field name</b>\r\n * is used to identify the mock.</li>\r\n * </ul>\r\n * \r\n * <pre>\r\n * public class ArticleManagerTest { \r\n * \r\n * &#064;Mock private ArticleCalculator calculator;\r\n * &#064;Mock private ArticleDatabase database;\r\n * &#064;Mock private UserProvider userProvider;\r\n * \r\n * private ArticleManager manager;\r\n * </pre>\r\n * \r\n * <b>Important!</b> This needs to be somewhere in the base class or a test\r\n * runner:\r\n * \r\n * <pre>\r\n * MockitoAnnotations.initMocks(testClass);\r\n * </pre>\r\n * \r\n * You can use built-in runner: {@link MockitoJUnitRunner}.\r\n * <p>\r\n * Read more here: {@link MockitoAnnotations}\r\n * \r\n * <h3 id=\"10\"> 10. Stubbing consecutive calls (iterator-style stubbing)</h3>\r\n * \r\n * Sometimes we need to stub with different return value/exception for the same\r\n * method call. Typical use case could be mocking iterators. \r\n * Original version of Mockito did not have this feature to promote simple mocking. \r\n * For example, instead of iterators one could use {@link Iterable} or simply\r\n * collections. Those offer natural ways of stubbing (e.g. using real\r\n * collections). In rare scenarios stubbing consecutive calls could be useful,\r\n * though:\r\n * <p>\r\n * \r\n * <pre>\r\n * when(mock.someMethod(\"some arg\"))\r\n * .thenThrow(new RuntimeException())\r\n * .thenReturn(\"foo\");\r\n * \r\n * //First call: throws runtime exception:\r\n * mock.someMethod(\"some arg\");\r\n * \r\n * //Second call: prints \"foo\"\r\n * System.out.println(mock.someMethod(\"some arg\"));\r\n * \r\n * //Any consecutive call: prints \"foo\" as well (last stubbing wins). \r\n * System.out.println(mock.someMethod(\"some arg\"));\r\n * </pre>\r\n * \r\n * Alternative, shorter version of consecutive stubbing:\r\n * \r\n * <pre>\r\n * when(mock.someMethod(\"some arg\"))\r\n * .thenReturn(\"one\", \"two\", \"three\");\r\n * </pre>\r\n * \r\n * <h3 id=\"11\"> 11. Stubbing with callbacks</h3>\r\n * \r\n * Allows stubbing with generic {@link Answer} interface.\r\n * <p>\r\n * Yet another controversial feature which was not included in Mockito\r\n * originally. We recommend using simple stubbing with thenReturn() or\r\n * thenThrow() only. Those two should be <b>just enough</b> to test/test-drive\r\n * any clean & simple code.\r\n * \r\n * <pre>\r\n * when(mock.someMethod(anyString())).thenAnswer(new Answer() {\r\n * Object answer(InvocationOnMock invocation) {\r\n * Object[] args = invocation.getArguments();\r\n * Object mock = invocation.getMock();\r\n * return \"called with arguments: \" + args;\r\n * }\r\n * });\r\n * \r\n * //Following prints \"called with arguments: foo\"\r\n * System.out.println(mock.someMethod(\"foo\"));\r\n * </pre>\r\n * \r\n * <h3 id=\"12\"> 12. doThrow()|doAnswer()|doNothing()|doReturn() family of methods for stubbing voids (mostly)</h3>\r\n * \r\n * Stubbing voids requires different approach from {@link Mockito#when(Object)} because the compiler does not like void methods inside brackets...\r\n * <p>\r\n * {@link Mockito#doThrow(Throwable)} replaces the {@link Mockito#stubVoid(Object)} method for stubbing voids. \r\n * The main reason is improved readability and consistency with the family of doAnswer() methods.\r\n * <p>\r\n * Use doThrow() when you want to stub a void method with an exception:\r\n * <pre>\r\n * doThrow(new RuntimeException()).when(mockedList).clear();\r\n * \r\n * //following throws RuntimeException:\r\n * mockedList.clear();\r\n * </pre>\r\n * \r\n * Read more about other methods:\r\n * <p>\r\n * {@link Mockito#doThrow(Throwable)}\r\n * <p>\r\n * {@link Mockito#doAnswer(Answer)}\r\n * <p>\r\n * {@link Mockito#doNothing()}\r\n * <p>\r\n * {@link Mockito#doReturn(Object)}\r\n * \r\n * <h3 id=\"13\"> 13. Spying on real objects</h3>\r\n * \r\n * You can create spies of real objects. When you use the spy then the <b>real</b> methods are called (unless a method was stubbed).\r\n * <p>\r\n * Real spies should be used <b>carefully and occasionally</b>, for example when dealing with legacy code.\r\n * \r\n * <p>\r\n * Spying on real objects can be associated with \"partial mocking\" concept. \r\n * <b>Before the release 1.8</b>, Mockito spies were not real partial mocks. \r\n * The reason was we thought partial mock is a code smell. \r\n * At some point we found legitimate use cases for partial mocks \r\n * (3rd party interfaces, interim refactoring of legacy code, the full article is <a href=\r\n * \"http://monkeyisland.pl/2009/01/13/subclass-and-override-vs-partial-mocking-vs-refactoring\"\r\n * >here</a>)\r\n * <p>\r\n *\r\n * <pre>\r\n * List list = new LinkedList();\r\n * List spy = spy(list);\r\n * \r\n * //optionally, you can stub out some methods:\r\n * when(spy.size()).thenReturn(100);\r\n * \r\n * //using the spy calls <b>real</b> methods\r\n * spy.add(\"one\");\r\n * spy.add(\"two\");\r\n * \r\n * //prints \"one\" - the first element of a list\r\n * System.out.println(spy.get(0));\r\n * \r\n * //size() method was stubbed - 100 is printed\r\n * System.out.println(spy.size());\r\n * \r\n * //optionally, you can verify\r\n * verify(spy).add(\"one\");\r\n * verify(spy).add(\"two\");\r\n * </pre>\r\n * \r\n * <h4>Important gotcha on spying real objects!</h4>\r\n * \r\n * 1. Sometimes it's impossible to use {@link Mockito#when(Object)} for stubbing spies. Example:\r\n * \r\n * <pre>\r\n * List list = new LinkedList();\r\n * List spy = spy(list);\r\n * \r\n * //Impossible: real method is called so spy.get(0) throws IndexOutOfBoundsException (the list is yet empty)\r\n * when(spy.get(0)).thenReturn(\"foo\");\r\n * \r\n * //You have to use doReturn() for stubbing\r\n * doReturn(\"foo\").when(spy).get(0);\r\n * </pre>\r\n * \r\n * 2. Watch out for final methods. \r\n * Mockito doesn't mock final methods so the bottom line is: when you spy on real objects + you try to stub a final method = trouble.\r\n * What will happen is the real method will be called *on mock* but *not on the real instance* you passed to the spy() method.\r\n * Typically you may get a NullPointerException because mock instances don't have fields initiated.\r\n * \r\n * <h3 id=\"14\">14. Changing default return values of unstubbed invocations (Since 1.7) </h3>\r\n * \r\n * You can create a mock with specified strategy for its return values.\r\n * It's quite advanced feature and typically you don't need it to write decent tests.\r\n * However, it can be helpful for working with <b>legacy systems</b>.\r\n * <p>\r\n * It is the default answer so it will be used <b>only when you don't</b> stub the method call.\r\n * \r\n * <pre>\r\n * Foo mock = mock(Foo.class, Mockito.RETURNS_SMART_NULLS);\r\n * Foo mockTwo = mock(Foo.class, new YourOwnAnswer()); \r\n * </pre>\r\n * \r\n * <p>\r\n * Read more about this interesting implementation of <i>Answer</i>: {@link Mockito#RETURNS_SMART_NULLS}\r\n * \r\n * <h3 id=\"15\">15. Capturing arguments for further assertions (Since 1.8.0) </h3>\r\n * \r\n * Mockito verifies argument values in natural java style: by using an equals() method.\r\n * This is also the recommended way of matching arguments because it makes tests clean & simple.\r\n * In some situations though, it is helpful to assert on certain arguments after the actual verification.\r\n * For example:\r\n * <pre>\r\n * ArgumentCaptor&lt;Person&gt; argument = ArgumentCaptor.forClass(Person.class);\r\n * verify(mock).doSomething(argument.capture());\r\n * assertEquals(\"John\", argument.getValue().getName());\r\n * </pre>\r\n * \r\n * <b>Warning:</b> it is recommended to use ArgumentCaptor with verification <b>but not</b> with stubbing.\r\n * Using ArgumentCaptor with stubbing may decrease test readability because captor is created outside of assert (aka verify or 'then') block.\r\n * Also it may reduce defect localization because if stubbed method was not called then no argument is captured.\r\n * <p>\r\n * In a way ArgumentCaptor is related to custom argument matchers (see javadoc for {@link ArgumentMatcher} class).\r\n * Both techniques can be used for making sure certain arguments where passed to mocks. \r\n * However, ArgumentCaptor may be a better fit if:\r\n * <ul> \r\n * <li>custom argument matcher is not likely to be reused</li>\r\n * <li>you just need it to assert on argument values to complete verification</li>\r\n * </ul>\r\n * Custom argument matchers via {@link ArgumentMatcher} are usually better for stubbing.\r\n * \r\n * <h3 id=\"16\">16. Real partial mocks (Since 1.8.0) </h3>\r\n * \r\n * Finally, after many internal debates & discussions on the mailing list, partial mock support was added to Mockito.\r\n * Previously we considered partial mocks as code smells. However, we found a legitimate use case for partial mocks - more reading:\r\n * <a href=\"http://monkeyisland.pl/2009/01/13/subclass-and-override-vs-partial-mocking-vs-refactoring\">here</a>\r\n * <p>\r\n * <b>Before release 1.8</b> spy() was not producing real partial mocks and it was confusing for some users.\r\n * Read more about spying: <a href=\"#13\">here</a> or in javadoc for {@link Mockito#spy(Object)} method. \r\n * <p>\r\n * <pre>\r\n * //you can create partial mock with spy() method: \r\n * List list = spy(new LinkedList());\r\n * \r\n * //you can enable partial mock capabilities selectively on mocks:\r\n * Foo mock = mock(Foo.class);\r\n * //Be sure the real implementation is 'safe'.\r\n * //If real implementation throws exceptions or depends on specific state of the object then you're in trouble.\r\n * when(mock.someMethod()).thenCallRealMethod();\r\n * </pre>\r\n * \r\n * As usual you are going to read <b>the partial mock warning</b>:\r\n * Object oriented programming is more less tackling complexity by dividing the complexity into separate, specific, SRPy objects.\r\n * How does partial mock fit into this paradigm? Well, it just doesn't... \r\n * Partial mock usually means that the complexity has been moved to a different method on the same object.\r\n * In most cases, this is not the way you want to design your application.\r\n * <p>\r\n * However, there are rare cases when partial mocks come handy: \r\n * dealing with code you cannot change easily (3rd party interfaces, interim refactoring of legacy code etc.)\r\n * However, I wouldn't use partial mocks for new, test-driven & well-designed code.\r\n * \r\n * <h3 id=\"17\">17. Resetting mocks (Since 1.8.0) </h3>\r\n * \r\n * Smart Mockito users hardly use this feature because they know it could be a sign of poor tests.\r\n * Normally, you don't need to reset your mocks, just create new mocks for each test method. \r\n * <p>\r\n * Instead of reset() please consider writing simple, small and focused test methods over lengthy, over-specified tests.\r\n * <b>First potential code smell is reset() in the middle of the test method.</b> This probably means you're testing too much.\r\n * Follow the whisper of your test methods: \"Please keep us small & focused on single behavior\". \r\n * There are several threads about it on mockito mailing list.\r\n * <p>\r\n * The only reason we added reset() method is to\r\n * make it possible to work with container-injected mocks.\r\n * See issue 55 (<a href=\"http://code.google.com/p/mockito/issues/detail?id=55\">here</a>)\r\n * or FAQ (<a href=\"http://code.google.com/p/mockito/wiki/FAQ\">here</a>).\r\n * <p>\r\n * <b>Don't harm yourself.</b> reset() in the middle of the test method is a code smell (you're probably testing too much). \r\n * <pre>\r\n * List mock = mock(List.class);\r\n * when(mock.size()).thenReturn(10);\r\n * mock.add(1);\r\n * \r\n * reset(mock);\r\n * //at this point the mock forgot any interactions & stubbing\r\n * </pre>\r\n * \r\n * <h3 id=\"18\">18. Troubleshooting & validating framework usage (Since 1.8.0) </h3>\r\n * \r\n * First of all, in case of any trouble, I encourage you to read the Mockito FAQ: \r\n * <a href=\"http://code.google.com/p/mockito/wiki/FAQ\">http://code.google.com/p/mockito/wiki/FAQ</a>\r\n * <p>\r\n * In case of questions you may also post to mockito mailing list: \r\n * <a href=\"http://groups.google.com/group/mockito\">http://groups.google.com/group/mockito</a>\r\n * <p>\r\n * Next, you should know that Mockito validates if you use it correctly <b>all the time</b>. \r\n * However, there's a gotcha so please read the javadoc for {@link Mockito#validateMockitoUsage()}\r\n * \r\n * <h3 id=\"19\">19. Aliases for behavior driven development (Since 1.8.0) </h3>\r\n * \r\n * Behavior Driven Development style of writing tests uses <b>//given //when //then</b> comments as fundamental parts of your test methods.\r\n * This is exactly how we write our tests and we warmly encourage you to do so!\r\n * <p>\r\n * Start learning about BDD here: <a href=\"http://en.wikipedia.org/wiki/Behavior_Driven_Development\">http://en.wikipedia.org/wiki/Behavior_Driven_Development</a>\r\n * <p>\r\n * The problem is that current stubbing api with canonical role of <b>when</b> word does not integrate nicely with <b>//given //when //then</b> comments.\r\n * It's because stubbing belongs to <b>given</b> component of the test and not to the <b>when</b> component of the test. \r\n * Hence {@link BDDMockito} class introduces an alias so that you stub method calls with {@link BDDMockito#given(Object)} method. \r\n * Now it really nicely integrates with the <b>given</b> component of a BDD style test! \r\n * <p>\r\n * Here is how the test might look like: \r\n * <pre>\r\n * import static org.mockito.BDDMockito.*;\r\n * \r\n * Seller seller = mock(Seller.class);\r\n * Shop shop = new Shop(seller);\r\n * \r\n * public void shouldBuyBread() throws Exception {\r\n * //given \r\n * given(seller.askForBread()).willReturn(new Bread());\r\n * \r\n * //when\r\n * Goods goods = shop.buyBread();\r\n * \r\n * //then\r\n * assertThat(goods, containBread());\r\n * } \r\n * </pre>\r\n * \r\n * <h3 id=\"20\">20. (**New**) Serializable mocks (Since 1.8.1) </h3>\r\n * \r\n * Mocks can be made serializable. With this feature you can use a mock in a place that requires dependencies to be serializable.\r\n * <p>\r\n * WARNING: This should be rarely used in unit testing. \r\n * <p>\r\n * The behaviour was implemented for a specific use case of a BDD spec that had an unreliable external dependency. This\r\n * was in a web environment and the objects from the external dependency were being serialized to pass between layers. \r\n * <p>\r\n * To create serializable mock use {@link MockSettings#serializable()}:\r\n * <pre>\r\n * List serializableMock = mock(List.class, withSettings().serializable());\r\n * </pre>\r\n * <p>\r\n * The mock can be serialized assuming all the normal <a href='http://java.sun.com/j2se/1.5.0/docs/api/java/io/Serializable.html'>\r\n * serialization requirements</a> are met by the class.\r\n * <p>\r\n * Making a real object spy serializable is a bit more effort as the spy(...) method does not have an overloaded version \r\n * which accepts MockSettings. No worries, you will hardly ever use it.\r\n * \r\n * <pre>\r\n * List<Object> list = new ArrayList<Object>();\r\n * List<Object> spy = mock(ArrayList.class, withSettings()\r\n * .spiedInstance(list)\r\n * .defaultAnswer(CALLS_REAL_METHODS)\r\n * .serializable());\r\n * </pre>\r\n */\r\n @SuppressWarnings(\"unchecked\")\r\n public class Mockito extends Matchers {\r\n \r\n private static final MockitoCore MOCKITO_CORE = new MockitoCore();\r\n \r\n /**\r\n * The default Answer of every mock <b>if</b> the mock was not stubbed. \r\n * Typically it just returns some empty value. \r\n * <p>\r\n * {@link Answer} can be used to define the return values of unstubbed invocations. \r\n * <p>\r\n * This implementation first tries the global configuration. \r\n * If there is no global configuration then it uses {@link ReturnsEmptyValues} (returns zeros, empty collections, nulls, etc.)\r\n */\r\n public static final Answer<Object> RETURNS_DEFAULTS = new GloballyConfiguredAnswer();\r\n \r\n /**\r\n * Optional Answer to be used with {@link Mockito#mock(Class, Answer)}\r\n * <p>\r\n * {@link Answer} can be used to define the return values of unstubbed invocations.\r\n * <p>\r\n * This implementation can be helpful when working with legacy code.\r\n * Unstubbed methods often return null. If your code uses the object returned by an unstubbed call you get a NullPointerException.\r\n * This implementation of Answer <b>returns SmartNull instead of null</b>.\r\n * SmartNull gives nicer exception message than NPE because it points out the line where unstubbed method was called. You just click on the stack trace.\r\n * <p>\r\n * ReturnsSmartNulls first tries to return ordinary return values (see {@link ReturnsMoreEmptyValues})\r\n * then it tries to return SmartNull. If the return type is final then plain null is returned.\r\n * <p>\r\n * ReturnsSmartNulls will be probably the default return values strategy in Mockito 2.0\r\n * <p>\r\n * Example:\r\n * <pre>\r\n * Foo mock = (Foo.class, RETURNS_SMART_NULLS);\r\n * \r\n * //calling unstubbed method here:\r\n * Stuff stuff = mock.getStuff();\r\n * \r\n * //using object returned by unstubbed call:\r\n * stuff.doSomething();\r\n * \r\n * //Above doesn't yield NullPointerException this time!\r\n * //Instead, SmartNullPointerException is thrown. \r\n * //Exception's cause links to unstubbed <i>mock.getStuff()</i> - just click on the stack trace. \r\n * </pre>\r\n */\r\n public static final Answer<Object> RETURNS_SMART_NULLS = new ReturnsSmartNulls();\r\n \r\n /**\r\n * Optional Answer to be used with {@link Mockito#mock(Class, Answer)}\r\n * <p>\r\n * {@link Answer} can be used to define the return values of unstubbed invocations.\r\n * <p>\r\n * This implementation can be helpful when working with legacy code. \r\n * <p>\r\n * ReturnsMocks first tries to return ordinary return values (see {@link ReturnsMoreEmptyValues})\r\n * then it tries to return mocks. If the return type cannot be mocked (e.g. is final) then plain null is returned.\r\n * <p>\r\n */\r\n public static final Answer<Object> RETURNS_MOCKS = new ReturnsMocks();\r\n \r\n /**\r\n * Optional Answer to be used with {@link Mockito#mock(Class, Answer)}\r\n * <p>\r\n * {@link Answer} can be used to define the return values of unstubbed invocations.\r\n * <p>\r\n * This implementation can be helpful when working with legacy code.\r\n * When this implementation is used, unstubbed methods will delegate to the real implementation.\r\n * This is a way to create a partial mock object that calls real methods by default.\r\n * <p>\r\n * As usual you are going to read <b>the partial mock warning</b>:\r\n * Object oriented programming is more less tackling complexity by dividing the complexity into separate, specific, SRPy objects.\r\n * How does partial mock fit into this paradigm? Well, it just doesn't... \r\n * Partial mock usually means that the complexity has been moved to a different method on the same object.\r\n * In most cases, this is not the way you want to design your application.\r\n * <p>\r\n * However, there are rare cases when partial mocks come handy: \r\n * dealing with code you cannot change easily (3rd party interfaces, interim refactoring of legacy code etc.)\r\n * However, I wouldn't use partial mocks for new, test-driven & well-designed code.\r\n * <p>\r\n * Example:\r\n * <pre>\r\n * Foo mock = mock(Foo.class, CALLS_REAL_METHODS);\r\n *\r\n * // this calls the real implementation of Foo.getSomething()\r\n * value = mock.getSomething();\r\n *\r\n * when(mock.getSomething()).thenReturn(fakeValue);\r\n *\r\n * // now fakeValue is returned\r\n * value = mock.getSomething();\r\n * </pre>\r\n */\r\n public static final Answer<Object> CALLS_REAL_METHODS = new CallsRealMethods();\r\n \r\n /**\r\n * Creates mock object of given class or interface.\r\n * <p>\r\n * See examples in javadoc for {@link Mockito} class\r\n * \r\n * @param classToMock class or interface to mock\r\n * @return mock object\r\n */\r\n public static <T> T mock(Class<T> classToMock) {\r\n return mock(classToMock, withSettings().defaultAnswer(RETURNS_DEFAULTS));\r\n }\r\n \r\n /**\r\n * Specifies mock name. Naming mocks can be helpful for debugging - the name is used in all verification errors. \r\n * <p>\r\n * Beware that naming mocks is not a solution for complex code which uses too many mocks or collaborators. \r\n * <b>If you have too many mocks then refactor the code</b> so that it's easy to test/debug without necessity of naming mocks.\r\n * <p>\r\n * <b>If you use &#064;Mock annotation then you've got naming mocks for free!</b> &#064;Mock uses field name as mock name. {@link Mock Read more.}\r\n * <p>\r\n * \r\n * See examples in javadoc for {@link Mockito} class\r\n * \r\n * @param classToMock class or interface to mock\r\n * @param name of the mock \r\n * @return mock object\r\n */\r\n public static <T> T mock(Class<T> classToMock, String name) {\r\n return mock(classToMock, withSettings()\r\n .name(name)\r\n .defaultAnswer(RETURNS_DEFAULTS));\r\n }\r\n \r\n /**\r\n * @deprecated\r\n * <b>Please use mock(Foo.class, defaultAnswer);</b>\r\n * <p>\r\n * See {@link Mockito#mock(Class, Answer)}\r\n * <p>\r\n * Why it is deprecated? ReturnValues is being replaced by Answer\r\n * for better consistency & interoperability of the framework. \r\n * Answer interface has been in Mockito for a while and it has the same responsibility as ReturnValues.\r\n * There's no point in mainting exactly the same interfaces.\r\n * <p>\r\n * Creates mock with a specified strategy for its return values. \r\n * It's quite advanced feature and typically you don't need it to write decent tests.\r\n * However it can be helpful when working with legacy systems.\r\n * <p>\r\n * Obviously return values are used only when you don't stub the method call.\r\n *\r\n * <pre>\r\n * Foo mock = mock(Foo.class, Mockito.RETURNS_SMART_NULLS);\r\n * Foo mockTwo = mock(Foo.class, new YourOwnReturnValues()); \r\n * </pre>\r\n * \r\n * <p>See examples in javadoc for {@link Mockito} class</p>\r\n * \r\n * @param classToMock class or interface to mock\r\n * @param returnValues default return values for unstubbed methods\r\n *\r\n * @return mock object\r\n */\r\n @Deprecated\r\n public static <T> T mock(Class<T> classToMock, ReturnValues returnValues) {\r\n return mock(classToMock, withSettings().defaultAnswer(new AnswerReturnValuesAdapter(returnValues)));\r\n }\r\n \r\n /**\r\n * Creates mock with a specified strategy for its answers to interactions. \r\n * It's quite advanced feature and typically you don't need it to write decent tests.\r\n * However it can be helpful when working with legacy systems.\r\n * <p>\r\n * It is the default answer so it will be used <b>only when you don't</b> stub the method call.\r\n *\r\n * <pre>\r\n * Foo mock = mock(Foo.class, RETURNS_SMART_NULLS);\r\n * Foo mockTwo = mock(Foo.class, new YourOwnAnswer()); \r\n * </pre>\r\n * \r\n * <p>See examples in javadoc for {@link Mockito} class</p>\r\n * \r\n * @param classToMock class or interface to mock\r\n * @param defaultAnswer default answer for unstubbed methods\r\n *\r\n * @return mock object\r\n */\r\n public static <T> T mock(Class<T> classToMock, Answer defaultAnswer) {\r\n return mock(classToMock, withSettings().defaultAnswer(defaultAnswer));\r\n }\r\n \r\n /**\r\n * Creates a mock with some non-standard settings.\r\n * <p>\r\n * The number of configuration points for a mock grows \r\n * so we need a fluent way to introduce new configuration without adding more and more overloaded Mockito.mock() methods. \r\n * Hence {@link MockSettings}.\r\n * <pre>\r\n * Listener mock = mock(Listener.class, withSettings()\r\n * .name(\"firstListner\").defaultBehavior(RETURNS_SMART_NULLS));\r\n * ); \r\n * </pre>\r\n * <b>Use it carefully and occasionally</b>. What might be reason your test needs non-standard mocks? \r\n * Is the code under test so complicated that it requires non-standard mocks? \r\n * Wouldn't you prefer to refactor the code under test so it is testable in a simple way?\r\n * <p>\r\n * See also {@link Mockito#withSettings()}\r\n * <p>\r\n * See examples in javadoc for {@link Mockito} class\r\n * \r\n * @param classToMock class or interface to mock\r\n * @param mockSettings additional mock settings\r\n * @return mock object\r\n */\r\n public static <T> T mock(Class<T> classToMock, MockSettings mockSettings) {\r\n- return MOCKITO_CORE.mock(classToMock, mockSettings);\r\n+ return MOCKITO_CORE.mock(classToMock, mockSettings, true);\r\n }\r\n \r\n /**\r\n * Creates a spy of the real object. The spy calls <b>real</b> methods unless they are stubbed.\r\n * <p>\r\n * Real spies should be used <b>carefully and occasionally</b>, for example when dealing with legacy code.\r\n * <p>\r\n * As usual you are going to read <b>the partial mock warning</b>:\r\n * Object oriented programming is more less tackling complexity by dividing the complexity into separate, specific, SRPy objects.\r\n * How does partial mock fit into this paradigm? Well, it just doesn't... \r\n * Partial mock usually means that the complexity has been moved to a different method on the same object.\r\n * In most cases, this is not the way you want to design your application.\r\n * <p>\r\n * However, there are rare cases when partial mocks come handy: \r\n * dealing with code you cannot change easily (3rd party interfaces, interim refactoring of legacy code etc.)\r\n * However, I wouldn't use partial mocks for new, test-driven & well-designed code.\r\n * <p>\r\n * Example:\r\n * \r\n * <pre>\r\n * List list = new LinkedList();\r\n * List spy = spy(list);\r\n * \r\n * //optionally, you can stub out some methods:\r\n * when(spy.size()).thenReturn(100);\r\n * \r\n * //using the spy calls <b>real</b> methods\r\n * spy.add(\"one\");\r\n * spy.add(\"two\");\r\n * \r\n * //prints \"one\" - the first element of a list\r\n * System.out.println(spy.get(0));\r\n * \r\n * //size() method was stubbed - 100 is printed\r\n * System.out.println(spy.size());\r\n * \r\n * //optionally, you can verify\r\n * verify(spy).add(\"one\");\r\n * verify(spy).add(\"two\");\r\n * </pre>\r\n * \r\n * <h4>Important gotcha on spying real objects!</h4>\r\n * \r\n * 1. Sometimes it's impossible to use {@link Mockito#when(Object)} for stubbing spies. Example:\r\n * \r\n * <pre>\r\n * List list = new LinkedList();\r\n * List spy = spy(list);\r\n * \r\n * //Impossible: real method is called so spy.get(0) throws IndexOutOfBoundsException (the list is yet empty)\r\n * when(spy.get(0)).thenReturn(\"foo\");\r\n * \r\n * //You have to use doReturn() for stubbing\r\n * doReturn(\"foo\").when(spy).get(0);\r\n * </pre>\r\n * \r\n * 2. Watch out for final methods. \r\n * Mockito doesn't mock final methods so the bottom line is: when you spy on real objects + you try to stub a final method = trouble.\r\n * What will happen is the real method will be called *on mock* but *not on the real instance* you passed to the spy() method.\r\n * Typically you may get a NullPointerException because mock instances don't have fields initiated.\r\n * \r\n * <p>\r\n * See examples in javadoc for {@link Mockito} class\r\n * \r\n * @param object\r\n * to spy on\r\n * @return a spy of the real object\r\n */\r\n public static <T> T spy(T object) {\r\n return MOCKITO_CORE.mock((Class<T>) object.getClass(), withSettings()\r\n .spiedInstance(object)\r\n- .defaultAnswer(CALLS_REAL_METHODS)); \r\n+ .defaultAnswer(CALLS_REAL_METHODS), true); \r\n }\r\n \r\n /**\r\n * <pre>\r\n * //Instead of:\r\n * stub(mock.count()).toReturn(10);\r\n * \r\n * //Please do:\r\n * when(mock.count()).thenReturn(10);\r\n * </pre> \r\n * \r\n * Many users found stub() confusing therefore stub() has been deprecated in favor of {@link Mockito#when(Object)} \r\n * <p>\r\n * How to fix deprecation warnings? Typically it's just few minutes of search & replace job:\r\n * <pre>\r\n * Mockito.stub; <i>replace with:</i> Mockito.when;\r\n * stub( <i>replace with:</i> when(\r\n * .toReturn( <i>replace with:</i> .thenReturn(\r\n * .toThrow( <i>replace with:</i> .thenThrow(\r\n * .toAnswer( <i>replace with:</i> .thenAnswer(\r\n * </pre>\r\n * If you're an existing user then sorry for making your code littered with deprecation warnings. \r\n--- a/src/org/mockito/internal/MockitoCore.java\n+++ b/src/org/mockito/internal/MockitoCore.java\n@@ -1,38 +1,39 @@\n /*\r\n * Copyright (c) 2007 Mockito contributors\r\n * This program is made available under the terms of the MIT License.\r\n */\r\n package org.mockito.internal;\r\n \r\n import org.mockito.InOrder;\r\n import org.mockito.MockSettings;\r\n import org.mockito.exceptions.Reporter;\r\n import org.mockito.exceptions.misusing.NotAMockException;\r\n import org.mockito.internal.creation.MockSettingsImpl;\r\n import org.mockito.internal.invocation.Invocation;\r\n import org.mockito.internal.progress.IOngoingStubbing;\r\n import org.mockito.internal.progress.MockingProgress;\r\n import org.mockito.internal.progress.ThreadSafeMockingProgress;\r\n import org.mockito.internal.stubbing.OngoingStubbingImpl;\r\n import org.mockito.internal.stubbing.StubberImpl;\r\n import org.mockito.internal.util.MockUtil;\r\n import org.mockito.internal.verification.api.VerificationMode;\r\n import org.mockito.stubbing.*;\r\n \r\n import java.util.Arrays;\r\n import java.util.List;\r\n \r\n @SuppressWarnings(\"unchecked\")\r\n public class MockitoCore {\r\n \r\n private final Reporter reporter = new Reporter();\r\n private final MockUtil mockUtil = new MockUtil();\r\n private final MockingProgress mockingProgress = new ThreadSafeMockingProgress();\r\n \r\n- public <T> T mock(Class<T> classToMock, MockSettings mockSettings, boolean shouldResetOngoingStubbing) { return mock(classToMock, mockSettings); }\r\n- public <T> T mock(Class<T> classToMock, MockSettings mockSettings) {\r\n+ public <T> T mock(Class<T> classToMock, MockSettings mockSettings, boolean shouldResetOngoingStubbing) {\r\n mockingProgress.validateState();\r\n+ if (shouldResetOngoingStubbing) {\r\n mockingProgress.resetOngoingStubbing();\r\n+ }\r\n return mockUtil.createMock(classToMock, (MockSettingsImpl) mockSettings);\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.StubbingMocksThatAreConfiguredToReturnMocksTest",
"error": "org.mockito.exceptions.misusing.MissingMethodInvocationException",
"message": "",
"methodName": "shouldAllowStubbingMocksConfiguredWithRETURNS_MOCKS"
}
],
"metrics": {
"chunks": 5,
"classes": 2,
"files": 2,
"linesAdd": 2,
"linesMod": 3,
"linesRem": 1,
"methods": 3,
"sizeInLines": 6,
"spreadAllLines": 73,
"spreadCodeOnly": 6
},
"observations": "Merged two overloaded method definitions.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcParAdd",
"mcRepl",
"mdRem",
"retExpChange"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [],
"revisionId": "620f8faed0ad132961aae3a8671120e0929ce828"
},
{
"bugId": 15,
"changedFiles": {
"org/mockito/internal/configuration/injection/FinalMockCandidateFilter.java": {
"inserts": [
[
-1
],
[
25
],
[
26
]
]
}
},
"diff": "--- a/src/org/mockito/internal/configuration/injection/FinalMockCandidateFilter.java\n+++ b/src/org/mockito/internal/configuration/injection/FinalMockCandidateFilter.java\n@@ -1,6 +1,7 @@\n package org.mockito.internal.configuration.injection;\r\n \r\n import org.mockito.exceptions.base.MockitoException;\r\n+import org.mockito.internal.util.reflection.BeanPropertySetter;\r\n import org.mockito.internal.util.reflection.FieldSetter;\r\n \r\n import java.lang.reflect.Field;\r\n@@ -22,7 +23,9 @@ public OngoingInjecter filterCandidate(final Collection<Object> mocks, final Fie\n return new OngoingInjecter() {\r\n public boolean thenInject() {\r\n try {\r\n+ if (!new BeanPropertySetter(fieldInstance, field).set(matchingMock)) {\r\n new FieldSetter(fieldInstance, field).set(matchingMock);\r\n+ }\r\n } catch (Exception e) {\r\n throw new MockitoException(\"Problems injecting dependency in \" + field.getName(), e);\r\n }\r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.InjectMocksShouldTryPropertySettersFirstBeforeFieldAccessTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldInjectUsingPropertySetterIfAvailable"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 22,
"spreadCodeOnly": 11
},
"observations": "Instantiated a BeanPropertySetter object",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"wrapsIf"
],
"repairTools": [],
"revisionId": "81a380951402d2a158af115ed616ab36e94793b8"
},
{
"bugId": 14,
"changedFiles": {
"org/mockito/internal/MockHandler.java": {
"inserts": [
[
-1
],
[
74,
75,
76
],
[
79
]
]
},
"org/mockito/internal/MockitoCore.java": {
"changes": [
[
73
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/MockHandler.java\n+++ b/src/org/mockito/internal/MockHandler.java\n@@ -17,6 +17,7 @@\n import org.mockito.internal.stubbing.OngoingStubbingImpl;\r\n import org.mockito.internal.stubbing.StubbedInvocationMatcher;\r\n import org.mockito.internal.stubbing.VoidMethodStubbableImpl;\r\n+import org.mockito.internal.verification.MockAwareVerificationMode;\r\n import org.mockito.internal.verification.VerificationDataImpl;\r\n import org.mockito.stubbing.Answer;\r\n import org.mockito.stubbing.VoidMethodStubbable;\r\n@@ -73,9 +74,11 @@ public Object handle(Invocation invocation) throws Throwable {\n if (verificationMode != null) {\r\n //We need to check if verification was started on the correct mock \r\n // - see VerifyingWithAnExtraCallToADifferentMockTest\r\n+ if (verificationMode instanceof MockAwareVerificationMode && ((MockAwareVerificationMode) verificationMode).getMock() == invocation.getMock()) {\r\n VerificationDataImpl data = new VerificationDataImpl(invocationContainerImpl.getInvocations(), invocationMatcher); \r\n verificationMode.verify(data);\r\n return null;\r\n+ }\r\n }\r\n \r\n invocationContainerImpl.setInvocationForPotentialStubbing(invocationMatcher);\r\n--- a/src/org/mockito/internal/MockitoCore.java\n+++ b/src/org/mockito/internal/MockitoCore.java\n@@ -20,6 +20,7 @@\n import org.mockito.internal.stubbing.OngoingStubbingImpl;\r\n import org.mockito.internal.stubbing.StubberImpl;\r\n import org.mockito.internal.util.MockUtil;\r\n+import org.mockito.internal.verification.MockAwareVerificationMode;\r\n import org.mockito.internal.verification.VerificationDataImpl;\r\n import org.mockito.internal.verification.VerificationModeFactory;\r\n import org.mockito.internal.verification.api.InOrderContext;\r\n@@ -70,7 +71,7 @@ public IOngoingStubbing stub() {\n } else if (!mockUtil.isMock(mock)) {\r\n reporter.notAMockPassedToVerify();\r\n }\r\n- mockingProgress.verificationStarted(mode);\r\n+ mockingProgress.verificationStarted(new MockAwareVerificationMode(mock, mode));\r\n return mock;\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.VerifyingWithAnExtraCallToADifferentMockTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldAllowVerifyingWhenOtherMockCallIsInTheSameLine"
}
],
"metrics": {
"chunks": 5,
"classes": 2,
"files": 2,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 5,
"spreadAllLines": 109,
"spreadCodeOnly": 80
},
"observations": "An existing parameter (\"mode\") was wrapped by a constructor call, instantiating MockAwareVerificationMode object",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"mcParValChange",
"objInstAdd"
],
"repairPatterns": [
"wrapsIf",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "9b2cf8072ece7c7629eff6037853b3e14ab5f524"
},
{
"bugId": 12,
"changedFiles": {
"org/mockito/internal/util/reflection/GenericMaster.java": {
"inserts": [
[
20
],
[
21,
22
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/reflection/GenericMaster.java\n+++ b/src/org/mockito/internal/util/reflection/GenericMaster.java\n@@ -17,8 +17,12 @@ public Class getGenericType(Field field) {\n Type generic = field.getGenericType();\r\n if (generic != null && generic instanceof ParameterizedType) {\r\n Type actual = ((ParameterizedType) generic).getActualTypeArguments()[0];\r\n+ if (actual instanceof Class) {\r\n return (Class) actual;\r\n+ } else if (actual instanceof ParameterizedType) {\r\n //in case of nested generics we don't go deep\r\n+ return (Class) ((ParameterizedType) actual).getRawType();\r\n+ }\r\n }\r\n \r\n return Object.class;\r\n",
"failingTests": [
{
"className": " org.mockito.internal.util.reflection.GenericMasterTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldDealWithNestedGenerics"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationBasicTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldUseAnnotatedCaptor"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationBasicTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldUseCaptorInOrdinaryWay"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationBasicTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldCaptureGenericList"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationBasicTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldUseGenericlessAnnotatedCaptor"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldScreamWhenWrongTypeForCaptor"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "testNormalUsage"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldScreamWhenMoreThanOneMockitoAnnotaton"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldScreamWhenInitializingCaptorsForNullClass"
},
{
"className": " org.mockitousage.annotation.CaptorAnnotationTest",
"error": "java.lang.ClassCastException",
"message": "sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl cannot be cast to java.lang.Class",
"methodName": "shouldLookForAnnotatedCaptorsInSuperClasses"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 2,
"spreadCodeOnly": 1
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd"
],
"repairPatterns": [
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "7a647a702c8af81ccf5d37b09c11529c6c0cb1b7"
},
{
"bugId": 13,
"changedFiles": {
"org/mockito/internal/MockHandler.java": {
"changes": [
[
77
]
],
"inserts": [
[
81,
82,
83
]
]
}
},
"diff": "--- a/src/org/mockito/internal/MockHandler.java\n+++ b/src/org/mockito/internal/MockHandler.java\n@@ -74,12 +74,14 @@ public Object handle(Invocation invocation) throws Throwable {\n if (verificationMode != null) {\r\n //We need to check if verification was started on the correct mock \r\n // - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\r\n- if (verificationMode instanceof MockAwareVerificationMode && ((MockAwareVerificationMode) verificationMode).getMock() == invocation.getMock()) { \r\n+ if (((MockAwareVerificationMode) verificationMode).getMock() == invocation.getMock()) { \r\n VerificationDataImpl data = new VerificationDataImpl(invocationContainerImpl, invocationMatcher); \r\n verificationMode.verify(data);\r\n return null;\r\n+ } else {\r\n // this means there is an invocation on a different mock. Re-adding verification mode \r\n // - see VerifyingWithAnExtraCallToADifferentMockTest (bug 138)\r\n+ mockingProgress.verificationStarted(verificationMode);\r\n }\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.VerifyingWithAnExtraCallToADifferentMockTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldAllowVerifyingWhenOtherMockCallIsInTheSameLine"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 5,
"spreadCodeOnly": 3
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranElseAdd",
"condExpRed",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expLogicReduce"
],
"repairTools": [],
"revisionId": "2037361bea014c9ac87393eb96a95374dff46182"
},
{
"bugId": 17,
"changedFiles": {
"org/mockito/internal/creation/MockSettingsImpl.java": {
"changes": [
[
22
],
[
74
]
],
"inserts": [
[
-1
]
]
},
"org/mockito/internal/util/MockUtil.java": {
"inserts": [
[
-1
],
[
45
],
[
46,
47
]
]
}
},
"diff": "--- a/src/org/mockito/internal/creation/MockSettingsImpl.java\n+++ b/src/org/mockito/internal/creation/MockSettingsImpl.java\n@@ -17,9 +17,11 @@\n private Object spiedInstance;\r\n private Answer<Object> defaultAnswer;\r\n private MockName mockName;\r\n+ private boolean serializable;\r\n \r\n public MockSettings serializable() {\r\n- return this.extraInterfaces(java.io.Serializable.class);\r\n+ this.serializable = true;\r\n+ return this;\r\n }\r\n \r\n public MockSettings extraInterfaces(Class<?>... extraInterfaces) {\r\n@@ -71,7 +73,7 @@ public MockSettings defaultAnswer(Answer defaultAnswer) {\n }\r\n \r\n public boolean isSerializable() {\r\n- return extraInterfaces != null && java.util.Arrays.asList(extraInterfaces).contains(java.io.Serializable.class);\r\n+ return serializable;\r\n }\r\n \r\n public void initiateMockName(Class classToMock) {\r\n--- a/src/org/mockito/internal/util/MockUtil.java\n+++ b/src/org/mockito/internal/util/MockUtil.java\n@@ -16,6 +16,7 @@\n import org.mockito.internal.creation.jmock.ClassImposterizer;\r\n import org.mockito.internal.util.reflection.LenientCopyTool;\r\n \r\n+import java.io.Serializable;\r\n \r\n @SuppressWarnings(\"unchecked\")\r\n public class MockUtil {\r\n@@ -42,7 +43,11 @@ public MockUtil() {\n Class<?>[] interfaces = settings.getExtraInterfaces();\r\n \r\n Class<?>[] ancillaryTypes;\r\n+ if (settings.isSerializable()) {\r\n+ ancillaryTypes = interfaces == null ? new Class<?>[] {Serializable.class} : new ArrayUtils().concat(interfaces, Serializable.class);\r\n+ } else {\r\n ancillaryTypes = interfaces == null ? new Class<?>[0] : interfaces;\r\n+ }\r\n \r\n Object spiedInstance = settings.getSpiedInstance();\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.basicapi.MocksSerializationTest",
"error": "java.io.NotSerializableException",
"message": "org.mockitousage.IMethods$$EnhancerByMockitoWithCGLIB$$3a0bdfbc",
"methodName": "shouldBeSerializeAndHaveExtraInterfaces"
}
],
"metrics": {
"chunks": 6,
"classes": 2,
"files": 2,
"linesAdd": 7,
"linesMod": 2,
"linesRem": 0,
"methods": 3,
"sizeInLines": 9,
"spreadAllLines": 80,
"spreadCodeOnly": 61
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"mcAdd",
"mcRem",
"objInstAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"expLogicMod",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "77cb2037314dd024eb53ffe2e9e06304088a2d53"
},
{
"bugId": 18,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java": {
"inserts": [
[
87
],
[
89
],
[
91
],
[
93
],
[
95
],
[
97
],
[
99
],
[
101
],
[
103
],
[
105
],
[
107
],
[
109
],
[
111
],
[
113
],
[
115
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java\n@@ -84,6 +84,8 @@ Object returnValueFor(Class<?> type) {\n return Primitives.defaultValueForPrimitiveOrWrapper(type);\n //new instances are used instead of Collections.emptyList(), etc.\n //to avoid UnsupportedOperationException if code under test modifies returned collection\n+ } else if (type == Iterable.class) {\n+ return new ArrayList<Object>(0);\n } else if (type == Collection.class) {\n return new LinkedList<Object>();\n } else if (type == Set.class) {\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValuesTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "should_return_empty_iterable"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Returns instantiated ArrayList<Object>",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"objInstAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "8ceb04ad7317d8db24476b3b5f56ec9f658bc43a"
},
{
"bugId": 22,
"changedFiles": {
"org/mockito/internal/matchers/Equality.java": {
"inserts": [
[
13
]
]
}
},
"diff": "--- a/src/org/mockito/internal/matchers/Equality.java\n+++ b/src/org/mockito/internal/matchers/Equality.java\n@@ -10,7 +10,9 @@\n public class Equality {\r\n \r\n public static boolean areEqual(Object o1, Object o2) {\r\n- if (o1 == null || o2 == null) {\r\n+ if (o1 == o2 ) {\r\n+ return true;\r\n+\t} else if (o1 == null || o2 == null) {\r\n return o1 == null && o2 == null;\r\n } else if (isArray(o1)) {\r\n return isArray(o2) && areArraysEqual(o1, o2);\r\n",
"failingTests": [
{
"className": " org.mockito.internal.matchers.EqualityTest",
"error": "java.lang.RuntimeException",
"message": "",
"methodName": "shouldKnowIfObjectsAreEqual"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfElseAdd",
"retBranchAdd"
],
"repairPatterns": [
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "d0c872e4b0837aef1e1635bf5f15d33c3d8d9698"
},
{
"bugId": 20,
"changedFiles": {
"org/mockito/internal/creation/bytebuddy/ByteBuddyMockMaker.java": {
"changes": [
[
34
],
[
45
]
],
"inserts": [
[
32,
33
]
]
}
},
"diff": "--- a/src/org/mockito/internal/creation/bytebuddy/ByteBuddyMockMaker.java\n+++ b/src/org/mockito/internal/creation/bytebuddy/ByteBuddyMockMaker.java\n@@ -29,9 +29,10 @@ public ByteBuddyMockMaker() {\n settings.getTypeToMock(),\n settings.getExtraInterfaces()\n );\n+ Instantiator instantiator = new InstantiatorProvider().getInstantiator(settings);\n T mockInstance = null;\n try {\n- mockInstance = classInstantiator.instantiate(mockedProxyType);\n+ mockInstance = instantiator.newInstance(mockedProxyType);\n MockMethodInterceptor.MockAccess mockAccess = (MockMethodInterceptor.MockAccess) mockInstance;\n mockAccess.setMockitoInterceptor(new MockMethodInterceptor(asInternalMockHandler(handler), settings));\n \n@@ -42,7 +43,7 @@ public ByteBuddyMockMaker() {\n \" class to mock : \" + describeClass(mockedProxyType),\n \" created class : \" + describeClass(settings.getTypeToMock()),\n \" proxy instance class : \" + describeClass(mockInstance),\n- \" instance creation by : \" + classInstantiator.getClass().getSimpleName(),\n+ \" instance creation by : \" + instantiator.getClass().getSimpleName(),\n \"\",\n \"You might experience classloading issues, please ask the mockito mailing-list.\",\n \"\"\n",
"failingTests": [
{
"className": " org.mockitousage.annotation.SpyAnnotationTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[inner] strength> but was:<[null] strength>",
"methodName": "should_spy_inner_class"
},
{
"className": " org.mockitousage.annotation.SpyAnnotationTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "should_report_when_constructor_is_explosive"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<hey!> but was:<null>",
"methodName": "can_spy_abstract_classes"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "exception_message_when_constructor_not_found"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<hey!> but was:<null>",
"methodName": "can_create_mock_with_constructor"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<hey!> but was:<null>",
"methodName": "can_mock_inner_classes"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "mocking_inner_classes_with_wrong_outer_instance"
},
{
"className": " org.mockitousage.constructor.CreatingMocksWithConstructorTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<hey!> but was:<null>",
"methodName": "can_mock_abstract_classes"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 12,
"spreadCodeOnly": 11
},
"observations": "Instantiates an InstantiatonProvider object",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"assignExpChange",
"mcAdd",
"mcRepl",
"objInstAdd",
"varAdd",
"varReplVar"
],
"repairPatterns": [
"wrongVarRef"
],
"repairTools": [],
"revisionId": "7616cd17d5e1dc7c3dee080c6969183821d4797a"
},
{
"bugId": 19,
"changedFiles": {
"org/mockito/internal/configuration/injection/PropertyAndSetterInjection.java": {
"changes": [
[
114
]
]
},
"org/mockito/internal/configuration/injection/filter/FinalMockCandidateFilter.java": {
"changes": [
[
23
]
],
"inserts": [
[
-1
]
]
},
"org/mockito/internal/configuration/injection/filter/MockCandidateFilter.java": {
"changes": [
[
15
]
],
"inserts": [
[
-1
]
]
},
"org/mockito/internal/configuration/injection/filter/NameBasedCandidateFilter.java": {
"changes": [
[
23
],
[
31
],
[
43
]
],
"inserts": [
[
33,
34,
35,
36,
37,
38,
39,
40,
41,
42
]
]
},
"org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java": {
"changes": [
[
20
],
[
28
]
]
}
},
"diff": "--- a/src/org/mockito/internal/configuration/injection/PropertyAndSetterInjection.java\n+++ b/src/org/mockito/internal/configuration/injection/PropertyAndSetterInjection.java\n@@ -111,7 +111,7 @@ private boolean injectMockCandidates(Class<?> awaitingInjectionClazz, Set<Object\n private boolean injectMockCandidatesOnFields(Set<Object> mocks, Object instance, boolean injectionOccurred, List<Field> orderedInstanceFields) {\n for (Iterator<Field> it = orderedInstanceFields.iterator(); it.hasNext(); ) {\n Field field = it.next();\n- Object injected = mockCandidateFilter.filterCandidate(mocks, field, instance).thenInject();\n+ Object injected = mockCandidateFilter.filterCandidate(mocks, field, orderedInstanceFields, instance).thenInject();\n if (injected != null) {\n injectionOccurred |= true;\n mocks.remove(injected);\n--- a/src/org/mockito/internal/configuration/injection/filter/FinalMockCandidateFilter.java\n+++ b/src/org/mockito/internal/configuration/injection/filter/FinalMockCandidateFilter.java\n@@ -10,6 +10,7 @@\n \n import java.lang.reflect.Field;\n import java.util.Collection;\n+import java.util.List;\n \n /**\n * This node returns an actual injecter which will be either :\n@@ -20,7 +21,7 @@\n * </ul>\n */\n public class FinalMockCandidateFilter implements MockCandidateFilter {\n- public OngoingInjecter filterCandidate(final Collection<Object> mocks, final Field field, final Object fieldInstance) {\n+ public OngoingInjecter filterCandidate(final Collection<Object> mocks, final Field field, List<Field> fields, final Object fieldInstance) {\n if(mocks.size() == 1) {\n final Object matchingMock = mocks.iterator().next();\n \n--- a/src/org/mockito/internal/configuration/injection/filter/MockCandidateFilter.java\n+++ b/src/org/mockito/internal/configuration/injection/filter/MockCandidateFilter.java\n@@ -6,13 +6,14 @@\n \n import java.lang.reflect.Field;\n import java.util.Collection;\n+import java.util.List;\n \n public interface MockCandidateFilter {\n \n OngoingInjecter filterCandidate(\n Collection<Object> mocks,\n Field fieldToBeInjected,\n- Object fieldInstance\n+ List<Field> fields, Object instance\n );\n \n }\n--- a/src/org/mockito/internal/configuration/injection/filter/NameBasedCandidateFilter.java\n+++ b/src/org/mockito/internal/configuration/injection/filter/NameBasedCandidateFilter.java\n@@ -20,7 +20,7 @@ public NameBasedCandidateFilter(MockCandidateFilter next) {\n \t}\n \n \tpublic OngoingInjecter filterCandidate(Collection<Object> mocks,\n-\t\t\tField field, Object fieldInstance) {\n+\t\t\tField field, List<Field> fields, Object fieldInstance) {\n \t\tList<Object> mockNameMatches = new ArrayList<Object>();\n \t\tif (mocks.size() > 1) {\n \t\t\tfor (Object mock : mocks) {\n@@ -28,7 +28,7 @@ public OngoingInjecter filterCandidate(Collection<Object> mocks,\n \t\t\t\t\tmockNameMatches.add(mock);\n \t\t\t\t}\n \t\t\t}\n-\t\t\treturn next.filterCandidate(mockNameMatches, field,\n+\t\t\treturn next.filterCandidate(mockNameMatches, field, fields,\n \t\t\t\t\tfieldInstance);\n \t\t\t/*\n \t\t\t * In this case we have to check whether we have conflicting naming\n@@ -39,7 +39,23 @@ public OngoingInjecter filterCandidate(Collection<Object> mocks,\n \t\t\t * whenever we find a field that does match its name with the mock\n \t\t\t * name, we should take that field instead.\n \t\t\t */\n+\t\t} else if (mocks.size() == 1) {\n+\t\t\tString mockName = mockUtil.getMockName(mocks.iterator().next())\n+\t\t\t\t\t.toString();\n+\n+\t\t\tfor (Field otherField : fields) {\n+\t\t\t\tif (!otherField.equals(field)\n+\t\t\t\t\t\t&& otherField.getType().equals(field.getType())\n+\t\t\t\t\t\t&& otherField.getName().equals(mockName)) {\n+\n+\t\t\t\t\treturn new OngoingInjecter() {\n+\t\t\t\t\t\tpublic Object thenInject() {\n+\t\t\t\t\t\t\treturn null;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t};\n+\t\t\t\t}\n+\t\t\t}\n \t\t}\n-\t\treturn next.filterCandidate(mocks, field, fieldInstance);\n+\t\treturn next.filterCandidate(mocks, field, fields, fieldInstance);\n \t}\n }\n--- a/src/org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java\n+++ b/src/org/mockito/internal/configuration/injection/filter/TypeBasedCandidateFilter.java\n@@ -17,7 +17,7 @@ public TypeBasedCandidateFilter(MockCandidateFilter next) {\n this.next = next;\n }\n \n- public OngoingInjecter filterCandidate(Collection<Object> mocks, Field field, Object fieldInstance) {\n+ public OngoingInjecter filterCandidate(Collection<Object> mocks, Field field, List<Field> fields, Object fieldInstance) {\n List<Object> mockTypeMatches = new ArrayList<Object>();\n for (Object mock : mocks) {\n if (field.getType().isAssignableFrom(mock.getClass())) {\n@@ -25,6 +25,6 @@ public OngoingInjecter filterCandidate(Collection<Object> mocks, Field field, Ob\n }\n }\n \n- return next.filterCandidate(mockTypeMatches, field, fieldInstance);\n+ return next.filterCandidate(mockTypeMatches, field, fields, fieldInstance);\n }\n }\n",
"failingTests": [
{
"className": " org.mockitousage.annotation.MockInjectionUsingSetterOrPropertyTest",
"error": "junit.framework.AssertionFailedError",
"message": "Expected: <null> but was: candidate2",
"methodName": "shouldInsertFieldWithCorrectNameWhenMultipleTypesAvailable"
}
],
"metrics": {
"chunks": 11,
"classes": 5,
"files": 5,
"linesAdd": 18,
"linesMod": 8,
"linesRem": 0,
"methods": 5,
"sizeInLines": 26,
"spreadAllLines": 41,
"spreadCodeOnly": 20
},
"observations": "Adds new parameter to existent method. Adjust code to reflect this.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"condBranIfElseAdd",
"loopAdd",
"mcAdd",
"mcParAdd",
"mcRepl",
"mdAdd",
"mdParAdd",
"objInstAdd",
"retBranchAdd",
"retExpChange"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd"
],
"repairTools": [],
"revisionId": "110ffa80070bf54ab8efabdaaa27b193a93d6128"
},
{
"bugId": 21,
"changedFiles": {
"org/mockito/internal/creation/instance/ConstructorInstantiator.java": {
"changes": [
[
17
],
[
20
],
[
25
]
],
"deletes": [
[
24
]
],
"inserts": [
[
25
],
[
26
],
[
29
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/creation/instance/ConstructorInstantiator.java\n+++ b/src/org/mockito/internal/creation/instance/ConstructorInstantiator.java\n@@ -14,18 +14,23 @@ public ConstructorInstantiator(Object outerClassInstance) {\n if (outerClassInstance == null) {\n return noArgConstructor(cls);\n }\n- return withOuterClass(cls);\n+ return withParams(cls, outerClassInstance);\n }\n \n- private <T> T withOuterClass(Class<T> cls) {\n+ private static <T> T withParams(Class<T> cls, Object... params) {\n try {\n //this is kind of overengineered because we don't need to support more params\n //however, I know we will be needing it :)\n- Constructor<T> c = cls.getDeclaredConstructor(outerClassInstance.getClass());\n- return c.newInstance(outerClassInstance);\n+ for (Constructor<?> constructor : cls.getDeclaredConstructors()) {\n+ Class<?>[] types = constructor.getParameterTypes();\n+ if (paramsMatch(types, params)) {\n+ return (T) constructor.newInstance(params);\n+ }\n+ }\n } catch (Exception e) {\n throw paramsException(cls, e);\n }\n+ throw paramsException(cls, null);\n }\n \n private static <T> InstantationException paramsException(Class<T> cls, Exception e) {\n@@ -33,6 +38,17 @@ public ConstructorInstantiator(Object outerClassInstance) {\n + cls.getSimpleName() + \"'.\\nPlease ensure that the outer instance has correct type and that the target class has parameter-less constructor.\", e);\n }\n \n+ private static boolean paramsMatch(Class<?>[] types, Object[] params) {\n+ if (params.length != types.length) {\n+ return false;\n+ }\n+ for (int i = 0; i < params.length; i++) {\n+ if (!types[i].isInstance(params[i])) {\n+ return false;\n+ }\n+ }\n+ return true;\n+ }\n \n private static <T> T noArgConstructor(Class<T> cls) {\n try {\n",
"failingTests": [
{
"className": " org.mockito.internal.creation.instance.ConstructorInstantiatorTest",
"error": "org.mockito.internal.creation.instance.InstantationException",
"message": "Unable to create mock instance of 'SomeInnerClass'.",
"methodName": "creates_instances_of_inner_classes"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 16,
"linesMod": 4,
"linesRem": 0,
"methods": 3,
"sizeInLines": 20,
"spreadAllLines": 15,
"spreadCodeOnly": 10
},
"observations": "Apply \"static\" modifier to withParams method",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"loopAdd",
"mcAdd",
"mcRepl",
"mdAdd",
"mdModChange",
"mdParAdd",
"mdRen",
"retBranchAdd",
"retExpChange",
"retRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"wrongComp"
],
"repairTools": [],
"revisionId": "8912aa176ea8414c2fc57df0d9b030b918630e9f"
},
{
"bugId": 23,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java": {
"changes": [
[
44
],
[
45
],
[
99
],
[
100
],
[
114
]
],
"inserts": [
[
48,
49,
50,
51,
52
],
[
-1
],
[
-1
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n@@ -41,14 +41,16 @@\n \r\n private static final long serialVersionUID = -7105341425736035847L;\r\n \r\n- private MockitoCore mockitoCore = new MockitoCore();\r\n- private ReturnsEmptyValues delegate = new ReturnsEmptyValues();\r\n+ private transient MockitoCore mockitoCore;\r\n+ private transient ReturnsEmptyValues delegate;\r\n \r\n public Object answer(InvocationOnMock invocation) throws Throwable {\r\n GenericMetadataSupport returnTypeGenericMetadata =\r\n actualParameterizedType(invocation.getMock()).resolveGenericReturnType(invocation.getMethod());\r\n \r\n Class<?> rawType = returnTypeGenericMetadata.rawType();\r\n+ instantiateMockitoCoreIfNeeded();\r\n+ instantiateDelegateIfNeeded();\r\n if (!mockitoCore.isTypeMockable(rawType)) {\r\n return delegate.returnValueFor(rawType);\r\n }\r\n@@ -56,7 +58,17 @@ public Object answer(InvocationOnMock invocation) throws Throwable {\n return getMock(invocation, returnTypeGenericMetadata);\r\n }\r\n \r\n+ private synchronized void instantiateMockitoCoreIfNeeded() {\r\n+ if (mockitoCore == null) {\r\n+ mockitoCore = new MockitoCore();\r\n+ }\r\n+ }\r\n \r\n+ private synchronized void instantiateDelegateIfNeeded() {\r\n+ if (delegate == null) {\r\n+ delegate = new ReturnsEmptyValues();\r\n+ }\r\n+ }\r\n \r\n private Object getMock(InvocationOnMock invocation, GenericMetadataSupport returnTypeGenericMetadata) throws Throwable {\r\n \tInternalMockHandler<Object> handler = new MockUtil().getMockHandler(invocation.getMock());\r\n@@ -97,6 +109,7 @@ private MockSettings withSettingsUsing(GenericMetadataSupport returnTypeGenericM\n : withSettings();\r\n \r\n return mockSettings\r\n+\t\t .serializable()\r\n .defaultAnswer(returnsDeepStubsAnswerUsing(returnTypeGenericMetadata));\r\n }\r\n \r\n@@ -111,7 +124,7 @@ protected GenericMetadataSupport actualParameterizedType(Object mock) {\n \r\n private Object recordDeepStubMock(final Object mock, InvocationContainerImpl container) throws Throwable {\r\n \r\n- container.addAnswer(new Answer<Object>() {\r\n+ container.addAnswer(new SerializableAnswer() {\r\n public Object answer(InvocationOnMock invocation) throws Throwable {\r\n return mock;\r\n }\r\n@@ -120,7 +133,9 @@ public Object answer(InvocationOnMock invocation) throws Throwable {\n return mock;\r\n }\r\n \t\r\n+\tabstract class SerializableAnswer implements Answer<Object>, Serializable {\r\n \t\t\r\n+\t}\r\n \t\r\n \r\n protected GenericMetadataSupport actualParameterizedType(Object mock) {\r\n",
"failingTests": [
{
"className": " org.mockitousage.stubbing.DeepStubsSerializableTest",
"error": "java.io.NotSerializableException",
"message": "org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs$2",
"methodName": "should_serialize_and_deserialize_mock_created_by_deep_stubs"
}
],
"metrics": {
"chunks": 8,
"classes": 2,
"files": 1,
"linesAdd": 15,
"linesMod": 3,
"linesRem": 0,
"methods": 5,
"sizeInLines": 18,
"spreadAllLines": 77,
"spreadCodeOnly": 48
},
"observations": "Instantiates MockitoCore and ReturnsEmptyValues objects. Replaces instantiation of Answer to SerializabelAnswer object.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"assignRem",
"condBranIfAdd",
"mcAdd",
"mdAdd",
"objInstAdd",
"objInstRem",
"retExpChange",
"tyAdd",
"varModChange",
"varTyChange"
],
"repairPatterns": [
"condBlockOthersAdd",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "82935114a09390cbab0c6b6df9b6fd6788bf55d9"
},
{
"bugId": 28,
"changedFiles": {
"org/mockito/internal/configuration/DefaultInjectionEngine.java": {
"changes": [
[
93
]
],
"inserts": [
[
94
]
]
}
},
"diff": "--- a/src/org/mockito/internal/configuration/DefaultInjectionEngine.java\n+++ b/src/org/mockito/internal/configuration/DefaultInjectionEngine.java\n@@ -90,7 +90,8 @@ public void injectMocksOnFields(Set<Field> injectMocksFields, Set<Object> mocks,\n \r\n private void injectMockCandidate(Class<?> awaitingInjectionClazz, Set<Object> mocks, Object fieldInstance) {\r\n for(Field field : orderedInstanceFieldsFrom(awaitingInjectionClazz)) {\r\n- mockCandidateFilter.filterCandidate(mocks, field, fieldInstance).thenInject();\r\n+ Object injected = mockCandidateFilter.filterCandidate(mocks, field, fieldInstance).thenInject();\r\n+ mocks.remove(injected);\r\n }\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.InjectionByTypeShouldFirstLookForExactTypeThenAncestorTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected same:<java.lang.Object@6cc90398> was not:<mockedBean>",
"methodName": "mock_should_be_injected_once_and_in_the_best_matching_type"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes method signature adding new parameter.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"missComp",
"singleLine",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "0464f5657dc8c76a4ff209a2cf7fd6312885cdc3"
},
{
"bugId": 24,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java": {
"changes": [
[
76
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsEmptyValues.java\n@@ -73,7 +73,7 @@ public Object answer(InvocationOnMock invocation) {\n //see issue 184.\n //mocks by default should return 0 if references are the same, otherwise some other value because they are not the same. Hence we return 1 (anything but 0 is good).\n //Only for compareTo() method by the Comparable interface\n- return 1;\n+ return invocation.getMock() == invocation.getArguments()[0] ? 0 : 1;\n }\n \n Class<?> returnType = invocation.getMethod().getReturnType();\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValuesTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<1>",
"methodName": "should_return_zero_if_mock_is_compared_to_itself"
},
{
"className": " org.mockitousage.bugs.ShouldMocksCompareToBeConsistentWithEqualsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<1> but was:<2>",
"methodName": "should_compare_to_be_consistent_with_equals_when_comparing_the_same_reference"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "If-Else implicit in \"exp?x:y\" format",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfElseAdd",
"mcAdd",
"retExpChange"
],
"repairPatterns": [
"singleLine",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "c17169c2cbb0b3d055d64ec2c4859122ca919c42"
},
{
"bugId": 29,
"changedFiles": {
"org/mockito/internal/matchers/Same.java": {
"changes": [
[
29
]
]
}
},
"diff": "--- a/src/org/mockito/internal/matchers/Same.java\n+++ b/src/org/mockito/internal/matchers/Same.java\n@@ -26,7 +26,7 @@ public boolean matches(Object actual) {\n public void describeTo(Description description) {\n description.appendText(\"same(\");\n appendQuoting(description);\n- description.appendText(wanted.toString());\n+ description.appendText(wanted == null ? \"null\" : wanted.toString());\n appendQuoting(description);\n description.appendText(\")\");\n }\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.NPEWithCertainMatchersTest",
"error": "java.lang.Exception",
"message": "Unexpected exception, expected<java.lang.AssertionError> but was<java.lang.NullPointerException>",
"methodName": "shouldNotThrowNPEWhenNullPassedToSame"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Wrapping implicit in \"exp?x:y\" format",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfElseAdd"
],
"repairPatterns": [
"missNullCheckP",
"singleLine",
"wrapsIfElse"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "918f0a5aed6454b307004b6c9c86afc8e96353ff"
},
{
"bugId": 25,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java": {
"changes": [
[
53
],
[
56
],
[
68
],
[
81
],
[
82
],
[
83
]
],
"inserts": [
[
-1
],
[
-1
],
[
-1
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs.java\n@@ -1,85 +1,108 @@\n /*\r\n * Copyright (c) 2007 Mockito contributors\r\n * This program is made available under the terms of the MIT License.\r\n */\r\n package org.mockito.internal.stubbing.defaultanswers;\r\n \r\n+import org.mockito.MockSettings;\r\n import org.mockito.internal.InternalMockHandler;\r\n import org.mockito.internal.creation.settings.CreationSettings;\r\n import org.mockito.internal.stubbing.InvocationContainerImpl;\r\n import org.mockito.internal.stubbing.StubbedInvocationMatcher;\r\n import org.mockito.internal.util.MockCreationValidator;\r\n import org.mockito.internal.util.MockUtil;\r\n import org.mockito.internal.util.reflection.GenericMetadataSupport;\r\n import org.mockito.invocation.InvocationOnMock;\r\n import org.mockito.stubbing.Answer;\r\n \r\n import java.io.Serializable;\r\n \r\n+import static org.mockito.Mockito.mock;\r\n+import static org.mockito.Mockito.withSettings;\r\n \r\n /**\r\n * Returning deep stub implementation.\r\n *\r\n * Will return previously created mock if the invocation matches.\r\n *\r\n * <p>Supports nested generic information, with this answer you can write code like this :\r\n *\r\n * <pre class=\"code\"><code class=\"java\">\r\n * interface GenericsNest&lt;K extends Comparable&lt;K&gt; & Cloneable&gt; extends Map&lt;K, Set&lt;Number&gt;&gt; {}\r\n *\r\n * GenericsNest&lt;?&gt; mock = mock(GenericsNest.class, new ReturnsGenericDeepStubs());\r\n * Number number = mock.entrySet().iterator().next().getValue().iterator().next();\r\n * </code></pre>\r\n * </p>\r\n *\r\n * @see org.mockito.Mockito#RETURNS_DEEP_STUBS\r\n * @see org.mockito.Answers#RETURNS_DEEP_STUBS\r\n */\r\n public class ReturnsDeepStubs implements Answer<Object>, Serializable {\r\n \r\n private static final long serialVersionUID = -7105341425736035847L;\r\n \r\n private ReturnsEmptyValues delegate = new ReturnsEmptyValues();\r\n \r\n public Object answer(InvocationOnMock invocation) throws Throwable {\r\n GenericMetadataSupport returnTypeGenericMetadata =\r\n actualParameterizedType(invocation.getMock()).resolveGenericReturnType(invocation.getMethod());\r\n \r\n Class<?> rawType = returnTypeGenericMetadata.rawType();\r\n if (!new MockCreationValidator().isTypeMockable(rawType)) {\r\n return delegate.returnValueFor(rawType);\r\n }\r\n \r\n- return getMock(invocation);\r\n+ return getMock(invocation, returnTypeGenericMetadata);\r\n }\r\n \r\n- private Object getMock(InvocationOnMock invocation) throws Throwable {\r\n+ private Object getMock(InvocationOnMock invocation, GenericMetadataSupport returnTypeGenericMetadata) throws Throwable {\r\n \tInternalMockHandler<Object> handler = new MockUtil().getMockHandler(invocation.getMock());\r\n \tInvocationContainerImpl container = (InvocationContainerImpl) handler.getInvocationContainer();\r\n \r\n // matches invocation for verification\r\n for (StubbedInvocationMatcher stubbedInvocationMatcher : container.getStubbedInvocations()) {\r\n \t\tif(container.getInvocationForStubbing().matches(stubbedInvocationMatcher.getInvocation())) {\r\n \t\t\treturn stubbedInvocationMatcher.answer(invocation);\r\n \t\t}\r\n \t\t}\r\n \r\n // deep stub\r\n- return recordDeepStubMock(invocation, container);\r\n+ return recordDeepStubMock(createNewDeepStubMock(returnTypeGenericMetadata), container);\r\n }\r\n \r\n /**\r\n * Creates a mock using the Generics Metadata.\r\n *\r\n * @param returnTypeGenericMetadata The metadata to use to create the new mock.\r\n * @return The mock\r\n */\r\n+ private Object createNewDeepStubMock(GenericMetadataSupport returnTypeGenericMetadata) {\r\n+ return mock(\r\n+ returnTypeGenericMetadata.rawType(),\r\n+ withSettingsUsing(returnTypeGenericMetadata)\r\n+ );\r\n+ }\r\n \r\n+ private MockSettings withSettingsUsing(GenericMetadataSupport returnTypeGenericMetadata) {\r\n+ MockSettings mockSettings =\r\n+ returnTypeGenericMetadata.rawExtraInterfaces().length > 0 ?\r\n+ withSettings().extraInterfaces(returnTypeGenericMetadata.rawExtraInterfaces())\r\n+ : withSettings();\r\n \r\n+ return mockSettings\r\n+ .defaultAnswer(returnsDeepStubsAnswerUsing(returnTypeGenericMetadata));\r\n+ }\r\n \r\n+ private ReturnsDeepStubs returnsDeepStubsAnswerUsing(final GenericMetadataSupport returnTypeGenericMetadata) {\r\n+ return new ReturnsDeepStubs() {\r\n+ @Override\r\n+ protected GenericMetadataSupport actualParameterizedType(Object mock) {\r\n+ return returnTypeGenericMetadata;\r\n+ }\r\n+ };\r\n+ }\r\n \r\n- private Object recordDeepStubMock(InvocationOnMock invocation, InvocationContainerImpl container) {\r\n- Class<?> clz = invocation.getMethod().getReturnType();\r\n- final Object mock = org.mockito.Mockito.mock(clz, this);\r\n+ private Object recordDeepStubMock(final Object mock, InvocationContainerImpl container) throws Throwable {\r\n \r\n container.addAnswer(new Answer<Object>() {\r\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "org.mockito.internal.creation.jmock.ClassImposterizer$ClassWithSuperclassToWorkAroundCglibBug$$EnhancerByMockitoWithCGLIB$$c14e755e cannot be cast to java.lang.String",
"methodName": "will_return_default_value_on_non_mockable_nested_generic"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "$java.lang.Comparable$$EnhancerByMockitoWithCGLIB$$e317f21e cannot be cast to java.lang.Cloneable",
"methodName": "can_create_mock_from_multiple_type_variable_bounds_when_return_type_of_parameterized_method_is_a_typevar_that_is_referencing_a_typevar_on_class"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "org.mockito.internal.creation.jmock.ClassImposterizer$ClassWithSuperclassToWorkAroundCglibBug$$EnhancerByMockitoWithCGLIB$$c14e755e cannot be cast to java.lang.Number",
"methodName": "can_create_mock_from_return_types_declared_with_a_bounded_wildcard"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "org.mockito.internal.creation.jmock.ClassImposterizer$ClassWithSuperclassToWorkAroundCglibBug$$EnhancerByMockitoWithCGLIB$$c14e755e cannot be cast to java.lang.Cloneable",
"methodName": "can_create_mock_from_multiple_type_variable_bounds_when_return_type_of_parameterized_method_is_a_parameterizedtype_that_is_referencing_a_typevar_on_class"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "org.mockito.internal.creation.jmock.ClassImposterizer$ClassWithSuperclassToWorkAroundCglibBug$$EnhancerByMockitoWithCGLIB$$c14e755e cannot be cast to java.util.Map$Entry",
"methodName": "generic_deep_mock_frenzy__look_at_these_chained_calls"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsGenericDeepStubsTest",
"error": "java.lang.ClassCastException",
"message": "$java.lang.Comparable$$EnhancerByMockitoWithCGLIB$$e317f21e cannot be cast to java.lang.Cloneable",
"methodName": "can_create_mock_from_multiple_type_variable_bounds_when_method_return_type_is_referencing_a_typevar_on_class"
}
],
"metrics": {
"chunks": 10,
"classes": 1,
"files": 1,
"linesAdd": 25,
"linesMod": 4,
"linesRem": 2,
"methods": 6,
"sizeInLines": 31,
"spreadAllLines": 71,
"spreadCodeOnly": 29
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignRem",
"mcAdd",
"mcParAdd",
"mcParValChange",
"mcRem",
"mcRepl",
"mdAdd",
"mdOverride",
"mdParAdd",
"mdParRem",
"objInstAdd",
"retExpChange",
"varRem"
],
"repairPatterns": [
"missComp",
"notClassified"
],
"repairTools": [],
"revisionId": "a6ccf070a267e0a165b8efaaefa8938e787bb6a0"
},
{
"bugId": 27,
"changedFiles": {
"org/mockito/internal/util/MockUtil.java": {
"changes": [
[
64
],
[
65
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/MockUtil.java\n+++ b/src/org/mockito/internal/util/MockUtil.java\n@@ -61,8 +61,7 @@ public MockUtil() {\n \r\n public <T> void resetMock(T mock) {\r\n MockHandlerInterface<T> oldMockHandler = getMockHandler(mock);\r\n- MockHandler<T> newMockHandler = new MockHandler<T>(oldMockHandler);\r\n- MethodInterceptorFilter newFilter = new MethodInterceptorFilter(newMockHandler, (MockSettingsImpl) org.mockito.Mockito.withSettings().defaultAnswer(org.mockito.Mockito.RETURNS_DEFAULTS));\r\n+ MethodInterceptorFilter newFilter = newMethodInterceptorFilter(oldMockHandler.getMockSettings());\r\n ((Factory) mock).setCallback(0, newFilter);\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.ListenersLostOnResetMockTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "listener"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 1,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignExpChange",
"mcAdd",
"mcRem",
"objInstRem",
"varRem"
],
"repairPatterns": [
"initFix",
"notClassified"
],
"repairTools": [],
"revisionId": "a8ec4fa290bc1cdde060218d6bb811ac1fa6da6f"
},
{
"bugId": 26,
"changedFiles": {
"org/mockito/internal/util/Primitives.java": {
"changes": [
[
66
]
]
}
},
"diff": "--- a/src/org/mockito/internal/util/Primitives.java\n+++ b/src/org/mockito/internal/util/Primitives.java\n@@ -63,6 +63,6 @@ public static boolean isPrimitiveWrapper(Class<?> type) {\n primitiveValues.put(int.class, 0);\r\n primitiveValues.put(long.class, 0L);\r\n primitiveValues.put(float.class, 0F);\r\n- primitiveValues.put(double.class, 0);\r\n+ primitiveValues.put(double.class, 0D);\r\n }\r\n }\n\\ No newline at end of file\n",
"failingTests": [
{
"className": " org.mockito.internal.progress.HandyReturnValuesTest",
"error": "java.lang.ClassCastException",
"message": "java.lang.Integer cannot be cast to java.lang.Character",
"methodName": "should_default_values_for_primitive"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsEmptyValuesTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<0>",
"methodName": "should_return_primitive"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsMocksTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<0>",
"methodName": "should_return_the_usual_default_values_for_primitives"
},
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNullsTest",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<0>",
"methodName": "should_return_the_usual_default_values_for_primitives"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcParValChange"
],
"repairPatterns": [
"constChange",
"singleLine",
"wrongComp"
],
"repairTools": [],
"revisionId": "af44738c7de74f24e37ea0c1242e73b07c3f4362"
},
{
"bugId": 32,
"changedFiles": {
"org/mockito/internal/configuration/SpyAnnotationEngine.java": {
"changes": [
[
49
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/configuration/SpyAnnotationEngine.java\n+++ b/src/org/mockito/internal/configuration/SpyAnnotationEngine.java\n@@ -16,6 +16,7 @@\n import org.mockito.exceptions.base.MockitoException;\r\n import org.mockito.internal.util.MockUtil;\r\n \r\n+import static org.mockito.Mockito.withSettings;\r\n \r\n @SuppressWarnings({\"unchecked\"})\r\n public class SpyAnnotationEngine implements AnnotationEngine {\r\n@@ -46,7 +47,10 @@ public void process(Class<?> context, Object testClass) {\n // instance has been spied earlier\r\n Mockito.reset(instance);\r\n } else {\r\n- field.set(testClass, Mockito.spy(instance));\r\n+ field.set(testClass, Mockito.mock(instance.getClass(), withSettings()\r\n+ .spiedInstance(instance)\r\n+ .defaultAnswer(Mockito.CALLS_REAL_METHODS)\r\n+ .name(field.getName())));\r\n }\r\n } catch (IllegalAccessException e) {\r\n throw new MockitoException(\"Problems initiating spied field \" + field.getName(), e);\r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.SpyShouldHaveNiceNameTest",
"error": "junit.framework.AssertionFailedError",
"message": "<'",
"methodName": "shouldPrintNiceName"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 30,
"spreadCodeOnly": 25
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcParValChange",
"mcRepl"
],
"repairPatterns": [
"missComp",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "4f7060cc54bb50292ccfbf3b9fca27f0282abf51"
},
{
"bugId": 31,
"changedFiles": {
"org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java": {
"changes": [
[
60
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java\n@@ -6,6 +6,7 @@\n \r\n import java.io.Serializable;\r\n import java.lang.reflect.Method;\r\n+import java.util.Arrays;\r\n \r\n import org.mockito.Mockito;\r\n import org.mockito.cglib.proxy.MethodInterceptor;\r\n@@ -57,7 +58,8 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr\n }\r\n \r\n \t\tprivate String formatMethodCall() {\r\n-\t\t\treturn invocation.getMethod().getName() + \"()\";\r\n+\t\t\tString args = Arrays.toString(invocation.getArguments());\r\n+\t\t\treturn invocation.getMethod().getName() + \"(\" + args.substring(1, args.length() - 1) +\t\")\";\r\n \t\t}\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNullsTest",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<... unstubbed withArgs([oompa, lumpa]) method on mock> but was:<... unstubbed withArgs([]) method on mock>",
"methodName": "shouldPrintTheParametersWhenCallingAMethodWithArgs"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 51,
"spreadCodeOnly": 25
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"mcAdd",
"retExpChange",
"varAdd"
],
"repairPatterns": [
"missComp",
"notClassified"
],
"repairTools": [],
"revisionId": "62b6bdf44baeee172b2b1684835fb995bad2a47d"
},
{
"bugId": 34,
"changedFiles": {
"org/mockito/internal/invocation/InvocationMatcher.java": {
"changes": [
[
106
]
]
}
},
"diff": "--- a/src/org/mockito/internal/invocation/InvocationMatcher.java\n+++ b/src/org/mockito/internal/invocation/InvocationMatcher.java\n@@ -103,7 +103,7 @@ public String toString(PrintSettings printSettings) {\n public void captureArgumentsFrom(Invocation i) {\n int k = 0;\n for (Matcher m : matchers) {\n- if (m instanceof CapturesArguments) {\n+ if (m instanceof CapturesArguments && i.getArguments().length > k) {\n ((CapturesArguments) m).captureFrom(i.getArguments()[k]);\n }\n k++;\n",
"failingTests": [
{
"className": " org.mockito.internal.invocation.InvocationMatcherTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "0",
"methodName": "shouldMatchCaptureArgumentsWhenArgsCountDoesNOTMatch"
},
{
"className": " org.mockitousage.basicapi.UsingVarargsTest",
"error": "java.lang.ArrayIndexOutOfBoundsException",
"message": "0",
"methodName": "shouldMatchEasilyEmptyVararg"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condExpExpand",
"mcAdd"
],
"repairPatterns": [
"expLogicExpand",
"singleLine"
],
"repairTools": [],
"revisionId": "e8cebe01abae49a09aadd6a26c6f7e2f90e5e772"
},
{
"bugId": 36,
"changedFiles": {
"org/mockito/internal/invocation/Invocation.java": {
"inserts": [
[
-1
],
[
202
]
]
}
},
"diff": "--- a/src/org/mockito/internal/invocation/Invocation.java\n+++ b/src/org/mockito/internal/invocation/Invocation.java\n@@ -8,6 +8,7 @@\n \n import org.hamcrest.Matcher;\n import org.mockito.exceptions.PrintableInvocation;\n+import org.mockito.exceptions.Reporter;\n import org.mockito.internal.debugging.Location;\n import org.mockito.internal.invocation.realmethod.RealMethod;\n import org.mockito.internal.matchers.*;\n@@ -199,6 +200,9 @@ public int getArgumentsCount() {\n }\n \n public Object callRealMethod() throws Throwable {\n+ if (this.getMethod().getDeclaringClass().isInterface()) {\n+ new Reporter().cannotCallRealMethodOnInterface();\n+ }\n return realMethod.invoke(mock, rawArguments);\n }\n \n",
"failingTests": [
{
"className": " org.mockito.internal.invocation.InvocationTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldScreamWhenCallingRealMethodOnInterface"
},
{
"className": " org.mockitousage.spies.SpyingOnInterfacesTest",
"error": "java.lang.NoSuchMethodError",
"message": "java.lang.Object.get(I)Ljava/lang/Object;",
"methodName": "shouldFailInRuntimeWhenCallingRealMethodOnInterface"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 4,
"spreadAllLines": 191,
"spreadCodeOnly": 146
},
"observations": "Instantiates an Reporter object",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "84c142f56fe971ed52ecfe42b42bc0aa7bef8354"
},
{
"bugId": 33,
"changedFiles": {
"org/mockito/internal/invocation/InvocationMatcher.java": {
"deletes": [
[
99
]
],
"inserts": [
[
97,
98,
99,
100
]
]
}
},
"diff": "--- a/src/org/mockito/internal/invocation/InvocationMatcher.java\n+++ b/src/org/mockito/internal/invocation/InvocationMatcher.java\n@@ -95,8 +95,19 @@ public boolean hasSameMethod(Invocation candidate) {\n Method m1 = invocation.getMethod();\n Method m2 = candidate.getMethod();\n \n+ if (m1.getName() != null && m1.getName().equals(m2.getName())) {\n \t/* Avoid unnecessary cloning */\n- return m1.equals(m2);\n+ \tClass[] params1 = m1.getParameterTypes();\n+ \tClass[] params2 = m2.getParameterTypes();\n+ \tif (params1.length == params2.length) {\n+ \t for (int i = 0; i < params1.length; i++) {\n+ \t\tif (params1[i] != params2[i])\n+ \t\t return false;\n+ \t }\n+ \t return true;\n+ \t}\n+ }\n+ return false;\n }\n \n public Location getLocation() {\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.InheritedGenericsPolimorphicCallTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldStubbingWork"
},
{
"className": " org.mockitousage.bugs.InheritedGenericsPolimorphicCallTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldVerificationWorks"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 11,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd",
"retBranchAdd",
"retRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missNullCheckN",
"wrongComp"
],
"repairTools": [],
"revisionId": "5cb37751c0aba81d025dc5fe4f2f9a3bf86cc958"
},
{
"bugId": 35,
"changedFiles": {
"org/mockito/Matchers.java": {
"changes": [
[
362
],
[
479
],
[
516
]
]
}
},
"diff": "--- a/src/org/mockito/Matchers.java\n+++ b/src/org/mockito/Matchers.java\n@@ -359,7 +359,7 @@ public static Collection anyCollection() {\n * @return <code>null</code>.\r\n */\r\n public static <T> T isA(Class<T> clazz) {\r\n- return reportMatcher(new InstanceOf(clazz)).<T>returnNull();\r\n+ return reportMatcher(new InstanceOf(clazz)).<T>returnFor(clazz);\r\n }\r\n \r\n /**\r\n@@ -476,7 +476,7 @@ public static short eq(short value) {\n * @return <code>null</code>.\r\n */\r\n public static <T> T eq(T value) {\r\n- return reportMatcher(new Equals(value)).<T>returnNull();\r\n+ return (T) reportMatcher(new Equals(value)).<T>returnFor((Class) value.getClass());\r\n } \r\n \r\n /**\r\n@@ -513,7 +513,7 @@ public static short eq(short value) {\n * @return <code>null</code>.\r\n */\r\n public static <T> T same(T value) {\r\n- return reportMatcher(new Same(value)).<T>returnNull();\r\n+ return (T) reportMatcher(new Same(value)).<T>returnFor((Class) value.getClass());\r\n }\r\n \r\n /**\r\n",
"failingTests": [
{
"className": " org.mockitousage.bugs.NPEWithCertainMatchersTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldNotThrowNPEWhenIntPassed"
},
{
"className": " org.mockitousage.bugs.NPEWithCertainMatchersTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldNotThrowNPEWhenIntegerPassed"
},
{
"className": " org.mockitousage.bugs.NPEWithCertainMatchersTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldNotThrowNPEWhenIntegerPassedToEq"
},
{
"className": " org.mockitousage.bugs.NPEWithCertainMatchersTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldNotThrowNPEWhenIntegerPassedToSame"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 3,
"linesRem": 0,
"methods": 3,
"sizeInLines": 3,
"spreadAllLines": 152,
"spreadCodeOnly": 31
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcAdd",
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"copyPaste",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "27a2f515197d4688c4df82afb791bf8ce20a5504"
},
{
"bugId": 30,
"changedFiles": {
"org/mockito/exceptions/Reporter.java": {
"changes": [
[
438
],
[
441
],
[
442
]
],
"inserts": [
[
442
]
]
},
"org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java": {
"changes": [
[
56
]
]
}
},
"diff": "--- a/src/org/mockito/exceptions/Reporter.java\n+++ b/src/org/mockito/exceptions/Reporter.java\n@@ -435,10 +435,11 @@ public void misplacedArgumentMatcher(Location location) {\n ));\n }\n \n- public void smartNullPointerException(Location location) {\n+ public void smartNullPointerException(Object obj, Location location) {\n throw new SmartNullPointerException(join(\n \"You have a NullPointerException here:\",\n new Location(),\n+ obj,\n \"Because this method was *not* stubbed correctly:\",\n location,\n \"\"\n--- a/src/org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java\n+++ b/src/org/mockito/internal/stubbing/defaultanswers/ReturnsSmartNulls.java\n@@ -53,7 +53,7 @@ public Object intercept(Object obj, Method method, Object[] args, MethodProxy pr\n return \"SmartNull returned by unstubbed \" + formatMethodCall() + \" method on mock\";\r\n }\r\n \r\n- new Reporter().smartNullPointerException(location);\r\n+ new Reporter().smartNullPointerException(obj, location);\r\n return null;\r\n }\r\n \r\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.defaultanswers.ReturnsSmartNullsTest",
"error": "junit.framework.AssertionFailedError",
"message": "Exception message should include oompa and lumpa, but was: ",
"methodName": "shouldPrintTheParametersOnSmartNullPointerExceptionMessage"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 1,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 3,
"spreadAllLines": 3,
"spreadCodeOnly": 3
},
"observations": "Adds new parameter to method signature, ajust code.",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"mcParAdd",
"mcRepl",
"mdParAdd",
"objInstMod"
],
"repairPatterns": [
"initFix",
"notClassified"
],
"repairTools": [],
"revisionId": "3c924f80a4db3692a13341f0da4517052ab77a2a"
},
{
"bugId": 38,
"changedFiles": {
"org/mockito/internal/verification/argumentmatching/ArgumentMatchingTool.java": {
"changes": [
[
48
]
]
}
},
"diff": "--- a/src/org/mockito/internal/verification/argumentmatching/ArgumentMatchingTool.java\n+++ b/src/org/mockito/internal/verification/argumentmatching/ArgumentMatchingTool.java\n@@ -45,6 +45,6 @@ private boolean safelyMatches(Matcher m, Object arg) {\n }\r\n \r\n private boolean toStringEquals(Matcher m, Object arg) {\r\n- return StringDescription.toString(m).equals(arg.toString());\r\n+ return StringDescription.toString(m).equals(arg == null? \"null\" : arg.toString());\r\n }\r\n }\r\n",
"failingTests": [
{
"className": " org.mockito.internal.verification.argumentmatching.ArgumentMatchingToolTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldWorkFineWhenGivenArgIsNull"
},
{
"className": " org.mockitousage.bugs.ActualInvocationHasNullArgumentNPEBugTest",
"error": "java.lang.NullPointerException",
"message": "",
"methodName": "shouldAllowPassingNullArgument"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfElseAdd"
],
"repairPatterns": [
"missNullCheckP",
"singleLine",
"wrapsIfElse"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "c1f2c4e6b5bab4cfc004f22999e11e8ac140d377"
},
{
"bugId": 5,
"changedFiles": {
"org/joda/time/Period.java": {
"changes": [
[
1628
],
[
1629
],
[
1630
],
[
1631
],
[
1632
],
[
1633
],
[
1634
],
[
1635
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/Period.java\n+++ b/src/main/java/org/joda/time/Period.java\n@@ -1625,13 +1625,19 @@ public Period normalizedStandard(PeriodType type) {\n int years = getYears();\n int months = getMonths();\n if (years != 0 || months != 0) {\n- years = FieldUtils.safeAdd(years, months / 12);\n- months = months % 12;\n- if (years != 0) {\n- result = result.withYears(years);\n+ long totalMonths = years * 12L + months;\n+ if (type.isSupported(DurationFieldType.YEARS_TYPE)) {\n+ int normalizedYears = FieldUtils.safeToInt(totalMonths / 12);\n+ result = result.withYears(normalizedYears);\n+ totalMonths = totalMonths - (normalizedYears * 12);\n }\n- if (months != 0) {\n- result = result.withMonths(months);\n+ if (type.isSupported(DurationFieldType.MONTHS_TYPE)) {\n+ int normalizedMonths = FieldUtils.safeToInt(totalMonths);\n+ result = result.withMonths(normalizedMonths);\n+ totalMonths = totalMonths - normalizedMonths;\n+ }\n+ if (totalMonths != 0) {\n+ throw new UnsupportedOperationException(\"Unable to normalize as PeriodType is missing either years or months but period has a month/year amount: \" + toString());\n }\n }\n return result;\n",
"failingTests": [
{
"className": " org.joda.time.TestPeriod_Basics",
"error": "java.lang.UnsupportedOperationException",
"message": "Field is not supported",
"methodName": "testNormalizedStandard_periodType_months1"
},
{
"className": " org.joda.time.TestPeriod_Basics",
"error": "java.lang.UnsupportedOperationException",
"message": "Field is not supported",
"methodName": "testNormalizedStandard_periodType_months2"
},
{
"className": " org.joda.time.TestPeriod_Basics",
"error": "java.lang.UnsupportedOperationException",
"message": "Field is not supported",
"methodName": "testNormalizedStandard_periodType_monthsWeeks"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 6,
"linesRem": 0,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 1,
"spreadCodeOnly": 1
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"assignExpChange",
"assignRem",
"condBranIfAdd",
"condExpMod",
"exThrowsAdd",
"mcAdd",
"mcParValChange",
"mcRem",
"objInstAdd",
"varAdd",
"varReplVar"
],
"repairPatterns": [
"blockRemove",
"condBlockExcAdd",
"expLogicMod",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "a6cb59ed2280ab0a32995fa8b5f1a7b0d47cb815"
},
{
"bugId": 3,
"changedFiles": {
"org/joda/time/MutableDateTime.java": {
"inserts": [
[
639
],
[
640
],
[
660
],
[
661
],
[
681
],
[
682
],
[
702
],
[
703
],
[
723
],
[
724
],
[
764
],
[
765
],
[
785
],
[
786
],
[
816
],
[
817
],
[
847
],
[
848
],
[
880
],
[
881
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/MutableDateTime.java\n+++ b/src/main/java/org/joda/time/MutableDateTime.java\n@@ -636,7 +636,9 @@ public void add(DurationFieldType type, int amount) {\n if (type == null) {\n throw new IllegalArgumentException(\"Field must not be null\");\n }\n+ if (amount != 0) {\n setMillis(type.getField(getChronology()).add(getMillis(), amount));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -657,7 +659,9 @@ public void setYear(final int year) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addYears(final int years) {\n+ if (years != 0) {\n setMillis(getChronology().years().add(getMillis(), years));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -678,7 +682,9 @@ public void setWeekyear(final int weekyear) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addWeekyears(final int weekyears) {\n+ if (weekyears != 0) {\n setMillis(getChronology().weekyears().add(getMillis(), weekyears));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -699,7 +705,9 @@ public void setMonthOfYear(final int monthOfYear) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addMonths(final int months) {\n+ if (months != 0) {\n setMillis(getChronology().months().add(getMillis(), months));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -720,7 +728,9 @@ public void setWeekOfWeekyear(final int weekOfWeekyear) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addWeeks(final int weeks) {\n+ if (weeks != 0) {\n setMillis(getChronology().weeks().add(getMillis(), weeks));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -761,7 +771,9 @@ public void setDayOfWeek(final int dayOfWeek) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addDays(final int days) {\n+ if (days != 0) {\n setMillis(getChronology().days().add(getMillis(), days));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -782,7 +794,9 @@ public void setHourOfDay(final int hourOfDay) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addHours(final int hours) {\n+ if (hours != 0) {\n setMillis(getChronology().hours().add(getMillis(), hours));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -813,7 +827,9 @@ public void setMinuteOfHour(final int minuteOfHour) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addMinutes(final int minutes) {\n+ if (minutes != 0) {\n setMillis(getChronology().minutes().add(getMillis(), minutes));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -844,7 +860,9 @@ public void setSecondOfMinute(final int secondOfMinute) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addSeconds(final int seconds) {\n+ if (seconds != 0) {\n setMillis(getChronology().seconds().add(getMillis(), seconds));\n+ }\n }\n \n //-----------------------------------------------------------------------\n@@ -877,7 +895,9 @@ public void setMillisOfSecond(final int millisOfSecond) {\n * @throws IllegalArgumentException if the value is invalid\n */\n public void addMillis(final int millis) {\n+ if (millis != 0) {\n setMillis(getChronology().millis().add(getMillis(), millis));\n+ }\n }\n \n //-----------------------------------------------------------------------\n",
"failingTests": [
{
"className": " org.joda.time.TestMutableDateTime_Adds",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-30T02:30:00.000+0[1]:00> but was:<...10-30T02:30:00.000+0[2]:00>",
"methodName": "testAddYears_int_dstOverlapWinter_addZero"
},
{
"className": " org.joda.time.TestMutableDateTime_Adds",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-30T02:30:00.000+0[1]:00> but was:<...10-30T02:30:00.000+0[2]:00>",
"methodName": "testAddDays_int_dstOverlapWinter_addZero"
},
{
"className": " org.joda.time.TestMutableDateTime_Adds",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-30T02:30:00.000+0[1]:00> but was:<...10-30T02:30:00.000+0[2]:00>",
"methodName": "testAddWeeks_int_dstOverlapWinter_addZero"
},
{
"className": " org.joda.time.TestMutableDateTime_Adds",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-30T02:30:00.000+0[1]:00> but was:<...10-30T02:30:00.000+0[2]:00>",
"methodName": "testAdd_DurationFieldType_int_dstOverlapWinter_addZero"
},
{
"className": " org.joda.time.TestMutableDateTime_Adds",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-30T02:30:00.000+0[1]:00> but was:<...10-30T02:30:00.000+0[2]:00>",
"methodName": "testAddMonths_int_dstOverlapWinter_addZero"
}
],
"metrics": {
"chunks": 20,
"classes": 1,
"files": 1,
"linesAdd": 20,
"linesMod": 0,
"linesRem": 0,
"methods": 10,
"sizeInLines": 20,
"spreadAllLines": 242,
"spreadCodeOnly": 70
},
"observations": "The patches makes a type of \"bypass\" null check, where the logic is applyed only if the value is different of null.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"copyPaste",
"wrapsIf"
],
"repairTools": [],
"revisionId": "8d109fe1a999a11b4557536dd96f9210460a5936"
},
{
"bugId": 1,
"changedFiles": {
"org/joda/time/Partial.java": {
"changes": [
[
221
]
],
"inserts": [
[
217
]
]
},
"org/joda/time/field/UnsupportedDurationField.java": {
"deletes": [
[
227
],
[
228
],
[
229
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/Partial.java\n+++ b/src/main/java/org/joda/time/Partial.java\n@@ -214,11 +214,20 @@ public Partial(DateTimeFieldType[] types, int[] values, Chronology chronology) {\n DateTimeFieldType loopType = types[i];\n DurationField loopUnitField = loopType.getDurationType().getField(iChronology);\n if (i > 0) {\n+ if (loopUnitField.isSupported() == false) {\n+ if (lastUnitField.isSupported()) {\n+ throw new IllegalArgumentException(\"Types array must be in order largest-smallest: \" +\n+ types[i - 1].getName() + \" < \" + loopType.getName());\n+ } else {\n+ throw new IllegalArgumentException(\"Types array must not contain duplicate unsupported: \" +\n+ types[i - 1].getName() + \" and \" + loopType.getName());\n+ }\n+ }\n int compare = lastUnitField.compareTo(loopUnitField);\n if (compare < 0) {\n throw new IllegalArgumentException(\"Types array must be in order largest-smallest: \" +\n types[i - 1].getName() + \" < \" + loopType.getName());\n- } else if (compare == 0) {\n+ } else if (compare == 0 && lastUnitField.equals(loopUnitField)) {\n if (types[i - 1].getRangeDurationType() == null) {\n if (loopType.getRangeDurationType() == null) {\n throw new IllegalArgumentException(\"Types array must not contain duplicate: \" +\n--- a/src/main/java/org/joda/time/field/UnsupportedDurationField.java\n+++ b/src/main/java/org/joda/time/field/UnsupportedDurationField.java\n@@ -224,9 +224,6 @@ public long getUnitMillis() {\n * @return zero always\n */\n public int compareTo(DurationField durationField) {\n- if (durationField.isSupported()) {\n- return 1;\n- }\n return 0;\n }\n \n",
"failingTests": [
{
"className": " org.joda.time.TestPartial_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testConstructorEx7_TypeArray_intArray"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 9,
"linesMod": 1,
"linesRem": 3,
"methods": 2,
"sizeInLines": 13,
"spreadAllLines": 4,
"spreadCodeOnly": 4
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condBranIfElseAdd",
"condBranRem",
"condExpExpand",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"retRem"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"condBlockRem",
"expLogicExpand"
],
"repairTools": [],
"revisionId": "9a62b06be5d0df8e833ff8583398cca386608cac"
},
{
"bugId": 4,
"changedFiles": {
"org/joda/time/Partial.java": {
"changes": [
[
464
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/Partial.java\n+++ b/src/main/java/org/joda/time/Partial.java\n@@ -461,7 +461,7 @@ public Partial with(DateTimeFieldType fieldType, int value) {\n System.arraycopy(iValues, i, newValues, i + 1, newValues.length - i - 1);\n // use public constructor to ensure full validation\n // this isn't overly efficient, but is safe\n- Partial newPartial = new Partial(iChronology, newTypes, newValues);\n+ Partial newPartial = new Partial(newTypes, newValues, iChronology);\n iChronology.validate(newPartial, newValues);\n return newPartial;\n }\n",
"failingTests": [
{
"className": " org.joda.time.TestPartial_Basics",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testWith3"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "The swap was made on a constructor call.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"mcParSwap",
"mcParValChange",
"objInstMod",
"varReplVar"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtElixir",
"rtGPFL",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "3ba9ba799b3261b7332a467a88be142c83b298fd"
},
{
"bugId": 37,
"changedFiles": {
"org/mockito/internal/stubbing/answers/AnswersValidator.java": {
"inserts": [
[
27,
28
],
[
-1
]
]
}
},
"diff": "--- a/src/org/mockito/internal/stubbing/answers/AnswersValidator.java\n+++ b/src/org/mockito/internal/stubbing/answers/AnswersValidator.java\n@@ -25,8 +25,16 @@ public void validate(Answer<?> answer, Invocation invocation) {\n validateDoNothing((DoesNothing) answer, invocation);\r\n }\r\n \r\n+ if (answer instanceof CallsRealMethods) {\r\n+ validateMockingConcreteClass((CallsRealMethods) answer, invocation);\r\n+ }\r\n }\r\n \r\n+ private void validateMockingConcreteClass(CallsRealMethods answer, Invocation invocation) {\r\n+ if (invocation.getMethod().getDeclaringClass().isInterface()) {\r\n+ reporter.cannotCallRealMethodOnInterface();\r\n+ }\r\n+ }\r\n \r\n private void validateDoNothing(DoesNothing answer, Invocation invocation) {\r\n if (!invocation.isVoid()) {\r\n",
"failingTests": [
{
"className": " org.mockito.internal.stubbing.answers.AnswersValidatorTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldFailWhenCallingRealMethodOnIterface"
},
{
"className": " org.mockitousage.spies.SpyingOnInterfacesTest",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "shouldFailFastWhenCallingRealMethodOnInterface"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 8,
"linesMod": 0,
"linesRem": 0,
"methods": 2,
"sizeInLines": 8,
"spreadAllLines": 2,
"spreadCodeOnly": 1
},
"observations": "",
"program": "mockito",
"project": "Mockito",
"repairActions": [
"condBranIfAdd",
"mcAdd",
"mdAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "c0222c2dbfbd2b053961a46e4c2a3973aec55a75"
},
{
"bugId": 2,
"changedFiles": {
"org/joda/time/Partial.java": {
"changes": [
[
218
]
],
"inserts": [
[
449
]
]
},
"org/joda/time/field/UnsupportedDurationField.java": {
"inserts": [
[
227
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/Partial.java\n+++ b/src/main/java/org/joda/time/Partial.java\n@@ -215,7 +215,7 @@ public Partial(DateTimeFieldType[] types, int[] values, Chronology chronology) {\n DurationField loopUnitField = loopType.getDurationType().getField(iChronology);\n if (i > 0) {\n int compare = lastUnitField.compareTo(loopUnitField);\n- if (compare < 0 || (compare != 0 && loopUnitField.isSupported() == false)) {\n+ if (compare < 0) {\n throw new IllegalArgumentException(\"Types array must be in order largest-smallest: \" +\n types[i - 1].getName() + \" < \" + loopType.getName());\n } else if (compare == 0) {\n@@ -446,6 +446,9 @@ public Partial with(DateTimeFieldType fieldType, int value) {\n if (compare > 0) {\n break;\n } else if (compare == 0) {\n+ if (fieldType.getRangeDurationType() == null) {\n+ break;\n+ }\n DurationField rangeField = fieldType.getRangeDurationType().getField(iChronology);\n DurationField loopRangeField = loopType.getRangeDurationType().getField(iChronology);\n if (rangeField.compareTo(loopRangeField) > 0) {\n--- a/src/main/java/org/joda/time/field/UnsupportedDurationField.java\n+++ b/src/main/java/org/joda/time/field/UnsupportedDurationField.java\n@@ -224,6 +224,9 @@ public long getUnitMillis() {\n * @return zero always\n */\n public int compareTo(DurationField durationField) {\n+ if (durationField.isSupported()) {\n+ return 1;\n+ }\n return 0;\n }\n \n",
"failingTests": [
{
"className": " org.joda.time.TestPartial_Basics",
"error": "java.lang.IllegalArgumentException",
"message": "Types array must not contain duplicate: era and year",
"methodName": "testWith_baseAndArgHaveNoRange"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 2,
"linesAdd": 6,
"linesMod": 1,
"linesRem": 0,
"methods": 2,
"sizeInLines": 7,
"spreadAllLines": 230,
"spreadCodeOnly": 108
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condBranIfAdd",
"condExpRed",
"mcAdd",
"mcRem",
"retBranchAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"expLogicReduce",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "8612f9e5b88c1bea933ef9ab1e431f5db3006b48"
},
{
"bugId": 8,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"changes": [
[
279
],
[
286
]
],
"inserts": [
[
282
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -276,14 +276,17 @@ public static DateTimeZone forOffsetHoursMinutes(int hoursOffset, int minutesOff\n if (hoursOffset < -23 || hoursOffset > 23) {\n throw new IllegalArgumentException(\"Hours out of range: \" + hoursOffset);\n }\n- if (minutesOffset < 0 || minutesOffset > 59) {\n+ if (minutesOffset < -59 || minutesOffset > 59) {\n throw new IllegalArgumentException(\"Minutes out of range: \" + minutesOffset);\n }\n+ if (hoursOffset > 0 && minutesOffset < 0) {\n+ throw new IllegalArgumentException(\"Positive hours must not have negative minutes: \" + minutesOffset);\n+ }\n int offset = 0;\n try {\n int hoursInMinutes = hoursOffset * 60;\n if (hoursInMinutes < 0) {\n- minutesOffset = hoursInMinutes - minutesOffset;\n+ minutesOffset = hoursInMinutes - Math.abs(minutesOffset);\n } else {\n minutesOffset = hoursInMinutes + minutesOffset;\n }\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZone",
"error": "java.lang.IllegalArgumentException",
"message": "Minutes out of range: -15",
"methodName": "testForOffsetHoursMinutes_int_int"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 6,
"spreadCodeOnly": 6
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignExpChange",
"condBranIfAdd",
"condExpMod",
"exThrowsAdd",
"mcAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"constChange",
"expArithMod",
"expLogicMod",
"wrapsMethod"
],
"repairTools": [],
"revisionId": "362ed1787724cda3ded37de2b0aa0f13adf0a66e"
},
{
"bugId": 6,
"changedFiles": {
"org/joda/time/chrono/GJChronology.java": {
"inserts": [
[
196
],
[
979
],
[
1001
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/chrono/GJChronology.java\n+++ b/src/main/java/org/joda/time/chrono/GJChronology.java\n@@ -193,6 +193,10 @@ public static synchronized GJChronology getInstance(\n cutoverInstant = DEFAULT_CUTOVER;\n } else {\n cutoverInstant = gregorianCutover.toInstant();\n+ LocalDate cutoverDate = new LocalDate(cutoverInstant.getMillis(), GregorianChronology.getInstance(zone));\n+ if (cutoverDate.getYear() <= 0) {\n+ throw new IllegalArgumentException(\"Cutover too early. Must be on or after 0001-01-01.\");\n+ }\n }\n \n GJChronology chrono;\n@@ -976,6 +980,17 @@ public long add(long instant, int value) {\n if (instant < iCutover) {\n // Only adjust if gap fully crossed.\n if (instant + iGapDuration < iCutover) {\n+ if (iConvertByWeekyear) {\n+ int wyear = iGregorianChronology.weekyear().get(instant);\n+ if (wyear <= 0) {\n+ instant = iGregorianChronology.weekyear().add(instant, -1);\n+ }\n+ } else {\n+ int year = iGregorianChronology.year().get(instant);\n+ if (year <= 0) {\n+ instant = iGregorianChronology.year().add(instant, -1);\n+ }\n+ }\n instant = gregorianToJulian(instant);\n }\n }\n@@ -998,6 +1013,17 @@ public long add(long instant, long value) {\n if (instant < iCutover) {\n // Only adjust if gap fully crossed.\n if (instant + iGapDuration < iCutover) {\n+ if (iConvertByWeekyear) {\n+ int wyear = iGregorianChronology.weekyear().get(instant);\n+ if (wyear <= 0) {\n+ instant = iGregorianChronology.weekyear().add(instant, -1);\n+ }\n+ } else {\n+ int year = iGregorianChronology.year().get(instant);\n+ if (year <= 0) {\n+ instant = iGregorianChronology.year().add(instant, -1);\n+ }\n+ }\n instant = gregorianToJulian(instant);\n }\n }\n",
"failingTests": [
{
"className": " org.joda.time.chrono.TestGJDate",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "test_cutoverPreZero"
},
{
"className": " org.joda.time.chrono.TestGJDate",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-06-30> but was:<-0001-06-28>",
"methodName": "test_plusWeekyears_positiveToNegative_crossCutover"
},
{
"className": " org.joda.time.chrono.TestGJDate",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 0 for year is not supported",
"methodName": "test_plusYears_positiveToZero_crossCutover"
},
{
"className": " org.joda.time.chrono.TestGJDate",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-06-30> but was:<-0001-06-30>",
"methodName": "test_plusYears_positiveToNegative_crossCutover"
},
{
"className": " org.joda.time.chrono.TestGJDate",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 0 for year is not supported",
"methodName": "test_plusWeekyears_positiveToZero_crossCutover"
}
],
"metrics": {
"chunks": 3,
"classes": 2,
"files": 1,
"linesAdd": 26,
"linesMod": 0,
"linesRem": 0,
"methods": 3,
"sizeInLines": 26,
"spreadAllLines": 805,
"spreadCodeOnly": 556
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"exThrowsAdd",
"mcAdd",
"objInstAdd",
"varAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"condBlockOthersAdd",
"copyPaste",
"missComp"
],
"repairTools": [],
"revisionId": "28aeba952e838fb12c9b934ce6ef65658e45d7b2"
},
{
"bugId": 7,
"changedFiles": {
"org/joda/time/format/DateTimeFormatter.java": {
"deletes": [
[
710
]
],
"inserts": [
[
708,
709
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/DateTimeFormatter.java\n+++ b/src/main/java/org/joda/time/format/DateTimeFormatter.java\n@@ -705,9 +705,9 @@ public int parseInto(ReadWritableInstant instant, String text, int position) {\n \n long instantMillis = instant.getMillis();\n Chronology chrono = instant.getChronology();\n+ int defaultYear = DateTimeUtils.getChronology(chrono).year().get(instantMillis);\n long instantLocal = instantMillis + chrono.getZone().getOffset(instantMillis);\n chrono = selectChronology(chrono);\n- int defaultYear = chrono.year().get(instantLocal);\n \n DateTimeParserBucket bucket = new DateTimeParserBucket(\n instantLocal, chrono, iLocale, iPivotYear, defaultYear);\n",
"failingTests": [
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Cannot parse \"2 29\": Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testParseInto_monthDay_feb29_newYork_startOfYear"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Cannot parse \"2 29\": Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testParseInto_monthDay_feb29_tokyo_endOfYear"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 0,
"linesRem": 1,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 2,
"spreadCodeOnly": 2
},
"observations": "Move assignment of var and changed assignment expression.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignExpChange",
"mcParValChange",
"mcRem",
"mcRepl"
],
"repairPatterns": [
"initFix",
"notClassified",
"wrongComp"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtNopol"
],
"revisionId": "1adb1e69863dcd1ff282692bf1452c422528eeb9"
},
{
"bugId": 9,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"changes": [
[
263
],
[
265
],
[
267
]
],
"inserts": [
[
258
],
[
283
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -255,16 +255,19 @@ public static DateTimeZone forOffsetHoursMinutes(int hoursOffset, int minutesOff\n if (hoursOffset == 0 && minutesOffset == 0) {\n return DateTimeZone.UTC;\n }\n+ if (hoursOffset < -23 || hoursOffset > 23) {\n+ throw new IllegalArgumentException(\"Hours out of range: \" + hoursOffset);\n+ }\n if (minutesOffset < 0 || minutesOffset > 59) {\n throw new IllegalArgumentException(\"Minutes out of range: \" + minutesOffset);\n }\n int offset = 0;\n try {\n- int hoursInMinutes = FieldUtils.safeMultiply(hoursOffset, 60);\n+ int hoursInMinutes = hoursOffset * 60;\n if (hoursInMinutes < 0) {\n- minutesOffset = FieldUtils.safeAdd(hoursInMinutes, -minutesOffset);\n+ minutesOffset = hoursInMinutes - minutesOffset;\n } else {\n- minutesOffset = FieldUtils.safeAdd(hoursInMinutes, minutesOffset);\n+ minutesOffset = hoursInMinutes + minutesOffset;\n }\n offset = FieldUtils.safeMultiply(minutesOffset, DateTimeConstants.MILLIS_PER_MINUTE);\n } catch (ArithmeticException ex) {\n@@ -280,6 +283,9 @@ public static DateTimeZone forOffsetHoursMinutes(int hoursOffset, int minutesOff\n * @return the DateTimeZone object for the offset\n */\n public static DateTimeZone forOffsetMillis(int millisOffset) {\n+ if (millisOffset < -MAX_MILLIS || millisOffset > MAX_MILLIS) {\n+ throw new IllegalArgumentException(\"Millis out of range: \" + millisOffset);\n+ }\n String id = printOffset(millisOffset);\n return fixedOffsetZone(id, millisOffset);\n }\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZone",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testForOffsetHoursMinutes_int_int"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 3,
"linesRem": 0,
"methods": 2,
"sizeInLines": 9,
"spreadAllLines": 22,
"spreadCodeOnly": 15
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignExpChange",
"condBranIfAdd",
"exThrowsAdd",
"mcRem",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"expArithMod"
],
"repairTools": [
"rtCardumen"
],
"revisionId": "96f586cb8dac7eee62e9be519a3eab125c47bb23"
},
{
"bugId": 10,
"changedFiles": {
"org/joda/time/base/BaseSingleFieldPeriod.java": {
"changes": [
[
104
]
],
"inserts": [
[
-1
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/base/BaseSingleFieldPeriod.java\n+++ b/src/main/java/org/joda/time/base/BaseSingleFieldPeriod.java\n@@ -49,6 +49,7 @@\n /** Serialization version. */\n private static final long serialVersionUID = 9386874258972L;\n /** The start of 1972. */\n+ private static final long START_1972 = 2L * 365L * 86400L * 1000L;\n \n /** The period in the units of this period. */\n private volatile int iPeriod;\n@@ -101,7 +102,7 @@ protected static int between(ReadablePartial start, ReadablePartial end, Readabl\n throw new IllegalArgumentException(\"ReadablePartial objects must be contiguous\");\n }\n Chronology chrono = DateTimeUtils.getChronology(start.getChronology()).withUTC();\n- int[] values = chrono.get(zeroInstance, chrono.set(start, 0L), chrono.set(end, 0L));\n+ int[] values = chrono.get(zeroInstance, chrono.set(start, START_1972), chrono.set(end, START_1972));\n return values[0];\n }\n \n",
"failingTests": [
{
"className": " org.joda.time.TestDays",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testFactory_daysBetween_RPartial_MonthDay"
},
{
"className": " org.joda.time.TestMonths",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testFactory_monthsBetween_RPartial_MonthDay"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 52,
"spreadCodeOnly": 25
},
"observations": "Adds new variable and its initialization.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"mcParValChange",
"varAdd"
],
"repairPatterns": [
"constChange",
"initFix"
],
"repairTools": [],
"revisionId": "3a413d7844c22dc6ddd50bf5d0d55ff3589e47ac"
},
{
"bugId": 12,
"changedFiles": {
"org/joda/time/LocalDate.java": {
"changes": [
[
212
]
],
"inserts": [
[
210,
211
],
[
243,
244
]
]
},
"org/joda/time/LocalDateTime.java": {
"changes": [
[
201
]
],
"inserts": [
[
199,
200
],
[
236,
237
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/LocalDate.java\n+++ b/src/main/java/org/joda/time/LocalDate.java\n@@ -207,9 +207,10 @@ public static LocalDate fromCalendarFields(Calendar calendar) {\n if (calendar == null) {\n throw new IllegalArgumentException(\"The calendar must not be null\");\n }\n+ int era = calendar.get(Calendar.ERA);\n int yearOfEra = calendar.get(Calendar.YEAR);\n return new LocalDate(\n- yearOfEra,\n+ (era == GregorianCalendar.AD ? yearOfEra : 1 - yearOfEra),\n calendar.get(Calendar.MONTH) + 1,\n calendar.get(Calendar.DAY_OF_MONTH)\n );\n@@ -240,7 +241,12 @@ public static LocalDate fromDateFields(Date date) {\n if (date == null) {\n throw new IllegalArgumentException(\"The date must not be null\");\n }\n+ if (date.getTime() < 0) {\n // handle years in era BC\n+ GregorianCalendar cal = new GregorianCalendar();\n+ cal.setTime(date);\n+ return fromCalendarFields(cal);\n+ }\n return new LocalDate(\n date.getYear() + 1900,\n date.getMonth() + 1,\n--- a/src/main/java/org/joda/time/LocalDateTime.java\n+++ b/src/main/java/org/joda/time/LocalDateTime.java\n@@ -196,9 +196,10 @@ public static LocalDateTime fromCalendarFields(Calendar calendar) {\n if (calendar == null) {\n throw new IllegalArgumentException(\"The calendar must not be null\");\n }\n+ int era = calendar.get(Calendar.ERA);\n int yearOfEra = calendar.get(Calendar.YEAR);\n return new LocalDateTime(\n- yearOfEra,\n+ (era == GregorianCalendar.AD ? yearOfEra : 1 - yearOfEra),\n calendar.get(Calendar.MONTH) + 1,\n calendar.get(Calendar.DAY_OF_MONTH),\n calendar.get(Calendar.HOUR_OF_DAY),\n@@ -233,7 +234,12 @@ public static LocalDateTime fromDateFields(Date date) {\n if (date == null) {\n throw new IllegalArgumentException(\"The date must not be null\");\n }\n+ if (date.getTime() < 0) {\n // handle years in era BC\n+ GregorianCalendar cal = new GregorianCalendar();\n+ cal.setTime(date);\n+ return fromCalendarFields(cal);\n+ }\n return new LocalDateTime(\n date.getYear() + 1900,\n date.getMonth() + 1,\n",
"failingTests": [
{
"className": " org.joda.time.TestLocalDateTime_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0000-02-03T04:05:06.007> but was:<0001-02-03T04:05:06.007>",
"methodName": "testFactory_fromDateFields_beforeYearZero1"
},
{
"className": " org.joda.time.TestLocalDateTime_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-02-03T04:05:06.007> but was:<0003-02-03T04:05:06.007>",
"methodName": "testFactory_fromDateFields_beforeYearZero3"
},
{
"className": " org.joda.time.TestLocalDateTime_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0000-02-03T04:05:06.007> but was:<0001-02-03T04:05:06.007>",
"methodName": "testFactory_fromCalendarFields_beforeYearZero1"
},
{
"className": " org.joda.time.TestLocalDateTime_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-02-03T04:05:06.007> but was:<0003-02-03T04:05:06.007>",
"methodName": "testFactory_fromCalendarFields_beforeYearZero3"
},
{
"className": " org.joda.time.TestLocalDate_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0000-02-03> but was:<0001-02-03>",
"methodName": "testFactory_fromDateFields_beforeYearZero1"
},
{
"className": " org.joda.time.TestLocalDate_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-02-03> but was:<0003-02-03>",
"methodName": "testFactory_fromDateFields_beforeYearZero3"
},
{
"className": " org.joda.time.TestLocalDate_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0000-02-03> but was:<0001-02-03>",
"methodName": "testFactory_fromCalendarFields_beforeYearZero1"
},
{
"className": " org.joda.time.TestLocalDate_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<-0002-02-03> but was:<0003-02-03>",
"methodName": "testFactory_fromCalendarFields_beforeYearZero3"
}
],
"metrics": {
"chunks": 8,
"classes": 2,
"files": 2,
"linesAdd": 12,
"linesMod": 2,
"linesRem": 0,
"methods": 2,
"sizeInLines": 14,
"spreadAllLines": 70,
"spreadCodeOnly": 26
},
"observations": "The if/else added is implicit in the passed parameter format (exp?x:y) for the LocalDate constructor call.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"mcParValChange",
"objInstAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"copyPaste",
"missComp",
"wrapsIfElse"
],
"repairTools": [
"rtGPFL",
"rtNopol"
],
"revisionId": "77a6b3a44da7ae4af62e88b4b27eeefec2d768c2"
},
{
"bugId": 11,
"changedFiles": {
"org/joda/time/tz/ZoneInfoCompiler.java": {
"changes": [
[
68
],
[
69
],
[
70
],
[
71
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java\n+++ b/src/main/java/org/joda/time/tz/ZoneInfoCompiler.java\n@@ -65,10 +65,11 @@\n \n static Chronology cLenientISO;\n \n- static ThreadLocal<Boolean> cVerbose = new ThreadLocal<Boolean>();\n- static {\n- cVerbose.set(Boolean.FALSE);\n- }\n+ static ThreadLocal<Boolean> cVerbose = new ThreadLocal<Boolean>() {\n+ protected Boolean initialValue() {\n+ return Boolean.FALSE;\n+ }\n+ };\n \n /**\n * Gets a flag indicating that verbose logging is required.\n",
"failingTests": [
{
"className": " org.joda.time.tz.TestCompiler",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testDateTimeZoneBuilder"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 1,
"linesMod": 4,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changed a static initialization for a method inline implementation.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"mcRem",
"mdAdd",
"mdOverride",
"objInstMod",
"retBranchAdd"
],
"repairPatterns": [
"initFix",
"notClassified"
],
"repairTools": [
"rtCardumen",
"rtDynaMoth",
"rtElixir",
"rtGenProg",
"rtKali",
"rtNopol"
],
"revisionId": "57eb4cbb9044771cd46a9eee0c62016618930226"
},
{
"bugId": 14,
"changedFiles": {
"org/joda/time/chrono/BasicMonthOfYearDateTimeField.java": {
"inserts": [
[
209,
210
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/chrono/BasicMonthOfYearDateTimeField.java\n+++ b/src/main/java/org/joda/time/chrono/BasicMonthOfYearDateTimeField.java\n@@ -206,7 +206,12 @@ public long add(long instant, long months) {\n if (valueToAdd == 0) {\n return values;\n }\n+ if (partial.size() > 0 && partial.getFieldType(0).equals(DateTimeFieldType.monthOfYear()) && fieldIndex == 0) {\n // month is largest field and being added to, such as month-day\n+ int curMonth0 = partial.getValue(0) - 1;\n+ int newMonth = ((curMonth0 + (valueToAdd % 12) + 12) % 12) + 1;\n+ return set(partial, 0, values, newMonth);\n+ }\n if (DateTimeUtils.isContiguous(partial)) {\n long instant = 0L;\n for (int i = 0, isize = partial.size(); i < isize; i++) {\n",
"failingTests": [
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testPlusMonths_int_negativeFromLeap"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testMinusDays_int_negativeFromLeap"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testPlusMonths_int_fromLeap"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<--02-29> but was:<--02-28>",
"methodName": "testPlusMonths_int_negativeEndOfMonthAdjust"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<--02-29> but was:<--02-28>",
"methodName": "testMinusMonths_int_endOfMonthAdjust"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testMinusMonths_int_negativeFromLeap"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testMinusMonths_int_fromLeap"
},
{
"className": " org.joda.time.TestMonthDay_Basics",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testPlusDays_int_fromLeap"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockRetAdd",
"missComp"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "2ea856328ed5710537778d755a5ff52a6831a2ee"
},
{
"bugId": 13,
"changedFiles": {
"org/joda/time/format/PeriodFormatterBuilder.java": {
"changes": [
[
1098
]
],
"inserts": [
[
1133,
1134
],
[
1139
],
[
1142
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java\n+++ b/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java\n@@ -1095,7 +1095,7 @@ public int calculatePrintedLength(ReadablePeriod period, Locale locale) {\n if (iFieldType >= SECONDS_MILLIS) {\n // valueLong contains the seconds and millis fields\n // the minimum output is 0.000, which is 4 or 5 digits with a negative\n- sum = Math.max(sum, 4);\n+ sum = (valueLong < 0 ? Math.max(sum, 5) : Math.max(sum, 4));\n // plus one for the decimal point\n sum++;\n if (iFieldType == SECONDS_OPTIONAL_MILLIS &&\n@@ -1130,6 +1130,7 @@ public void printTo(StringBuffer buf, ReadablePeriod period, Locale locale) {\n if (iPrefix != null) {\n iPrefix.printTo(buf, value);\n }\n+ int bufLen = buf.length();\n int minDigits = iMinPrintedDigits;\n if (minDigits <= 1) {\n FormatUtils.appendUnpaddedInteger(buf, value);\n@@ -1139,6 +1140,9 @@ public void printTo(StringBuffer buf, ReadablePeriod period, Locale locale) {\n if (iFieldType >= SECONDS_MILLIS) {\n int dp = (int) (Math.abs(valueLong) % DateTimeConstants.MILLIS_PER_SECOND);\n if (iFieldType == SECONDS_MILLIS || dp > 0) {\n+ if (valueLong < 0 && valueLong > -DateTimeConstants.MILLIS_PER_SECOND) {\n+ buf.insert(bufLen, '-');\n+ }\n buf.append('.');\n FormatUtils.appendPaddedInteger(buf, dp, 3);\n }\n",
"failingTests": [
{
"className": " org.joda.time.format.TestISOPeriodFormat",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<PT[-]0.008S> but was:<PT[]0.008S>",
"methodName": "testFormatStandard_negative"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 4,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 43,
"spreadCodeOnly": 37
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"expArithMod",
"wrapsIfElse"
],
"repairTools": [],
"revisionId": "5d08a1cdbfa6ce86a0baf637493c464e91e91968"
},
{
"bugId": 15,
"changedFiles": {
"org/joda/time/field/FieldUtils.java": {
"inserts": [
[
138
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/field/FieldUtils.java\n+++ b/src/main/java/org/joda/time/field/FieldUtils.java\n@@ -135,6 +135,9 @@ public static int safeMultiply(int val1, int val2) {\n public static long safeMultiply(long val1, int val2) {\n switch (val2) {\n case -1:\n+ if (val1 == Long.MIN_VALUE) {\n+ throw new ArithmeticException(\"Multiplication overflows a long: \" + val1 + \" * \" + val2);\n+ }\n return -val1;\n case 0:\n return 0L;\n",
"failingTests": [
{
"className": " org.joda.time.field.TestFieldUtils",
"error": "junit.framework.AssertionFailedError",
"message": "",
"methodName": "testSafeMultiplyLongInt"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 3,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 3,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condBranIfAdd",
"exThrowsAdd",
"objInstAdd"
],
"repairPatterns": [
"condBlockExcAdd"
],
"repairTools": [
"rtAcs",
"rtElixir"
],
"revisionId": "0cefc4c212e92e5dccdfa658785c419483317558"
},
{
"bugId": 17,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"changes": [
[
1167
],
[
1168
],
[
1169
],
[
1174
],
[
1175
]
],
"inserts": [
[
1176,
1177,
1178,
1179,
1180
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -1164,19 +1164,32 @@ public long adjustOffset(long instant, boolean earlierOrLater) {\n // a bit messy, but will work in all non-pathological cases\n \n // evaluate 3 hours before and after to work out if anything is happening\n- long instantBefore = convertUTCToLocal(instant - 3 * DateTimeConstants.MILLIS_PER_HOUR);\n- long instantAfter = convertUTCToLocal(instant + 3 * DateTimeConstants.MILLIS_PER_HOUR);\n- if (instantBefore == instantAfter) {\n+ long instantBefore = instant - 3 * DateTimeConstants.MILLIS_PER_HOUR;\n+ long instantAfter = instant + 3 * DateTimeConstants.MILLIS_PER_HOUR;\n+ long offsetBefore = getOffset(instantBefore);\n+ long offsetAfter = getOffset(instantAfter);\n+ if (offsetBefore <= offsetAfter) {\n return instant; // not an overlap (less than is a gap, equal is normal case)\n }\n \n // work out range of instants that have duplicate local times\n- long local = convertUTCToLocal(instant);\n- return convertLocalToUTC(local, false, earlierOrLater ? instantAfter : instantBefore);\n+ long diff = offsetBefore - offsetAfter;\n+ long transition = nextTransition(instantBefore);\n+ long overlapStart = transition - diff;\n+ long overlapEnd = transition + diff;\n+ if (instant < overlapStart || instant >= overlapEnd) {\n+ return instant; // not an overlap\n+ }\n \n // calculate result\n+ long afterStart = instant - overlapStart;\n+ if (afterStart >= diff) {\n // currently in later offset\n+ return earlierOrLater ? instant : instant - diff;\n+ } else {\n // currently in earlier offset\n+ return earlierOrLater ? instant + diff : instant;\n+ }\n }\n // System.out.println(new DateTime(transitionStart, DateTimeZone.UTC) + \" \" + new DateTime(transitionStart, this));\n \n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2012-02-25T23:15:00.000-03:00> but was:<2012-02-25T23:15:00.000-02:00>",
"methodName": "testBug3476684_adjustOffset"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 13,
"linesMod": 5,
"linesRem": 0,
"methods": 1,
"sizeInLines": 18,
"spreadAllLines": 8,
"spreadCodeOnly": 2
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"assignExpChange",
"condBranIfAdd",
"condBranIfElseAdd",
"condExpMod",
"mcAdd",
"mcRem",
"retBranchAdd",
"retRem",
"varAdd",
"varRem"
],
"repairPatterns": [
"condBlockRetAdd",
"expArithMod",
"expLogicMod",
"missComp",
"unwrapMethod",
"wrongComp"
],
"repairTools": [
"rtCardumen"
],
"revisionId": "a8913f5ad5dfde59263c981c9e9eb28e43fd2e00"
},
{
"bugId": 16,
"changedFiles": {
"org/joda/time/format/DateTimeFormatter.java": {
"changes": [
[
709
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/DateTimeFormatter.java\n+++ b/src/main/java/org/joda/time/format/DateTimeFormatter.java\n@@ -706,7 +706,7 @@ public int parseInto(ReadWritableInstant instant, String text, int position) {\n chrono = selectChronology(chrono);\n \n DateTimeParserBucket bucket = new DateTimeParserBucket(\n- instantLocal, chrono, iLocale, iPivotYear, iDefaultYear);\n+ instantLocal, chrono, iLocale, iPivotYear, chrono.year().get(instantLocal));\n int newPos = parser.parseInto(bucket, text, position);\n instant.setMillis(bucket.computeMillis(false, text));\n if (iOffsetParsed && bucket.getOffsetInteger() != null) {\n",
"failingTests": [
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-05-01T12:20:30.000+09:00> but was:<2000-05-01T12:20:30.000+09:00>",
"methodName": "testParseInto_monthOnly_baseStartYear"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-01-01T12:20:30.000+09:00> but was:<2000-01-01T12:20:30.000+09:00>",
"methodName": "testParseInto_monthOnly_parseStartYear"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-05-31T12:20:30.000+09:00> but was:<2000-05-31T12:20:30.000+09:00>",
"methodName": "testParseInto_monthOnly_baseEndYear"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-05-09T12:20:30.000+01:00> but was:<2000-05-09T12:20:30.000+01:00>",
"methodName": "testParseInto_monthOnly"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-02-29T12:20:30.000Z> but was:<2012-02-29T12:20:30.000Z>",
"methodName": "testParseInto_monthDay_withDefaultYear_feb29"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-02-29T12:20:30.000Z> but was:<2000-02-29T12:20:30.000Z>",
"methodName": "testParseInto_monthDay_feb29"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2004-12-31T12:20:30.000+09:00> but was:<2000-12-31T12:20:30.000+09:00>",
"methodName": "testParseInto_monthOnly_parseEndYear"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "Changes parameter for constructor call.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"mcAdd",
"mcParValChange",
"varReplMc"
],
"repairPatterns": [
"initFix",
"singleLine",
"wrongVarRef"
],
"repairTools": [
"rtDynaMoth",
"rtNopol"
],
"revisionId": "706513d59425e7a9dc6bdb972f25b03b02e48558"
},
{
"bugId": 20,
"changedFiles": {
"org/joda/time/format/DateTimeFormatterBuilder.java": {
"deletes": [
[
2544
],
[
2545
]
],
"inserts": [
[
2541,
2542
],
[
2546
],
[
2548
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java\n+++ b/src/main/java/org/joda/time/format/DateTimeFormatterBuilder.java\n@@ -2539,12 +2539,18 @@ public int estimateParsedLength() {\n \n public int parseInto(DateTimeParserBucket bucket, String text, int position) {\n String str = text.substring(position);\n+ String best = null;\n for (String id : ALL_IDS) {\n if (str.startsWith(id)) {\n- bucket.setZone(DateTimeZone.forID(id));\n- return position + id.length();\n+ \tif (best == null || id.length() > best.length()) {\n+ \t\tbest = id;\n+ \t}\n }\n }\n+ if (best != null) {\n+ bucket.setZone(DateTimeZone.forID(best));\n+ return position + best.length();\n+ }\n return ~position;\n }\n }\n",
"failingTests": [
{
"className": " org.joda.time.format.TestDateTimeFormatterBuilder",
"error": "java.lang.IllegalArgumentException",
"message": "Invalid format: \"2007-03-04 12:30 America/Dawson_Creek\" is malformed at \"_Creek\"",
"methodName": "test_printParseZoneDawsonCreek"
}
],
"metrics": {
"chunks": 3,
"classes": 1,
"files": 1,
"linesAdd": 6,
"linesMod": 2,
"linesRem": 0,
"methods": 1,
"sizeInLines": 8,
"spreadAllLines": 4,
"spreadCodeOnly": 4
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"mcAdd",
"mcRem",
"retBranchAdd",
"retRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missNullCheckN",
"missNullCheckP"
],
"repairTools": [],
"revisionId": "a92450e88df85d6b7a0fa53517da46286c24f53f"
},
{
"bugId": 18,
"changedFiles": {
"org/joda/time/chrono/GJChronology.java": {
"inserts": [
[
364
],
[
367
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/chrono/GJChronology.java\n+++ b/src/main/java/org/joda/time/chrono/GJChronology.java\n@@ -361,9 +361,21 @@ public long getDateTimeMillis(int year, int monthOfYear, int dayOfMonth,\n \n // Assume date is Gregorian.\n long instant;\n+ try {\n instant = iGregorianChronology.getDateTimeMillis\n (year, monthOfYear, dayOfMonth,\n hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);\n+ } catch (IllegalFieldValueException ex) {\n+ if (monthOfYear != 2 || dayOfMonth != 29) {\n+ throw ex;\n+ }\n+ instant = iGregorianChronology.getDateTimeMillis\n+ (year, monthOfYear, 28,\n+ hourOfDay, minuteOfHour, secondOfMinute, millisOfSecond);\n+ if (instant >= iCutoverMillis) {\n+ throw ex;\n+ }\n+ }\n if (instant < iCutoverMillis) {\n // Maybe it's Julian.\n instant = iJulianChronology.getDateTimeMillis\n",
"failingTests": [
{
"className": " org.joda.time.chrono.TestGJChronology",
"error": "org.joda.time.IllegalFieldValueException",
"message": "Value 29 for dayOfMonth must be in the range [1,28]",
"methodName": "testLeapYearRulesConstruction"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 12,
"spreadAllLines": 3,
"spreadCodeOnly": 3
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"exThrowsAdd",
"exTryCatchAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockExcAdd",
"missComp",
"wrapsTryCatch"
],
"repairTools": [
"rtCardumen",
"rtNopol"
],
"revisionId": "b609d7d66d180f2eb537b27f5d605d0596e096ce"
},
{
"bugId": 19,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"changes": [
[
900
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -897,7 +897,7 @@ public int getOffsetFromLocal(long instantLocal) {\n return offsetLocal;\n }\n }\n- } else if (offsetLocal > 0) {\n+ } else if (offsetLocal >= 0) {\n long prev = previousTransition(instantAdjusted);\n if (prev < instantAdjusted) {\n int offsetPrev = getOffset(prev);\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...1-10-30T01:15:00.000[+01:00]> but was:<...1-10-30T01:15:00.000[Z]>",
"methodName": "testDateTimeCreation_london"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 1,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condExpMod"
],
"repairPatterns": [
"expLogicMod",
"singleLine"
],
"repairTools": [
"rtHDRepair",
"rtNopol"
],
"revisionId": "82c5e4f9550e4df36e07b66f35f7c3e9d7eb5eba"
},
{
"bugId": 21,
"changedFiles": {
"org/joda/time/tz/DefaultNameProvider.java": {
"changes": [
[
72
],
[
76
],
[
77
],
[
79
]
],
"deletes": [
[
81
],
[
82
],
[
83
]
],
"inserts": [
[
65,
66
],
[
71,
72
],
[
71,
72
],
[
84
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/tz/DefaultNameProvider.java\n+++ b/src/main/java/org/joda/time/tz/DefaultNameProvider.java\n@@ -63,22 +63,32 @@ public String getName(Locale locale, String id, String nameKey) {\n if (byNameKeyCache == null) {\n byIdCache.put(id, byNameKeyCache = createCache());\n \n+ String[][] zoneStringsEn = DateTimeUtils.getDateFormatSymbols(Locale.ENGLISH).getZoneStrings();\n+ String[] setEn = null;\n+ for (String[] strings : zoneStringsEn) {\n+ if (strings != null && strings.length == 5 && id.equals(strings[0])) {\n+ setEn = strings;\n+ break;\n+ }\n+ }\n String[][] zoneStringsLoc = DateTimeUtils.getDateFormatSymbols(locale).getZoneStrings();\n String[] setLoc = null;\n for (String[] strings : zoneStringsLoc) {\n if (strings != null && strings.length == 5 && id.equals(strings[0])) {\n setLoc = strings;\n+ break;\n+ }\n+ }\n \n- byNameKeyCache.put(setLoc[2], new String[] {setLoc[2], setLoc[1]});\n+ if (setEn != null && setLoc != null) {\n+ byNameKeyCache.put(setEn[2], new String[] {setLoc[2], setLoc[1]});\n // need to handle case where summer and winter have the same\n // abbreviation, such as EST in Australia [1716305]\n // we handle this by appending \"-Summer\", cf ZoneInfoCompiler\n- if (setLoc[2].equals(setLoc[4])) {\n- byNameKeyCache.put(setLoc[4] + \"-Summer\", new String[] {setLoc[4], setLoc[3]});\n+ if (setEn[2].equals(setEn[4])) {\n+ byNameKeyCache.put(setEn[4] + \"-Summer\", new String[] {setLoc[4], setLoc[3]});\n } else {\n- byNameKeyCache.put(setLoc[4], new String[] {setLoc[4], setLoc[3]});\n- }\n- break;\n+ byNameKeyCache.put(setEn[4], new String[] {setLoc[4], setLoc[3]});\n }\n }\n }\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZone",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[Mitteleuropäische Zeit]> but was:<[+01:00]>",
"methodName": "testGetName_berlin"
},
{
"className": " org.joda.time.TestDateTimeZone",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[MEZ]> but was:<[+01:00]>",
"methodName": "testGetShortName_berlin"
}
],
"metrics": {
"chunks": 5,
"classes": 1,
"files": 1,
"linesAdd": 12,
"linesMod": 4,
"linesRem": 2,
"methods": 1,
"sizeInLines": 18,
"spreadAllLines": 10,
"spreadCodeOnly": 6
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condExpMod",
"loopAdd",
"mcAdd",
"mcParValChange",
"mcRem",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"missNullCheckN",
"wrapsIf",
"wrongComp",
"wrongVarRef"
],
"repairTools": [],
"revisionId": "0973b46039c4db0be3a969d36c220dee1e1fb4da"
},
{
"bugId": 22,
"changedFiles": {
"org/joda/time/base/BasePeriod.java": {
"changes": [
[
222
]
],
"inserts": [
[
223,
224
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/base/BasePeriod.java\n+++ b/src/main/java/org/joda/time/base/BasePeriod.java\n@@ -219,8 +219,13 @@ protected BasePeriod(ReadableDuration duration, ReadableInstant endInstant, Peri\n * @param duration the duration, in milliseconds\n */\n protected BasePeriod(long duration) {\n- this(duration, null, null);\n+ super();\n // bug [3264409]\n+ iType = PeriodType.time();\n+ int[] values = ISOChronology.getInstanceUTC().get(this, duration);\n+ iType = PeriodType.standard();\n+ iValues = new int[8];\n+ System.arraycopy(values, 0, iValues, 4, 4);\n }\n \n /**\n",
"failingTests": [
{
"className": " org.joda.time.TestDuration_Basics",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<64>",
"methodName": "testToPeriod_fixedZone"
},
{
"className": " org.joda.time.TestPeriod_Constructors",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<0> but was:<64>",
"methodName": "testConstructor_long_fixedZone"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 1,
"linesRem": 0,
"methods": 1,
"sizeInLines": 6,
"spreadAllLines": 1,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"mcAdd",
"mcRepl",
"varAdd"
],
"repairPatterns": [
"initFix",
"notClassified",
"wrongComp"
],
"repairTools": [],
"revisionId": "57c8aaf94b95323c295dcfec5f40f181846164e7"
},
{
"bugId": 23,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"changes": [
[
572
],
[
575
],
[
577
],
[
578
],
[
581
],
[
583
],
[
586
],
[
588
]
],
"inserts": [
[
563,
564,
565,
566,
567,
568,
569,
570,
571,
572,
573,
574,
575,
576,
577,
578,
579,
580,
581,
582,
583,
584,
585,
586,
587,
588,
589,
590,
591,
592,
593,
594,
595
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -561,6 +561,11 @@ private static synchronized String getConvertedId(String id) {\n // Backwards compatibility with TimeZone.\n map = new HashMap<String, String>();\n map.put(\"GMT\", \"UTC\");\n+ map.put(\"WET\", \"WET\");\n+ map.put(\"CET\", \"CET\");\n+ map.put(\"MET\", \"CET\");\n+ map.put(\"ECT\", \"CET\");\n+ map.put(\"EET\", \"EET\");\n map.put(\"MIT\", \"Pacific/Apia\");\n map.put(\"HST\", \"Pacific/Honolulu\"); // JDK 1.1 compatible\n map.put(\"AST\", \"America/Anchorage\");\n@@ -569,23 +574,19 @@ private static synchronized String getConvertedId(String id) {\n map.put(\"PNT\", \"America/Phoenix\");\n map.put(\"CST\", \"America/Chicago\");\n map.put(\"EST\", \"America/New_York\"); // JDK 1.1 compatible\n- map.put(\"IET\", \"America/Indianapolis\");\n+ map.put(\"IET\", \"America/Indiana/Indianapolis\");\n map.put(\"PRT\", \"America/Puerto_Rico\");\n map.put(\"CNT\", \"America/St_Johns\");\n- map.put(\"AGT\", \"America/Buenos_Aires\");\n+ map.put(\"AGT\", \"America/Argentina/Buenos_Aires\");\n map.put(\"BET\", \"America/Sao_Paulo\");\n- map.put(\"WET\", \"Europe/London\");\n- map.put(\"ECT\", \"Europe/Paris\");\n map.put(\"ART\", \"Africa/Cairo\");\n map.put(\"CAT\", \"Africa/Harare\");\n- map.put(\"EET\", \"Europe/Bucharest\");\n map.put(\"EAT\", \"Africa/Addis_Ababa\");\n- map.put(\"MET\", \"Asia/Tehran\");\n map.put(\"NET\", \"Asia/Yerevan\");\n map.put(\"PLT\", \"Asia/Karachi\");\n- map.put(\"IST\", \"Asia/Calcutta\");\n+ map.put(\"IST\", \"Asia/Kolkata\");\n map.put(\"BST\", \"Asia/Dhaka\");\n- map.put(\"VST\", \"Asia/Saigon\");\n+ map.put(\"VST\", \"Asia/Ho_Chi_Minh\");\n map.put(\"CTT\", \"Asia/Shanghai\");\n map.put(\"JST\", \"Asia/Tokyo\");\n map.put(\"ACT\", \"Australia/Darwin\");\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZone",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<[WET]> but was:<[Europe/London]>",
"methodName": "testForID_String_old"
}
],
"metrics": {
"chunks": 8,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 4,
"linesRem": 4,
"methods": 1,
"sizeInLines": 13,
"spreadAllLines": 17,
"spreadCodeOnly": 17
},
"observations": "Changes entries in a key-value map.",
"program": "joda-time",
"project": "Time",
"repairActions": [
"mcAdd",
"mcParValChange",
"mcRem"
],
"repairPatterns": [
"constChange",
"initFix"
],
"repairTools": [],
"revisionId": "14dedcbc04682c1b1b6c5ebe91bc930b79eeb572"
},
{
"bugId": 25,
"changedFiles": {
"org/joda/time/DateTimeZone.java": {
"inserts": [
[
900
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/DateTimeZone.java\n+++ b/src/main/java/org/joda/time/DateTimeZone.java\n@@ -896,6 +896,15 @@ public int getOffsetFromLocal(long instantLocal) {\n return offsetLocal;\n }\n }\n+ } else if (offsetLocal > 0) {\n+ long prev = previousTransition(instantAdjusted);\n+ if (prev < instantAdjusted) {\n+ int offsetPrev = getOffset(prev);\n+ int diff = offsetPrev - offsetLocal;\n+ if (instantAdjusted - prev <= diff) {\n+ return offsetPrev;\n+ }\n+ }\n }\n return offsetAdjusted;\n }\n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-28T02:30:00.000+0[4]:00> but was:<...10-28T02:30:00.000+0[3]:00>",
"methodName": "test_DateTime_constructor_Moscow_Autumn"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "2007-10-28T02:00:00.000+03:00 expected:<...10-28T02:00:00.000+0[4]:00> but was:<...10-28T02:00:00.000+0[3]:00>",
"methodName": "test_getOffsetFromLocal_Moscow_Autumn_overlap_mins"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "2007-10-28T02:00:00.000+03:00 expected:<...10-28T02:00:00.000+0[4]:00> but was:<...10-28T02:00:00.000+0[3]:00>",
"methodName": "test_getOffsetFromLocal_Moscow_Autumn"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 9,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 9,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"condBranIfElseAdd",
"mcAdd",
"retBranchAdd",
"varAdd"
],
"repairPatterns": [
"condBlockOthersAdd",
"condBlockRetAdd",
"missComp"
],
"repairTools": [],
"revisionId": "552be4b677ec30a34d04d234395ba1a8c7beaacf"
},
{
"bugId": 26,
"changedFiles": {
"org/joda/time/chrono/ZonedChronology.java": {
"changes": [
[
436
],
[
448
],
[
460
],
[
467
],
[
481
],
[
528
],
[
540
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/chrono/ZonedChronology.java\n+++ b/src/main/java/org/joda/time/chrono/ZonedChronology.java\n@@ -433,7 +433,7 @@ public long add(long instant, int value) {\n } else {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.add(localInstant, value);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n }\n \n@@ -445,7 +445,7 @@ public long add(long instant, long value) {\n } else {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.add(localInstant, value);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n }\n \n@@ -457,14 +457,14 @@ public long addWrapField(long instant, int value) {\n } else {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.addWrapField(localInstant, value);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n }\n \n public long set(long instant, int value) {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.set(localInstant, value);\n- long result = iZone.convertLocalToUTC(localInstant, false);\n+ long result = iZone.convertLocalToUTC(localInstant, false, instant);\n if (get(result) != value) {\n throw new IllegalFieldValueException(iField.getType(), new Integer(value),\n \"Illegal instant due to time zone offset transition: \" +\n@@ -478,7 +478,7 @@ public long set(long instant, String text, Locale locale) {\n // cannot verify that new value stuck because set may be lenient\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.set(localInstant, text, locale);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n \n public int getDifference(long minuendInstant, long subtrahendInstant) {\n@@ -525,7 +525,7 @@ public long roundFloor(long instant) {\n } else {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.roundFloor(localInstant);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n }\n \n@@ -537,7 +537,7 @@ public long roundCeiling(long instant) {\n } else {\n long localInstant = iZone.convertUTCToLocal(instant);\n localInstant = iField.roundCeiling(localInstant);\n- return iZone.convertLocalToUTC(localInstant, false);\n+ return iZone.convertLocalToUTC(localInstant, false, instant);\n }\n }\n \n",
"failingTests": [
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-31T02:30:00.123+0[2]:00> but was:<...10-31T02:30:00.123+0[1]:00>",
"methodName": "testWithSecondOfMinuteInDstChange"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-31T02:00:10.123+0[2]:00> but was:<...10-31T02:00:10.123+0[1]:00>",
"methodName": "testWithMinuteOfHourInDstChange"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-31T01:30:00.000+0[1:0]0> but was:<...10-31T01:30:00.000+0[0:3]0>",
"methodName": "testWithMinuteOfHourInDstChange_mockZone"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2008-11-02T01:00:00.000-06:00> but was:<2008-11-02T01:00:00.000-05:00>",
"methodName": "testBug2182444_usCentral"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-31T02:30:10.000+0[2]:00> but was:<...10-31T02:30:10.000+0[1]:00>",
"methodName": "testWithMillisOfSecondInDstChange_Paris_summer"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...10-31T02:30:10.123+0[2]:00> but was:<...10-31T02:30:10.123+0[1]:00>",
"methodName": "testWithHourOfDayInDstChange"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.ComparisonFailure",
"message": "expected:<...11-04T01:30:00.000-0[5]:00> but was:<...11-04T01:30:00.000-0[4]:00>",
"methodName": "testWithMillisOfSecondInDstChange_NewYork_winter"
},
{
"className": " org.joda.time.TestDateTimeZoneCutover",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2008-04-06T02:00:00.000+11:00> but was:<2008-04-06T02:00:00.000+10:00>",
"methodName": "testBug2182444_ausNSW"
}
],
"metrics": {
"chunks": 7,
"classes": 1,
"files": 1,
"linesAdd": 0,
"linesMod": 7,
"linesRem": 0,
"methods": 7,
"sizeInLines": 7,
"spreadAllLines": 98,
"spreadCodeOnly": 84
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"mcParAdd",
"mcRepl",
"retExpChange"
],
"repairPatterns": [
"copyPaste",
"wrongMethodRef"
],
"repairTools": [],
"revisionId": "c7a581e55fc988bd90fa4bb1b0acece5181b7c5f"
},
{
"bugId": 24,
"changedFiles": {
"org/joda/time/format/DateTimeParserBucket.java": {
"inserts": [
[
355
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/DateTimeParserBucket.java\n+++ b/src/main/java/org/joda/time/format/DateTimeParserBucket.java\n@@ -352,6 +352,11 @@ public long computeMillis(boolean resetFields, String text) {\n for (int i = 0; i < count; i++) {\n millis = savedFields[i].set(millis, resetFields);\n }\n+ if (resetFields) {\n+ for (int i = 0; i < count; i++) {\n+ millis = savedFields[i].set(millis, i == (count - 1));\n+ }\n+ }\n } catch (IllegalFieldValueException e) {\n if (text != null) {\n e.prependMessage(\"Cannot parse \\\"\" + text + '\"');\n",
"failingTests": [
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2010-01-04> but was:<2008-12-29>",
"methodName": "testParseLocalDate_weekyear_month_week_2010"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2011-01-03> but was:<2010-01-04>",
"methodName": "testParseLocalDate_weekyear_month_week_2011"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2012-01-02> but was:<2011-01-03>",
"methodName": "testParseLocalDate_weekyear_month_week_2012"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2010-01-04> but was:<2008-12-29>",
"methodName": "testParseLocalDate_year_month_week_2010"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2011-01-03> but was:<2010-01-04>",
"methodName": "testParseLocalDate_year_month_week_2011"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2012-01-02> but was:<2011-01-03>",
"methodName": "testParseLocalDate_year_month_week_2012"
},
{
"className": " org.joda.time.format.TestDateTimeFormatter",
"error": "junit.framework.AssertionFailedError",
"message": "expected:<2016-01-04> but was:<2014-12-29>",
"methodName": "testParseLocalDate_year_month_week_2016"
}
],
"metrics": {
"chunks": 1,
"classes": 1,
"files": 1,
"linesAdd": 5,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 5,
"spreadAllLines": 0,
"spreadCodeOnly": 0
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"assignAdd",
"condBranIfAdd",
"loopAdd",
"mcAdd"
],
"repairPatterns": [
"condBlockOthersAdd"
],
"repairTools": [],
"revisionId": "d50efdf75a8daeced88d79b168f68d189fb87e13"
},
{
"bugId": 27,
"changedFiles": {
"org/joda/time/format/PeriodFormatterBuilder.java": {
"inserts": [
[
801
],
[
804
]
]
}
},
"diff": "--- a/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java\n+++ b/src/main/java/org/joda/time/format/PeriodFormatterBuilder.java\n@@ -798,9 +798,11 @@ private static PeriodFormatter toFormatter(List<Object> elementPairs, boolean no\n int size = elementPairs.size();\n if (size >= 2 && elementPairs.get(0) instanceof Separator) {\n Separator sep = (Separator) elementPairs.get(0);\n+ if (sep.iAfterParser == null && sep.iAfterPrinter == null) {\n PeriodFormatter f = toFormatter(elementPairs.subList(2, size), notPrinter, notParser);\n sep = sep.finish(f.getPrinter(), f.getParser());\n return new PeriodFormatter(sep, sep);\n+ }\n }\n Object[] comp = createComposite(elementPairs);\n if (notPrinter) {\n",
"failingTests": [
{
"className": " org.joda.time.format.TestPeriodFormatterBuilder",
"error": "java.lang.IllegalArgumentException",
"message": "Invalid format: \"PT1003199059S\" is malformed at \"1003199059S\"",
"methodName": "testBug2495455"
}
],
"metrics": {
"chunks": 2,
"classes": 1,
"files": 1,
"linesAdd": 2,
"linesMod": 0,
"linesRem": 0,
"methods": 1,
"sizeInLines": 2,
"spreadAllLines": 3,
"spreadCodeOnly": 3
},
"observations": "",
"program": "joda-time",
"project": "Time",
"repairActions": [
"condBranIfAdd"
],
"repairPatterns": [
"missNullCheckP",
"wrapsIf"
],
"repairTools": [],
"revisionId": "e0559c503f65641b9546c37e7c84c866caf37e66"
}
]