-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the resource scanner in KnotClassLoader not respecting the additi…
…on order, at least for quilt's own additions. This is implemented by handling jar files ourselves in KnotClassLoader.addPath, rather than delegating directly to URLClassLoader. This fixes an issue when mods include incompatible versions of an existing library that minecraft ships, causing later crashes. This doesn't handle URLs added through addURL yet - those will always be added to the end of the search order, even if other paths are added later.
- Loading branch information
Showing
9 changed files
with
223 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/main/java/org/quiltmc/loader/impl/util/JavaVersionUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2024 QuiltMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.quiltmc.loader.impl.util; | ||
|
||
@MultiReleaseJarCandidate | ||
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL) | ||
public final class JavaVersionUtil { | ||
|
||
private static int JAVA_VERSION = -1; | ||
|
||
public static int getJavaVersion() { | ||
if (JAVA_VERSION < 0) { | ||
String jVersion = System.getProperty("java.version", ""); | ||
if (jVersion.startsWith("1.")) { | ||
// Java 8 or earlier | ||
// However loader itself requires java 8, so just force java 8 | ||
JAVA_VERSION = 8; | ||
} else { | ||
int firstDot = jVersion.indexOf('.'); | ||
if (firstDot > 0) { | ||
try { | ||
JAVA_VERSION = Integer.parseInt(jVersion.substring(0, firstDot)); | ||
} catch (NumberFormatException nfe) { | ||
throw new IllegalStateException( | ||
"Unable to convert 'java.version' (" + jVersion + ") into a version number!", nfe | ||
); | ||
} | ||
} else { | ||
throw new IllegalStateException("Unable to convert 'java.version' (" + jVersion + ") into a version number!"); | ||
} | ||
} | ||
} | ||
|
||
return JAVA_VERSION; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/org/quiltmc/loader/impl/util/MultiReleaseJarCandidate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright 2024 QuiltMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.quiltmc.loader.impl.util; | ||
|
||
import static java.lang.annotation.ElementType.TYPE; | ||
import static java.lang.annotation.RetentionPolicy.SOURCE; | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.Target; | ||
|
||
/** Indicates to future quilt maintainers that the class is intended to be converted to a Multi-Release jar after we add | ||
* support for it, and then this annotation should be deleted. | ||
* <p> | ||
* (This merely allows for this to be searched) */ | ||
@QuiltLoaderInternal(QuiltLoaderInternalType.NEW_INTERNAL) | ||
@Retention(SOURCE) | ||
@Target(TYPE) | ||
public @interface MultiReleaseJarCandidate { | ||
|
||
} |