Skip to content

fix(app): only load the Java agent on versions that need injected Quick Play - #8333

Closed
seiftnesse wants to merge 1 commit into
modrinth:mainfrom
seiftnesse:main
Closed

seiftnesse wants to merge 1 commit into
modrinth:mainfrom
seiftnesse:main

Conversation

@seiftnesse

Copy link
Copy Markdown

the launcher currently passes -javaagent on every minecraft launch. this registers a class file transformer even on versions where it has no patch to apply, which can trigger false positives in tools that monitor JVM instrumentation.

only pass -javaagent when the minecraft version uses QuickPlayServerVersion::Injected, the launcher still puts theseus.jar on the classpath for its launch wrapper and IPC.

@github-actions

Copy link
Copy Markdown
Contributor

Pull request changelog

App

Added

Changed

Deprecated

Removed

Fixed

Security

Website

Added

Changed

Deprecated

Removed

Fixed

Security

Hosting

Added

Changed

Deprecated

Removed

Fixed

Security

@mergify

mergify Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

This pull request is closed, so it cannot be queued. Reopen it to get the box back.

@IMB11 IMB11 closed this Nov 15, 2026
@seiftnesse

Copy link
Copy Markdown
Author

hi there, @IMB11
closing this without an explanation leaves one question unanswered. what does loading the agent accomplish on a minecraft version where its only transformer returns false?
the launcher passes -javaagent on every launch. the agent registers the transformer, and only later does it check whether the version needs injected quick play. by then the jvm has already had to load the agent

parsed_arguments.push(format!(
"-javaagent:{}",
canonicalize(agent_path)
.context(crate::ErrorKind::LauncherError(format!(
"specified java agent path {} does not exist",
agent_path.display()
)))?
.to_string_lossy()
));

final Map<String, ClassTransformer> transformers = new HashMap<>();
transformers.put("net/minecraft/client/Minecraft", new MinecraftTransformer());
instrumentation.addTransformer((loader, className, classBeingRedefined, protectionDomain, classData) -> {
final ClassTransformer transformer = transformers.get(className);
if (transformer == null) {
return null;
}
final ClassReader reader = new ClassReader(classData);
final ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_MAXS);
try {
if (!transformer.transform(reader, writer)) {

@Override
protected boolean transform(ClassNode classNode) {
if (QuickPlayServerVersion.CURRENT == QuickPlayServerVersion.INJECTED) {
return addServerJoinSupport(classNode);
}
return false;
}

@flowergardn

flowergardn commented Nov 15, 2026 •

Copy link
Copy Markdown

@seiftnesse here's the explanation #7300 (comment), a similar PR was already made for this & rejected.

tldr; the java agent will be used for more than just quick play within the future, so it doesn't make sense to add additional logic only for them to remove it later.

(it's worth noting that i'm not apart of the modrinth team, so take this with a grain of salt)

@seiftnesse

seiftnesse commented Nov 15, 2026 •

Copy link
Copy Markdown
Author

@seiftnesse here's the explanation #7300 (comment), a similar PR was already made for this & rejected.

tldr; the java agent will be used for more than just quick play within the future, so it doesn't make sense to add additional logic only for them to remove it later.

(it's worth noting that i'm not apart of the modrinth team, so take this with a grain of salt)

i hadn’t seen that report before, thanks for linking it. after reading it, i think we’re running into a similar compatibility issue. their protection blocks any java agent, while ours allows the agent and only flags an active ClassFileLoadHook. i think it’s worth addressing the cases where that hook stays active even though quick play has nothing to patch.

@Prospector

Copy link
Copy Markdown
Member

why are you doing that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants