private Symbol.MethodSymbol findReflectUtilConstructor( JCTree.JCNewClass tree ) { Symtab symtab = _tp.getSymtab(); Type.ArrayType classArrayType = new Type.ArrayType( symtab.classType, symtab.arrayClass ); Type.ArrayType objectArrayType = new Type.ArrayType( symtab.objectType, symtab.arrayClass ); List<Type> paramTypes = List.of( symtab.classType, classArrayType, objectArrayType ); Symbol.ClassSymbol reflectMethodClassSym = IDynamicJdk.instance().getTypeElement( _tp.getContext(), _tp.getCompilationUnit(), ReflectionRuntimeMethods.class.getName() ); Names names = Names.instance( _tp.getContext() ); return resolveMethod( tree.pos(), names.fromString( "construct" ), reflectMethodClassSym.type, paramTypes ); }
private Symbol.MethodSymbol findReflectUtilConstructor( JCTree.JCNewClass tree ) { Symtab symtab = _tp.getSymtab(); Type.ArrayType classArrayType = new Type.ArrayType( symtab.classType, symtab.arrayClass ); Type.ArrayType objectArrayType = new Type.ArrayType( symtab.objectType, symtab.arrayClass ); List<Type> paramTypes = List.of( symtab.classType, classArrayType, objectArrayType ); Symbol.ClassSymbol reflectMethodClassSym = IDynamicJdk.instance().getTypeElement( _tp.getContext(), _tp.getCompilationUnit(), ReflectionRuntimeMethods.class.getName() ); Names names = Names.instance( _tp.getContext() ); return resolveMethod( tree.pos(), names.fromString( "construct" ), reflectMethodClassSym.type, paramTypes ); }
clazztype.getEnclosingType().hasTag(CLASS)) { rs.resolveImplicitThis(tree.pos(), env, clazztype); (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); log.error(tree.pos(), "abstract.cant.be.instantiated", clazztype.tsym); } else if (cdef != null && clazztype.tsym.isInterface()) { Symbol constructor = rs.resolveDiamond(tree.pos(), diamondEnv, site, rsEnv.info.pendingResolutionPhase = null; tree.constructor = rs.resolveConstructor( tree.pos(), rsEnv, clazztype, argtypes, typeargtypes); if (cdef == null) { //do not check twice! tree.constructorType = checkId(noCheckTree, tree.pos(), localEnv, clazztype, argtypes, typeargtypes); Assert.check(sym.kind < AMBIGUOUS); tree.constructor = sym;
clazztype.getEnclosingType().hasTag(CLASS)) { rs.resolveImplicitThis(tree.pos(), env, clazztype); (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); log.error(tree.pos(), "abstract.cant.be.instantiated", clazztype.tsym); } else if (cdef != null && clazztype.tsym.isInterface()) { Symbol constructor = rs.resolveDiamond(tree.pos(), diamondEnv, site, rsEnv.info.pendingResolutionPhase = null; tree.constructor = rs.resolveConstructor( tree.pos(), rsEnv, clazztype, argtypes, typeargtypes); if (cdef == null) { //do not check twice! tree.constructorType = checkId(tree, tree.pos(), localEnv, clazztype, argtypes, typeargtypes); Assert.check(sym.kind < AMBIGUOUS); tree.constructor = sym;
clazztype.getEnclosingType().tag == CLASS) { rs.resolveImplicitThis(tree.pos(), env, clazztype); (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); log.error(tree.pos(), "abstract.cant.be.instantiated", clazztype.tsym); } else if (cdef != null && clazztype.tsym.isInterface()) { localEnv.info.varArgs = false; tree.constructor = rs.resolveConstructor( tree.pos(), localEnv, clazztype, argtypes, typeargtypes); Type ctorType = checkMethod(clazztype, tree.constructor, tree.pos(), localEnv, clazztype, argtypes, typeargtypes, true, tree.varargsElement != null); assert sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous();
clazztype.getEnclosingType().tag == CLASS) { rs.resolveImplicitThis(tree.pos(), env, clazztype); (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); log.error(tree.pos(), "abstract.cant.be.instantiated", clazztype.tsym); } else if (cdef != null && clazztype.tsym.isInterface()) { localEnv.info.varArgs = false; tree.constructor = rs.resolveConstructor( tree.pos(), localEnv, clazztype, argtypes, typeargtypes); Type ctorType = checkMethod(clazztype, tree.constructor, tree.pos(), localEnv, clazztype, argtypes, typeargtypes, true, tree.varargsElement != null); assert sym.kind < AMBIGUOUS || tree.constructor.type.isErroneous();
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); Symbol constructor = accessConstructor(tree.pos(), tree.constructor); if (constructor != tree.constructor) { tree.args = tree.args.append(makeNull()); } else if (c.isLocal()) { thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); } else { thisArg = makeOwnerThis(tree.pos(), c, false);
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); Symbol constructor = accessConstructor(tree.pos(), tree.constructor); if (constructor != tree.constructor) { tree.args = tree.args.append(makeNull()); } else if (c.isLocal()) { thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); } else { thisArg = makeOwnerThis(tree.pos(), c, false);
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); Symbol constructor = accessConstructor(tree.pos(), tree.constructor); if (constructor != tree.constructor) { tree.args = tree.args.append(makeNull()); } else if ((c.owner.kind & (MTH | VAR)) != 0) { thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); } else { thisArg = makeOwnerThis(tree.pos(), c, false);
tree.args = tree.args.appendList(loadFreevars(tree.pos(), freevars(c))); Symbol constructor = accessConstructor(tree.pos(), tree.constructor); if (constructor != tree.constructor) { tree.args = tree.args.append(makeNull()); } else if ((c.owner.kind & (MTH | VAR)) != 0) { thisArg = makeThis(tree.pos(), c.type.getEnclosingType().tsym); } else { thisArg = makeOwnerThis(tree.pos(), c, false);
public void visitNewClass(JCNewClass tree) { // Enclosing instances or anonymous classes should have been eliminated // by now. Assert.check(tree.encl == null && tree.def == null); setTypeAnnotationPositions(tree.pos); code.emitop2(new_, makeRef(tree.pos(), tree.type)); code.emitop0(dup); // Generate code for all arguments, where the expected types are // the parameters of the constructor's external type (that is, // any implicit outer instance appears as first parameter). genArgs(tree.args, tree.constructor.externalType(types).getParameterTypes()); items.makeMemberItem(tree.constructor, true).invoke(); result = items.makeStackItem(tree.type); }
public void visitNewClass(JCNewClass tree) { // Enclosing instances or anonymous classes should have been eliminated // by now. Assert.check(tree.encl == null && tree.def == null); setTypeAnnotationPositions(tree.pos); code.emitop2(new_, makeRef(tree.pos(), tree.type)); code.emitop0(dup); // Generate code for all arguments, where the expected types are // the parameters of the constructor's external type (that is, // any implicit outer instance appears as first parameter). genArgs(tree.args, tree.constructor.externalType(types).getParameterTypes()); items.makeMemberItem(tree.constructor, true).invoke(); result = items.makeStackItem(tree.type); }
public void visitNewClass(JCNewClass tree) { // Enclosing instances or anonymous classes should have been eliminated // by now. assert tree.encl == null && tree.def == null; code.emitop2(new_, makeRef(tree.pos(), tree.type)); code.emitop0(dup); // Generate code for all arguments, where the expected types are // the parameters of the constructor's external type (that is, // any implicit outer instance appears as first parameter). genArgs(tree.args, tree.constructor.externalType(types).getParameterTypes()); items.makeMemberItem(tree.constructor, true).invoke(); result = items.makeStackItem(tree.type); }
public void visitNewClass(JCNewClass tree) { // Enclosing instances or anonymous classes should have been eliminated // by now. assert tree.encl == null && tree.def == null; code.emitop2(new_, makeRef(tree.pos(), tree.type)); code.emitop0(dup); // Generate code for all arguments, where the expected types are // the parameters of the constructor's external type (that is, // any implicit outer instance appears as first parameter). genArgs(tree.args, tree.constructor.externalType(types).getParameterTypes()); items.makeMemberItem(tree.constructor, true).invoke(); result = items.makeStackItem(tree.type); }
@Override public void visitNewClass(JCNewClass tree) { super.visitNewClass(tree); Symbol c = tree.constructor != null ? tree.constructor.owner : null; if (c != null && c.hasOuterInstance()) { if (tree.encl == null && c.isLocal()) { checkThis(tree.pos(), c.type.getEnclosingType().tsym); } } }