-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32432 from Karm/issue-31596
Adapts AWT extension to the new dynamic .so loading [JDK 17, 19, 20]
- Loading branch information
Showing
9 changed files
with
496 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...main/java/io/quarkus/deployment/builditem/nativeimage/JniRuntimeAccessFieldBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.quarkus.deployment.builditem.nativeimage; | ||
|
||
import java.lang.reflect.Field; | ||
|
||
import org.jboss.jandex.FieldInfo; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* JNI access registration fine-grained to single fields | ||
* for a given class. | ||
*/ | ||
public final class JniRuntimeAccessFieldBuildItem extends MultiBuildItem { | ||
|
||
final String declaringClass; | ||
final String name; | ||
|
||
public JniRuntimeAccessFieldBuildItem(FieldInfo field) { | ||
this.name = field.name(); | ||
this.declaringClass = field.declaringClass().name().toString(); | ||
} | ||
|
||
public JniRuntimeAccessFieldBuildItem(Field field) { | ||
this.name = field.getName(); | ||
this.declaringClass = field.getDeclaringClass().getName(); | ||
} | ||
|
||
public JniRuntimeAccessFieldBuildItem(String declaringClass, String name) { | ||
this.name = name; | ||
this.declaringClass = declaringClass; | ||
} | ||
|
||
public String getDeclaringClass() { | ||
return declaringClass; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...ain/java/io/quarkus/deployment/builditem/nativeimage/JniRuntimeAccessMethodBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package io.quarkus.deployment.builditem.nativeimage; | ||
|
||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.Objects; | ||
|
||
import org.jboss.jandex.MethodInfo; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
/** | ||
* JNI access registration fine-grained to single methods | ||
* for a given class. | ||
*/ | ||
public final class JniRuntimeAccessMethodBuildItem extends MultiBuildItem { | ||
|
||
final String declaringClass; | ||
final String name; | ||
final String[] params; | ||
|
||
public JniRuntimeAccessMethodBuildItem(MethodInfo methodInfo) { | ||
String[] params = new String[methodInfo.parametersCount()]; | ||
for (int i = 0; i < params.length; ++i) { | ||
params[i] = methodInfo.parameterType(i).name().toString(); | ||
} | ||
this.name = methodInfo.name(); | ||
this.params = params; | ||
this.declaringClass = methodInfo.declaringClass().name().toString(); | ||
} | ||
|
||
public JniRuntimeAccessMethodBuildItem(Method method) { | ||
this.params = new String[method.getParameterCount()]; | ||
if (method.getParameterCount() > 0) { | ||
Class<?>[] parameterTypes = method.getParameterTypes(); | ||
for (int i = 0; i < params.length; ++i) { | ||
params[i] = parameterTypes[i].getName(); | ||
} | ||
} | ||
this.name = method.getName(); | ||
this.declaringClass = method.getDeclaringClass().getName(); | ||
} | ||
|
||
public JniRuntimeAccessMethodBuildItem(String declaringClass, String name, String... params) { | ||
this.declaringClass = declaringClass; | ||
this.name = name; | ||
this.params = params; | ||
} | ||
|
||
public JniRuntimeAccessMethodBuildItem(String declaringClass, String name, Class<?>... params) { | ||
this.declaringClass = declaringClass; | ||
this.name = name; | ||
this.params = new String[params.length]; | ||
for (int i = 0; i < params.length; ++i) { | ||
this.params[i] = params[i].getName(); | ||
} | ||
} | ||
|
||
public JniRuntimeAccessMethodBuildItem(String declaringClass, String name) { | ||
this.declaringClass = declaringClass; | ||
this.name = name; | ||
this.params = new String[0]; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String[] getParams() { | ||
return params; | ||
} | ||
|
||
public String getDeclaringClass() { | ||
return declaringClass; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) | ||
return true; | ||
if (o == null || getClass() != o.getClass()) | ||
return false; | ||
JniRuntimeAccessMethodBuildItem that = (JniRuntimeAccessMethodBuildItem) o; | ||
return Objects.equals(declaringClass, that.declaringClass) && | ||
Objects.equals(name, that.name) && | ||
Arrays.equals(params, that.params); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Objects.hash(declaringClass, name); | ||
result = 31 * result + Arrays.hashCode(params); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.