Bug 124824 - IlegalAccessError from separate compilation
Summary: IlegalAccessError from separate compilation
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 1.5.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-23 02:20 EST by Ron Bodkin CLA
Modified: 2007-12-05 09:45 EST (History)
1 user (show)

See Also:


Attachments
Woven file that references private method (12.87 KB, application/java)
2006-01-23 02:26 EST, Ron Bodkin CLA
no flags Details
The pertypewithin aspect (55.81 KB, application/java)
2006-01-23 02:32 EST, Ron Bodkin CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ron Bodkin CLA 2006-01-23 02:20:04 EST
When I compile my pertypewithin aspect into a jar and then build another project with it on the classpath & aspectpath, I find that the woven project has references to private around advice methods in it. Here's the stack trace I'm seeing:

java.lang.IllegalAccessError: tried to access method glassbox.util.logging.api.L
ogManagement.ajc$around$glassbox_util_logging_api_LogManagement$9$ff3f21f8_aroun
dBody17$advice(Lglassbox/util/logging/api/LogManagement;Ljava/lang/String;Lorg/a
spectj/runtime/internal/AroundClosure;Lorg/aspectj/lang/JoinPoint;Lglassbox/util
/logging/api/LogManagement$HandleUninitialized;Lorg/aspectj/runtime/internal/Aro
undClosure;Lorg/aspectj/lang/JoinPoint;)Ljava/lang/Object; from class glassbox.c
onfig.GlassboxInitializationImpl
        at glassbox.config.GlassboxInitializationImpl.logInfo_aroundBody1$advice
(GlassboxInitializationImpl.java:101)
        at glassbox.config.GlassboxInitializationImpl.startUp(GlassboxInitializa
tionImpl.java:39)
        at glassbox.config.GlassboxInitializer.ajc$before$glassbox_config_Glassb
oxInitializer$1$e7e1d0be_aroundBody2(GlassboxInitializer.aj:28)

I tested this out using the standard 1.5.0 build AspectJ compiler & ant task inside ant. I'm attaching the separately compiled output from the 2 offending classes, which shows the issue with javap -c -private:
LogManagement.class (from the library aspect)
GlassboxInitializationImpl.class (from the jar being build separately with classpath & aspectpath entries)

I can sometimes see the problem with 2 simple projects in AJDT intermittently, but it seems to be unstable, as if some other random factor in the build changes the result (so it's been quite hard to create a simpler version of the problem!).
Comment 1 Ron Bodkin CLA 2006-01-23 02:26:32 EST
Created attachment 33448 [details]
Woven file that references private method
Comment 2 Ron Bodkin CLA 2006-01-23 02:32:05 EST
Created attachment 33449 [details]
The pertypewithin aspect

The basic idiom of this aspect is the following:

public aspect LogManagement pertypewithin(LogOwner+) {
    declare parents: ... implements LogOwner;

    after() returning: staticinitialization(*) {
        managedClass = thisJoinPointStaticPart.getSignature().getDeclaringType();
        initialize();
    }
    
    private void initialize() {
        if (factory != null) {
            logger = getLogger(managedClass);            
        ...
    }

    public void LogOwner.logInfo(String message) {
    }
    void around(String message) : call(void LogOwner.logInfo(String)) && args(message) {
        logger.info(message);
    }
    
}
Comment 3 Ron Bodkin CLA 2006-01-23 02:33:04 EST
From javap -private -c -l GlassboxInitializationImpl
...
   35:  invokestatic    #171; //Method glassbox/util/logging/api/LogManagement.a
jc$around$glassbox_util_logging_api_LogManagement$9$ff3f21f8_aroundBody17$advice
:(Lglassbox/util/logging/api/LogManagement;Ljava/lang/String;Lorg/aspectj/runtim
e/internal/AroundClosure;Lorg/aspectj/lang/JoinPoint;Lglassbox/util/logging/api/
LogManagement$HandleUninitialized;Lorg/aspectj/runtime/internal/AroundClosure;Lo
rg/aspectj/lang/JoinPoint;)Ljava/lang/Object;

From javap -private -c -l LogManagement
...
private static final java.lang.Object ajc$around$glassbox_util_logging_api_LogMa
nagement$9$ff3f21f8_aroundBody17$advice(glassbox.util.logging.api.LogManagement,
 java.lang.String, org.aspectj.runtime.internal.AroundClosure, org.aspectj.lang.
JoinPoint, glassbox.util.logging.api.LogManagement$HandleUninitialized, org.aspe
ctj.runtime.internal.AroundClosure, org.aspectj.lang.JoinPoint);
  Code:
   0:   aload   5
   2:   astore  8
   4:   aload_0
   5:   aload_1
   6:   aload_2
   7:   aload_3
   8:   invokestatic    #453; //Method ajc$around$glassbox_util_logging_api_LogM
anagement$9$ff3f21f8_aroundBody16:(Lglassbox/util/logging/api/LogManagement;Ljav
a/lang/String;Lorg/aspectj/runtime/internal/AroundClosure;Lorg/aspectj/lang/Join
Point;)V
   11:  aconst_null
   12:  areturn
   13:  pop
...
Comment 4 Ron Bodkin CLA 2006-01-23 14:29:00 EST
If I build with -Xnoline end-to-end, this error goes away (thanks for suggesting I test that Andy!). The code that is being generated in this case is so ugly/inefficient that I'm looking more closely to see if there's a reasonable alternative to the approach I've been using to access the field from the pertypewithin aspect... which hopefully will also work around this issue.
Comment 5 Andrew Clement CLA 2006-01-24 04:02:14 EST
Ron ... I get an error very similar to this if I mess about with the typemap strategy for looking after types.  Was this bug seen on 1.5.0 final - on HEAD or on a patched HEAD?  
Comment 6 Ron Bodkin CLA 2006-01-24 09:38:08 EST
Each one. I was able to reproduce it with 1.5.0 final.
Comment 7 Andrew Clement CLA 2007-10-23 12:05:57 EDT
take a look if time...
Comment 8 Andrew Clement CLA 2007-11-08 12:16:39 EST
interestingly this is exactly the problem I saw when mixing annotation style and code style aspects in a hierarchy.  I suspect this might be fixed now because of what I did for the other bug.
Comment 9 Andrew Clement CLA 2007-12-05 09:45:46 EST
suspected fixed after making those other changes.