RFR: 7903633: Make source mode the default, and drop compiled mode [v2]

Jorn Vernee jvernee at openjdk.org
Fri Jan 19 12:42:53 UTC 2024


On Fri, 19 Jan 2024 10:32:23 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Simplify Writer + Remove JavaFileObject dependency
>
> Regarding NameMangler - we also have these methods:
> * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Character.html#isJavaIdentifierStart(char)
> * https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/Character.html#isJavaIdentifierPart(char)
> 
> This is what the method in SourceVersion uses. Since NameMangler seems to copy other code from the javac sources, perhaps we can copy that predicate too, and drop the dependency - that method has not been updated in ages.
> 
> 
> public static boolean isIdentifier(CharSequence name) {
>         String id = name.toString();
> 
>         if (id.length() == 0) {
>             return false;
>         }
>         int cp = id.codePointAt(0);
>         if (!Character.isJavaIdentifierStart(cp)) {
>             return false;
>         }
>         for (int i = Character.charCount(cp);
>                 i < id.length();
>                 i += Character.charCount(cp)) {
>             cp = id.codePointAt(i);
>             if (!Character.isJavaIdentifierPart(cp)) {
>                 return false;
>             }
>         }
>         return true;
>     }

@mcimadamore Note that besides `isIdentifier`, we also use `isKeyword` from SourceVersion. We could copy that as well, but it seems more likely to change.

-------------

PR Comment: https://git.openjdk.org/jextract/pull/186#issuecomment-1900343840


More information about the jextract-dev mailing list