On Fri, 2 Jun 2023 17:25:20 GMT, Joe Darcy <da...@openjdk.org> wrote:

>> src/java.base/share/classes/java/lang/Class.java line 1884:
>> 
>>> 1882:                     reflective=true)
>>> 1883:     public boolean isUnnamedClass() {
>>> 1884:         return isSynthetic() && PreviewFeatures.isEnabled() && 
>>> isTopLevelClass();
>> 
>> Should this include more tests such as not abstract, final, package access, 
>> in an unnamed package, etc to accurately determine it's an unnamed class?
>
> Hmm. I think adding at least a check for ACC_FINAL should be fine as it 
> should have near-zero cost on top of the existing predicate once the method 
> get compiled. (In future iterations of the JEP, the idiom to identify 
> isUnnamed will likely change.)

As mentioned in https://bugs.openjdk.org/browse/JDK-8308916 the expression 
should be `PreviewFeatures.isEnabled() && isSynthetic() &&  isTopLevelClass()` 
as `PreviewFeatures.isEnabled()` is a private static final test that will 
effectively make the full expression constant `false` when not in preview mode.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14165#discussion_r1214670484

Reply via email to