Bug 92163 - NPE compiling a TestSetup subclass (ClassScope.java:945)
Summary: NPE compiling a TestSetup subclass (ClassScope.java:945)
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 93395 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-20 18:33 EDT by Barry Kaplan CLA
Modified: 2005-08-26 11:20 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Barry Kaplan CLA 2005-04-20 18:33:18 EDT
(eclipse 3.1M6, java5 enabled)

I added aspectj nature to an existing project. [At least] one of the files
generates an NPR:

java.lang.NullPointerException
	at
org.eclipse.ajdt.internal.ui.editor.AdviceActionDelegate.menuAboutToShow(AdviceActionDelegate.java:279)
	at
org.eclipse.ui.texteditor.AbstractTextEditor.rulerContextMenuAboutToShow(AbstractTextEditor.java:4514)
	at
org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.rulerContextMenuAboutToShow(AbstractDecoratedTextEditor.java:1277)
	at
org.eclipse.jdt.internal.ui.javaeditor.JavaEditor.rulerContextMenuAboutToShow(JavaEditor.java:3667)
	at
org.eclipse.ui.texteditor.AbstractTextEditor$11.menuAboutToShow(AbstractTextEditor.java:2195)
	at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:285)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:372)
	at org.eclipse.jface.action.MenuManager.access$0(MenuManager.java:369)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:386)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:116)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:866)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847)
	at org.eclipse.swt.widgets.Control.WM_INITMENUPOPUP(Control.java:3327)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3055)
	at org.eclipse.swt.widgets.Decorations.windowProc(Decorations.java:1493)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3466)
	at org.eclipse.swt.internal.win32.OS.TrackPopupMenu(Native Method)
	at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:225)
	at org.eclipse.swt.widgets.Display.runPopups(Display.java:2920)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2521)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1570)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1534)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:306)
	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:228)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:156)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:315)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:268)
	at org.eclipse.core.launcher.Main.run(Main.java:942)
	at org.eclipse.core.launcher.Main.main(Main.java:926)


Here is the complete file:

package org.blackboxtrader.liquidityarbitrage;

import java.util.Properties;

import junit.extensions.TestSetup;
import junit.framework.Test;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

/**
 * Creates the single specified spring ApplicationContext for the entire TestCase.
 * The context is destroyed after all tests have run.
 */
public class SpringTestSetup extends TestSetup {

    public static class ContextHolder {
        public ConfigurableApplicationContext context;
    }

    private final Properties contextProperties;
    private final ContextHolder contextHolder;
    private final String[] configFilenames;

    public SpringTestSetup(Test test, ContextHolder contextHolder, String...
configFilenames) {
        this(test, null, contextHolder, configFilenames);
    }

    public SpringTestSetup(Test test, Properties contextProperties,
ContextHolder contextHolder, String... configFilenames) {
        super(test);
        this.contextProperties = contextProperties;
        this.contextHolder = contextHolder;
        this.configFilenames = configFilenames;
    }

    protected void setUp() throws Exception {
        Logger.getLogger("org.springframework").setLevel(Level.WARN);
        contextHolder.context = new
FileSystemXmlApplicationContext(configFilenames, (contextProperties == null));
        assertNotNull(contextHolder.context);

        if (contextProperties != null) {
            PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new
PropertyPlaceholderConfigurer();
            propertyPlaceholderConfigurer.setProperties(contextProperties);
           
contextHolder.context.addBeanFactoryPostProcessor(propertyPlaceholderConfigurer);
            contextHolder.context.refresh();
        }
    }

    protected void tearDown() throws Exception {
        contextHolder.context.close();
        contextHolder.context = null;
    }

    protected void setLoggerLevel(String name, Level level) {
        Logger.getLogger(name).setLevel(level);
    }
}

