Java Code Examples for com.sun.tools.javac.code.Types#instance()
The following examples show how to use
com.sun.tools.javac.code.Types#instance() .
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: lua-for-android File: TypeEnter.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
protected TypeEnter(Context context) { context.put(typeEnterKey, this); names = Names.instance(context); enter = Enter.instance(context); memberEnter = MemberEnter.instance(context); log = Log.instance(context); chk = Check.instance(context); attr = Attr.instance(context); syms = Symtab.instance(context); make = TreeMaker.instance(context); todo = Todo.instance(context); annotate = Annotate.instance(context); typeAnnotations = TypeAnnotations.instance(context); types = Types.instance(context); diags = JCDiagnostic.Factory.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); lint = Lint.instance(context); typeEnvs = TypeEnvs.instance(context); dependencies = Dependencies.instance(context); Source source = Source.instance(context); allowTypeAnnos = source.allowTypeAnnotations(); allowDeprecationOnImport = source.allowDeprecationOnImport(); }
Example 2
Source Project: manifold File: ExtensionTransformer.java License: Apache License 2.0 | 6 votes |
private JCExpression makeClassExpr( JCTree tree, Type type ) { BasicJavacTask javacTask = (BasicJavacTask)_tp.getJavacTask(); Types types = Types.instance( javacTask.getContext() ); type = types.erasure( type ); JCExpression classExpr; if( isPrimitiveOrPrimitiveArray( type ) || (JreUtil.isJava8() && type.tsym.getModifiers().contains( javax.lang.model.element.Modifier.PUBLIC )) ) { // class is publicly accessible, assume we can use class literal classExpr = _tp.getTreeMaker().ClassLiteral( type ); classExpr.pos = tree.pos; } else { // generate `ReflectUtil.type( typeName )` classExpr = classForNameCall( type, tree ); } return classExpr; }
Example 3
Source Project: j2objc File: TreeConverter.java License: Apache License 2.0 | 6 votes |
private TreeNode convertFunctionalExpression( JCFunctionalExpression node, TreePath parent, FunctionalExpression newNode) { List<? extends TypeMirror> targets = getTargets(node, parent); for (TypeMirror type : targets) { newNode.addTargetType(type); } Types types = Types.instance(((com.sun.tools.javac.api.BasicJavacTask) env.task()).getContext()); return newNode .setTypeMirror(targets.iterator().next()) .setDescriptor( new ExecutablePair( (ExecutableElement) types .findDescriptorSymbol(((com.sun.tools.javac.code.Type) targets.get(0)).tsym), (ExecutableType) node.getDescriptorType(types))); }
Example 4
Source Project: openjdk-8-source File: TestInvokeDynamic.java License: GNU General Public License v2.0 | 6 votes |
public void run() { int id = checkCount.incrementAndGet(); JavaSource source = new JavaSource(id); JavacTaskImpl ct = (JavacTaskImpl)comp.getTask(null, fm.get(), dc, Arrays.asList("-g"), null, Arrays.asList(source)); Context context = ct.getContext(); Symtab syms = Symtab.instance(context); Names names = Names.instance(context); Types types = Types.instance(context); ct.addTaskListener(new Indifier(syms, names, types)); try { ct.generate(); } catch (Throwable t) { t.printStackTrace(); throw new AssertionError( String.format("Error thrown when compiling following code\n%s", source.source)); } if (dc.diagFound) { throw new AssertionError( String.format("Diags found when compiling following code\n%s\n\n%s", source.source, dc.printDiags())); } verifyBytecode(id); }
Example 5
Source Project: jdk8u60 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 6
Source Project: java-n-IDE-for-Android 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: 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 8
Source Project: lua-for-android 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 9
Source Project: lua-for-android File: TransTypes.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
protected TransTypes(Context context) { context.put(transTypesKey, this); compileStates = CompileStates.instance(context); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); enter = Enter.instance(context); bridgeSpans = new HashMap<>(); types = Types.instance(context); make = TreeMaker.instance(context); resolve = Resolve.instance(context); Source source = Source.instance(context); allowInterfaceBridges = source.allowDefaultMethods(); allowGraphInference = source.allowGraphInference(); annotate = Annotate.instance(context); attr = Attr.instance(context); }
Example 10
Source Project: openjdk-jdk8u 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 11
Source Project: TencentKona-8 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 12
Source Project: lua-for-android File: MemberEnter.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
protected MemberEnter(Context context) { context.put(memberEnterKey, this); enter = Enter.instance(context); log = Log.instance(context); chk = Check.instance(context); attr = Attr.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); types = Types.instance(context); deferredLintHandler = DeferredLintHandler.instance(context); }
Example 13
Source Project: openjdk-8-source File: RichDiagnosticFormatter.java License: GNU General Public License v2.0 | 5 votes |
protected RichDiagnosticFormatter(Context context) { super((AbstractDiagnosticFormatter)Log.instance(context).getDiagnosticFormatter()); setRichPrinter(new RichPrinter()); this.syms = Symtab.instance(context); this.diags = JCDiagnostic.Factory.instance(context); this.types = Types.instance(context); this.messages = JavacMessages.instance(context); whereClauses = new EnumMap<WhereClauseKind, Map<Type, JCDiagnostic>>(WhereClauseKind.class); configuration = new RichConfiguration(Options.instance(context), formatter); for (WhereClauseKind kind : WhereClauseKind.values()) whereClauses.put(kind, new LinkedHashMap<Type, JCDiagnostic>()); }
Example 14
Source Project: lua-for-android File: JNIWriter.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
private void lazyInit() { if (types == null) types = Types.instance(context); if (syms == null) syms = Symtab.instance(context); }
Example 15
Source Project: lua-for-android File: StringConcat.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
protected StringConcat(Context context) { context.put(concatKey, this); gen = Gen.instance(context); syms = Symtab.instance(context); types = Types.instance(context); names = Names.instance(context); make = TreeMaker.instance(context); rs = Resolve.instance(context); sbAppends = new HashMap<>(); }
Example 16
Source Project: netbeans File: PostFlowAnalysis.java License: Apache License 2.0 | 5 votes |
private PostFlowAnalysis(Context ctx) { log = Log.instance(ctx); types = Types.instance(ctx); enter = Enter.instance(ctx); names = Names.instance(ctx); syms = Symtab.instance(ctx); outerThisStack = List.nil(); }
Example 17
Source Project: openjdk-jdk9 File: JavacProcessingEnvironment.java License: GNU General Public License v2.0 | 4 votes |
protected JavacProcessingEnvironment(Context context) { this.context = context; context.put(JavacProcessingEnvironment.class, this); log = Log.instance(context); source = Source.instance(context); diags = JCDiagnostic.Factory.instance(context); options = Options.instance(context); printProcessorInfo = options.isSet(Option.XPRINTPROCESSORINFO); printRounds = options.isSet(Option.XPRINTROUNDS); verbose = options.isSet(Option.VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); compiler = JavaCompiler.instance(context); if (options.isSet(Option.PROC, "only") || options.isSet(Option.XPRINT)) { compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(Option.WERROR); fileManager = context.get(JavaFileManager.class); platformAnnotations = initPlatformAnnotations(); // Initialize services before any processors are initialized // in case processors use them. filer = new JavacFiler(context); messager = new JavacMessager(context, this); elementUtils = JavacElements.instance(context); typeUtils = JavacTypes.instance(context); modules = Modules.instance(context); types = Types.instance(context); annotate = Annotate.instance(context); processorOptions = initProcessorOptions(); unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); symtab = Symtab.instance(context); names = Names.instance(context); enter = Enter.instance(context); initialCompleter = ClassFinder.instance(context).getCompleter(); chk = Check.instance(context); initProcessorLoader(); allowModules = source.allowModules(); }
Example 18
Source Project: lua-for-android File: JavacProcessingEnvironment.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
protected JavacProcessingEnvironment(Context context) { this.context = context; context.put(JavacProcessingEnvironment.class, this); log = Log.instance(context); source = Source.instance(context); diags = JCDiagnostic.Factory.instance(context); options = Options.instance(context); printProcessorInfo = options.isSet(Option.XPRINTPROCESSORINFO); printRounds = options.isSet(Option.XPRINTROUNDS); verbose = options.isSet(Option.VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); compiler = JavaCompiler.instance(context); if (options.isSet(Option.PROC, "only") || options.isSet(Option.XPRINT)) { compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(Option.WERROR); fileManager = context.get(JavaFileManager.class); platformAnnotations = initPlatformAnnotations(); // Initialize services before any processors are initialized // in case processors use them. filer = new JavacFiler(context); messager = new JavacMessager(context, this); elementUtils = JavacElements.instance(context); typeUtils = JavacTypes.instance(context); modules = Modules.instance(context); types = Types.instance(context); annotate = Annotate.instance(context); processorOptions = initProcessorOptions(); unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); symtab = Symtab.instance(context); names = Names.instance(context); enter = Enter.instance(context); initialCompleter = ClassFinder.instance(context).getCompleter(); chk = Check.instance(context); initProcessorLoader(); allowModules = source.allowModules(); }
Example 19
Source Project: manifold File: ExtensionTransformer.java License: Apache License 2.0 | 4 votes |
@Override public void visitUnary( JCTree.JCUnary tree ) { super.visitUnary( tree ); if( _tp.isGenerate() && !shouldProcessForGeneration() ) { // Don't process tree during GENERATE, unless the tree was generated e.g., a bridge method return; } Symbol op = IDynamicJdk.instance().getOperator( tree ); if( op instanceof OverloadOperatorSymbol ) // handle negation overload { TreeMaker make = _tp.getTreeMaker(); // Handle operator overload expressions Symbol.MethodSymbol operatorMethod = (Symbol.MethodSymbol)op; while( operatorMethod instanceof OverloadOperatorSymbol ) { operatorMethod = ((OverloadOperatorSymbol)operatorMethod).getMethod(); } if( operatorMethod != null ) { JCTree.JCMethodInvocation methodCall; JCExpression receiver = tree.getExpression(); methodCall = make.Apply( List.nil(), make.Select( receiver, operatorMethod ), List.nil() ); methodCall.setPos( tree.pos ); methodCall.type = operatorMethod.getReturnType(); // If methodCall is an extension method, rewrite it accordingly Symbol.MethodSymbol extMethod = findExtMethod( methodCall ); if( extMethod != null ) { // Replace with extension method call methodCall = replaceExtCall( methodCall, extMethod ); } result = methodCall; } } else if( isJailbreakReceiver( tree ) ) { Tree.Kind kind = tree.getKind(); if( kind == Tree.Kind.POSTFIX_INCREMENT || kind == Tree.Kind.POSTFIX_DECREMENT || kind == Tree.Kind.PREFIX_INCREMENT || kind == Tree.Kind.PREFIX_DECREMENT ) { // ++, -- operators not supported with jailbreak access to fields, only direct assignment _tp.report( tree, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_INCREMENT_OP_NOT_ALLOWED_REFLECTION.get() ); Types types = Types.instance( ((BasicJavacTask)_tp.getJavacTask()).getContext() ); tree.type = types.createErrorType( tree.type ); } result = tree; } else { result = tree; } }
Example 20
Source Project: javaide File: JavaCompiler.java License: GNU General Public License v3.0 | 4 votes |
/** * Construct a new compiler using a shared context. */ public JavaCompiler(Context context) { this.context = context; context.put(compilerKey, this); // if fileManager not already set, register the JavacFileManager to be used if (context.get(JavaFileManager.class) == null) JavacFileManager.preRegister(context); names = Names.instance(context); log = Log.instance(context); diagFactory = JCDiagnostic.Factory.instance(context); reader = ClassReader.instance(context); make = TreeMaker.instance(context); writer = ClassWriter.instance(context); enter = Enter.instance(context); todo = Todo.instance(context); fileManager = context.get(JavaFileManager.class); parserFactory = ParserFactory.instance(context); try { // catch completion problems with predefineds syms = Symtab.instance(context); } catch (CompletionFailure ex) { // inlined Check.completionError as it is not initialized yet log.error("cant.access", ex.sym, ex.getDetailValue()); if (ex instanceof ClassReader.BadClassFile) throw new Abort(); } source = Source.instance(context); attr = Attr.instance(context); chk = Check.instance(context); gen = Gen.instance(context); flow = Flow.instance(context); transTypes = TransTypes.instance(context); lower = Lower.instance(context); annotate = Annotate.instance(context); types = Types.instance(context); taskListener = context.get(TaskListener.class); reader.sourceCompleter = this; options = Options.instance(context); verbose = options.isSet(VERBOSE); sourceOutput = options.isSet(PRINTSOURCE); // used to be -s stubOutput = options.isSet("-stubs"); relax = options.isSet("-relax"); printFlat = options.isSet("-printflat"); attrParseOnly = options.isSet("-attrparseonly"); encoding = options.get(ENCODING); lineDebugInfo = options.isUnset(G_CUSTOM) || options.isSet(G_CUSTOM, "lines"); genEndPos = options.isSet(XJCOV) || context.get(DiagnosticListener.class) != null; devVerbose = options.isSet("dev"); processPcks = options.isSet("process.packages"); werror = options.isSet(WERROR); if (source.compareTo(Source.DEFAULT) < 0) { if (options.isUnset(XLINT_CUSTOM, "-" + LintCategory.OPTIONS.option)) { if (fileManager instanceof BaseFileManager) { if (((BaseFileManager) fileManager).isDefaultBootClassPath()) log.warning(LintCategory.OPTIONS, "source.no.bootclasspath", source.name); } } } verboseCompilePolicy = options.isSet("verboseCompilePolicy"); if (attrParseOnly) compilePolicy = CompilePolicy.ATTR_ONLY; else compilePolicy = CompilePolicy.decode(options.get("compilePolicy")); implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit")); completionFailureName = options.isSet("failcomplete") ? names.fromString(options.get("failcomplete")) : null; shouldStopPolicy = options.isSet("shouldStopPolicy") ? CompileState.valueOf(options.get("shouldStopPolicy")) : null; if (options.isUnset("oldDiags")) log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context)); }