Java Code Examples for com.sun.tools.javac.tree.TreeMaker
The following examples show how to use
com.sun.tools.javac.tree.TreeMaker. These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: TencentKona-8 Source File: LambdaToMethod.java License: GNU General Public License v2.0 | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); }
Example 2
Source Project: manifold Source File: ExtensionTransformer.java License: Apache License 2.0 | 6 votes |
/** Unbox an object to a primitive value. */ private JCExpression unbox( Types types, TreeMaker make, Names names, JCExpression tree, Type primitive ) { Type unboxedType = types.unboxedType(tree.type); if (unboxedType.hasTag(NONE)) { unboxedType = primitive; if (!unboxedType.isPrimitive()) throw new AssertionError(unboxedType); make.at(tree.pos()); tree = make.TypeCast(types.boxedClass(unboxedType).type, tree); } else { // There must be a conversion from unboxedType to primitive. if (!types.isSubtype(unboxedType, primitive)) throw new AssertionError(tree); } make.at(tree.pos()); Symbol valueSym = resolveMethod(tree.pos(), unboxedType.tsym.name.append(names.Value), // x.intValue() tree.type, List.<Type>nil()); return make.App(make.Select(tree, valueSym)); }
Example 3
Source Project: TencentKona-8 Source File: MakeLiteralTest.java License: GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Symtab syms = Symtab.instance(context); maker = TreeMaker.instance(context); types = Types.instance(context); test("abc", CLASS, syms.stringType, "abc"); test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0)); test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1)); test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1)); test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a')); test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d)); test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f)); test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1)); test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1)); test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1)); if (errors > 0) throw new Exception(errors + " errors found"); }
Example 4
Source Project: manifold Source File: ExtensionTransformer.java License: Apache License 2.0 | 6 votes |
private JCExpression classForNameCall( Type type, JCTree tree ) { TreeMaker make = _tp.getTreeMaker(); JavacElements javacElems = _tp.getElementUtil(); JCTree.JCMethodInvocation typeCall = make.Apply( List.nil(), memberAccess( make, javacElems, ReflectUtil.class.getName() + ".type" ), List.of( make.Literal( makeLiteralName( type ) ) ) ); typeCall.setPos( Position.NOPOS ); typeCall.type = _tp.getSymtab().classType; JCTree.JCFieldAccess newMethodSelect = (JCTree.JCFieldAccess)typeCall.getMethodSelect(); Symbol.ClassSymbol reflectMethodClassSym = IDynamicJdk.instance().getTypeElement( _tp.getContext(), _tp.getCompilationUnit(), ReflectUtil.class.getName() ); Symbol.MethodSymbol typeMethodSymbol = resolveMethod( tree.pos(), Names.instance( _tp.getContext() ).fromString( "type" ), reflectMethodClassSym.type, List.of( _tp.getSymtab().stringType ) ); newMethodSelect.sym = typeMethodSymbol; newMethodSelect.type = typeMethodSymbol.type; newMethodSelect.pos = tree.pos; assignTypes( newMethodSelect.selected, reflectMethodClassSym ); return typeCall; }
Example 5
Source Project: jdk8u60 Source File: MakeLiteralTest.java License: GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Symtab syms = Symtab.instance(context); maker = TreeMaker.instance(context); types = Types.instance(context); test("abc", CLASS, syms.stringType, "abc"); test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0)); test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1)); test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1)); test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a')); test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d)); test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f)); test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1)); test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1)); test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1)); if (errors > 0) throw new Exception(errors + " errors found"); }
Example 6
Source Project: java-n-IDE-for-Android Source File: Enter.java License: Apache License 2.0 | 6 votes |
protected Enter(Context context) { context.put(enterKey, this); log = Log.instance(context); reader = ClassReader.instance(context); make = TreeMaker.instance(context); syms = Symtab.instance(context); chk = Check.instance(context); memberEnter = MemberEnter.instance(context); types = Types.instance(context); annotate = Annotate.instance(context); lint = Lint.instance(context); names = Names.instance(context); predefClassDef = make.ClassDef( make.Modifiers(PUBLIC), syms.predefClass.name, null, null, null, null); predefClassDef.sym = syms.predefClass; todo = Todo.instance(context); fileManager = context.get(JavaFileManager.class); Options options = Options.instance(context); pkginfoOpt = PkgInfo.get(options); }
Example 7
Source Project: hottub Source File: MakeLiteralTest.java License: GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Symtab syms = Symtab.instance(context); maker = TreeMaker.instance(context); types = Types.instance(context); test("abc", CLASS, syms.stringType, "abc"); test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0)); test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1)); test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1)); test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a')); test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d)); test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f)); test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1)); test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1)); test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1)); if (errors > 0) throw new Exception(errors + " errors found"); }
Example 8
Source Project: tutorials Source File: SampleJavacPlugin.java License: MIT License | 6 votes |
private static JCTree.JCBlock createIfBlock(TreeMaker factory, Names symbolsTable, VariableTree parameter) { String parameterName = parameter.getName().toString(); Name parameterId = symbolsTable.fromString(parameterName); String errorMessagePrefix = String.format("Argument '%s' of type %s is marked by @%s but got '", parameterName, parameter.getType(), Positive.class.getSimpleName()); String errorMessageSuffix = "' for it"; return factory.Block(0, com.sun.tools.javac.util.List.of( factory.Throw( factory.NewClass(null, nil(), factory.Ident(symbolsTable.fromString(IllegalArgumentException.class.getSimpleName())), com.sun.tools.javac.util.List.of(factory.Binary(JCTree.Tag.PLUS, factory.Binary(JCTree.Tag.PLUS, factory.Literal(TypeTag.CLASS, errorMessagePrefix), factory.Ident(parameterId)), factory.Literal(TypeTag.CLASS, errorMessageSuffix))), null)))); }
Example 9
Source Project: lua-for-android Source File: JavacTrees.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
private void init(Context context) { modules = Modules.instance(context); attr = Attr.instance(context); enter = Enter.instance(context); elements = JavacElements.instance(context); log = Log.instance(context); resolve = Resolve.instance(context); treeMaker = TreeMaker.instance(context); memberEnter = MemberEnter.instance(context); names = Names.instance(context); types = Types.instance(context); docTreeMaker = DocTreeMaker.instance(context); parser = ParserFactory.instance(context); syms = Symtab.instance(context); fileManager = context.get(JavaFileManager.class); JavacTask t = context.get(JavacTask.class); if (t instanceof JavacTaskImpl) javacTaskImpl = (JavacTaskImpl) t; }
Example 10
Source Project: openjdk-8 Source File: LambdaToMethod.java License: GNU General Public License v2.0 | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); }
Example 11
Source Project: openjdk-jdk9 Source File: MakeLiteralTest.java License: GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Symtab syms = Symtab.instance(context); maker = TreeMaker.instance(context); types = Types.instance(context); test("abc", CLASS, syms.stringType, "abc"); test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0)); test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1)); test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1)); test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a')); test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d)); test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f)); test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1)); test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1)); test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1)); if (errors > 0) throw new Exception(errors + " errors found"); }
Example 12
Source Project: lua-for-android Source File: Analyzer.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
protected Analyzer(Context context) { context.put(analyzerKey, this); types = Types.instance(context); log = Log.instance(context); attr = Attr.instance(context); deferredAttr = DeferredAttr.instance(context); argumentAttr = ArgumentAttr.instance(context); make = TreeMaker.instance(context); copier = new AnalyzerCopier(); Options options = Options.instance(context); String findOpt = options.get("find"); //parse modes Source source = Source.instance(context); allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation(); analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source); }
Example 13
Source Project: lua-for-android Source File: LambdaToMethod.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); operators = Operators.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("debug.dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); }
Example 14
Source Project: manifold Source File: ExtensionTransformer.java License: Apache License 2.0 | 6 votes |
private JCExpression replaceStringLiteral( Symbol.ClassSymbol fragSym, JCTree tree, String methodName, String type ) { TreeMaker make = _tp.getTreeMaker(); Names names = Names.instance( _tp.getContext() ); Symbol.MethodSymbol fragmentValueMethod = resolveMethod( tree.pos(), names.fromString( methodName ), fragSym.type, List.nil() ); JCTree.JCMethodInvocation fragmentValueCall = make.Apply( List.nil(), memberAccess( make, _tp.getElementUtil(), fragSym.getQualifiedName() + "." + methodName ), List.nil() ); fragmentValueCall.type = fragmentValueMethod.getReturnType(); // type fragmentValueCall.setPos( tree.pos ); JCTree.JCFieldAccess newMethodSelect = (JCTree.JCFieldAccess)fragmentValueCall.getMethodSelect(); newMethodSelect.sym = fragmentValueMethod; newMethodSelect.type = fragmentValueMethod.type; assignTypes( newMethodSelect.selected, fragSym ); return fragmentValueCall; }
Example 15
Source Project: openjdk-jdk9 Source File: TwrAvoidNullCheck.java License: GNU General Public License v2.0 | 6 votes |
@Override public List<JCTree> translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) { List<JCTree> result = super.translateTopLevelClass(env, cdef, make); new TreeScanner() { @Override public void visitBinary(JCBinary tree) { hasNullCheck |= tree.operator.getSimpleName().contentEquals("!=") && "resource".equals(String.valueOf(TreeInfo.name(tree.lhs))) && TreeInfo.isNull(tree.rhs); super.visitBinary(tree); } }.scan(result); return result; }
Example 16
Source Project: hottub Source File: LambdaToMethod.java License: GNU General Public License v2.0 | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); forceSerializable = options.isSet("forceSerializable"); }
Example 17
Source Project: openjdk-jdk9 Source File: Annotate.java License: GNU General Public License v2.0 | 6 votes |
protected Annotate(Context context) { context.put(annotateKey, this); attr = Attr.instance(context); chk = Check.instance(context); cfolder = ConstFold.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); enter = Enter.instance(context); log = Log.instance(context); lint = Lint.instance(context); make = TreeMaker.instance(context); names = Names.instance(context); resolve = Resolve.instance(context); syms = Symtab.instance(context); typeEnvs = TypeEnvs.instance(context); types = Types.instance(context); theUnfinishedDefaultValue = new Attribute.Error(syms.errType); Source source = Source.instance(context); allowRepeatedAnnos = source.allowRepeatedAnnotations(); sourceName = source.name; blockCount = 1; }
Example 18
Source Project: openjdk-8-source Source File: LambdaToMethod.java License: GNU General Public License v2.0 | 6 votes |
private LambdaToMethod(Context context) { context.put(unlambdaKey, this); diags = JCDiagnostic.Factory.instance(context); log = Log.instance(context); lower = Lower.instance(context); names = Names.instance(context); syms = Symtab.instance(context); rs = Resolve.instance(context); make = TreeMaker.instance(context); types = Types.instance(context); transTypes = TransTypes.instance(context); analyzer = new LambdaAnalyzerPreprocessor(); Options options = Options.instance(context); dumpLambdaToMethodStats = options.isSet("dumpLambdaToMethodStats"); attr = Attr.instance(context); }
Example 19
Source Project: openjdk-8 Source File: MakeLiteralTest.java License: GNU General Public License v2.0 | 6 votes |
void run() throws Exception { Context context = new Context(); JavacFileManager.preRegister(context); Symtab syms = Symtab.instance(context); maker = TreeMaker.instance(context); types = Types.instance(context); test("abc", CLASS, syms.stringType, "abc"); test(Boolean.FALSE, BOOLEAN, syms.booleanType, Integer.valueOf(0)); test(Boolean.TRUE, BOOLEAN, syms.booleanType, Integer.valueOf(1)); test(Byte.valueOf((byte) 1), BYTE, syms.byteType, Byte.valueOf((byte) 1)); test(Character.valueOf('a'), CHAR, syms.charType, Integer.valueOf('a')); test(Double.valueOf(1d), DOUBLE, syms.doubleType, Double.valueOf(1d)); test(Float.valueOf(1f), FLOAT, syms.floatType, Float.valueOf(1f)); test(Integer.valueOf(1), INT, syms.intType, Integer.valueOf(1)); test(Long.valueOf(1), LONG, syms.longType, Long.valueOf(1)); test(Short.valueOf((short) 1), SHORT, syms.shortType, Short.valueOf((short) 1)); if (errors > 0) throw new Exception(errors + " errors found"); }
Example 20
Source Project: java-master Source File: GenerateGetMethodProcessor.java License: Apache License 2.0 | 5 votes |
@Override public synchronized void init(ProcessingEnvironment processingEnv) { super.init(processingEnv); this.processingEnv = processingEnv; this.elementUtils = processingEnv.getElementUtils(); this.typeUtils = processingEnv.getTypeUtils(); this.filer = processingEnv.getFiler(); this.trees = JavacTrees.instance(processingEnv); Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); this.treeMaker = TreeMaker.instance(context); this.names = Names.instance(context); }
Example 21
Source Project: TencentKona-8 Source File: GenStubs.java License: GNU General Public License v2.0 | 5 votes |
ImportCleaner(JavaFileManager fm) { // ImportCleaner itself doesn't require a filemanager, but instantiating // a TreeMaker does, indirectly (via ClassReader, sigh) Context c = new Context(); c.put(JavaFileManager.class, fm); m = TreeMaker.instance(c); }
Example 22
Source Project: TencentKona-8 Source File: ParserFactory.java License: GNU General Public License v2.0 | 5 votes |
protected ParserFactory(Context context) { super(); context.put(parserFactoryKey, this); this.F = TreeMaker.instance(context); this.docTreeMaker = DocTreeMaker.instance(context); this.log = Log.instance(context); this.names = Names.instance(context); this.tokens = Tokens.instance(context); this.source = Source.instance(context); this.options = Options.instance(context); this.scannerFactory = ScannerFactory.instance(context); this.locale = context.get(Locale.class); }
Example 23
Source Project: TencentKona-8 Source File: JavacTrees.java License: GNU General Public License v2.0 | 5 votes |
private void init(Context context) { attr = Attr.instance(context); enter = Enter.instance(context); elements = JavacElements.instance(context); log = Log.instance(context); resolve = Resolve.instance(context); treeMaker = TreeMaker.instance(context); memberEnter = MemberEnter.instance(context); names = Names.instance(context); types = Types.instance(context); JavacTask t = context.get(JavacTask.class); if (t instanceof JavacTaskImpl) javacTaskImpl = (JavacTaskImpl) t; }
Example 24
Source Project: manifold Source File: BootstrapInserter.java License: Apache License 2.0 | 5 votes |
private JCTree.JCStatement buildBootstrapStaticBlock() { TreeMaker make = _javacJacker.getTreeMaker(); JavacElements javacElems = _javacJacker.getJavacElements(); JCTree.JCMethodInvocation bootstrapInitCall = make.Apply( List.nil(), memberAccess( make, javacElems, IBootstrap.class.getName() + ".dasBoot" ), List.nil() ); return make.Block( Modifier.STATIC, List.of( make.Exec( bootstrapInitCall ) ) ); }
Example 25
Source Project: manifold Source File: ManTypes.java License: Apache License 2.0 | 5 votes |
private void reassignEarlyHolders( Context context ) { ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Analyzer" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Annotate.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Attr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Check.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( DeferredAttr.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Flow.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Gen.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Infer.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavaCompiler.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacElements.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacProcessingEnvironment.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTrees.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( JavacTypes.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( LambdaToMethod.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( Lower.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ManResolve.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( MemberEnter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Modules" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.Operators" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); //noinspection ConstantConditions ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.jvm.StringConcat" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( RichDiagnosticFormatter.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( TransTypes.instance( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( ReflectUtil.method( ReflectUtil.type( "com.sun.tools.javac.comp.TypeEnter" ), "instance", Context.class ) .invokeStatic( context ), TYPES_FIELD ).set( this ); ReflectUtil.field( TreeMaker.instance( context ), TYPES_FIELD ).set( this ); }
Example 26
Source Project: TencentKona-8 Source File: T8024415.java License: GNU General Public License v2.0 | 5 votes |
public T8024415() { Context ctx = new Context(); JavacFileManager.preRegister(ctx); maker = TreeMaker.instance(ctx); Names names = Names.instance(ctx); x = maker.Ident(names.fromString("x")); }
Example 27
Source Project: TencentKona-8 Source File: MakeQualIdent.java License: GNU General Public License v2.0 | 5 votes |
public static void main(String... args) throws Exception { JavacTool tool = JavacTool.create(); JavacTask task = tool.getTask(null, null, null, new ArrayList<String>(), null, null); Context ctx = ((JavacTaskImpl)task).getContext(); TreeMaker treeMaker = TreeMaker.instance(ctx); Symtab syms = Symtab.instance(ctx); String stringTree = printTree(treeMaker.QualIdent(syms.stringType.tsym)); if (!"java.lang.String".equals(stringTree)) { throw new IllegalStateException(stringTree); } }
Example 28
Source Project: manifold Source File: ManTransTypes.java License: Apache License 2.0 | 5 votes |
/** * Override to keep track of when/if translate() is in scope, if ManTypes#memberType() should not try to substitute * the qualifier type for @Self because the qualifier is not really a call site, rather it is the declaring class * of the method being checked for bridge method possibilities etc. Thus we need to let the normal signature flow * through. */ @Override public JCTree translateTopLevelClass( JCTree cdef, TreeMaker make ) { _translateCount++; try { return super.translateTopLevelClass( cdef, make ); } finally { _translateCount--; } }
Example 29
Source Project: jdk8u60 Source File: JavacTrees.java License: GNU General Public License v2.0 | 5 votes |
private void init(Context context) { attr = Attr.instance(context); enter = Enter.instance(context); elements = JavacElements.instance(context); log = Log.instance(context); resolve = Resolve.instance(context); treeMaker = TreeMaker.instance(context); memberEnter = MemberEnter.instance(context); names = Names.instance(context); types = Types.instance(context); JavacTask t = context.get(JavacTask.class); if (t instanceof JavacTaskImpl) javacTaskImpl = (JavacTaskImpl) t; }
Example 30
Source Project: openjdk-8-source Source File: LambdaToMethod.java License: GNU General Public License v2.0 | 5 votes |
public JCTree translateTopLevelClass(Env<AttrContext> env, JCTree cdef, TreeMaker make) { this.make = make; this.attrEnv = env; this.context = null; this.contextMap = new HashMap<JCTree, TranslationContext<?>>(); return translate(cdef); }