Bug 441741 - Incorrect class modifiers in compiled class
Summary: Incorrect class modifiers in compiled class
Status: RESOLVED NOT_ECLIPSE
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.7.4   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: 1.8.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-13 18:22 EDT by Abhishek Kumar CLA
Modified: 2014-11-05 11:42 EST (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 Abhishek Kumar CLA 2014-08-13 18:22:27 EDT
In the following code, the printed modifier is "static" when compiled with javac while its empty when compiled with ajc

package org.mywork.akka.monitor;

import java.lang.reflect.Modifier;

public class MyClass {
  public static interface TestInterface{
    public void test();
  }

  public static void main(String [] args){
    TestInterface t = new TestInterface() {
      @Override
      public void test() {
        System.out.println("created...");
      }
    };

    int mods = t.getClass().getModifiers();
    System.out.println("Modifiers are: " + Modifier.toString(mods));
  }
}
Comment 1 Andrew Clement CLA 2014-08-14 15:29:32 EDT
This looks like a javac bug. From the JLS, see the last clause here:

http://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.9.5

===
An anonymous class declaration is automatically derived from a class instance creation expression by the Java compiler.

An anonymous class is never abstract (§8.1.1.1).

An anonymous class is always implicitly final (§8.1.1.2).

An anonymous class is always an inner class (§8.1.3); it is never static (§8.1.1, §8.5.1).
===
Comment 2 Abhishek Kumar CLA 2014-08-15 13:58:50 EDT
Thanks Andrew!
I have opened a defect for javac. Feel free to close this out.
Comment 3 Andrew Clement CLA 2014-11-05 11:42:04 EST
tidying up, closing this.