Skip to content

Commit

Permalink
https://github.com/manifold-systems/manifold/issues/613
Browse files Browse the repository at this point in the history
- account for javac `--release` option with `@Expires` usage
  • Loading branch information
rsmckinney committed Aug 5, 2024
1 parent 38b7fb2 commit 521d27b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Options;
import manifold.internal.javac.JavacPlugin;
import manifold.util.JreUtil;

import javax.lang.model.SourceVersion;

Expand All @@ -35,4 +37,17 @@ public static int getSourceNumber()
{
return getSourceVersion().ordinal();
}

public static int getReleaseNumber()
{
String release = Options.instance( JavacPlugin.instance().getContext() ).get( "--release" );
try
{
return Integer.parseInt( release );
}
catch( NumberFormatException e )
{
return JreUtil.JAVA_VERSION;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import manifold.api.gen.*;
import manifold.api.host.IModule;
import manifold.api.util.JavacUtil;
import manifold.rt.api.util.ManEscapeUtil;
import manifold.util.JreUtil;
import manifold.util.ReflectUtil;
Expand Down Expand Up @@ -976,7 +977,7 @@ private boolean isExpired( Symbol symbol )
{
for( Pair<Symbol.MethodSymbol, Attribute> value: annotationMirror.values )
{
return JreUtil.JAVA_VERSION >= (int)value.snd.getValue();
return JavacUtil.getReleaseNumber() >= (int)value.snd.getValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import manifold.api.host.IModule;
import manifold.api.type.ITypeManifold;
import manifold.api.util.JavacDiagnostic;
import manifold.api.util.JavacUtil;
import manifold.ext.rt.ExtensionMethod;
import manifold.ext.rt.ForwardingExtensionMethod;
import manifold.ext.rt.api.Expires;
Expand Down Expand Up @@ -649,7 +650,7 @@ private boolean isExtensionMethod( AbstractSrcMethod method, SrcClass extendedTy

SrcAnnotationExpression expires = method.getAnnotation( Expires.class );
if( expires != null &&
JreUtil.JAVA_VERSION >= Integer.parseInt( expires.getArgument( "value" ).getValue().toString() ) )
JavacUtil.getReleaseNumber() >= Integer.parseInt( expires.getArgument( "value" ).getValue().toString() ) )
{
// on or past the method's expiration jdk
return false;
Expand Down

0 comments on commit 521d27b

Please sign in to comment.