public static Object getFieldStatic_Object( Class receiver, String name ) { //noinspection ConstantConditions return ReflectUtil.field( receiver, name ).getStatic(); }
public static Object getFieldStatic_Object( Class receiver, String name ) { //noinspection ConstantConditions return ReflectUtil.field( receiver, name ).getStatic(); }
@SuppressWarnings("UnusedReturnValue") public static Object setFieldStatic_Object( Class receiver, String name, Object value ) { //noinspection ConstantConditions ReflectUtil.field( receiver, name ).setStatic( value ); return value; }
@SuppressWarnings("UnusedReturnValue") public static Object setField_Object( Object receiver, String name, Object value ) { ReflectUtil.field( receiver, name ).set( value ); return value; }
@SuppressWarnings("UnusedReturnValue") public static Object setFieldStatic_Object( Class receiver, String name, Object value ) { //noinspection ConstantConditions ReflectUtil.field( receiver, name ).setStatic( value ); return value; }
@SuppressWarnings("UnusedReturnValue") public static Object setField_Object( Object receiver, String name, Object value ) { ReflectUtil.field( receiver, name ).set( value ); return value; }
public static LiveFieldRef field( Object receiver, String name ) { FieldRef ref = ReflectUtil.field( receiver.getClass(), name ); if( ref == null ) { return null; } return new LiveFieldRef( ref._field, receiver ); }
public static Object getField_Object( Object receiver, String name ) { return ReflectUtil.field( receiver, name ).get(); }
private DiagnosticHandler getDiagnosticHandler() { return (DiagnosticHandler)ReflectUtil.field( this, "diagnosticHandler" ).get(); }
public static Object getField_Object( Object receiver, String name ) { return ReflectUtil.field( receiver, name ).get(); }
/** * Get a {@link FieldRef} to the specified field. Typical use: * <p> * <pre> field("java.time.LocalTime", "hour").get(); </pre> * * @param fqn The qualified name of the class having the field * @param name The name of the field or a '|' separated list of names, where the first found is used * * @return A reference to the specified field or null if not found */ public static FieldRef field( String fqn, String name ) { return field( type( fqn ), name ); }
@Override public boolean hasLocation( Location location ) { return !JavacPlugin.IS_JAVA_8 && location == ReflectUtil.field( StandardLocation.class, "PATCH_MODULE_PATH" ).getStatic() || super.hasLocation( location ); }
private ManLog_8( Context ctx, DiagnosticHandler diagnosticHandler, DiagnosticSource source, PrintWriter errWriter, PrintWriter warnWriter, PrintWriter noticeWriter ) { super( ctx, errWriter, warnWriter, noticeWriter ); ReflectUtil.field( this, "diagnosticHandler" ).set( diagnosticHandler ); ReflectUtil.field( this, "source" ).set( source ); _suspendedIssues = new HashMap<>(); _extensionTransformerClass = LocklessLazyVar.make( () -> ReflectUtil.type( "manifold.ext.ExtensionTransformer" ) ); reassignAllEarlyHolders( ctx ); }
public static Log instance( Context ctx ) { Log log = ctx.get( logKey ); if( !(log instanceof ManLog_8) ) { ctx.put( logKey, (Log)null ); log = new ManLog_8( ctx, (DiagnosticHandler)ReflectUtil.field( log, "diagnosticHandler" ).get(), log.currentSource(), (PrintWriter)ReflectUtil.field( log, "errWriter" ).get(), (PrintWriter)ReflectUtil.field( log, "warnWriter" ).get(), (PrintWriter)ReflectUtil.field( log, "noticeWriter" ).get() ); } return log; }
private static Class defineClass( ClassLoader cl, String fqn ) throws IOException { InputStream stream = cl.getResourceAsStream( fqn ); byte[] bytes = StreamUtil.getContent( stream ); ClassLoader parent = (ClassLoader)Array.get( ReflectUtil.field( cl, "myParents" ).get(), 0 ); return (Class)ReflectUtil.method( parent, "defineClass", byte[].class, int.class, int.class ).invoke( bytes, 0, bytes.length ); }
/** * @since 9 */ @Override public Location getLocationForModule( Location location, String moduleName ) throws IOException { if( location == ReflectUtil.field( StandardLocation.class, "PATCH_MODULE_PATH" ).getStatic() ) { return new ManPatchModuleLocation( moduleName ); } return super.getLocationForModule( location, moduleName ); }
/** * @since 9 */ @Override public Location getLocationForModule( Location location, JavaFileObject fo ) throws IOException { if( fo instanceof GeneratedJavaStubFileObject && location == ReflectUtil.field( StandardLocation.class, "PATCH_MODULE_PATH" ).getStatic() ) { //System.err.println( "PATCH: " + fo.getName() ); return new ManPatchLocation( (GeneratedJavaStubFileObject)fo ); } return super.getLocationForModule( location, fo ); }
private ManAttr_8( Context ctx ) { super( ctx ); _names = Names.instance( ctx ); _syms = Symtab.instance( ctx ); _chk = Check.instance( ctx ); _selects = new Stack<>(); _annotatedTypes = new Stack<>(); // Override logger to handle final field assignment for @Jailbreak _manLog = (ManLog_8)ManLog_8.instance( ctx ); ReflectUtil.field( this, "log" ).set( _manLog ); ReflectUtil.field( this, "rs" ).set( ManResolve.instance( ctx ) ); reassignAllEarlyHolders( ctx ); }
private Location makeModuleLocation( ManPatchModuleLocation location ) { // Module module = Modules.instance( _ctx ).getObservableModule( Names.instance( _ctx ).fromString( location.getName() ) ); // return module.classLocation; Symbol moduleElement = (Symbol)ReflectUtil.method( Symtab.instance( _ctx ), "getModule", Name.class ) .invoke( Names.instance( _ctx ).fromString( location.getName() ) ); if( moduleElement == null ) { return null; } return (Location)ReflectUtil.field( moduleElement, "classLocation" ).get(); }
private TypeAnnotationPosition getTypeAnnotationPosition( List<TypeAnnotationPosition.TypePathEntry> attrLocationCopy ) { TypeAnnotationPosition posCopy; //noinspection ConstantConditions if( isJava8() ) { posCopy = (TypeAnnotationPosition)ReflectUtil.constructor( "com.sun.tools.javac.code.TypeAnnotationPosition" ).newInstance(); ReflectUtil.field( posCopy, "location" ).set( attrLocationCopy ); } else { posCopy = (TypeAnnotationPosition)ReflectUtil .method( TypeAnnotationPosition.class, "methodReceiver", List.class ).invokeStatic( attrLocationCopy ); } return posCopy; }