Skip to content

Commit

Permalink
Allow the -javaagent argument on Java 8, even though it does nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
DenWav committed Dec 19, 2020
1 parent e344bca commit 2d4c7b3
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assembly/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.papermc</groupId>
<artifactId>paperclip-assembly</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion java8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.papermc</groupId>
<artifactId>paperclip-java8</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
5 changes: 5 additions & 0 deletions java8/src/main/java/io/papermc/paperclip/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package io.papermc.paperclip;

import java.lang.instrument.Instrumentation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
Expand All @@ -18,6 +19,10 @@

public final class Agent {

public static void premain(final String agentArgs, final Instrumentation inst) {
// noop - if this is called on Java 8 we just ignore it
}

static void addToClassPath(final Path paperJar) {
final ClassLoader loader = ClassLoader.getSystemClassLoader();
if (!(loader instanceof URLClassLoader)) {
Expand Down
2 changes: 1 addition & 1 deletion java9/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.papermc</groupId>
<artifactId>paperclip-java9</artifactId>
<version>1.3-SNAPSHOT</version>
<version>1.4.1-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
Expand Down
4 changes: 3 additions & 1 deletion java9/src/main/java/io/papermc/paperclip/Agent.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public static void agentmain(final String agentArgs, final Instrumentation inst)
@SuppressWarnings("unused") // This class replaces the Agent class in the java8 module when run on Java9+
static void addToClassPath(final Path paperJar) {
if (inst == null) {
System.err.println("Unable to retrieve Instrumentation API to add Paper jar to ClassPath");
System.err.println("Unable to retrieve Instrumentation API to add Paper jar to classpath. If you're " +
"running paperclip without -jar then you also need to include the -javaagent:<paperclip_jar> JVM " +
"command line option.");
System.exit(1);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.papermc</groupId>
<artifactId>paperclip</artifactId>
<version>1.4-SNAPSHOT</version>
<version>1.4.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Paperclip</name>
Expand Down

0 comments on commit 2d4c7b3

Please sign in to comment.