Java default modifier in compilation

I’m currently working on modifying javac compiler to produce, in a certain way, our own Programming Language.

We want to get rid of Java’s default access modifier, making everything that has no access modifier as public.

But so far, I haven’t been successfull to find where in Java compilation code this is implemented. I could easily add into one of the declaration phases, but this is a poor solution that we wouldn’t like to have.

Any insight on this?


Looking at The class File Format, especially section 4.5 Fields and 4.6 Methods I see the following constants being defined:

ACC_PUBLIC     0x0001
ACC_PRIVATE    0x0002

However, a specific method (field) of a class may have at most one of its ACC_PRIVATE, ACC_PROTECTED, and ACC_PUBLIC flags set (JLS §8.3.1).

Since there is no ACC_DEFAULT flag and the documentation says at most one (not exactly one) I would guess that having no flags at all means default access.

Leave a Reply

Your email address will not be published. Required fields are marked *