Skip to content

Conversation

zrlk
Copy link
Contributor

@zrlk zrlk commented Apr 19, 2024

This PR emits name nodes in the csymbol language for Java native methods according to the JNI spec at
https://docs.oracle.com/en/java/javase/11/docs/specs/jni/design.html .

Doing this for the JVM indexer is left to future work, mainly thanks to an annoying detail that makes it necessary to know whether a method has multiple native overloads to determine if it will be given a symbol without arguments.

This PR emits name nodes in the csymbol language for Java
native methods according to the JNI spec at
https://docs.oracle.com/en/java/javase/11/docs/specs/jni/design.html .

Doing this for the JVM indexer is left to future work, mainly
thanks to an annoying detail that makes it necessary to know whether
a method has multiple native overloads to determine if it will be
given a symbol without arguments.
@zrlk zrlk requested a review from a team April 19, 2024 23:31
@@ -111,6 +144,61 @@ private static String methodSignature(
return parentClass.qualifiedName + "." + methodName + methodType;
}

private static String jniMangle(String s) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this or an equivalent not provided by the JDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is implemented in com/sun/tools/javac/jvm/JNIWriter.java, which doesn't expose any sort of external API (the methods are package visible).

@zrlk zrlk merged commit de55eb3 into kythe:master Apr 22, 2024
@zrlk zrlk deleted the java-native-methods branch April 22, 2024 19:07
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