Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 101718 Details for
Bug 232814
[compiler] Testcase with "value1 - (-value2)" not working when value2 is final
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
232814.txt (text/plain), 8.08 KB, created by
Philipe Mulet
on 2008-05-23 07:43:26 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2008-05-23 07:43:26 EDT
Size:
8.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v >retrieving revision 1.102 >diff -u -r1.102 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 5 May 2008 18:58:31 -0000 1.102 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 23 May 2008 11:42:42 -0000 >@@ -497,8 +497,6 @@ > break; > case Binding.LOCAL : // assigning to a local variable (cannot assign to outer local) > LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; >- Constant assignConstant; >- int increment; > // using incr bytecode if possible > switch (localBinding.type.id) { > case T_JavaLangString : >@@ -509,19 +507,23 @@ > codeStream.store(localBinding, false); > return; > case T_int : >+ Constant assignConstant; > if (((assignConstant = expression.constant) != Constant.NotAConstant) >- && (assignConstant.typeID() != TypeIds.T_float) // only for integral types >- && (assignConstant.typeID() != TypeIds.T_double) >- && ((increment = assignConstant.intValue()) == (short) increment)) { // 16 bits value >+ && (assignConstant.typeID() != TypeIds.T_float) // only for integral types >+ && (assignConstant.typeID() != TypeIds.T_double)) { > switch (operator) { > case PLUS : >+ int increment = assignConstant.intValue(); >+ if (increment != (short) increment) break; // not representable as a 16-bits value > codeStream.iinc(localBinding.resolvedPosition, increment); > if (valueRequired) { > codeStream.load(localBinding); > } > return; > case MINUS : >- codeStream.iinc(localBinding.resolvedPosition, -increment); >+ increment = -assignConstant.intValue(); >+ if (increment != (short) increment) break; // not representable as a 16-bits value >+ codeStream.iinc(localBinding.resolvedPosition, increment); > if (valueRequired) { > codeStream.load(localBinding); > } >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java,v >retrieving revision 1.50 >diff -u -r1.50 CodeSnippetSingleNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 16 Apr 2008 11:55:01 -0000 1.50 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 23 May 2008 11:42:42 -0000 >@@ -23,17 +23,6 @@ > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.*; >-import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >-import org.eclipse.jdt.internal.compiler.lookup.ClassScope; >-import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; >-import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; >-import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ProblemBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; >-import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; >-import org.eclipse.jdt.internal.compiler.lookup.Scope; >-import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >-import org.eclipse.jdt.internal.compiler.lookup.VariableBinding; > > /** > * A single name reference inside a code snippet can denote a field of a remote >@@ -335,8 +324,6 @@ > break; > case Binding.LOCAL : // assigning to a local variable (cannot assign to outer local) > LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; >- Constant assignConstant; >- int increment; > // using incr bytecode if possible > switch (localBinding.type.id) { > case T_JavaLangString : >@@ -347,19 +334,23 @@ > codeStream.store(localBinding, false); > return; > case T_int : >+ Constant assignConstant; > if (((assignConstant = expression.constant) != Constant.NotAConstant) >- && (assignConstant.typeID() != T_float) // only for integral types >- && (assignConstant.typeID() != T_double) >- && ((increment = assignConstant.intValue()) == (short) increment)) { // 16 bits value >+ && (assignConstant.typeID() != TypeIds.T_float) // only for integral types >+ && (assignConstant.typeID() != TypeIds.T_double)) { > switch (operator) { > case PLUS : >+ int increment = assignConstant.intValue(); >+ if (increment != (short) increment) break; // not representable as a 16-bits value > codeStream.iinc(localBinding.resolvedPosition, increment); > if (valueRequired) { > codeStream.load(localBinding); > } > return; > case MINUS : >- codeStream.iinc(localBinding.resolvedPosition, -increment); >+ increment = -assignConstant.intValue(); >+ if (increment != (short) increment) break; // not representable as a 16-bits value >+ codeStream.iinc(localBinding.resolvedPosition, increment); > if (valueRequired) { > codeStream.load(localBinding); > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NumericTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NumericTest.java,v >retrieving revision 1.7 >diff -u -r1.7 NumericTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NumericTest.java 29 Mar 2006 19:12:47 -0000 1.7 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NumericTest.java 23 May 2008 11:42:43 -0000 >@@ -89,6 +89,55 @@ > "The literal 9223372036854775808L of type long is out of range \n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=232814 >+public void test005() { >+ this.runConformTest(new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " int result;\n" + >+ " if (130 != (result = testShort1())) System.out.println(\"failed-testShort1():\" + result);\n" + >+ " if (130 != (result = testShort2())) System.out.println(\"failed-testShort2():\" + result);\n" + >+ " if (130 != (result = testInt1())) System.out.println(\"failed-testInt1():\" + result);\n" + >+ " if (130 != (result = testInt2())) System.out.println(\"failed-testInt2():\" + result);\n" + >+ " if (30 != (result = testByte1())) System.out.println(\"failed-testByte1():\" + result);\n" + >+ " if (30 != (result = testByte2())) System.out.println(\"failed-testByte2():\" + result);\n" + >+ " System.out.println(\"done\");\n" + >+ " }\n" + >+ " static int testShort1() {\n" + >+ " short min = Short.MIN_VALUE;\n" + >+ " int num = -32638;\n" + >+ " return num = num - min;\n" + >+ " }\n" + >+ " static int testShort2() {\n" + >+ " final short min = Short.MIN_VALUE;\n" + >+ " int num = -32638;\n" + >+ " return num = num - min;\n" + >+ " }\n" + >+ " static int testInt1() {\n" + >+ " short min = Short.MIN_VALUE;\n" + >+ " int num = -32638;\n" + >+ " return num = num - min;\n" + >+ " }\n" + >+ " static int testInt2() {\n" + >+ " final short min = Short.MIN_VALUE;\n" + >+ " int num = -32638;\n" + >+ " return num = num - min;\n" + >+ " } \n" + >+ " static int testByte1() {\n" + >+ " byte min = Byte.MIN_VALUE;\n" + >+ " int num = -98;\n" + >+ " return num = num - min;\n" + >+ " }\n" + >+ " static int testByte2() {\n" + >+ " final byte min = Byte.MIN_VALUE;\n" + >+ " int num = -98;\n" + >+ " return num = num - min;\n" + >+ " } \n" + >+ "}\n", >+ }, >+ "done"); >+} > public static Class testClass() { > return NumericTest.class; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 232814
:
100988
|
101716
| 101718 |
101733