@Override public Object invoke( Object proxy, Method method, Object[] args ) { return ReflectUtil.method( _wrapper, method.getName(), method.getParameterTypes() ).invoke( args ); } }
public static Object invokeStatic_Object( Class cls, String name, Class[] paramTypes, Object[] args ) { //noinspection ConstantConditions return ReflectUtil.method( cls, name, paramTypes ).invokeStatic( args ); }
public Iterable<? extends Path> getLocationAsPaths( Location location ) { try { //noinspection unchecked return (Iterable)ReflectUtil.method( fileManager, "getLocationAsPaths", Location.class ).invoke( location ); } catch( Exception e ) { throw new RuntimeException( e ); } }
public static LiveMethodRef method( Object receiver, String name, Class... params ) { MethodRef ref = ReflectUtil.method( receiver.getClass(), name, params ); if( ref == null ) { return null; } return new LiveMethodRef( ref._method, receiver ); }
public static Object invokeStatic_Object( Class cls, String name, Class[] paramTypes, Object[] args ) { //noinspection ConstantConditions return ReflectUtil.method( cls, name, paramTypes ).invokeStatic( args ); }
public void release( ByteBuffer bb ) { try { ReflectUtil.method( _delegate, "release", ByteBuffer.class ).invoke( bb ); } catch( Exception ignore ) { } }
public void close() { ReflectUtil.method( _delegate, "close" ).invoke(); } }
public static Object invoke_Object( Object receiver, String name, Class[] paramTypes, Object[] args ) { return ReflectUtil.method( receiver, name, paramTypes ).invoke( args ); }
public Optional<InputStream> open( String name ) { Optional<InputStream> input = (Optional<InputStream>)ReflectUtil.method( _delegate, "open", String.class ).invoke( name ); if( !input.isPresent() ) { Object/*Resource*/ resource = ReflectUtil.method( _ucp, "getResource", String.class, boolean.class ).invoke( name, false ); if( resource != null ) { input = Optional.of( (InputStream)ReflectUtil.method( resource, "getInputStream" ).invoke() ); } } return input; }
public Stream<String> list() { return (Stream<String>)ReflectUtil.method( _delegate, "list" ).invoke(); }
public static Object invoke_Object( Object receiver, String name, Class[] paramTypes, Object[] args ) { return ReflectUtil.method( receiver, name, paramTypes ).invoke( args ); }
private static boolean hasCallHandlerMethod( Class rootClass ) { if( ICallHandler.class.isAssignableFrom( rootClass ) ) { // Nominally implements ICallHandler return true; } if( ReflectUtil.method( rootClass, "call", Class.class, String.class, String.class, Class.class, Class[].class, Object[].class ) != null ) { // Structurally implements ICallHandler return true; } // maybe has an extension satisfying ICallHandler return hasCallHandlerFromExtension( rootClass ); }
private static boolean hasCallHandlerMethod( Class rootClass ) { if( ICallHandler.class.isAssignableFrom( rootClass ) ) { // Nominally implements ICallHandler return true; } if( ReflectUtil.method( rootClass, "call", Class.class, String.class, String.class, Class.class, Class[].class, Object[].class ) != null ) { // Structurally implements ICallHandler return true; } // maybe has an extension satisfying ICallHandler return hasCallHandlerFromExtension( rootClass ); }
/** * Get a {@link MethodRef} to the specified method. Typical use: * <p> * <pre> method("java.time.LocalTime", "of", int.class, int.class).invokeStatic(5, 30) </pre> * * @param fqn The qualified name of the class containing the method * @param name The name of the method or a '|' separated list of names, where the first found is used * @param params The types of the method's parameters * * @return A reference to the specified method or null if not found */ public static MethodRef method( String fqn, String name, Class... params ) { return method( type( fqn ), name, params ); }
public Optional<ByteBuffer> read( String name ) throws IOException { Optional<ByteBuffer> buffer = (Optional<ByteBuffer>)ReflectUtil.method( _delegate, "read", String.class ).invoke( name ); if( !buffer.isPresent() ) { Object/*Resource*/ resource = ReflectUtil.method( _ucp, "getResource", String.class, boolean.class ).invoke( name, false ); if( resource != null ) { ByteBuffer bytes = ByteBuffer.wrap( StreamUtil.getContent( (InputStream)ReflectUtil.method( resource, "getInputStream" ).invoke() ) ); buffer = Optional.of( bytes ); } } return buffer; }
private boolean isJailbreak( Symbol sym ) { Class<?> extensionTransformer = EXTENSION_TRANSFORMER.get(); if( extensionTransformer == null ) { return false; } return (boolean)ReflectUtil.method( extensionTransformer, "isJailbreakSymbol", Symbol.class ) .invokeStatic( sym ); }
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 ); }
boolean isJailbreakSelect( JCTree.JCFieldAccess pos ) { if( _extensionTransformerClass.get() == null ) { return false; } //noinspection ConstantConditions return (boolean)ReflectUtil.method( _extensionTransformerClass.get(), "isJailbreakReceiver", JCTree.JCFieldAccess.class ).invokeStatic( pos ); }
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; }