Of course this project compiles and runs fine without aspectj nature. The
project no aspects.
Comment 1 Barry Kaplan CLA 2005-04-20 18:36:05 EDT
I don't think this problem has anything to do with the file I attached. When I
remove that file from the project another file has the same problem.
Comment 2 Matt Chapman CLA 2005-04-25 09:16:27 EDT
Barry,
As from the ajdt newsgroup, the above exception shouldn't be possible with the
latest 1.2.0.20050420095141 build, because the referenced code has changed.
Please could you check that the build is installed okay and is being picked up
by eclipse (and it is not reverting to an earlier build). Go to Help > About and
click the AJ icon. Also check your eclipse error log for any other errors.
Regards,
Matt.
Comment 3 Barry Kaplan CLA 2005-04-28 12:22:27 EDT
Hmm. Below is the event trace. It clearly shows the correct version. From the
about box icon, it also shows the correct version. The eclipse error log only
contains the exception listed below. I'm using a freshly installed 3.1M6 and the
only version of ajdt on my disk is the correct version. I even created a new
workspace and imported the project there, but got the same exception.

I'll keep digging around, but any other guidance would be appreciated.

----
9:01:05 AM	 AJDT Plugin Startup
	AJDT version: 1.2.0 for Eclipse 3.1
	AspectJ Compiler version: DEVELOPMENT
	org.eclipse.ajdt.ui.ajoutline2 = true
	DontInformUserAboutFileFilter = true
	ajde.version.at.previous.startup = 1.5.0.20050420095141
	org.aspectj.ajdt.ui.compile-timeout = 120
	org.eclipse.ajdt.ui.preferences.ajdtPrefConfigDone = true
	org.aspectj.ajdt.core.compiler.BuildOptions.showweavemessages = true
	org.eclipse.ajdt.ui.preferences.prefRunForAjdtVersion = 1.2.0.20050420095141
	org.aspectj.ajdt.core.compiler.aj5 = true
9:01:10 AM	 Building AJ code scanner
9:02:50 AM	 Build configuration file read: build.ajproperties
9:02:50 AM	 Editor opened on StartupShutdown.aj
9:02:50 AM	 Configuration file
Q:\eclipse.workspaces\drools.trunk\.metadata\.plugins\org.eclipse.ajdt.core\watley.swingclient.generated.lst
selected for watley.swingclient
9:02:50 AM	 Building AJ code scanner
9:02:51 AM	 Successfully unregistered Java Build Path property pages
9:02:52 AM	 Outline view action triggered: Sorting Declaration order for
StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Fields for StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Static Members for
StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Non-Public Members for
StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Pointcuts for StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Advice for StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Introductions for StartupShutdown.aj
9:02:52 AM	 Outline view action triggered: Show Declarations for StartupShutdown.aj
9:02:52 AM	 Structure view requested for StartupShutdown.aj
9:02:54 AM	 Build configuration file read: build.ajproperties
9:02:55 AM	 build: Kind=FULLBUILD Project=watley.swingclient Mode=Full AspectJ
compilation
9:03:13 AM	 Builder: Tidied output folder, deleted 3842 .class files from
Q:\watleytrader\swingclient\target\eclipse
9:03:17 AM	 Time to first 'compiled:' message: 4641ms
9:03:19 AM	 Time to first 'woven' message: 6078ms
9:03:38 AM	 outline updateview called (file:StartupShutdown.aj):
org.aspectj.ajde.ui.FileStructureView@10e47b3
9:03:38 AM	 Model update notification for StartupShutdown.aj
9:03:38 AM	 Time spent in ajde = 25078ms
9:03:38 AM	 Created AJDT relationship map for project watley.swingclient in 0ms
9:03:38 AM	 Types affected during build = 9
9:03:43 AM	 Time spent in build() = 47531ms
9:03:43 AM	 Build configuration file read: build.ajproperties
9:06:46 AM	 AJDTContentProvider.selectionChanged(): Marking visualiser content
as out of date
9:06:48 AM	 Build configuration file read: build.ajproperties
9:06:48 AM	 Successfully unregistered Java Build Path property pages
9:06:48 AM	 Build configuration file read: build.ajproperties
9:06:49 AM	 build: Kind=FULLBUILD Project=bbt.liquidityarbitrage Mode=Full
AspectJ compilation
9:06:49 AM	 Builder: Tidied output folder, deleted 128 .class files from
Q:\blackboxtrader\liquidityarbitrage\target\eclipse
9:06:52 AM	 outline updateview called (file:StartupShutdown.aj):
org.aspectj.ajde.ui.FileStructureView@10e47b3
9:06:52 AM	 Time spent in ajde = 3063ms
9:06:52 AM	 Created AJDT relationship map for project bbt.liquidityarbitrage in 31ms
9:06:52 AM	 Types affected during build = 0
9:06:52 AM	 Time spent in build() = 3640ms
---

