Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolykt committed Apr 3, 2021
1 parent f81dfaa commit 7bf9324
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 123 deletions.
24 changes: 10 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ repositories {
name = 'Geolykt'
url = 'https://geolykt.de/maven/'
}
maven {
name 'fabric'
url 'https://maven.fabricmc.net/'
}
}

dependencies {
Expand All @@ -40,18 +36,18 @@ dependencies {
api 'com.google.guava:guava:21.0'

// Code modification
api "org.ow2.asm:asm:9.0"
api "org.ow2.asm:asm-tree:9.0"
api "org.ow2.asm:asm-analysis:9.0"
api "org.ow2.asm:asm-util:9.0"
api "org.ow2.asm:asm-commons:9.0"
api "org.spongepowered:mixin:0.8.1"
api "net.fabricmc:access-widener:1.0.0"
api "org.ow2.asm:asm:9.1"
api "org.ow2.asm:asm-tree:9.1"
api "org.ow2.asm:asm-analysis:9.1"
api "org.ow2.asm:asm-util:9.1"
api "org.ow2.asm:asm-commons:9.1"
api "org.spongepowered:mixin:0.8.3-SNAPSHOT"
api "de.geolykt.starloader:access-widener:2.0.0"

// Logging
api 'org.apache.logging.log4j:log4j-core:2.14.0'
// SLF4J is the base logger for most libraries, therefore we can hook it into log4j2.
api 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.0'
// SLF4J is the base logger for most libraries, therefore we should hook it into log4j2.
api 'org.apache.logging.log4j:log4j-core:2.14.1'
api 'org.apache.logging.log4j:log4j-slf4j-impl:2.14.1'

api("com.heretere.hch:hch-json:1.0.0") { // config handler
exclude group: 'com.google.code.gson' // We already import gson manually
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ final class DiscoveredExtension {
private String[] codeModifiers;
private String[] dependencies;
private String accessWidener;
private String enumWidener;
private ExternalDependencies externalDependencies;
transient List<URL> files = new LinkedList<>();
transient LoadStatus loadStatus = LoadStatus.LOAD_SUCCESS;
Expand Down Expand Up @@ -64,11 +63,6 @@ public String getAccessWidener() {
return accessWidener;
}

@NotNull
public String getEnumWidener() {
return enumWidener;
}

@NotNull
public String[] getDependencies() {
return dependencies;
Expand Down Expand Up @@ -133,9 +127,6 @@ static void verifyIntegrity(@NotNull DiscoveredExtension extension) {
if (extension.accessWidener == null) {
extension.accessWidener = "";
}
if (extension.enumWidener == null) {
extension.enumWidener = "";
}
if (extension.authors == null) {
extension.authors = new String[0];
}
Expand Down
51 changes: 0 additions & 51 deletions src/main/java/de/geolykt/starloader/mod/ExtensionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.gson.Gson;

import de.geolykt.starloader.transformers.EnumWidenerTransformer;
import net.fabricmc.accesswidener.AccessWidener;
import net.fabricmc.accesswidener.AccessWidenerReader;
import net.minestom.server.extras.selfmodification.MinestomExtensionClassLoader;
Expand Down Expand Up @@ -39,9 +38,7 @@ public class ExtensionManager {
private final File extensionFolder = new File("extensions");
private final File dependenciesFolder = new File(extensionFolder, ".libs");
private final AccessWidener accessWidener = new AccessWidener();
private final ArrayList<String> enumWidener = new ArrayList<>();
private boolean loaded;
private boolean loadedEnumWidener = false;

private final List<Extension> extensionList = new CopyOnWriteArrayList<>();
private final List<Extension> immutableExtensionListView = Collections.unmodifiableList(extensionList);
Expand Down Expand Up @@ -113,7 +110,6 @@ public void loadExtensions() {
// remove invalid extensions
discoveredExtensions.removeIf(ext -> ext.loadStatus != DiscoveredExtension.LoadStatus.LOAD_SUCCESS);
setupAccessWideners(discoveredExtensions);
setupEnumWideners(discoveredExtensions); // Enum wideners come before mixins as mixins can mix up some things
setupCodeModifiers(discoveredExtensions);

for (DiscoveredExtension discoveredExtension : discoveredExtensions) {
Expand Down Expand Up @@ -460,48 +456,6 @@ private void setupAccessWideners(List<DiscoveredExtension> extensionsToLoad) {
}
}

private void setupEnumWideners(List<DiscoveredExtension> extensionsToLoad) {
for (DiscoveredExtension extension : extensionsToLoad) {
if (extension.getEnumWidener().equals("")) {
continue;
}

try {
JarFile jar = new JarFile(extension.getOriginalJar(), false);
JarEntry entry = jar.getJarEntry(extension.getEnumWidener());
if (entry == null) {
LOGGER.warn("Unable to find the enum widener file for extension {}!", extension.getName());
jar.close();
continue;
}
Reader r = new InputStreamReader(jar.getInputStream(entry));
try (BufferedReader br = new BufferedReader(r)) {
String line = br.readLine();
while (line != null) {
String content = line.split("#")[0].trim();
if (content.length() == 0) {
return;
}
enumWidener.add(content);
line = br.readLine();
}
}
r.close();
jar.close();
} catch (IOException e) {
e.printStackTrace();
LOGGER.warn("Failed to set up an access widener for {}!", extension.getName());
}
}
if (!loadedEnumWidener && !enumWidener.isEmpty()) { // make sure it isn't registered when there is no need to or when the modifier is already added
loadedEnumWidener = true;
ClassLoader cl = getClass().getClassLoader();
if (cl instanceof MinestomRootClassLoader) {
((MinestomRootClassLoader) cl).addCodeModifier(new EnumWidenerTransformer(enumWidener));
}
}
}

/**
* Extensions are allowed to apply Mixin transformers, the magic happens here.
*/
Expand Down Expand Up @@ -698,9 +652,4 @@ public void shutdown() {
public AccessWidener getAccessWidener() {
return accessWidener;
}

@NotNull
public ArrayList<String> getWidenedEnums() {
return enumWidener;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public Class<?> loadClassAsChild(String name, boolean resolve) throws ClassNotFo
}

@Override
@Deprecated(forRemoval = false, since = "9")
protected void finalize() throws Throwable {
super.finalize();
System.err.println("Class loader "+getName()+" finalized.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class MinestomRootClassLoader extends HierarchyClassLoader {
add("org.jboss.shrinkwrap.resolver");
add("kotlin");
add("net.fabricmc.accesswidener"); // this package will throw a linkage error too when loaded otherwise
add("de.geolykt.starloader.transformers");
}
};

Expand Down

0 comments on commit 7bf9324

Please sign in to comment.