Skip to content

Illegal access not detected at compile time #73525

@DaveCTurner

Description

@DaveCTurner

The fundamental problem that led to #73514 is, I believe, that the compiler assumes that things will all be in the same classloader at runtime, so doesn't need to do anything special to access protected fields from one module in another module where the package names match. This wasn't a valid assumption in this case, we had matching package names in modules in different classloaders at runtime which led to the IllegalAccessException.

We've fixed this one case manually but I believe we should take action to avoid all problems of this nature. A couple of naive ideas:

  • Can we inform the compiler that these modules won't be in the same classloader somehow?
  • Can we forbid package name clashes across classloaders? Maybe even across modules? We duplicate package names to good effect in tests, but maybe we can be stricter about production code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions