Community
Participate
Working Groups
Using 20011114, when I try any evaluation in the debugger, I get the following NPE: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPackage (LookupEnvironment.java:320) at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings (CompilationUnitScope.java:90) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings (LookupEnvironment.java:110) at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile (Compiler.java:224) at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:247) at org.eclipse.jdt.internal.eval.Evaluator.getClasses (Evaluator.java:113) at org.eclipse.jdt.internal.eval.EvaluationContext.evaluateVariables (EvaluationContext.java:308) at org.eclipse.jdt.internal.eval.EvaluationContext.evaluate (EvaluationContext.java:191) at org.eclipse.jdt.internal.core.eval.EvaluationContextWrapper.evaluateCodeSnippet (EvaluationContextWrapper.java:158) at org.eclipse.jdt.internal.debug.eval.LocalEvaluationEngine$2.run (LocalEvaluationEngine.java:456) at java.lang.Thread.run(Thread.java:498)
This indicates the name environment which got passed to the IEvaluationContext.evaluate(...) call was null. This reveals that the project has no built state (#getLastBuiltState), which is probably true if using the new builder. So turn off the new builder, and we will had support for it soon.
The evaluation context should create its own name environment using something like the code below... it does not need to know a new build state since there is nothing in the state that it needs. It does not want to see source files so create binary classpath directories for every project. This code comes from JavaBuilder.initializeBuilder(), if it would be better in NameEnvironment then we can move it. workspaceRoot = currentProject.getWorkspace().getRoot(); outputFolder = (IContainer) workspaceRoot.findMember (javaProject.getOutputLocation()); if (outputFolder == null) { outputFolder = workspaceRoot.getFolder(javaProject.getOutputLocation()); createFolder(outputFolder); } IClasspathEntry[] entries = ((JavaProject) javaProject).getExpandedClasspath (true); int cpCount = 0; int max = entries.length; this.classpath = new ClasspathLocation[max]; nextEntry : for (int i = 0; i < max; i++) { IClasspathEntry entry = entries[i]; Object target = JavaModel.getTarget(workspaceRoot, entry.getPath(), true); if (target == null) continue nextEntry; if (target instanceof IResource) { IResource resource = (IResource) target; switch(entry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE : if (!(resource instanceof IContainer)) continue nextEntry; classpath[cpCount++] = ClasspathLocation.forRequiredProject(outputFolder.getLocation().toString()); continue nextEntry; case IClasspathEntry.CPE_PROJECT : if (!(resource instanceof IProject)) continue nextEntry; IProject prereqProject = (IProject) resource; IPath outputLocation = getJavaProject (prereqProject).getOutputLocation(); IResource prereqOutputFolder; if (prereqProject.getFullPath().equals (outputLocation)) { prereqOutputFolder = prereqProject; } else { prereqOutputFolder = workspaceRoot.findMember(outputLocation); if (prereqOutputFolder == null || ! prereqOutputFolder.exists() || !(prereqOutputFolder instanceof IFolder)) continue nextEntry; } classpath[cpCount++] = ClasspathLocation.forRequiredProject(prereqOutputFolder.getLocation().toString ()); continue nextEntry; case IClasspathEntry.CPE_LIBRARY : if (resource instanceof IFile) { String extension = entry.getPath ().getFileExtension(); if (!(JAR_EXTENSION.equalsIgnoreCase (extension) || ZIP_EXTENSION.equalsIgnoreCase(extension))) continue nextEntry; } else if (!(resource instanceof IFolder)) { continue nextEntry; } classpath[cpCount++] = ClasspathLocation.forLibrary(resource.getLocation().toString()); continue nextEntry; } } else if (target instanceof File) { String extension = entry.getPath().getFileExtension(); if (!(JAR_EXTENSION.equalsIgnoreCase(extension) || ZIP_EXTENSION.equalsIgnoreCase(extension))) continue nextEntry; classpath[cpCount++] = ClasspathLocation.forLibrary (entry.getPath().toString()); } } if (cpCount < max) System.arraycopy(classpath, 0, (classpath = new ClasspathLocation [cpCount]), 0, cpCount);
Fixed as indicated above.