Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: replacing the system classloader prevents instrumentation #320

Merged

Conversation

gtoison
Copy link
Contributor

@gtoison gtoison commented Aug 14, 2022

mockito-inline relies on instrumentation to mock static methods, this does not seem to be possible when the classloader is overridden because it does not implement the required methods

Pull request #260 was introduced to solve the problem when the classpath is too big to fit in the shell environment.
Since Java 9 it is possible to use argument file expanded by the java process, use this native feature instead of a custom classloader
https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html#java-command-line-argument-files

Introduced ClasspathArgumentBuilder to the pre Java 9 case (use standard arguments) and post Java 9 (use an argument file)

Fixes #319

mockito-inline relies on instrumentation to mock static methods, this
does not seem to be possible when the classloader is overridden because
it does not implement the required methods
Pull request infinitest#260 was introduced to solve the problem when the classpath
is too big to fit in the shell environment.
Since Java 9 it is possible to use argument file expanded by the java
process, use this native feature instead of a custom classloader

Introduced ClasspathArgumentBuilder to the pre Java 9 case (use standard
arguments) and post Java 9 (use an argument file)
@gtoison
Copy link
Contributor Author

gtoison commented Aug 21, 2022

java.lang.StringIndexOutOfBoundsException: begin 1, end -1, length 4
	at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4604)
	at java.base/java.lang.String.substring(String.java:2707)
	at org.infinitest.environment.RuntimeEnvironment.getJavaVersion(RuntimeEnvironment.java:306)

The java version is 18 (no .) for the reference OpenJDK build

@gtoison gtoison merged commit 59e9a75 into infinitest:master Sep 24, 2022
@gtoison gtoison deleted the pr-use-arg-file-for-runner-classpath branch September 24, 2022 17:57
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.

mockito-inline breaks infinitest
1 participant