Skip to content

Commit

Permalink
https://github.com/manifold-systems/manifold/issues/408
Browse files Browse the repository at this point in the history
- support latest valhalla ea jdk release
  • Loading branch information
rsmckinney committed Dec 19, 2022
1 parent c45e086 commit cc08c06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,18 @@ public class ManAttr_17 extends Attr implements ManAttr

@Override
public void visitForeachLoop( JCTree.JCEnhancedForLoop tree) {
if( JreUtil.isJava20orLater() &&
ReflectUtil.method( tree, "getDeclarationKind" ).invoke() ==
ReflectUtil.field( "com.sun.source.tree.EnhancedForLoopTree$DeclarationKind", "PATTERN" ).getStatic() )
boolean patternSupport = false;

if( JreUtil.isJava20orLater() )
{
super.visitForeachLoop( tree );
ReflectUtil.LiveMethodRef getDeclarationKind = ReflectUtil.WithNull.method( tree, "getDeclarationKind" );
patternSupport = getDeclarationKind != null;
if( patternSupport &&
getDeclarationKind.invoke() ==
ReflectUtil.field( "com.sun.source.tree.EnhancedForLoopTree$DeclarationKind", "PATTERN" ).getStatic() )
{
super.visitForeachLoop( tree );
}
}

Env<AttrContext> env = getEnv();
Expand Down Expand Up @@ -297,7 +304,7 @@ public class ManAttr_17 extends Attr implements ManAttr
}
}
}
JCTree.JCVariableDecl var = (JCTree.JCVariableDecl)(JreUtil.isJava20orLater()
JCTree.JCVariableDecl var = (JCTree.JCVariableDecl)(patternSupport
? ReflectUtil.method( tree, "getVariable" ).invoke()
: ReflectUtil.field( tree, "var" ).get());
if (var.isImplicitlyTyped()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ private boolean isJailbreakOnType()
@Override
public boolean isAccessible( Env<AttrContext> env, Type site, Symbol sym, boolean checkInner )
{
if( env.enclClass == null && JreUtil.isJava20orLater() )
{
// this check is here to fix an NPE caused by Valhalla build for java20, happens during ExtensionTransformer (env.enclClass is null)
// remove this if-stmt if/when valhalla fixes it
return sym.owner == site.tsym || sym.name == null || !"<init>".equals( sym.name.toString() );
}

boolean accessible = super.isAccessible( env, site, sym, checkInner );
if( accessible )
{
Expand Down
Binary file not shown.
Binary file not shown.

0 comments on commit cc08c06

Please sign in to comment.