Bug 87927 - NPE in PerFromSuper.concretize method
Summary: NPE in PerFromSuper.concretize method
Status: RESOLVED WORKSFORME
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-14 09:45 EST by Bo Yi CLA
Modified: 2005-10-28 06:19 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bo Yi CLA 2005-03-14 09:45:38 EST
I have the following advice

	Object around() : callingThirdParty() 
		&& ! call(java.lang.Throwable+.*(..))  // cause  trouble
		&& ! call(java.util.logging..*.*(..))  // cause  trouble
		&& ! call(String toString())
		&& ! call(void log(..)) {  ... }

I am not sure whether the syntax is allowed, but it should not throw exception 
is a syntax error is detected.

If I removed both troublsome lines, the compilation would be successful. Either 
of the lines will cause the following exception. Checked bug rebort database 
and found one bug from the same line of code, but the fix comment seems totally 
different.

compiling D:\WebSphere\AppServer60\aspects\trace\TraceMyClasses.java

ABORT

Exception thrown from AspectJ 1.2.1

This might be logged as a bug already -- find current bugs at
  http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler

Bugs for exceptions thrown have titles File:line from the top stack,
e.g., "SomeFile.java:243"

If you don't find the exception below in a bug, please add a new bug
at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ
To make the bug a priority, please include a test program
that can reproduce this exception.
null
java.lang.NullPointerException
        at org.aspectj.weaver.patterns.PerFromSuper.concretize(PerFromSuper.ja
:59)
        at org.aspectj.weaver.CrosscuttingMembers.setPerClause(CrosscuttingMem
rs.java:207)
        at org.aspectj.weaver.ResolvedTypeX.collectCrosscuttingMembers(Resolve
ypeX.java:329)
        at org.aspectj.weaver.CrosscuttingMembersSet.addOrReplaceAspect(Crossc
tingMembersSet.java:57)
        at org.aspectj.weaver.bcel.BcelWeaver.prepareForWeave(BcelWeaver.java:
3)
        at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.weave(AjCompil
Adapter.java:226)
        at org.aspectj.ajdt.internal.compiler.AjCompilerAdapter.afterCompiling
jCompilerAdapter.java:118)
        at org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.compile(Comp
er.java:383)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.performCompil
ion(AjBuildManager.java:680)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.doBuild(AjBui
Manager.java:168)
        at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild(Aj
ildManager.java:102)
        at org.aspectj.ajdt.ajc.AjdtCommand.doCommand(AjdtCommand.java:109)
        at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:60)
        at org.aspectj.tools.ajc.Main.run(Main.java:291)
        at org.aspectj.tools.ajc.Main.runMain(Main.java:227)
        at org.aspectj.tools.ajc.Main.main(Main.java:80)

Dumping to ajcore.20050311.233710.655.txt

1 fail|abort
Comment 1 Adrian Colyer CLA 2005-03-14 12:30:15 EST
This is a definite bug, you should never see an NPE coming out of the compiler.
If you change the advice to:

Object around() : callingThirdParty() 
		&& ! call(* java.lang.Throwable+.*(..))  // cause  trouble
		&& ! call(* java.util.logging..*.*(..))  // cause  trouble
		&& ! call(String toString())
		&& ! call(void log(..)) {  ... }

does your program now compile correctly or do you see the same / similar error?
 (There is a syntax error in your pointcut expression - you need to specify a
return type for the first two calls, but that should give you a compilation
error, not an NPE...)
Comment 2 Adrian Colyer CLA 2005-03-23 09:57:12 EST
scheduling for investigation in aj5m3
Comment 3 Andrew Clement CLA 2005-05-09 10:11:47 EDT
Hmmm.
I created this test program:

aspect C {

        Object around() : callingThirdParty()
                && ! call(java.lang.Throwable+.*(..))  // cause  trouble
                && ! call(java.util.logging..*.*(..))  // cause  trouble
                && ! call(String toString())
                && ! call(void log(..)) {   }

  public void log() { }
}

and under 1.2/1.2.1/1.5.0M2 I always got the kind of error you would normally
expect for getting the call sig wrong:

K:\ws\aspectj_ws\tests\bugs150\PR87297.aj:4 [error] Syntax error on token ".",
"expected name pattern" expected
&& ! call(java.lang.Throwable+.*(..))  // cause  trouble

Given the location of the NPE, I think there is also another part of the aspect
involved in the failure - did you have a per clause defined for it?

The failure appears to happen when there is a problem with the perclause - I can
imagine a situation where the syntax error for your pointcut occurs and it
leaves the perclause in a funny state which then fails NPE - but I can't imagine
what kind of perclause could be the problem?  I don't want to put some guards in
for the NPE without knowing the failing per clause that causes the problem.
Comment 4 Andrew Clement CLA 2005-08-24 10:07:29 EDT
still waiting to hear on the perclause...
Comment 5 Adrian Colyer CLA 2005-10-28 06:19:06 EDT
closing this bug out for now as per andy's last two comments. Please reopen with reproduceable test case 
if it is still an issue for you.... thanks, A.