Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protected method of enum should not be included #158

Open
dovchinnikov opened this issue Dec 4, 2023 · 3 comments
Open

protected method of enum should not be included #158

dovchinnikov opened this issue Dec 4, 2023 · 3 comments
Labels

Comments

@dovchinnikov
Copy link

package cases.enums;

public enum JavaEnum {
    A {
        @Override
        public void publicAbstractMethod() {
        }

        @Override
        protected void protectedAbstractMethod() {
        }

        @Override
        void packagePrivateAbstractMethod() {
        }
    };

    public abstract void publicAbstractMethod();

    protected abstract void protectedAbstractMethod();

    abstract void packagePrivateAbstractMethod();
}

Expected:

public abstract class cases/enums/JavaEnum : java/lang/Enum {
	public static final field A Lcases/enums/JavaEnum;
	public abstract fun publicAbstractMethod ()V
	public static fun valueOf (Ljava/lang/String;)Lcases/enums/JavaEnum;
	public static fun values ()[Lcases/enums/JavaEnum;
}

Actual:

public abstract class cases/enums/JavaEnum : java/lang/Enum {
	public static final field A Lcases/enums/JavaEnum;
	protected abstract fun protectedAbstractMethod ()V
	public abstract fun publicAbstractMethod ()V
	public static fun valueOf (Ljava/lang/String;)Lcases/enums/JavaEnum;
	public static fun values ()[Lcases/enums/JavaEnum;
}
@dovchinnikov dovchinnikov changed the title protected abstract method of enum should not be included protected method of enum should not be included Dec 6, 2023
@dovchinnikov
Copy link
Author

protected members of sealed classes are probably affected by the same problem (I didn't check).

@fzhinkin
Copy link
Collaborator

Well, JVMS doesn't stop us from having a class extending j.l.Enum, so one theoretically may have a "enum" with non-final protected methods that could be overridden by some other class on the classpath. 😢

What problem you're trying to solve? Do you have a bunch of enums that change constantly?

@dovchinnikov
Copy link
Author

What problem you're trying to solve?

I'm trying to minimize the amount of entries in the dump.

Do you have a bunch of enums that change constantly?

Not really. But the same argument can be used for any other member which is hidden from dumps by BCV and which technically constitutes API from JVMS perspective, right? If the argument applies here, then it should be applicable there, and if it's not applicable there, then it should not be considered here.

@fzhinkin fzhinkin added the jvm label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants