From eca219ee6433cd964f0549a114a791ca4eb9f0fa Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 29 Oct 2018 23:13:52 +0100 Subject: eliminate ‘you are using private API’ warnings by streamlining all reflective access via a class that uses sun.misc.Unsafe to arrange access. From the nqzero permit-reflect library. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/lombok/javac/java8/CommentCollectingParserFactory.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/utils/lombok/javac/java8') diff --git a/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java index 2fdaddfe..0988ce6d 100644 --- a/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java +++ b/src/utils/lombok/javac/java8/CommentCollectingParserFactory.java @@ -30,6 +30,8 @@ import com.sun.tools.javac.parser.ParserFactory; import com.sun.tools.javac.parser.ScannerFactory; import com.sun.tools.javac.util.Context; +import lombok.permit.Permit; + public class CommentCollectingParserFactory extends ParserFactory { private final Context context; @@ -66,8 +68,7 @@ public class CommentCollectingParserFactory extends ParserFactory { context.put(CommentCollectingParserFactory.key(), (ParserFactory) null); Field field; try { - field = JavaCompiler.class.getDeclaredField("parserFactory"); - field.setAccessible(true); + field = Permit.getField(JavaCompiler.class, "parserFactory"); field.set(compiler, new CommentCollectingParserFactory(context)); } catch (Exception e) { throw new IllegalStateException("Could not set comment sensitive parser in the compiler", e); -- cgit