Summary: | NullPointerException in Util.equalArraysOrNull | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Ulrich Kawald <ulrich.kawald> |
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> |
Status: | RESOLVED FIXED | QA Contact: | |
Severity: | minor | ||
Priority: | P3 | ||
Version: | 2.0 | ||
Target Milestone: | 2.0 M6 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Ulrich Kawald
2002-04-25 07:23:37 EDT
Which build are you using? In build 20020423, Flags.isPublic(int) doesn't use a HashMap. I'm sorry, but I missed a nested method call, the exception really occurred in a call to org.eclipse.jdt.internal.core.SourceMethod.getFlags() (see the following stack trace) org.eclipse.jdt.internal.core.Util.equalArraysOrNull(java.lang.Object[], java.lang.Object[]) line: 262 org.eclipse.jdt.internal.core.SourceMethod.equals(java.lang.Object) line: 41 java.util.HashMap.get(java.lang.Object) line: 269 [local variables unavailable] org.eclipse.jdt.internal.core.JavaModelManager.getInfo(org.eclipse.jdt.core. IJavaElement) line: 612 org.eclipse.jdt.internal.core.SourceMethod(org.eclipse.jdt.internal.core.Jav aElement).getElementInfo() line: 274 org.eclipse.jdt.internal.core.SourceMethod(org.eclipse.jdt.internal.core.Mem ber).getFlags() line: 83 If you can find a test case where the method is created with a null parameter type, I would be very interested in knowing about it. Otherwise, I added a protection in Util.equalArraysOrNull(Object[], Object[]). The exception occurred when I accidentally created a non-existing method-object: IType type; IJavaElement je = getJavaProject().findElement(new Path(path)); if (je != null) { if (je.getElementType() == IJavaElement.COMPILATION_UNIT) { type = (IType) ((ICompilationUnit) je).getTypes()[0]; } } IMethod method = type.getMethod(methodName, new String[]{(String) getParams()}); // getParams() did return null int flags = method.getFlags(); // NullPointerException Thanks for the info. I was afraid the method element had been created by the jdt/core. null is not specified as being a valid value for one of the parameter types in IMethod.getMethod(String, String[]). Thus the previous behavior would be expected. However, we now protect ourselfves against such a scenario. method.getFlags() will now throw a 'not present' exception. |