public static Object construct( Class type, Class[] paramTypes, Object[] args ) { //noinspection ConstantConditions return ReflectUtil.constructor( type, paramTypes ).newInstance( args ); } }
public static Object construct( Class type, Class[] paramTypes, Object[] args ) { //noinspection ConstantConditions return ReflectUtil.constructor( type, paramTypes ).newInstance( args ); } }
/** * Get a {@link ConstructorRef} to the specified constructor. Typical use: * <p> * <pre> constructor("java.util.ArrayList", int.class).newInstance(32) </pre> * * @param fqn The qualified name of the class to construct * @param params A list of parameter types for the constructor * * @return A reference to the constructor or null if not found */ public static ConstructorRef constructor( String fqn, Class<?>... params ) { return constructor( type( fqn ), params ); }
if( superclass != null ) mr = constructor( superclass, params ); if( mr != null ) mr = constructor( iface, params ); if( mr != null )
private static Object makeUrlLoader( ClassLoader cl, URL url ) throws IOException { Class cls = defineClass( cl, "/com/intellij/util/lang/UrlLoader.class" ); defineClass( cl, "/com/intellij/util/lang/UrlLoader$JavaResource.class" ); defineClass( cl, "/com/intellij/util/lang/UrlLoader$IjResource.class" ); //noinspection ConstantConditions return ReflectUtil.constructor( cls, URL.class, int.class ).newInstance( url, 0 ); }
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; }
ReflectUtil.ConstructorRef constructor = ReflectUtil.constructor( BaseConstructor.class.getTypeName() + inner, Object.class, Object.class ); Object recursiveTuple = constructor.newInstance( key, value );
Object addedRequires = ReflectUtil.constructor( "com.sun.tools.javac.code.Directive$RequiresDirective", ReflectUtil.type( "com.sun.tools.javac.code.Symbol$ModuleSymbol" ) ).newInstance( moduleToOpen ); newRequires.add( addedRequires ); requires = com.sun.tools.javac.util.List.from( newRequires ); Object exp = ReflectUtil.constructor( "com.sun.tools.javac.code.Directive$ExportsDirective", Symbol.PackageSymbol.class, com.sun.tools.javac.util.List.class ).newInstance( pkg, com.sun.tools.javac.util.List.of( rootModule ) ); exports.add( exp );
Object addedRequires = ReflectUtil.constructor( "com.sun.tools.javac.code.Directive$RequiresDirective", ReflectUtil.type( "com.sun.tools.javac.code.Symbol$ModuleSymbol" ) ).newInstance( moduleToOpen ); newRequires.add( addedRequires ); requires = com.sun.tools.javac.util.List.from( newRequires ); Object exp = ReflectUtil.constructor( "com.sun.tools.javac.code.Directive$ExportsDirective", Symbol.PackageSymbol.class, com.sun.tools.javac.util.List.class ).newInstance( pkg, com.sun.tools.javac.util.List.of( rootModule ) ); exports.add( exp );