Skip to content

Commit

Permalink
Fix Android reflection issue. (#155)
Browse files Browse the repository at this point in the history
* bump version

* android modifier
  • Loading branch information
Katsute authored Apr 5, 2021
1 parent 1972e8e commit 43bd1cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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>com.kttdevelopment</groupId>
<artifactId>mal4j</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>

<profiles>
<profile>
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/com/kttdevelopment/mal4j/APICall.java
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ private static class JDK11 {
final Field methods = HttpURLConnection.class.getDeclaredField("methods");

// allow variable modification
final Field modifiers = Field.class.getDeclaredField("modifiers");
Field modifiers;
try{
modifiers = Field.class.getDeclaredField("modifiers");
}catch(final NoSuchFieldException ignored){ // android
modifiers = Field.class.getDeclaredField("accessFlags");
}
modifiers.setAccessible(true);

modifiers.setInt(methods, methods.getModifiers() & ~Modifier.FINAL);
Expand Down

0 comments on commit 43bd1cd

Please sign in to comment.