Skip to content

Illegal reflective access operation (java 11) #36

@ccleve

Description

@ccleve

This is the same as #33 and #34. Adding a bit more information.

I'm using OpenJDK version 11.0.1 on a Mac. Using version 2.3.1 of the compiler library.

The error is:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by net.openhft.compiler.CompilerUtils (file:/Users/ccleve/.m2/repository/net/openhft/compiler/2.3.1/compiler-2.3.1.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int)
WARNING: Please consider reporting this to the maintainers of net.openhft.compiler.CompilerUtils
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

This warning is getting dumped to the console. I'm guessing that it's going to System.err.

The code I'm using is almost identical to the sample code in the Readme.

My best guess is that the problem is in CompilerUtils, these lines:

DEFINE_CLASS_METHOD = ClassLoader.class.getDeclaredMethod("defineClass", String.class, byte[].class, int.class, int.class);
DEFINE_CLASS_METHOD.setAccessible(true);

Here's a discussion of the issue: https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access

Can you subclass the classloader and get a reference to that defineClass() method, without having to do reflection?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions