mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-20 15:26:51 +00:00
Way too much
This commit is contained in:
131 files changed
+6825
-1093
No files matched your search
@@ -21,9 +21,7 @@ public final class BukkitArtifactVerifier {
|
||||
// class under one of these is a NoClassDefFoundError waiting for the right code path.
|
||||
private static final List<String> SHIPPED_PREFIXES = List.of(
|
||||
"art/arcane/iris/",
|
||||
"art/arcane/volmlib/",
|
||||
"com/google/gson/",
|
||||
"com/googlecode/concurrentlinkedhashmap/"
|
||||
"art/arcane/volmlib/"
|
||||
);
|
||||
// Relocation targets for the libraries slimjar downloads and relocates at runtime. Compiled
|
||||
// references to them are correct and the classes are correctly absent from the jar.
|
||||
@@ -38,9 +36,12 @@ public final class BukkitArtifactVerifier {
|
||||
"art/arcane/iris/util/aether/",
|
||||
"art/arcane/iris/util/guice/",
|
||||
"art/arcane/iris/util/dom4j/",
|
||||
"art/arcane/iris/util/jaxen/"
|
||||
"art/arcane/iris/util/jaxen/",
|
||||
"art/arcane/iris/util/gson/",
|
||||
"art/arcane/iris/util/lru/",
|
||||
"art/arcane/iris/util/caffeine/",
|
||||
"art/arcane/iris/util/paralithic/"
|
||||
);
|
||||
private static final String CAFFEINE_CACHE_PACKAGE = "art/arcane/iris/util/caffeine/cache/";
|
||||
private static final String MATTER_SLICE_PACKAGE = "art/arcane/volmlib/util/matter/slices/";
|
||||
private static final String LANGUAGE_DIRECTORY = "languages/";
|
||||
|
||||
@@ -48,10 +49,14 @@ public final class BukkitArtifactVerifier {
|
||||
}
|
||||
|
||||
public static void verify(File artifact, List<String> requiredEntries, int minimumLocales,
|
||||
int minimumCaffeineFactories, int minimumMatterSlices) {
|
||||
int minimumMatterSlices, long maximumArtifactBytes) {
|
||||
if (!artifact.isFile()) {
|
||||
throw new GradleException("Missing Bukkit Iris artifact: " + artifact.getAbsolutePath());
|
||||
}
|
||||
if (artifact.length() > maximumArtifactBytes) {
|
||||
throw new GradleException(artifact.getName() + " is " + artifact.length()
|
||||
+ " bytes; Bukkit artifacts must not exceed " + maximumArtifactBytes + " bytes");
|
||||
}
|
||||
|
||||
try (JarFile jar = new JarFile(artifact)) {
|
||||
for (String requiredEntry : requiredEntries) {
|
||||
@@ -65,7 +70,6 @@ public final class BukkitArtifactVerifier {
|
||||
|
||||
Set<String> shippedClasses = new LinkedHashSet<>();
|
||||
int locales = 0;
|
||||
int caffeineFactories = 0;
|
||||
int matterSlices = 0;
|
||||
Enumeration<JarEntry> entries = jar.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
@@ -84,9 +88,6 @@ public final class BukkitArtifactVerifier {
|
||||
|
||||
String internalName = name.substring(0, name.length() - ".class".length());
|
||||
shippedClasses.add(internalName);
|
||||
if (isGeneratedCaffeineFactory(internalName)) {
|
||||
caffeineFactories++;
|
||||
}
|
||||
if (internalName.startsWith(MATTER_SLICE_PACKAGE)) {
|
||||
matterSlices++;
|
||||
}
|
||||
@@ -96,14 +97,6 @@ public final class BukkitArtifactVerifier {
|
||||
throw new GradleException(artifact.getName() + " ships " + locales + " locale files; expected at least "
|
||||
+ minimumLocales);
|
||||
}
|
||||
// Caffeine picks its cache and node implementation with MethodHandles.Lookup.findClass on a
|
||||
// name built from the builder's feature flags. Nothing references these statically, so only a
|
||||
// population check can tell that an exclude or minimize() ate them.
|
||||
if (caffeineFactories < minimumCaffeineFactories) {
|
||||
throw new GradleException(artifact.getName() + " ships " + caffeineFactories
|
||||
+ " generated Caffeine cache classes; expected at least " + minimumCaffeineFactories
|
||||
+ ". Caffeine resolves these by name and cannot survive static pruning");
|
||||
}
|
||||
// Matter.read() resolves slice types from the canonical name stored in the payload.
|
||||
if (matterSlices < minimumMatterSlices) {
|
||||
throw new GradleException(artifact.getName() + " ships " + matterSlices
|
||||
@@ -148,23 +141,6 @@ public final class BukkitArtifactVerifier {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isGeneratedCaffeineFactory(String internalName) {
|
||||
if (!internalName.startsWith(CAFFEINE_CACHE_PACKAGE)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String simpleName = internalName.substring(CAFFEINE_CACHE_PACKAGE.length());
|
||||
if (simpleName.isEmpty() || simpleName.indexOf('/') >= 0) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < simpleName.length(); i++) {
|
||||
if (simpleName.charAt(i) < 'A' || simpleName.charAt(i) > 'Z') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static byte[] readEntryBytes(JarFile jar, JarEntry entry) throws IOException {
|
||||
try (InputStream input = jar.getInputStream(entry)) {
|
||||
return input.readAllBytes();
|
||||
|
||||
Reference in new issue
Block a user