Java Decompiler generates abstract enum

I used JD to decompile a .jar executable file. I encountered an abstract enum code which does not compile:

private static abstract enum Type {
    ANONYMOUS(4) , STANDARD(0);

    private final int start;

    private Type(int start) {
        this.start = start;
    }

    public int getStart() {
        return this.start;
    }

    public abstract void insertHeader(Sheet paramSheet,
            SummaryCodec.Style paramStyle, float paramFloat1,
            float paramFloat2);

    public abstract String insertCommentSource(String paramString);

    public abstract int insertBreakdown(Sheet paramSheet,
            SummaryCodec.Style paramStyle, String paramString,
            Entry paramEntry, int paramInt);

    public abstract void collateComment(List<String> paramList,
            String paramString);
}

Compiler errors: Illegal modifier for the member enum Type; only public, protected, private & static are permitted The enum constant ANONYMOUS must implement the abstract method collateComment(List, String) The enum constant STANDARD must implement the abstract method collateComment(List, String)

Where can I find the code for the implementations of the abstract methods for ANONYMOUS, and STANDARD? I can't find it in the same file. Tried looking for it in other files.


JD apparently has a bug decompiling enums with abstract methods; you shouldn't get that class signature (which does correspond to the bytecode but doesn't take into account the magic the Java compiler does with enum ).

Each enum instance that overrides a method declared gets its own .class file, just as anonymous classes do. Look for files named like Type$1.class in the same directory as Type.class .


Making an abstract enum does not make sense as you will definitely have instances. In fact ANONYMOUS and STANDARD are instances of the enum Type which also why the compiler tells you that you have to implement the abstract method insertCommentSource.

I have no idea why the decompiler produced this code but i am very sure that this does not conform to Java language specifications! Also it does not make sense ;)

链接地址: http://www.djcxy.com/p/96756.html

上一篇: Java抽象类不寻常的行为

下一篇: Java Decompiler生成抽象枚举