Skip to content

Commit

Permalink
https://github.com/manifold-systems/manifold/issues/627
Browse files Browse the repository at this point in the history
- one-off temporary fix, exclusive to Java 8: ensure top-level java.util.Map class loads before inner class Entry
  • Loading branch information
rsmckinney committed Oct 21, 2024
1 parent 2506acb commit a1576a3
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import com.sun.tools.javac.code.Symbol;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.comp.Annotate;
import com.sun.tools.javac.file.RelativePath;
import com.sun.tools.javac.jvm.ClassReader;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Names;
import com.sun.tools.javac.util.Name;
Expand Down Expand Up @@ -270,6 +272,7 @@ public Iterable<JavaFileObject> list( Location location, String packageName, Set
JavaFileObject file = findGeneratedFile( fqn, location, tn.getModule(), issueReporter );
if( file != null && isSourceOk( file, location ) && isCorrectModule( tn.getModule(), location, patchableFiles, file, fqn ) )
{
hackToFixJava8Issue( tn );
newList.add( file );
}
}
Expand All @@ -279,6 +282,17 @@ public Iterable<JavaFileObject> list( Location location, String packageName, Set
return list;
}

//todo: revisit
// temporary terrible hack for https://github.com/manifold-systems/manifold/issues/627
private void hackToFixJava8Issue( TypeName tn )
{
if( JreUtil.isJava8() && tn.name.equals( "java.util.Map" ) )
{
// ensure top-level Map class loads before inner class Entry, see https://github.com/manifold-systems/manifold/issues/627
Annotate.instance( _ctx ).normal( () -> ClassReader.instance( _ctx ).loadClass( Names.instance( _ctx ).fromString( tn.name ) ) );
}
}

private boolean isSourceOk( JavaFileObject file, Location location )
{
JavacPlugin javacPlugin = JavacPlugin.instance();
Expand Down

0 comments on commit a1576a3

Please sign in to comment.