Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Thomann2005-11-28 15:30:35 +0000
committerOlivier Thomann2005-11-28 15:30:35 +0000
commitb3b04d93715bc587f1cae467546b8cfd9c80b4db (patch)
tree3d7f2141bc76bc07d84a717658d5eb0c9676eccd
parent2cf0f83ec58484cd6314830d17988f2ea9adef20 (diff)
downloadeclipse.jdt.core-b3b04d93715bc587f1cae467546b8cfd9c80b4db.tar.gz
eclipse.jdt.core-b3b04d93715bc587f1cae467546b8cfd9c80b4db.tar.xz
eclipse.jdt.core-b3b04d93715bc587f1cae467546b8cfd9c80b4db.zip
3.1 maintenance - Fix for 117495
-rw-r--r--org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java27
-rw-r--r--org.eclipse.jdt.core/buildnotes_jdt-core.html4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java38
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java5
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java6
11 files changed, 57 insertions, 53 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
index d110bc57df..6e62d1dd08 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ConstantTest.java
@@ -636,6 +636,33 @@ public void test013() {
"The literal 23092395825689123986L of type long is out of range \n" +
"----------\n");
}
+//http://bugs.eclipse.org/bugs/show_bug.cgi?id=117495
+public void test014() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " int x = 2;\n" +
+ " System.out.println(\"n: \"+(x > 1 ? 2 : 1.0));\n" +
+ " }\n" +
+ "}",
+ },
+ "n: 2.0");
+}
+//http://bugs.eclipse.org/bugs/show_bug.cgi?id=117495
+public void test015() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " public static void main(String[] args) {\n" +
+ " System.out.println(\"n: \"+(true ? 2 : 1.0));\n" +
+ " }\n" +
+ "}",
+ },
+ "n: 2.0");
+}
public static Class testClass() {
return ConstantTest.class;
}
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index f30e689b96..0fef28a7ef 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -50,7 +50,9 @@ What's new in this drop</h2>
</ul>
<h3>Problem Reports Fixed</h3>
-<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117120">117120</a>
+<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117495">117495</a>
+Compiler: ternary ops return wrong type when condition is boolean literal
+<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117120">117120</a>
[compiler] VerifyError: Expecting to find integer on stack
<br><a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=117861">117861</a>
[1.5][compiler] invalid handling of static import
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
index 4eb624b9b4..84c3f88234 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/BooleanConstant.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.jdt.internal.compiler.impl;
-import org.eclipse.jdt.internal.compiler.util.Util;
-
public class BooleanConstant extends Constant {
boolean value;
@@ -26,9 +24,7 @@ public class BooleanConstant extends Constant {
public String stringValue() {
//spec 15.17.11
- String s = Util.toBoolean(value).toString();
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
index d73ea9a28e..446be1abe0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ByteConstant.java
@@ -38,10 +38,7 @@ public short shortValue() {
}
public String stringValue() {
//spec 15.17.11
-
- String s = new Integer(value).toString() ;
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
index ddf344a4ea..f5834a2b65 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/CharConstant.java
@@ -40,10 +40,7 @@ public class CharConstant extends Constant {
}
public String stringValue() {
//spec 15.17.11
-
- String s = new Character(value).toString() ;
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
index fe5bb5a0b3..1ec4f22d0b 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/Constant.java
@@ -1240,28 +1240,28 @@ public abstract class Constant implements TypeIds, OperatorIds {
break;
case T_JavaLangString :
switch (rightId){
- case T_char : return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_float: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_double: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_short: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_int: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_long: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_char : return Constant.fromValue(left.stringValue() + String.valueOf(right.charValue()));
+ case T_float: return Constant.fromValue(left.stringValue() + String.valueOf(right.floatValue()));
+ case T_double: return Constant.fromValue(left.stringValue() + String.valueOf(right.doubleValue()));
+ case T_byte: return Constant.fromValue(left.stringValue() + String.valueOf(right.byteValue()));
+ case T_short: return Constant.fromValue(left.stringValue() + String.valueOf(right.shortValue()));
+ case T_int: return Constant.fromValue(left.stringValue() + String.valueOf(right.intValue()));
+ case T_long: return Constant.fromValue(left.stringValue() + String.valueOf(right.longValue()));
case T_JavaLangString: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_boolean: return Constant.fromValue(left.stringValue() + right.stringValue());
+ case T_boolean: return Constant.fromValue(left.stringValue() + right.booleanValue());
}
break;
- case T_null :
- switch (rightId){
- case T_char : return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_float: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_double: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_short: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_int: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_long: return Constant.fromValue(left.stringValue() + right.stringValue());
- case T_JavaLangString: return Constant.fromValue(left.stringValue() + right.stringValue());
- }
+// case T_null :
+// switch (rightId){
+// case T_char : return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_float: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_double: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_byte: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_short: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_int: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_long: return Constant.fromValue(left.stringValue() + right.stringValue());
+// case T_JavaLangString: return Constant.fromValue(left.stringValue() + right.stringValue());
+// }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
index d6ff773771..ce72b721c6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/DoubleConstant.java
@@ -47,9 +47,7 @@ public class DoubleConstant extends Constant {
}
public String stringValue() {
- String s = Double.toString(value);
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
index 53a0c51039..efa77d3f0f 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/FloatConstant.java
@@ -47,9 +47,7 @@ public class FloatConstant extends Constant {
}
public String stringValue() {
- String s = Float.toString(value);
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
index 149ea6d9f4..69cde65f92 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/IntConstant.java
@@ -47,10 +47,7 @@ public class IntConstant extends Constant {
}
public String stringValue() {
- //spec 15.17.11
- String s = new Integer(value).toString();
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString() {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
index 20f22c71d2..c0434119a4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/LongConstant.java
@@ -37,11 +37,7 @@ public short shortValue() {
return (short) value;
}
public String stringValue() {
- //spec 15.17.11
-
- String s = new Long(value).toString() ;
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString(){
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
index df8eb6e572..d75495e81c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/impl/ShortConstant.java
@@ -37,11 +37,7 @@ public short shortValue() {
return value;
}
public String stringValue() {
- //spec 15.17.11
-
- String s = new Integer(value).toString() ;
- if (s == null) return "null"; //$NON-NLS-1$
- return s;
+ return String.valueOf(this.value);
}
public String toString(){

Back to the top