Skip to content

Commit

Permalink
Handle Termux in InlineDelegateByteBuddyMockMaker.java
Browse files Browse the repository at this point in the history
Termux on Android can run any JVM, so we cannot rely on the vendor
here to determine if we are in Termux. Nonetheless, ByteBuddy can fail to instrument correctly
on this platform, so it is worth showing a meaninful
error message in this scenario.
  • Loading branch information
ascopes committed Oct 24, 2023
1 parent 1bca5b8 commit d8cb1ef
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,17 @@ class InlineDelegateByteBuddyMockMaker
InlineDelegateByteBuddyMockMaker() {
if (INITIALIZATION_ERROR != null) {
String detail;
if (System.getProperty("java.specification.vendor", "")

boolean isNativeAndroid = System.getProperty("java.specification.vendor", "")
.toLowerCase()
.contains("android")) {
.contains("android");

// Termux can run any JVM, such as Oracle, but may still fail to instrument the
// JVM correctly, so it is worth detecting this as well.
boolean isTermuxAndroid = System.getProperty("java.home", "")
.contains("/com.termux/");

if (isNativeAndroid || isTermuxAndroid) {
detail =
"It appears as if you are trying to run this mock maker on Android which does not support the instrumentation API.";
} else {
Expand Down

0 comments on commit d8cb1ef

Please sign in to comment.