Hey Daniel.

The fix you've done doesn't seem to take into account that some arrays should 
be inaccessible.
I assume that's the case and that the following test should be added:

assertFalse(_JavaVersions.JAVA_9.isAccessibleAccordingToModuleExports(getSomeInternalClass().arrayType()));


Here's one idea for a fix:

Package accessedPackage = accessedClass.getPackage(); // null for arrays and 
primitives!
if (accessedPackage == null) {
        Class<?> componentClass = accessedClass.getComponentType(); // null for 
non-arrays!
        if (componentClass != null) {
                accessedPackage = componentClass.getPackage();
        }
}
if (accessedPackage == null) {
        return true;
}


P.S.
That Class.arrayType() method was added in Java12, but if that's a problem then 
it's implementation is a one liner anyway:

public Class<?> arrayType() {
    return Array.newInstance(this, 0).getClass();
}

P.P.S
Class has a componentType() method that was added in 12,
but there already existed getComponentType() which is identical.


Cheers,
Simon





On Thursday, 28 March 2024 at 00:40:46 GMT, Daniel Dekany 
<daniel.dek...@gmail.com> wrote: 


Yes, thanks for running into that! That was a bug with new code that
checks if we have access to a class according to Java 9+ modules. It
was because I didn't realize that for the class of an array,
Class.getPackage() returns null. The fixed version was pushed to the
Maven snapshot repo already.

Reply via email to