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 32755 Details for
Bug 61946
AST: NPE in IVariableBinding.getConstantValue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch against R3_1_maintenance branch
61946.txt (text/plain), 36.21 KB, created by
Jerome Lanneluc
on 2006-01-10 06:51:49 EST
(
hide
)
Description:
Patch against R3_1_maintenance branch
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2006-01-10 06:51:49 EST
Size:
36.21 KB
patch
obsolete
>Index: compiler/org/eclipse/jdt/internal/compiler/ClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ClassFile.java,v >retrieving revision 1.111.2.1 >diff -u -r1.111.2.1 ClassFile.java >--- compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 25 Jul 2005 15:09:51 -0000 1.111.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ClassFile.java 10 Jan 2006 11:51:23 -0000 >@@ -134,11 +134,6 @@ > // add its fields > FieldBinding[] fields = typeBinding.fields; > if ((fields != null) && (fields != NoFields)) { >- for (int i = 0, max = fields.length; i < max; i++) { >- if (fields[i].constant() == null) { >- FieldReference.getConstantFor(fields[i], null, false, null); >- } >- } > classFile.addFieldInfos(); > } else { > // we have to set the number of fields to be equals to 0 >@@ -680,7 +675,8 @@ > int attributesNumber = 0; > // 4.7.2 only static constant fields get a ConstantAttribute > // Generate the constantValueAttribute >- if (fieldBinding.isConstantValue()){ >+ Constant fieldConstant = fieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant){ > if (contentsOffset + 8 >= contents.length) { > resizeContents(8); > } >@@ -696,7 +692,6 @@ > contents[contentsOffset++] = 2; > attributesNumber++; > // Need to add the constant_value_index >- Constant fieldConstant = fieldBinding.constant(); > switch (fieldConstant.typeID()) { > case T_boolean : > int booleanValueIndex = >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java,v >retrieving revision 1.66.2.4 >diff -u -r1.66.2.4 FieldDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 5 Dec 2005 17:47:07 -0000 1.66.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 10 Jan 2006 11:51:23 -0000 >@@ -69,7 +69,7 @@ > if (this.binding != null > && this.binding.isValidBinding() > && this.binding.isStatic() >- && !this.binding.isConstantValue() >+ && this.binding.constant() == Constant.NotAConstant > && this.binding.declaringClass.isNestedType() > && !this.binding.declaringClass.isStatic()) { > initializationScope.problemReporter().unexpectedStaticModifierForField( >@@ -104,7 +104,7 @@ > int pc = codeStream.position; > boolean isStatic; > if (this.initialization != null >- && !((isStatic = this.binding.isStatic()) && this.binding.isConstantValue())) { >+ && !((isStatic = this.binding.isStatic()) && this.binding.constant() != Constant.NotAConstant)) { > // non-static field, need receiver > if (!isStatic) > codeStream.aload_0(); >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.85.2.1 >diff -u -r1.85.2.1 FieldReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 28 Jun 2005 21:27:27 -0000 1.85.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 10 Jan 2006 11:51:23 -0000 >@@ -192,14 +192,15 @@ > } > } else { > boolean isStatic = this.codegenBinding.isStatic(); >- if (this.codegenBinding.isConstantValue()) { >+ Constant fieldConstant = this.codegenBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > receiver.generateCode(currentScope, codeStream, !isStatic); > if (!isStatic){ > codeStream.invokeObjectGetClass(); > codeStream.pop(); > } > if (valueRequired) { >- codeStream.generateConstant(this.codegenBinding.constant(), implicitConversion); >+ codeStream.generateConstant(fieldConstant, implicitConversion); > } > } else { > receiver.generateCode(currentScope, codeStream, !isStatic); >@@ -365,61 +366,6 @@ > public TypeBinding[] genericTypeArguments() { > return null; > } >- public static final Constant getConstantFor( >- FieldBinding binding, >- Reference reference, >- boolean isImplicit, >- Scope referenceScope) { >- >- //propagation of the constant. >- >- //ref can be a FieldReference, a SingleNameReference or a QualifiedNameReference >- //indexInQualification may have a value greater than zero only for QualifiednameReference >- //if ref==null then indexInQualification==0 AND implicitReceiver == false. This case is a >- //degenerated case where a fake reference field (null) >- //is associted to a real FieldBinding in order >- //to allow its constant computation using the regular path (in other words, find the fieldDeclaration >- //and proceed to its type resolution). As implicitReceiver is false, no error reporting >- //against ref will be used ==> no nullPointerException risk .... >- >- //special treatment for langage-built-in field (their declaring class is null) >- if (binding.declaringClass == null) { >- //currently only one field "length" : the constant computation is never done >- return NotAConstant; >- } >- if (!binding.isFinal()) { >- binding.setConstant(NotAConstant); >- return NotAConstant; >- } >- Constant fieldConstant = binding.constant(); >- if (fieldConstant != null) { >- if (isImplicit || (reference instanceof QualifiedNameReference >- && binding == ((QualifiedNameReference)reference).binding)) { >- return fieldConstant; >- } >- return NotAConstant; >- } >- >- //The field has not been yet type checked. >- //It also means that the field is not coming from a class that >- //has already been compiled. It can only be from a class within >- //compilation units to process. Thus the field is NOT from a BinaryTypeBinbing >- >- FieldBinding originalField = binding.original(); >- SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass; >- TypeDeclaration typeDecl = sourceType.scope.referenceContext; >- FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField); >- >- fieldDecl.resolve(originalField.isStatic() //side effect on binding >- ? typeDecl.staticInitializerScope >- : typeDecl.initializerScope); >- >- if (isImplicit || (reference instanceof QualifiedNameReference >- && binding == ((QualifiedNameReference)reference).binding)) { >- return binding.constant(); >- } >- return NotAConstant; >- } > > public boolean isSuperAccess() { > >@@ -441,7 +387,7 @@ > this.codegenBinding = this.binding.original(); > > if (binding.isPrivate()) { >- if ((currentScope.enclosingSourceType() != this.codegenBinding.declaringClass) && !binding.isConstantValue()) { >+ if ((currentScope.enclosingSourceType() != this.codegenBinding.declaringClass) && binding.constant() == Constant.NotAConstant) { > if (syntheticAccessors == null) > syntheticAccessors = new MethodBinding[2]; > syntheticAccessors[isReadAccess ? READ : WRITE] = >@@ -486,7 +432,7 @@ > if (this.binding.declaringClass != this.receiverType > && !this.receiverType.isArrayType() > && this.binding.declaringClass != null // array.length >- && !this.binding.isConstantValue()) { >+ && binding.constant() == Constant.NotAConstant) { > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 > && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !receiver.isImplicitThis() || !this.codegenBinding.isStatic()) >@@ -549,10 +495,7 @@ > scope.problemReporter().deprecatedField(fieldBinding, this); > } > boolean isImplicitThisRcv = receiver.isImplicitThis(); >- constant = FieldReference.getConstantFor(fieldBinding, this, isImplicitThisRcv, scope); >- if (!isImplicitThisRcv) { >- constant = NotAConstant; >- } >+ constant = isImplicitThisRcv ? fieldBinding.constant() : Constant.NotAConstant; > if (fieldBinding.isStatic()) { > // static field accessed through receiver? legal but unoptimal (optional warning) > if (!(isImplicitThisRcv >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.89.2.5 >diff -u -r1.89.2.5 QualifiedNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 18 Nov 2005 11:16:05 -0000 1.89.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 10 Jan 2006 11:51:24 -0000 >@@ -366,13 +366,14 @@ > FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream); > if (lastFieldBinding != null) { > boolean isStatic = lastFieldBinding.isStatic(); >- if (lastFieldBinding.isConstantValue()) { >+ Constant fieldConstant = lastFieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > if (!isStatic){ > codeStream.invokeObjectGetClass(); > codeStream.pop(); > } > if (valueRequired) { // inline the last field constant >- codeStream.generateConstant(lastFieldBinding.constant(), implicitConversion); >+ codeStream.generateConstant(fieldConstant, implicitConversion); > } > } else { > if (valueRequired || currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4) { >@@ -554,7 +555,7 @@ > lastFieldBinding = (FieldBinding) this.codegenBinding; > lastGenericCast = this.genericCast; > // if first field is actually constant, we can inline it >- if (lastFieldBinding.isConstantValue()) { >+ if (lastFieldBinding.constant() != Constant.NotAConstant) { > break; > } > if ((needValue || complyTo14) && !lastFieldBinding.isStatic()) { >@@ -573,8 +574,9 @@ > if (!needValue) break; // no value needed > LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; > // regular local variable read >- if (localBinding.isConstantValue()) { >- codeStream.generateConstant(localBinding.constant(), 0); >+ Constant localConstant = localBinding.constant(); >+ if (localConstant != Constant.NotAConstant) { >+ codeStream.generateConstant(localConstant, 0); > // no implicit conversion > } else { > // outer local? >@@ -596,13 +598,14 @@ > TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i]; > if (lastFieldBinding != null) { > needValue = !nextField.isStatic(); >- if (lastFieldBinding.isConstantValue()) { >+ Constant fieldConstant = lastFieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > if (lastFieldBinding != this.codegenBinding && !lastFieldBinding.isStatic()) { > codeStream.invokeObjectGetClass(); // perform null check > codeStream.pop(); > } > if (needValue) { >- codeStream.generateConstant(lastFieldBinding.constant(), 0); >+ codeStream.generateConstant(fieldConstant, 0); > } > } else { > if (needValue || complyTo14) { >@@ -694,7 +697,7 @@ > TypeBinding type = ((VariableBinding) binding).type; > int index = indexOfFirstFieldBinding; > if (index == length) { // restrictiveFlag == FIELD >- this.constant = FieldReference.getConstantFor((FieldBinding) binding, this, false, scope); >+ this.constant = ((FieldBinding) binding).constant(); > // perform capture conversion if read access > return (type != null && (this.bits & IsStrictlyAssignedMASK) == 0) > ? type.capture(scope, this.sourceEnd) >@@ -706,9 +709,7 @@ > otherDepths = new int[otherBindingsLength]; > > // fill the first constant (the one of the binding) >- this.constant = field != null >- ? FieldReference.getConstantFor((FieldBinding) binding, this, false, scope) >- : ((VariableBinding) binding).constant(); >+ this.constant = ((VariableBinding) binding).constant(); > // save first depth, since will be updated by visibility checks of other bindings > int firstDepth = (bits & DepthMASK) >> DepthSHIFT; > // iteration on each field >@@ -743,10 +744,9 @@ > if (isFieldUseDeprecated(field, scope, (this.bits & IsStrictlyAssignedMASK) !=0 && index+1 == length)) { > scope.problemReporter().deprecatedField(field, this); > } >- Constant someConstant = FieldReference.getConstantFor(field, this, false, scope); > // constant propagation can only be performed as long as the previous one is a constant too. >- if (this.constant != NotAConstant) { >- this.constant = someConstant; >+ if (this.constant != Constant.NotAConstant) { >+ this.constant = field.constant(); > } > > if (field.isStatic()) { >@@ -795,7 +795,7 @@ > > if (!flowInfo.isReachable()) return; > // index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding) >- if (fieldBinding.isConstantValue()) >+ if (fieldBinding.constant() != Constant.NotAConstant) > return; > > // if field from parameterized type got found, use the original field at codegen time >@@ -833,7 +833,7 @@ > if (fieldBinding.declaringClass != lastReceiverType > && !lastReceiverType.isArrayType() > && fieldBinding.declaringClass != null // array.length >- && !fieldBinding.isConstantValue()) { >+ && fieldBinding.constant() == Constant.NotAConstant) { > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 > && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(index <= 1 && indexOfFirstFieldBinding == 1 && fieldBinding.isStatic())) >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.73.2.4 >diff -u -r1.73.2.4 SingleNameReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 28 Nov 2005 12:41:34 -0000 1.73.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 10 Jan 2006 11:51:25 -0000 >@@ -188,7 +188,7 @@ > return fieldBinding.type; > } > } >- this.constant = FieldReference.getConstantFor(fieldBinding, this, true, scope); >+ this.constant = fieldBinding.constant(); > > if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & IsStrictlyAssignedMASK) !=0)) > scope.problemReporter().deprecatedField(fieldBinding, this); >@@ -334,10 +334,11 @@ > switch (bits & RestrictiveFlagMASK) { > case Binding.FIELD : // reading a field > FieldBinding fieldBinding = (FieldBinding) this.codegenBinding; >- if (fieldBinding.isConstantValue()) { >+ Constant fieldConstant = fieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > // directly use inlined value for constant fields > if (valueRequired) { >- codeStream.generateConstant(fieldBinding.constant(), implicitConversion); >+ codeStream.generateConstant(fieldConstant, implicitConversion); > } > } else { > if (valueRequired) { >@@ -659,7 +660,7 @@ > if (fieldBinding.declaringClass != this.actualReceiverType > && !this.actualReceiverType.isArrayType() > && fieldBinding.declaringClass != null // array.length >- && !fieldBinding.isConstantValue()) { >+ && fieldBinding.constant() == Constant.NotAConstant) { > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 > && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !fieldBinding.isStatic()) >Index: compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java,v >retrieving revision 1.43 >diff -u -r1.43 UnconditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 23 Feb 2005 02:47:29 -0000 1.43 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 10 Jan 2006 11:51:25 -0000 >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.flow; > >+import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; > import org.eclipse.jdt.internal.compiler.lookup.LocalVariableBinding; > import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >@@ -385,7 +386,7 @@ > return true; > > // final constants are inlined, and thus considered as always initialized >- if (local.isConstantValue()) { >+ if (local.constant() != Constant.NotAConstant) { > return true; > } > return isDefinitelyAssigned(local.id + maxFieldCount); >@@ -413,7 +414,7 @@ > if ((this.reachMode & UNREACHABLE) != 0) > return false; > // final constants are inlined, and thus considered as always initialized >- if (local.isConstantValue()) { >+ if (local.constant() != Constant.NotAConstant) { > return true; > } > return isDefinitelyNonNull(local.id + maxFieldCount); >@@ -483,7 +484,7 @@ > final public boolean isPotentiallyAssigned(LocalVariableBinding local) { > > // final constants are inlined, and thus considered as always initialized >- if (local.isConstantValue()) { >+ if (local.constant() != Constant.NotAConstant) { > return true; > } > return isPotentiallyAssigned(local.id + maxFieldCount); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v >retrieving revision 1.89.2.2 >diff -u -r1.89.2.2 BlockScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 30 Jun 2005 14:16:31 -0000 1.89.2.2 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 10 Jan 2006 11:51:26 -0000 >@@ -14,6 +14,7 @@ > import org.eclipse.jdt.internal.compiler.ast.*; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.CodeStream; >+import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; > > public class BlockScope extends Scope { >@@ -221,7 +222,7 @@ > LocalVariableBinding local = locals[ilocal]; // if no local at all, will be locals[ilocal]==null > > // check if variable is actually used, and may force it to be preserved >- boolean generateCurrentLocalVar = (local.useFlag == LocalVariableBinding.USED && !local.isConstantValue()); >+ boolean generateCurrentLocalVar = (local.useFlag == LocalVariableBinding.USED && local.constant() == Constant.NotAConstant); > > // do not report fake used variable > if (local.useFlag == LocalVariableBinding.UNUSED >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java,v >retrieving revision 1.38 >diff -u -r1.38 FieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 2 Jun 2005 19:43:33 -0000 1.38 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/FieldBinding.java 10 Jan 2006 11:51:26 -0000 >@@ -179,6 +179,39 @@ > System.arraycopy(returnTypeKey, 0, uniqueKey, index, returnTypeLength); > return uniqueKey; > } >+ >+public Constant constant() { >+ Constant fieldConstant = this.constant; >+ if (fieldConstant == null) { >+ if (this.isFinal()) { >+ //The field has not been yet type checked. >+ //It also means that the field is not coming from a class that >+ //has already been compiled. It can only be from a class within >+ //compilation units to process. Thus the field is NOT from a BinaryTypeBinbing >+ FieldBinding originalField = this.original(); >+ if (originalField.declaringClass instanceof SourceTypeBinding) { >+ SourceTypeBinding sourceType = (SourceTypeBinding) originalField.declaringClass; >+ if (sourceType.scope != null) { >+ TypeDeclaration typeDecl = sourceType.scope.referenceContext; >+ FieldDeclaration fieldDecl = typeDecl.declarationOf(originalField); >+ fieldDecl.resolve(originalField.isStatic() //side effect on binding >+ ? typeDecl.staticInitializerScope >+ : typeDecl.initializerScope); >+ fieldConstant = originalField.constant(); >+ } else { >+ fieldConstant = Constant.NotAConstant; // shouldn't occur per construction (paranoid null check) >+ } >+ } else { >+ fieldConstant = Constant.NotAConstant; // shouldn't occur per construction (paranoid null check) >+ } >+ } else { >+ fieldConstant = Constant.NotAConstant; >+ } >+ this.constant = fieldConstant; >+ } >+ return fieldConstant; >+} >+ > /** > * X<T> t --> LX<TT;>; > */ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java,v >retrieving revision 1.9 >diff -u -r1.9 ParameterizedFieldBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java 11 May 2005 21:39:06 -0000 1.9 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedFieldBinding.java 10 Jan 2006 11:51:26 -0000 >@@ -42,12 +42,7 @@ > public Constant constant() { > return this.originalField.constant(); > } >- /** >- * @see org.eclipse.jdt.internal.compiler.lookup.VariableBinding#isConstantValue() >- */ >- public boolean isConstantValue() { >- return this.originalField.isConstantValue(); >- } >+ > /** > * @see org.eclipse.jdt.internal.compiler.lookup.FieldBinding#original() > */ >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java,v >retrieving revision 1.23 >diff -u -r1.23 VariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java 26 Apr 2005 18:00:02 -0000 1.23 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/VariableBinding.java 10 Jan 2006 11:51:26 -0000 >@@ -17,7 +17,7 @@ > public int modifiers; > public TypeBinding type; > public char[] name; >- private Constant constant; >+ protected Constant constant; > public int id; // for flow-analysis (position in flowInfo bit vector) > public long tagBits; > >@@ -35,12 +35,6 @@ > public final boolean isBlankFinal(){ > return (modifiers & AccBlankFinal) != 0; > } >- /* Answer true if the receiver is final and cannot be changed >- */ >- >- public boolean isConstantValue() { >- return constant != Constant.NotAConstant; >- } > > public final boolean isFinal() { > return (modifiers & AccFinal) != 0; >Index: dom/org/eclipse/jdt/core/dom/VariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java,v >retrieving revision 1.44 >diff -u -r1.44 VariableBinding.java >--- dom/org/eclipse/jdt/core/dom/VariableBinding.java 26 May 2005 04:24:34 -0000 1.44 >+++ dom/org/eclipse/jdt/core/dom/VariableBinding.java 10 Jan 2006 11:51:26 -0000 >@@ -46,9 +46,8 @@ > * @since 3.0 > */ > public Object getConstantValue() { >- if (!this.binding.isConstantValue()) return null; > Constant c = this.binding.constant(); >- if (c == null) return null; >+ if (c == null || c == Constant.NotAConstant) return null; > switch (c.typeID()) { > case TypeIds.T_boolean: > return Boolean.valueOf(c.booleanValue()); >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java,v >retrieving revision 1.29 >diff -u -r1.29 CodeSnippetClassFile.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java 4 May 2005 11:31:09 -0000 1.29 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java 10 Jan 2006 11:51:27 -0000 >@@ -14,7 +14,6 @@ > import org.eclipse.jdt.internal.compiler.ClassFile; > import org.eclipse.jdt.internal.compiler.CompilationResult; > import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; >-import org.eclipse.jdt.internal.compiler.ast.FieldReference; > import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; > import org.eclipse.jdt.internal.compiler.codegen.ConstantPool; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; >@@ -140,11 +139,6 @@ > // add its fields > FieldBinding[] fields = typeBinding.fields; > if ((fields != null) && (fields != NoFields)) { >- for (int i = 0, max = fields.length; i < max; i++) { >- if (fields[i].constant() == null) { >- FieldReference.getConstantFor(fields[i], null, false, null); >- } >- } > classFile.addFieldInfos(); > } else { > // we have to set the number of fields to be equals to 0 >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java,v >retrieving revision 1.33 >diff -u -r1.33 CodeSnippetFieldReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java 9 May 2005 16:57:54 -0000 1.33 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetFieldReference.java 10 Jan 2006 11:51:27 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.internal.compiler.codegen.CodeStream; > import org.eclipse.jdt.internal.compiler.flow.FlowInfo; > import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.BlockScope; > import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; > import org.eclipse.jdt.internal.compiler.lookup.ParameterizedFieldBinding; >@@ -85,7 +86,8 @@ > boolean isStatic = this.codegenBinding.isStatic(); > this.receiver.generateCode(currentScope, codeStream, !isStatic); > if (valueRequired) { >- if (!this.codegenBinding.isConstantValue()) { >+ Constant fieldConstant = this.codegenBinding.constant(); >+ if (fieldConstant == Constant.NotAConstant) { > if (this.codegenBinding.declaringClass == null) { // array length > codeStream.arraylength(); > } else { >@@ -109,7 +111,7 @@ > codeStream.invokeObjectGetClass(); // perform null check > codeStream.pop(); > } >- codeStream.generateConstant(this.codegenBinding.constant(), this.implicitConversion); >+ codeStream.generateConstant(fieldConstant, this.implicitConversion); > } > } else { > if (!isStatic){ >@@ -313,7 +315,7 @@ > if (this.binding.declaringClass != someReceiverType > && !someReceiverType.isArrayType() > && this.binding.declaringClass != null // array.length >- && !this.binding.isConstantValue()) { >+ && this.binding.constant() == Constant.NotAConstant) { > > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 >@@ -377,7 +379,7 @@ > scope.problemReporter().deprecatedField(this.binding, this); > } > // check for this.x in static is done in the resolution of the receiver >- this.constant = FieldReference.getConstantFor(this.binding, this, this.receiver.isImplicitThis(), scope); >+ this.constant = this.receiver.isImplicitThis() ? this.binding.constant() : Constant.NotAConstant; > if (!this.receiver.isThis()) { > this.constant = NotAConstant; > } >Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java,v >retrieving revision 1.45 >diff -u -r1.45 CodeSnippetQualifiedNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 9 May 2005 16:57:54 -0000 1.45 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java 10 Jan 2006 11:51:27 -0000 >@@ -13,7 +13,6 @@ > import org.eclipse.jdt.internal.compiler.ast.Assignment; > import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; > import org.eclipse.jdt.internal.compiler.ast.Expression; >-import org.eclipse.jdt.internal.compiler.ast.FieldReference; > import org.eclipse.jdt.internal.compiler.ast.IntLiteral; > import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >@@ -95,13 +94,14 @@ > codeStream.arraylength(); > codeStream.generateImplicitConversion(this.implicitConversion); > } else { >- if (lastFieldBinding.isConstantValue()) { >+ Constant fieldConstant = lastFieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > if (!lastFieldBinding.isStatic()){ > codeStream.invokeObjectGetClass(); > codeStream.pop(); > } > // inline the last field constant >- codeStream.generateConstant(lastFieldBinding.constant(), this.implicitConversion); >+ codeStream.generateConstant(fieldConstant, this.implicitConversion); > } else { > if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { > if (lastFieldBinding.isStatic()) { >@@ -294,7 +294,7 @@ > lastFieldBinding = (FieldBinding) this.codegenBinding; > lastGenericCast = this.genericCast; > // if first field is actually constant, we can inline it >- if (lastFieldBinding.isConstantValue()) { >+ if (lastFieldBinding.constant() != Constant.NotAConstant) { > break; > } > if (needValue) { >@@ -327,8 +327,9 @@ > if (!needValue) break; // no value needed > LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding; > // regular local variable read >- if (localBinding.isConstantValue()) { >- codeStream.generateConstant(localBinding.constant(), 0); >+ Constant localConstant = localBinding.constant(); >+ if (localConstant != Constant.NotAConstant) { >+ codeStream.generateConstant(localConstant, 0); > // no implicit conversion > } else { > // outer local? >@@ -352,12 +353,13 @@ > needValue = !nextField.isStatic(); > if (needValue) { > if (lastFieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { >- if (lastFieldBinding.isConstantValue()) { >+ Constant fieldConstant = lastFieldBinding.constant(); >+ if (fieldConstant != Constant.NotAConstant) { > if (lastFieldBinding != this.codegenBinding && !lastFieldBinding.isStatic()) { > codeStream.invokeObjectGetClass(); // perform null check > codeStream.pop(); > } >- codeStream.generateConstant(lastFieldBinding.constant(), 0); >+ codeStream.generateConstant(fieldConstant, 0); > } else if (lastFieldBinding.isStatic()) { > codeStream.getstatic(lastFieldBinding); > } else { >@@ -418,7 +420,7 @@ > TypeBinding type = ((VariableBinding) this.binding).type; > int index = this.indexOfFirstFieldBinding; > if (index == length) { // restrictiveFlag == FIELD >- this.constant = FieldReference.getConstantFor((FieldBinding) this.binding, this, false, scope); >+ this.constant = ((FieldBinding) this.binding).constant(); > return type; > } > >@@ -427,10 +429,7 @@ > this.otherCodegenBindings = this.otherBindings = new FieldBinding[otherBindingsLength]; > > // fill the first constant (the one of the binding) >- this.constant = >- ((this.bits & Binding.FIELD) != 0) >- ? FieldReference.getConstantFor((FieldBinding) this.binding, this, false, scope) >- : ((VariableBinding) this.binding).constant(); >+ this.constant =((VariableBinding) this.binding).constant(); > > // iteration on each field > while (index < length) { >@@ -462,10 +461,9 @@ > if (isFieldUseDeprecated(field, scope, (this.bits & IsStrictlyAssignedMASK) !=0 && index+1 == length)) { > scope.problemReporter().deprecatedField(field, this); > } >- Constant someConstant = FieldReference.getConstantFor(field, this, false, scope); > // constant propagation can only be performed as long as the previous one is a constant too. >- if (this.constant != NotAConstant){ >- this.constant = someConstant; >+ if (this.constant != Constant.NotAConstant){ >+ this.constant = field.constant(); > } > type = field.type; > index++; >@@ -523,7 +521,7 @@ > if (fieldBinding.declaringClass != lastReceiverType > && !lastReceiverType.isArrayType() > && fieldBinding.declaringClass != null // array.length >- && !fieldBinding.isConstantValue()) { >+ && fieldBinding.constant() == Constant.NotAConstant) { > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 > && (options.complianceLevel >= ClassFileConstants.JDK1_4 || (index < 0 ? fieldBinding != binding : index > 0) || this.indexOfFirstFieldBinding > 1 || !fieldBinding.isStatic()) >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.41 >diff -u -r1.41 CodeSnippetSingleNameReference.java >--- eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 9 May 2005 16:57:54 -0000 1.41 >+++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 10 Jan 2006 11:51:28 -0000 >@@ -14,7 +14,6 @@ > import org.eclipse.jdt.internal.compiler.ast.BinaryExpression; > import org.eclipse.jdt.internal.compiler.ast.CompoundAssignment; > import org.eclipse.jdt.internal.compiler.ast.Expression; >-import org.eclipse.jdt.internal.compiler.ast.FieldReference; > import org.eclipse.jdt.internal.compiler.ast.IntLiteral; > import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; >@@ -97,7 +96,7 @@ > return null; > } > } >- this.constant = FieldReference.getConstantFor(fieldBinding, this, true, scope); >+ this.constant = fieldBinding.constant(); > > if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & IsStrictlyAssignedMASK) !=0)) { > scope.problemReporter().deprecatedField(fieldBinding, this); >@@ -225,9 +224,10 @@ > } else { > switch (this.bits & RestrictiveFlagMASK) { > case Binding.FIELD : // reading a field >- FieldBinding fieldBinding; > if (valueRequired) { >- if (!(fieldBinding = (FieldBinding) this.codegenBinding).isConstantValue()) { // directly use inlined value for constant fields >+ FieldBinding fieldBinding = (FieldBinding) this.codegenBinding; >+ Constant fieldConstant = fieldBinding.constant(); >+ if (fieldConstant == Constant.NotAConstant) { // directly use inlined value for constant fields > if (fieldBinding.canBeSeenBy(getReceiverType(currentScope), this, currentScope)) { > // directly use inlined value for constant fields > boolean isStatic; >@@ -264,7 +264,7 @@ > if (this.genericCast != null) codeStream.checkcast(this.genericCast); > codeStream.generateImplicitConversion(this.implicitConversion); > } else { // directly use the inlined value >- codeStream.generateConstant(fieldBinding.constant(), this.implicitConversion); >+ codeStream.generateConstant(fieldConstant, this.implicitConversion); > } > } > break; >@@ -589,7 +589,7 @@ > // and not from Object or implicit static field access. > if (fieldBinding.declaringClass != this.delegateThis.type > && fieldBinding.declaringClass != null // array.length >- && !fieldBinding.isConstantValue()) { >+ && fieldBinding.constant() == Constant.NotAConstant) { > CompilerOptions options = currentScope.compilerOptions(); > if ((options.targetJDK >= ClassFileConstants.JDK1_2 > && (options.complianceLevel >= ClassFileConstants.JDK1_4 || !fieldBinding.isStatic())
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 61946
: 32755 |
32762