Community
Participate
Working Groups
The following class causes a compiler error public enum LevelEnum{ OFF( OFF_INT, "OFF" ), FATAL( FATAL_INT, "FATAL" ), ERROR( ERROR_INT, "ERROR" ), WARN( WARN_INT, "WARN" ), INFO( INFO_INT, "INFO" ), DEBUG( DEBUG_INT, "DEBUG" ), ALL( ALL_INT, "ALL" ); private String levelStr; protected LevelEnum( int level, String levelStr ) { this.levelStr = levelStr; } public String getLevelStr(){ return levelStr; } public String getDescription( ) { switch( this ) { case OFF: return "OFF"; case FATAL: return "FATAL"; case ERROR: return "ERROR"; case WARN: return "WARN"; case INFO: return "INFO"; case DEBUG: return "DEBUG"; case ALL: return "ALL"; default: return "Unknown Level"; } } } Trace is java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.FieldBinding.canBeSeenBy (FieldBinding.java:140) at org.eclipse.jdt.internal.compiler.lookup.Scope.findField (Scope.java:645) at org.eclipse.jdt.internal.compiler.lookup.Scope.getBinding (Scope.java:1455) at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.resolve (FieldDeclaration.java:176) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:981) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:1063) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java:280) at org.eclipse.jdt.internal.compiler.Compiler.resolve (Compiler.java:566) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process (CompilationUnitProblemFinder.java:175) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure (CompilationUnit.java:142) at org.eclipse.jdt.internal.core.Openable.generateInfos (Openable.java:203) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed (JavaElement.java:547) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent (CompilationUnit.java:979) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation (ReconcileWorkingCopyOperation.java:60) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation (JavaModelOperation.java:739) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile (CompilationUnit.java:1105) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile (JavaReconcilingStrategy.java:91) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile (JavaReconcilingStrategy.java:133) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile (CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile (JavaCompositeReconcilingStrategy.java:94) at org.eclipse.jface.text.reconciler.MonoReconciler.process (MonoReconciler.java:75) at org.eclipse.jdt.internal.ui.text.JavaReconciler.process (JavaReconciler.java:318) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run (AbstractReconciler.java:204)
I removed the 'protected' modifier from the constructor because javac reported a problem. It seems that only 'private' is acceptable. The eclipse compiler error remains the same but javac compiled it.
Where are the *_INT constants defined? OFF_INT, FATAL_INT, ...
Once I defined these constants, with latest, I get: ---------- 1. ERROR in C:\tests_sources\p\X.java (at line 23) protected X( int level, String levelStr ) { ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Illegal modifier for the enum constructor; only private is permitted. ---------- 1 problem (1 error) Ok to close?
Looks close to bug 81724
Indeed, but because the line number was different I didn't want to close it as a dup. *** This bug has been marked as a duplicate of 81724 ***
I have defined the constants now. There is no static import. The other bug that this marked as duplicate of seems to be related to static imports. I am using 3.1M4. Error remains the same.
Please reattach a complete test case for further investigation and accurately describe what the problem is.
You need to use at least 3.1M5a as the dup has been fixed for M5, not M4.
This bug seems to be caused by static imports in 3.1M4. I checked by adding and removing the static imports. Whenever the static import is added I get the original error I reported. So it could be a duplicate. java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.FieldBinding.canBeSeenBy (FieldBinding.java:140) at org.eclipse.jdt.internal.compiler.lookup.Scope.findField (Scope.java:645) at org.eclipse.jdt.internal.compiler.lookup.Scope.getBinding (Scope.java:1455) at org.eclipse.jdt.internal.compiler.ast.FieldDeclaration.resolve (FieldDeclaration.java:176) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:981) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve (TypeDeclaration.java:1063) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve (CompilationUnitDeclaration.java:280) at org.eclipse.jdt.internal.compiler.Compiler.resolve (Compiler.java:566) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process (CompilationUnitProblemFinder.java:175) at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure (CompilationUnit.java:142) at org.eclipse.jdt.internal.core.Openable.generateInfos (Openable.java:203) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed (JavaElement.java:547) at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent (CompilationUnit.java:979) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation (ReconcileWorkingCopyOperation.java:60) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation (JavaModelOperation.java:739) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile (CompilationUnit.java:1105) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile (JavaReconcilingStrategy.java:91) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile (JavaReconcilingStrategy.java:133) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile (CompositeReconcilingStrategy.java:86) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile (JavaCompositeReconcilingStrategy.java:94) at org.eclipse.jface.text.reconciler.MonoReconciler.process (MonoReconciler.java:75) at org.eclipse.jdt.internal.ui.text.JavaReconciler.process (JavaReconciler.java:318) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run (AbstractReconciler.java:204)
So, apart from the NPE which we think is a dup, is there anything else wrong ? If so, please reattach a complete test case for further investigation and accurately describe what the problem is. Once done, please reopen.
Reopen
The NPE does no longer happen with 3.1 RC2 => close as WORKSFORME