Bug 475200 - AJC creates class files that cause ClassFormatError exceptions when using around advice on default methods in an interface
Summary: AJC creates class files that cause ClassFormatError exceptions when using aro...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.6   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: 1.8.8   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-17 16:57 EDT by Larry Streepy CLA
Modified: 2015-11-19 11:44 EST (History)
1 user (show)

See Also:


Attachments
Zip file to recreate issue (97.64 KB, application/x-zip-compressed)
2015-08-17 16:57 EDT, Larry Streepy CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Larry Streepy CLA 2015-08-17 16:57:11 EDT
Created attachment 255910 [details]
Zip file to recreate issue

Compiling an aspect that advises a default method (in JDK 8) with around advice results in an exception at run time.

java.lang.ClassFormatError: Method defaultMethod_aroundBody0 in class IBase has illegal modifiers: 0x1A
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
        at java.lang.Class.privateGetMethodRecursive(Unknown Source)
        at java.lang.Class.getMethod0(Unknown Source)
        at java.lang.Class.getMethod(Unknown Source)
        at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

The attached zip file contains the artifacts needed to recreate this bug.

1. Unzip
2. Invoke the 'compile.bat' script (it works on both windows and unix)
3. Invoke the 'run.bat' script (it works on both windows and unix)
4. Note the exception
Comment 1 Andrew Clement CLA 2015-11-18 18:11:09 EST
This would probably get addressed alongside the other issues (like bug 461323) when proper handling of default methods and advice is added.
Comment 2 Andrew Clement CLA 2015-11-19 11:44:32 EST
Fixed. According to specs we aren't allowed FINAL modifiers on methods in interfaces and methods must be either PUBLIC or PRIVATE (other visibilities not allowed). With those changes made when recognizing we are adding a method to an interface, your test case gets further (it still fails but I think that is due to the class path not having aspectj on it).