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/core/lombok/javac/CompilerMessageSuppressor.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/core/lombok/javac/CompilerMessageSuppressor.java') diff --git a/src/core/lombok/javac/CompilerMessageSuppressor.java b/src/core/lombok/javac/CompilerMessageSuppressor.java index 391ec64a..02dc6c26 100644 --- a/src/core/lombok/javac/CompilerMessageSuppressor.java +++ b/src/core/lombok/javac/CompilerMessageSuppressor.java @@ -39,6 +39,8 @@ import com.sun.tools.javac.util.JCDiagnostic; import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Log; +import lombok.permit.Permit; + /** * During resolution, the resolver will emit resolution errors, but without appropriate file names and line numbers. If these resolution errors stick around * then they will be generated AGAIN, this time with proper names and line numbers, at the end. Therefore, we want to suppress the logger. @@ -89,11 +91,8 @@ public final class CompilerMessageSuppressor { static Field getDeclaredField(Class c, String fieldName) { try { - Field field = c.getDeclaredField(fieldName); - field.setAccessible(true); - return field; - } - catch (Throwable t) { + return Permit.getField(c, fieldName); + } catch (Throwable t) { return null; } } -- cgit