---
java.lang.NullPointerException
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.detectHierarchyCycle(ClassScope.java:945)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.internalResolveType(ParameterizedSingleTypeReference.java:143)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.ParameterizedSingleTypeReference.resolveType(ParameterizedSingleTypeReference.java:208)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveSuperType(TypeReference.java:112)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.findSupertype(ClassScope.java:1092)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectSuperInterfaces(ClassScope.java:827)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:885)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectMemberTypes(ClassScope.java:716)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:892)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:249)
	at
org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment.completeTypeBindings(AjLookupEnvironment.java:99)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:331)
	at
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:348)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompilation(AjBuildManager.java:683)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBuildManager.java:168)
	at
org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(AjBuildManager.java:102)
	at org.aspectj.ajde.internal.CompilerAdapter.compile(CompilerAdapter.java:122)
	at
org.aspectj.ajde.internal.AspectJBuildManager$CompilerThread.run(AspectJBuildManager.java:165)

Comment 4 Matt Chapman CLA 2005-04-29 08:24:02 EDT
The exception is now down in the compiler, so transferring component.
Barry, can you attach a simple self-contained testcase to reproduce this?
Comment 5 Andrew Clement CLA 2005-04-29 08:39:14 EDT
The relevant lines of code in the compiler look like this:

// TODO (philippe)	if ((this.bits & ASTNode.IsSuperType) != 0)
if (isClassScope)
  if (((ClassScope) scope).detectHierarchyCycle(currentType, this, argTypes))
	return null;

so with a bit of luck it'll be fixed when Adrian checks in the new 3.1M6
compiler next week.
Comment 6 Matt Chapman CLA 2005-05-03 04:46:23 EDT
*** Bug 93395 has been marked as a duplicate of this bug. ***
Comment 7 Andrew Clement CLA 2005-05-03 06:15:06 EDT
The TODO is gone in the latest AspectJ - the compiler upgrade has addressed it.
 This may fix this problem.  We should try and get a good AJDT build out soon so
Barry can try retesting (if that would be ok Barry?).  I suspect as it builds on
M6 without the AJ nature then we might be in luck :)
Comment 8 Barry Kaplan CLA 2005-05-03 11:08:34 EDT
I'm ready test at any time. Thanks.
Comment 9 Barry Kaplan CLA 2005-05-07 01:33:14 EDT
Just updated to 1.2.0.200050503135046 -- same problem,c same exception. Sorry.
Comment 10 Chris Burnley CLA 2005-05-07 04:17:03 EDT
Yeah, I tried it last night and got the same problem with the new AJDT build. Is
it worth getting the latest development build of eclipse ? 
Comment 11 Matt Chapman CLA 2005-05-08 07:10:32 EDT
We're not ready with the upgrade yet. We'll comment here as soon as an AJDT
containing the upgraded AJC compiler is available. Trying a development
(non-milestone) build of Eclipse won't help, and in fact AJDT may not work with it).
Comment 12 Andrew Clement CLA 2005-05-12 05:34:14 EDT
This is fixed in AspectJ now - just waiting for build to come through with the
fix in (also, see related bug 86832).
Comment 13 Adrian Colyer CLA 2005-08-26 11:20:52 EDT
referenced build in last append was published several months ago!