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 60927 Details for
Bug 177194
[1.5][compiler] preserveAllLocals option has undesirable side-effect when invoking generic method
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
177194.txt (text/plain), 49.02 KB, created by
Philipe Mulet
on 2007-03-15 09:03:18 EDT
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-03-15 09:03:18 EDT
Size:
49.02 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java,v >retrieving revision 1.51 >diff -u -r1.51 CodeSnippetMessageSend.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 29 Mar 2006 02:57:52 -0000 1.51 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java 15 Mar 2007 12:42:32 -0000 >@@ -29,6 +29,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.TypeConstants; >+import org.eclipse.jdt.internal.compiler.lookup.TypeIds; > import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; > > public class CodeSnippetMessageSend extends MessageSend implements ProblemReasons, EvaluationConstants { >@@ -70,6 +71,9 @@ > } > } else { > this.receiver.generateCode(currentScope, codeStream, !isStatic); >+ if (this.receiverGenericCast != null) >+ codeStream.checkcast(this.receiverGenericCast); >+ codeStream.recordPositionsFrom(pc, this.sourceStart); > } > // generate arguments > generateArguments(binding, arguments, currentScope, codeStream); >@@ -97,6 +101,9 @@ > currentScope.problemReporter().needImplementation(); > } else { > this.receiver.generateCode(currentScope, codeStream, !isStatic); >+ if (this.receiverGenericCast != null) >+ codeStream.checkcast(this.receiverGenericCast); >+ codeStream.recordPositionsFrom(pc, this.sourceStart); > } > if (isStatic) { > // we need an object on the stack which is ignored for the method invocation >@@ -139,25 +146,26 @@ > codeStream.checkcast(this.codegenBinding.returnType); > } > } >- // operation on the returned value >+ // required cast must occur even if no value is required >+ if (this.valueCast != null) codeStream.checkcast(this.valueCast); > if (valueRequired){ > // implicit conversion if necessary >- if (this.valueCast != null) >- codeStream.checkcast(this.valueCast); > codeStream.generateImplicitConversion(implicitConversion); > } else { >- // pop return value if any >- switch(binding.returnType.id){ >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : this.codegenBinding.returnType.id) { > case T_long : > case T_double : > codeStream.pop2(); > break; > case T_void : > break; >- default: >+ default : > codeStream.pop(); > } >- } >+ } > codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector > } > public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { >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.95 >diff -u -r1.95 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 6 Mar 2007 02:38:48 -0000 1.95 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 15 Mar 2007 12:42:32 -0000 >@@ -134,7 +134,7 @@ > > switch (bits & RestrictiveFlagMASK) { > case Binding.FIELD : // reading a field >- if (valueRequired) { >+ if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { > manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/); > } > FieldBinding fieldBinding = (FieldBinding) binding; >@@ -334,6 +334,8 @@ > if (valueRequired) { > codeStream.generateConstant(constant, implicitConversion); > } >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } else { > switch (bits & RestrictiveFlagMASK) { > case Binding.FIELD : // reading a field >@@ -344,15 +346,18 @@ > if (valueRequired) { > codeStream.generateConstant(fieldConstant, implicitConversion); > } >- break; >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } > if (fieldBinding.isStatic()) { >- if (!valueRequired) { >+ if (!valueRequired > // if no valueRequired, still need possible side-effects of <clinit> invocation, if field belongs to different class >- if (((FieldBinding)binding).original().declaringClass == this.actualReceiverType.erasure() >- && ((implicitConversion & TypeIds.UNBOXING) == 0)) { >- break; >- } >+ && ((FieldBinding)binding).original().declaringClass == this.actualReceiverType.erasure() >+ && ((implicitConversion & TypeIds.UNBOXING) == 0) >+ && this.genericCast == null) { >+ // if no valueRequired, optimize out entire gen >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } > // managing private access > if ((syntheticAccessors == null) || (syntheticAccessors[READ] == null)) { >@@ -360,27 +365,13 @@ > } else { > codeStream.invokestatic(syntheticAccessors[READ]); > } >- if (valueRequired) { >- if (this.genericCast != null) codeStream.checkcast(this.genericCast); >- codeStream.generateImplicitConversion(implicitConversion); >- } else { >- if ((implicitConversion & TypeIds.UNBOXING) != 0) { >- codeStream.generateImplicitConversion(implicitConversion); >- } >- // could occur if !valueRequired but static field belongs to different class >- switch (fieldBinding.type.id) { >- case T_long : >- case T_double : >- codeStream.pop2(); >- break; >- default : >- codeStream.pop(); >- } >- } > } else { >- if (!valueRequired && ((implicitConversion & TypeIds.UNBOXING) == 0)) { >+ if (!valueRequired >+ && (implicitConversion & TypeIds.UNBOXING) == 0 >+ && this.genericCast == null) { > // if no valueRequired, optimize out entire gen >- break; >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } > // managing enclosing instance access > if ((bits & DepthMASK) != 0) { >@@ -396,44 +387,47 @@ > } else { > codeStream.invokestatic(syntheticAccessors[READ]); > } >- // managing generic cast >- if (this.genericCast != null) codeStream.checkcast(this.genericCast); >- codeStream.generateImplicitConversion(implicitConversion); > } > break; > case Binding.LOCAL : // reading a local > LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; >- if (valueRequired) { >- // outer local? >- if ((bits & DepthMASK) != 0) { >- // outer local can be reached either through a synthetic arg or a synthetic field >- VariableBinding[] path = currentScope.getEmulationPath(localBinding); >- codeStream.generateOuterAccess(path, this, localBinding, currentScope); >- } else { >- // regular local variable read >- codeStream.load(localBinding); >- } >- codeStream.generateImplicitConversion(implicitConversion); >- } else if ((implicitConversion & TypeIds.UNBOXING) != 0) { >- >- // outer local? >- if ((bits & DepthMASK) != 0) { >- // outer local can be reached either through a synthetic arg or a synthetic field >- VariableBinding[] path = currentScope.getEmulationPath(localBinding); >- codeStream.generateOuterAccess(path, this, localBinding, currentScope); >- } else { >- // regular local variable read >- codeStream.load(localBinding); >- } >- codeStream.generateImplicitConversion(implicitConversion); >- if ((localBinding.type == TypeBinding.LONG) || (localBinding.type == TypeBinding.DOUBLE)) { >- codeStream.pop2(); >- } else { >- codeStream.pop(); >- } >+ if (!valueRequired && (implicitConversion & TypeIds.UNBOXING) == 0) { >+ // if no valueRequired, optimize out entire gen >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } >+ // outer local? >+ if ((bits & DepthMASK) != 0) { >+ // outer local can be reached either through a synthetic arg or a synthetic field >+ VariableBinding[] path = currentScope.getEmulationPath(localBinding); >+ codeStream.generateOuterAccess(path, this, localBinding, currentScope); >+ } else { >+ // regular local variable read >+ codeStream.load(localBinding); >+ } >+ break; >+ default: // type >+ codeStream.recordPositionsFrom(pc, this.sourceStart); >+ return; > } > } >+ // required cast must occur even if no value is required >+ if (this.genericCast != null) codeStream.checkcast(this.genericCast); >+ if (valueRequired) { >+ codeStream.generateImplicitConversion(implicitConversion); >+ } else { >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : this.resolvedType.id) { >+ case T_long : >+ case T_double : >+ codeStream.pop2(); >+ break; >+ default : >+ codeStream.pop(); >+ } >+ } > codeStream.recordPositionsFrom(pc, this.sourceStart); > } > /* >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v >retrieving revision 1.108 >diff -u -r1.108 FieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 21 Feb 2007 18:08:14 -0000 1.108 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 15 Mar 2007 12:42:31 -0000 >@@ -188,8 +188,10 @@ > codeStream.recordPositionsFrom(pc, this.sourceStart); > return; > } >- if (valueRequired || (!isThisReceiver && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) >- || ((implicitConversion & TypeIds.UNBOXING) != 0)) { >+ if (valueRequired >+ || (!isThisReceiver && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) >+ || ((implicitConversion & TypeIds.UNBOXING) != 0) >+ || (this.genericCast != null)) { > receiver.generateCode(currentScope, codeStream, !isStatic); > pc = codeStream.position; > if (this.codegenBinding.declaringClass == null) { // array length >@@ -210,15 +212,15 @@ > } else { > codeStream.invokestatic(syntheticAccessors[READ]); > } >+ // required cast must occur even if no value is required >+ if (this.genericCast != null) codeStream.checkcast(this.genericCast); > if (valueRequired) { >- if (this.genericCast != null) codeStream.checkcast(this.genericCast); > codeStream.generateImplicitConversion(implicitConversion); > } else { >- if ((implicitConversion & TypeIds.UNBOXING) != 0) { >- codeStream.generateImplicitConversion(implicitConversion); >- } >- // could occur if !valueRequired but compliance >= 1.4 >- switch (this.codegenBinding.type.id) { >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : this.codegenBinding.type.id) { > case T_long : > case T_double : > codeStream.pop2(); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v >retrieving revision 1.120 >diff -u -r1.120 MessageSend.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 6 Mar 2007 02:38:48 -0000 1.120 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 15 Mar 2007 12:42:31 -0000 >@@ -144,22 +144,23 @@ > } else { > codeStream.invokestatic(syntheticAccessor); > } >- // operation on the returned value >+ // required cast must occur even if no value is required >+ if (this.valueCast != null) codeStream.checkcast(this.valueCast); > if (valueRequired){ > // implicit conversion if necessary >- if (this.valueCast != null) >- codeStream.checkcast(this.valueCast); > codeStream.generateImplicitConversion(implicitConversion); > } else { >- // pop return value if any >- switch(binding.returnType.id){ >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : this.codegenBinding.returnType.id) { > case T_long : > case T_double : > codeStream.pop2(); > break; > case T_void : > break; >- default: >+ default : > codeStream.pop(); > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java,v >retrieving revision 1.46 >diff -u -r1.46 ArrayReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java 6 Mar 2007 02:38:48 -0000 1.46 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ArrayReference.java 15 Mar 2007 12:42:31 -0000 >@@ -95,14 +95,16 @@ > if (valueRequired) { > codeStream.generateImplicitConversion(implicitConversion); > } else { >- if ((implicitConversion & TypeIds.UNBOXING) != 0) { >- codeStream.generateImplicitConversion(implicitConversion); >- } >- if (this.resolvedType == TypeBinding.LONG >- || this.resolvedType == TypeBinding.DOUBLE) { >- codeStream.pop2(); >- } else { >- codeStream.pop(); >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : this.resolvedType.id) { >+ case T_long : >+ case T_double : >+ codeStream.pop2(); >+ break; >+ default : >+ codeStream.pop(); > } > } > codeStream.recordPositionsFrom(pc, this.sourceStart); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v >retrieving revision 1.113 >diff -u -r1.113 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 21 Feb 2007 18:08:13 -0000 1.113 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 15 Mar 2007 12:42:31 -0000 >@@ -220,7 +220,7 @@ > boolean complyTo14 = currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4; > switch (bits & RestrictiveFlagMASK) { > case Binding.FIELD : // reading a field >- if (needValue) { >+ if (needValue || complyTo14) { > manageSyntheticAccessIfNecessary(currentScope, (FieldBinding) binding, this.actualReceiverType, 0, flowInfo); > } > if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding >@@ -266,7 +266,7 @@ > if (otherBindings != null) { > for (int i = 0; i < otherBindingsCount; i++) { > needValue = i < otherBindingsCount-1 ? !otherBindings[i+1].isStatic() : valueRequired; >- if (needValue || (i > 0 && complyTo14)) { >+ if (needValue || complyTo14) { > TypeBinding lastReceiverType = getGenericCast(i); > if (lastReceiverType == null) { > if (i == 0) { >@@ -375,11 +375,8 @@ > codeStream.generateImplicitConversion(assignment.implicitConversion); > } > } >- public void generateCode( >- BlockScope currentScope, >- CodeStream codeStream, >- boolean valueRequired) { >- >+ >+ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { > int pc = codeStream.position; > if (constant != Constant.NotAConstant) { > if (valueRequired) { >@@ -402,8 +399,11 @@ > boolean isFirst = lastFieldBinding == this.binding > && (this.indexOfFirstFieldBinding == 1 || lastFieldBinding.declaringClass == currentScope.enclosingReceiverType()) > && this.otherBindings == null; // could be dup: next.next.next >- if (valueRequired || (!isFirst && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) >- || ((implicitConversion & TypeIds.UNBOXING) != 0)) { >+ TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length); >+ if (valueRequired >+ || (!isFirst && currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) >+ || ((implicitConversion & TypeIds.UNBOXING) != 0) >+ || requiredGenericCast != null) { > int lastFieldPc = codeStream.position; > if (lastFieldBinding.declaringClass == null) { // array length > codeStream.arraylength(); >@@ -427,23 +427,21 @@ > } else { > codeStream.invokestatic(accessor); > } >- TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length); >+ if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast); > if (valueRequired) { >- if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast); > codeStream.generateImplicitConversion(implicitConversion); > } else { >- if ((implicitConversion & TypeIds.UNBOXING) != 0) { >- codeStream.generateImplicitConversion(implicitConversion); >- } >- // could occur if !valueRequired but compliance >= 1.4 >- switch (lastFieldBinding.type.id) { >+ boolean isUnboxing = (implicitConversion & TypeIds.UNBOXING) != 0; >+ // conversion only generated if unboxing >+ if (isUnboxing) codeStream.generateImplicitConversion(implicitConversion); >+ switch (isUnboxing ? postConversionType(currentScope).id : lastFieldBinding.type.id) { > case T_long : > case T_double : > codeStream.pop2(); > break; > default : > codeStream.pop(); >- } >+ } > } > } > >@@ -594,7 +592,7 @@ > if (lastFieldBinding.constant() != Constant.NotAConstant) { > break; > } >- if (needValue && !lastFieldBinding.isStatic()) { >+ if ((needValue && !lastFieldBinding.isStatic()) || lastGenericCast != null) { > int pc = codeStream.position; > if ((bits & DepthMASK) != 0) { > ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((bits & DepthMASK) >> DepthSHIFT); >@@ -647,7 +645,7 @@ > codeStream.generateConstant(fieldConstant, 0); > } > } else { >- if (needValue || (i > 0 && complyTo14)) { >+ if (needValue || (i > 0 && complyTo14) || lastGenericCast != null) { > MethodBinding accessor = syntheticReadAccessors == null ? null : syntheticReadAccessors[i]; > if (accessor == null) { > if (lastFieldBinding.isStatic()) { >@@ -658,11 +656,8 @@ > } else { > codeStream.invokestatic(accessor); > } >- if (needValue) { >- if (lastGenericCast != null) codeStream.checkcast(lastGenericCast); >- } else { >- codeStream.pop(); >- } >+ if (lastGenericCast != null) codeStream.checkcast(lastGenericCast); >+ if (!needValue) codeStream.pop(); > } else { > if (this.codegenBinding == lastFieldBinding) { > if (lastFieldBinding.isStatic()){ >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java,v >retrieving revision 1.37 >diff -u -r1.37 AssignmentTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 6 Mar 2007 04:42:12 -0000 1.37 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AssignmentTest.java 15 Mar 2007 12:42:33 -0000 >@@ -131,7 +131,25 @@ > "The assignment to variable next has no effect\n" + > "----------\n"); > } >+public void test003() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " int portNumber;\n" + >+ " public static void main(String[] args) {\n" + >+ " X x = new X();\n" + >+ " x.portNumber = Integer.parseInt(\"12\");\n" + >+ " x.run();\n" + >+ " }\n" + >+ " private void run() {\n" + >+ " System.out.println(portNumber);\n" + >+ " }\n" + >+ "}", // ================= > >+ }, >+ "12"); >+} > // final multiple assignment > public void test020() { > this.runNegativeTest( >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.602 >diff -u -r1.602 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 15 Mar 2007 09:33:56 -0000 1.602 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 15 Mar 2007 12:42:43 -0000 >@@ -15129,20 +15129,21 @@ > " 6 dup\n" + > " 7 invokespecial X() [28]\n" + > " 10 getfield X.e : XA [29]\n" + >- " 13 pop\n" + >- " 14 getstatic XAB.CONST : XB [31]\n" + >- " 17 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" + >- " 20 new X [1]\n" + >- " 23 dup\n" + >- " 24 invokespecial X() [28]\n" + >- " 27 invokevirtual X.foo() : void [43]\n" + >- " 30 return\n" + >+ " 13 checkcast XAB [31]\n" + >+ " 16 pop\n" + >+ " 17 getstatic XAB.CONST : XB [33]\n" + >+ " 20 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" + >+ " 23 new X [1]\n" + >+ " 26 dup\n" + >+ " 27 invokespecial X() [28]\n" + >+ " 30 invokevirtual X.foo() : void [43]\n" + >+ " 33 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 10]\n" + >- " [pc: 20, line: 11]\n" + >- " [pc: 30, line: 12]\n" + >+ " [pc: 23, line: 11]\n" + >+ " [pc: 33, line: 12]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 0, pc: 34] local: args index: 0 type: java.lang.String[]\n" + > " \n" + > " // Method descriptor #10 ()V\n" + > " // Stack: 2, Locals: 1\n" + >@@ -15238,20 +15239,21 @@ > " 6 dup\n" + > " 7 invokespecial X() [28]\n" + > " 10 invokevirtual X.e() : XA [29]\n" + >- " 13 pop\n" + >- " 14 getstatic XAB.CONST : XB [31]\n" + >- " 17 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" + >- " 20 new X [1]\n" + >- " 23 dup\n" + >- " 24 invokespecial X() [28]\n" + >- " 27 invokevirtual X.foo() : void [43]\n" + >- " 30 return\n" + >+ " 13 checkcast XAB [31]\n" + >+ " 16 pop\n" + >+ " 17 getstatic XAB.CONST : XB [33]\n" + >+ " 20 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [37]\n" + >+ " 23 new X [1]\n" + >+ " 26 dup\n" + >+ " 27 invokespecial X() [28]\n" + >+ " 30 invokevirtual X.foo() : void [43]\n" + >+ " 33 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 10]\n" + >- " [pc: 20, line: 11]\n" + >- " [pc: 30, line: 12]\n" + >+ " [pc: 23, line: 11]\n" + >+ " [pc: 33, line: 12]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" + >+ " [pc: 0, pc: 34] local: args index: 0 type: java.lang.String[]\n" + > " \n" + > " // Method descriptor #6 ()V\n" + > " // Stack: 2, Locals: 1\n" + >@@ -15360,18 +15362,22 @@ > " 5 invokespecial X$1(X) [30]\n" + > " 8 invokevirtual X$1.run() : void [33]\n" + > " 11 getstatic java.lang.System.out : java.io.PrintStream [36]\n" + >- " 14 getstatic XB.CONST : XB [42]\n" + >- " 17 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [48]\n" + >- " 20 return\n" + >+ " 14 aload_0 [this]\n" + >+ " 15 getfield X.e : XA [42]\n" + >+ " 18 checkcast XB [44]\n" + >+ " 21 pop\n" + >+ " 22 getstatic XB.CONST : XB [46]\n" + >+ " 25 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [50]\n" + >+ " 28 return\n" + > " Line numbers:\n" + > " [pc: 0, line: 13]\n" + > " [pc: 8, line: 17]\n" + > " [pc: 11, line: 18]\n" + >- " [pc: 20, line: 19]\n" + >+ " [pc: 28, line: 19]\n" + > " Local variable table:\n" + >- " [pc: 0, pc: 21] local: this index: 0 type: X\n" + >+ " [pc: 0, pc: 29] local: this index: 0 type: X\n" + > " Local variable type table:\n" + >- " [pc: 0, pc: 21] local: this index: 0 type: X<E>\n"; >+ " [pc: 0, pc: 29] local: this index: 0 type: X<E>\n"; > > try { > File f = new File(OUTPUT_DIR + File.separator + "X.class"); >@@ -33663,7 +33669,7 @@ > " 5 ldc <String \"[B.local_field]\"> [32]\n" + > " 7 invokestatic A.foo(java.lang.String) : Value [17]\n" + > " 10 putfield B.local_field : Value [34]\n" + >- " 13 getstatic I.CONST : Value [36]\n" + >+ " 13 getstatic B.CONST : Value [36]\n" + > " 16 pop\n" + > " 17 getstatic Value.NAME : java.lang.String [39]\n" + > " 20 pop\n" + >@@ -36736,8 +36742,8 @@ > }, > ""); > } >-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=176591 >-// ?: cuts assignment context >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=176591 >+//?: cuts assignment context > public void test1109() { > this.runNegativeTest( > new String[] { >@@ -36763,8 +36769,8 @@ > "Type mismatch: cannot convert from Y<Object> to Y<String>\n" + > "----------\n"); > } >-// https://bugs.eclipse.org/bugs/show_bug.cgi?id=176591 >-// variant >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=176591 >+//variant > public void test1110() { > this.runConformTest( > new String[] { >@@ -36785,4 +36791,302 @@ > }, > ""); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 >+public void test1111() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo(Object o) {\n" + >+ " return (T) o; // should get unchecked warning\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<X> a = new A<X>();\n" + >+ " try {\n" + >+ " X s = a.foo(new Object());\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1112() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<X> a = new A<X>();\n" + >+ " A ua = a;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " X s = a.foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1113() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A<X>{\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().foo();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " A ua = this;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " X s = foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1114() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A<X>{\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().foo();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " A ua = this;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " X s = this.foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1115() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " static X ROOT;\n" + >+ " public static void main(String[] args) {\n" + >+ " A<X> a = new A<X>();\n" + >+ " A ua = a;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " X s = a.foo.ROOT;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1116() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "import java.io.Serializable;\n" + >+ "\n" + >+ "interface I {\n" + >+ " int CONST = 1;\n" + >+ "}\n" + >+ "\n" + >+ "class Z<T extends Serializable&I> {\n" + >+ " T c;\n" + >+ " Z(T c) {\n" + >+ " this.c = c;\n" + >+ " }\n" + >+ " int foo() {\n" + >+ " return c.CONST;\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X implements Serializable, I {\n" + >+ " public static void main(String argv[]) {\n" + >+ " Z<X> z = new Z<X>(new X());\n" + >+ " Z rawz = z;\n" + >+ " rawz.c = new Serializable(){};\n" + >+ " try {\n" + >+ " z.foo();\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177194 - variation >+public void test1117() { >+ Map options = getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "interface I<T> {\n" + >+ " Value<String> CONST = null;\n" + >+ "}\n" + >+ "class Value<V> {\n" + >+ " String NAME = \"VALUE\";\n" + >+ "}\n" + >+ "class B<V> implements I<V> {\n" + >+ " B(Value<String> param) {\n" + >+ " Value<String> v0 = CONST;\n" + >+ " Value<String> v1 = this.CONST;\n" + >+ " String s2 = CONST.NAME;\n" + >+ " Value<String> v3 = I.CONST;\n" + >+ " Value<String> v4 = B.CONST;\n" + >+ " }\n" + >+ "}\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " try {\n" + >+ " new B<String>(new Value<String>());\n" + >+ " } catch(NullPointerException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ false, >+ null, >+ options, >+ null); >+ // check the reference to I.CONST is generated as B.CONST, except for v3 still issuing I.CONST >+ String expectedOutput = >+ " // Method descriptor #8 (LValue;)V\n" + >+ " // Signature: (LValue<Ljava/lang/String;>;)V\n" + >+ " // Stack: 1, Locals: 2\n" + >+ " B(Value param);\n" + >+ " 0 aload_0 [this]\n" + >+ " 1 invokespecial java.lang.Object() [12]\n" + >+ " 4 getstatic B.CONST : Value [15]\n" + >+ " 7 pop\n" + >+ " 8 getstatic B.CONST : Value [15]\n" + >+ " 11 pop\n" + >+ " 12 getstatic B.CONST : Value [15]\n" + >+ " 15 getfield Value.NAME : java.lang.String [19]\n" + >+ " 18 pop\n" + >+ " 19 getstatic I.CONST : Value [25]\n" + >+ " 22 pop\n" + >+ " 23 getstatic B.CONST : Value [15]\n" + >+ " 26 pop\n" + >+ " 27 return\n" + >+ " Line numbers:\n" + >+ " [pc: 0, line: 8]\n" + >+ " [pc: 4, line: 9]\n" + >+ " [pc: 8, line: 10]\n" + >+ " [pc: 12, line: 11]\n" + >+ " [pc: 19, line: 12]\n" + >+ " [pc: 23, line: 13]\n" + >+ " [pc: 27, line: 14]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 28] local: this index: 0 type: B\n" + >+ " [pc: 0, pc: 28] local: param index: 1 type: Value\n" + >+ " Local variable type table:\n" + >+ " [pc: 0, pc: 28] local: this index: 0 type: B<V>\n" + >+ " [pc: 0, pc: 28] local: param index: 1 type: Value<java.lang.String>\n"; >+ >+ try { >+ File f = new File(OUTPUT_DIR + File.separator + "B.class"); >+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >+ int index = result.indexOf(expectedOutput); >+ if (index == -1 || expectedOutput.length() == 0) { >+ System.out.println(Util.displayString(result, 3)); >+ } >+ if (index == -1) { >+ assertEquals("Wrong contents", expectedOutput, result); >+ } >+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) { >+ assertTrue(false); >+ } catch (IOException e) { >+ assertTrue(false); >+ } >+} >+ > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java,v >retrieving revision 1.106 >diff -u -r1.106 AutoBoxingTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java 6 Mar 2007 04:42:12 -0000 1.106 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/AutoBoxingTest.java 15 Mar 2007 12:42:34 -0000 >@@ -3969,4 +3969,371 @@ > }, > "SUCCESS"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 >+public void test135() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo() { return null; }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<Long> a = new A<Long>();\n" + >+ " A ua = a;\n" + >+ " try {\n" + >+ " long s = a.foo();\n" + >+ " } catch(NullPointerException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test136() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo(Object o) {\n" + >+ " return (T) o; // should get unchecked warning\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<Long> a = new A<Long>();\n" + >+ " try {\n" + >+ " long s = a.foo(new Object());\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test137() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<Long> a = new A<Long>();\n" + >+ " A ua = a;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " long s = a.foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test138() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A<Long>{\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().foo();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " A ua = this;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " long s = foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test139() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A<Long>{\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().foo();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " A ua = this;\n" + >+ " ua.foo = new Object();\n" + >+ " try {\n" + >+ " long s = this.foo;\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test140() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " long foo() {\n" + >+ " return 0L;\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A a = new A();\n" + >+ " Long s = a.foo();\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test141() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " long foo = 0L;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A a = new A();\n" + >+ " Long s = a.foo;\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test142() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " long foo = 0L;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A {\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().bar();\n" + >+ " }\n" + >+ " void bar() {\n" + >+ " Long s = foo;\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test143() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " long foo = 0L;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A {\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().bar();\n" + >+ " }\n" + >+ " void bar() {\n" + >+ " Long s = this.foo;\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test144() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T[] foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A<Long>{\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().foo();\n" + >+ " }\n" + >+ " public void foo() {\n" + >+ " A ua = this;\n" + >+ " ua.foo = new Object[1];\n" + >+ " try {\n" + >+ " long s = this.foo[0];\n" + >+ " } catch(ClassCastException e) {\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " return;\n" + >+ " }\n" + >+ " System.out.println(\"FAILED\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test145() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " long[] foo = { 0L };\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A {\n" + >+ " public static void main(String[] args) {\n" + >+ " new X().bar();\n" + >+ " }\n" + >+ " void bar() {\n" + >+ " Long s = this.foo[0];\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=177372 - variation >+public void test146() { >+ Map settings = getCompilerOptions(); >+ settings.put(CompilerOptions.OPTION_PreserveUnusedLocal, CompilerOptions.OPTIMIZE_OUT); >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " public T foo;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " A<Long> a = new A<Long>();\n" + >+ " long s = a.foo.MAX_VALUE;\n" + >+ " System.out.println(\"SUCCESS\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "SUCCESS", >+ null, >+ true, >+ null, >+ settings, >+ null); >+} > } >#P org.eclipse.jdt.core.tests >Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java >=================================================================== >RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java,v >retrieving revision 1.105 >diff -u -r1.105 InitializationTest.java >--- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 6 Mar 2007 04:29:57 -0000 1.105 >+++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 15 Mar 2007 12:42:45 -0000 >@@ -5319,7 +5319,7 @@ > " 5 ldc <String \"[B.local_field]\"> [29]\n" + > " 7 invokestatic A.foo(java.lang.String) : Value [15]\n" + > " 10 putfield B.local_field : Value [31]\n" + >- " 13 getstatic I.CONST : Value [33]\n" + >+ " 13 getstatic B.CONST : Value [33]\n" + > " 16 pop\n" + > " 17 getstatic Value.NAME : java.lang.String [36]\n" + > " 20 pop\n" +
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 177194
:
60750
|
60757
|
60920
| 60927 |
60990