Skip to content

TS-46443 Locate the agent's JAR without relying on its code source - #979

Merged
stahlbauer merged 1 commit into
masterfrom
ts/46443_agent_jar_location
Sep 24, 2026
Merged

stahlbauer merged 1 commit into
masterfrom
ts/46443_agent_jar_location

Conversation

@sewe

@sewe sewe commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Addresses issue TS-46443

The profiler read its installation directory from its own CodeSource to look for a
teamscale.properties file next to the agent's JAR. A class loader that records no location, or no
local file, for that JAR made premain throw, and a premain that throws aborts the JVM during
startup. IntelliJ's PathClassLoader is one such class loader, so the profiler could not be
attached to the test JVM of an IntelliJ plug-in at all.

It now falls back to the JAR named by the -javaagent argument, which premain already reads for
its warning about other agents.

Verified end to end outside this repository: with this change the Teamscale Gradle plugin records
test-wise coverage for our own IntelliJ plug-in, 314 tests with coverage. That path additionally
needs the fix for TS-48018, which follows in a separate pull request.

  • Changes are tested adequately
  • Teamscale documentation updated in case of user-visible changes
  • CHANGELOG.md updated
  • Present new features in N&N
  • TGA Tutorial updated
  • TIA Tutorial updated

The profiler read its installation directory from its own CodeSource to look
for a teamscale.properties file next to the agent's JAR. IntelliJ's
PathClassLoader records no location for a JAR appended for instrumentation, so
CodeSource.getLocation() returned null and the resulting NullPointerException
escaped premain, which aborts the JVM during startup. A location that names
something other than a local file, such as a JAR nested in another one, ends in
the same abort, as Paths.get rejects every scheme but file.

Fall back to the JAR named by the -javaagent argument, which premain already
reads for its warning about other agents.
@sewe sewe self-assigned this Sep 23, 2026
@stahlbauer
stahlbauer merged commit 9da9a7b into master Sep 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants