@@ -3007,7 +3007,11 @@ public static Source ofTypes(
30073007 }
30083008 for (Map .Entry <ClassFileVersion , Map <TypeDescription , byte []>> versioned : versionedBinaryRepresentations .entrySet ()) {
30093009 for (Map .Entry <TypeDescription , byte []> entry : versioned .getValue ().entrySet ()) {
3010- storage .put (ClassFileLocator .META_INF_VERSIONS + versioned .getKey ().getJavaVersion () + "/" + entry .getKey ().getInternalName () + ClassFileLocator .CLASS_FILE_EXTENSION , entry .getValue ());
3010+ storage .put (ClassFileLocator .META_INF_VERSIONS
3011+ + versioned .getKey ().getJavaVersion ()
3012+ + "/"
3013+ + entry .getKey ().getInternalName ()
3014+ + ClassFileLocator .CLASS_FILE_EXTENSION , entry .getValue ());
30113015 }
30123016 }
30133017 return new InMemory (storage );
@@ -3339,7 +3343,8 @@ interface Sink extends Closeable {
33393343 /**
33403344 * Stores the supplied binary representation of types in this sink.
33413345 *
3342- * @param version The version of the multi-release jar file.
3346+ * @param version The version of the multi-release jar file, which should at least be {@code 8} as previous
3347+ * versions are not recognized by regular class loaders.
33433348 * @param binaryRepresentations The binary representations to store.
33443349 * @throws IOException If an I/O error occurs.
33453350 */
@@ -4890,19 +4895,28 @@ public Summary apply(Source source, Target target, List<? extends Plugin.Factory
48904895 && !name .endsWith (PACKAGE_INFO )
48914896 && !name .endsWith (MODULE_INFO )) {
48924897 try {
4893- String typeName = name .substring (name .startsWith (ClassFileLocator .META_INF_VERSIONS )
4894- ? name .indexOf ('/' , ClassFileLocator .META_INF_VERSIONS .length ()) + 1
4895- : 0 , name .length () - ClassFileLocator .CLASS_FILE_EXTENSION .length ()).replace ('/' , '.' );
4896- dispatcher .accept (new Preprocessor (element ,
4897- typeName ,
4898- name .startsWith (ClassFileLocator .META_INF_VERSIONS )
4899- ? Integer .parseInt (name .substring (ClassFileLocator .META_INF_VERSIONS .length (), name .indexOf ('/' , ClassFileLocator .META_INF_VERSIONS .length ())))
4900- : 0 ,
4901- new SourceEntryPrependingClassFileLocator (typeName , element , classFileLocator ),
4902- typePool ,
4903- listener ,
4904- plugins ,
4905- preprocessors ), preprocessors .isEmpty ());
4898+ int version = name .startsWith (ClassFileLocator .META_INF_VERSIONS )
4899+ ? Math .max (7 , Integer .parseInt (name .substring (ClassFileLocator .META_INF_VERSIONS .length (), name .indexOf ('/' , ClassFileLocator .META_INF_VERSIONS .length ()))))
4900+ : 0 ;
4901+ if (version == 0 || version > 7
4902+ && classFileVersion != null
4903+ && classFileVersion .isAtLeast (ClassFileVersion .JAVA_V9 )
4904+ && version <= classFileVersion .getJavaVersion ()) {
4905+ String typeName = name .substring (name .startsWith (ClassFileLocator .META_INF_VERSIONS )
4906+ ? name .indexOf ('/' , ClassFileLocator .META_INF_VERSIONS .length ()) + 1
4907+ : 0 , name .length () - ClassFileLocator .CLASS_FILE_EXTENSION .length ()).replace ('/' , '.' );
4908+ dispatcher .accept (new Preprocessor (element ,
4909+ typeName ,
4910+ version ,
4911+ new SourceEntryPrependingClassFileLocator (typeName , element , classFileLocator ),
4912+ typePool ,
4913+ listener ,
4914+ plugins ,
4915+ preprocessors ), preprocessors .isEmpty ());
4916+ } else {
4917+ listener .onResource (name );
4918+ sink .retain (element );
4919+ }
49064920 } catch (NumberFormatException ignored ) {
49074921 listener .onResource (name );
49084922 sink .retain (element );
0 commit comments