JDK-8261532 : Archived superinterface class cannot be accessed
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-02-10
  • Updated: 2021-03-11
  • Resolved: 2021-03-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b13Fixed
Related Reports
Relates :  
Description
$ unzip pkg.zip
$ java -XX:ArchiveClassesAtExit=foo.jsa -cp pkg.jar pkg.Foo
$ java -XX:SharedArchiveFile=foo.jsa -cp pkg.jar pkg.Foo Baz
pkg.Bar
Exception in thread "main" java.lang.IllegalAccessError: class pkg.Baz cannot access its superinterface pkg.Bar (pkg.Baz and pkg.Bar are in unnamed module of loader 'app')
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1010)
	at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)

The bug seems to happen after JDK-8249262
Comments
Changeset: 02fbcb52 Author: Calvin Cheung <ccheung@openjdk.org> Date: 2021-03-04 19:57:48 +0000 URL: https://git.openjdk.java.net/jdk/commit/02fbcb52
04-03-2021

During dynamic dump, the _package_entry could be set to NULL in the following: void InstanceKlass::init_shared_package_entry() { #if !INCLUDE_CDS_JAVA_HEAP _package_entry = NULL; #else if (!MetaspaceShared::use_full_module_graph()) { _package_entry = NULL; } else if (DynamicDumpSharedSpaces) { if (!MetaspaceShared::is_in_shared_metaspace(_package_entry)) { _package_entry = NULL; <<<<< here } } Therefore, during runtime, in InstanceKlass::set_package(), we can't just return with the following condition: if (is_shared() && _package_entry == pkg_entry) { <<< bug here if (MetaspaceShared::use_full_module_graph()) { // we can use the saved package return; } The first "if" condition should also check for non-NULL _package_entry so that _package_entry for a class loaded from the dynamic archive will be setup correctly. Suggested change to the "if" condition: if (is_shared() && _package_entry != NULL && _package_entry == pkg_entry) {
02-03-2021

ILW = MLM = P4
16-02-2021