Open jiekang opened 3 years ago
@jiekang thanks for reporting the bug We will look into it
Thanks. To be clear, I'm curious if this is intentional or not, but I'd also prefer that behavior was the same between Java and native image.
@jiekang We have added this in our feature list and will be fixed in future releases, please do check out https://www.graalvm.org/ to get update on future releases.
@mcraj017 Okay sounds good; I appreciate the communication!
The reason there is a difference between native and Java mode is that this Native Image substitution causes classes loaded by the bootstrap class loader to construct new packages when Class#getPackage()
is called. In regular Java, new package instances are not created.
So in @jiekang's example, 2 independent objects are created and compared. Thus not equal.
Package p1 = c.getPackage();
Package p2 = c.getPackage();
This is related to another open issue here: https://github.com/oracle/graal/issues/8796
Describe the issue
The default ClassLoader class getPackage is equal in Java but not equal in Native Image. Is this an expected result?
Steps to reproduce the issue
Describe GraalVM and your environment:
4d56547a080c7f97fef5b8e6d19827ed66a0c398
labsjdk-ce-11.0.9-jvmci-20.3-b06