Community
Participate
Working Groups
I'm trying to get an ITypeBinding for a parameterized type. When I pass in java.util.List<Integer> to the following method, I get an npe in the jdt code. See below for stack trace: public static ITypeBinding getTypeBinding(final String typeName, IJavaProject javaProject) { class BindingRequestor extends ASTRequestor { private ITypeBinding _result = null; public void acceptBinding(String bindingKey, IBinding binding) { if (_result == null && binding != null && binding.getKind() == IBinding.TYPE) _result = (ITypeBinding) binding; } } String[] keys = new String[] { BindingKey.createTypeBindingKey( typeName ) }; final BindingRequestor requestor = new BindingRequestor(); final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setProject(javaProject); // this doesn’t really do a parse; it’s a type lookup parser.createASTs(new ICompilationUnit[] {}, keys, requestor, null); return requestor._result; } Stack Trace:: java.lang.NullPointerException at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.initialize (ParameterizedTypeBinding.java:544) at org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding.<init> (ParameterizedTypeBinding.java:38) at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createParameterizedT ype(LookupEnvironment.java:559) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.consumeParameterizedType (BindingKeyResolver.java:279) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parseParameterizedType (BindingKeyParser.java:759) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse (BindingKeyParser.java:571) at org.eclipse.jdt.internal.core.util.BindingKeyParser.parse (BindingKeyParser.java:540) at org.eclipse.jdt.internal.core.util.BindingKeyResolver.getCompilerBinding (BindingKeyResolver.java:439) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:734) at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve (CompilationUnitResolver.java:460) at org.eclipse.jdt.core.dom.ASTParser.createASTs (ASTParser.java:664) at com.bea.wlw.common.core.util.ParameterizedTypeUtil.getTypeBinding (ParameterizedTypeUtil.java:155) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor$ListItemInfo.validateType (ActionOutputEditor.java:1068) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor$ListItemInfo.validate (ActionOutputEditor.java:1014) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor$ListItemInfo.access$9 (ActionOutputEditor.java:1000) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor.doValidate (ActionOutputEditor.java:527) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor.loadData (ActionOutputEditor.java:501) at com.bea.wlw.netui.ui.dialogs.ActionOutputEditor.<init> (ActionOutputEditor.java:199) at com.bea.wlw.netui.ui.actions.EditActionOutputAction.newSwingDialog (EditActionOutputAction.java:56) at com.bea.wlw.netui.ui.actions.SwingDialogLauncher.run (SwingDialogLauncher.java:78) at com.bea.wlw.netui.ui.actions.MenuItemAction.widgetSelected (MenuItemAction.java:49) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:90) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843) at org.eclipse.swt.widgets.Display.runDeferredEvents (Display.java:3080) at org.eclipse.swt.widgets.Display.readAndDispatch (Display.java:2713) at org.eclipse.ui.internal.Workbench.runEventLoop (Workbench.java:1699) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:367) at org.eclipse.ui.PlatformUI.createAndRunWorkbench (PlatformUI.java:143) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:103) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:376) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:163) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334) at org.eclipse.core.launcher.Main.basicRun(Main.java:278) at org.eclipse.core.launcher.Main.run(Main.java:973) at org.eclipse.core.launcher.Main.main(Main.java:948)
In this case the _result should be null since the given type is incorrect. java.util.List<java.lang.Integer> would work however.
Released for 3.3M6. Regression tests added in org.eclipse.jdt.core.tests.dom.BatchASTCreationTests#test081/test082
Verified for 3.3 M6 using build I20070320-0010