com.sun.tools.javac.util.Log Java Examples
The following examples show how to use
com.sun.tools.javac.util.Log.
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 File: StrictJavaDepsPlugin.java From bazel with Apache License 2.0 | 6 votes |
@Override public void init( Context context, Log log, JavaCompiler compiler, BlazeJavacStatistics.Builder statisticsBuilder) { super.init(context, log, compiler, statisticsBuilder); errWriter = log.getWriter(WriterKind.ERROR); implicitDependencyExtractor = new ImplicitDependencyExtractor( dependencyModule.getImplicitDependenciesMap(), dependencyModule.getPlatformJars()); checkingTreeScanner = context.get(CheckingTreeScanner.class); if (checkingTreeScanner == null) { Set<Path> platformJars = dependencyModule.getPlatformJars(); checkingTreeScanner = new CheckingTreeScanner(dependencyModule, diagnostics, missingTargets, platformJars); context.put(CheckingTreeScanner.class, checkingTreeScanner); } }
Example #2
Source File: JavacProcessingEnvironment.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** Create a round (common code). */ private Round(int number, Set<JCCompilationUnit> treesToClean, Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { this.number = number; if (number == 1) { Assert.checkNonNull(deferredDiagnosticHandler); this.deferredDiagnosticHandler = deferredDiagnosticHandler; } else { this.deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log); compiler.setDeferredDiagnosticHandler(this.deferredDiagnosticHandler); } // the following will be populated as needed topLevelClasses = List.nil(); packageInfoFiles = List.nil(); moduleInfoFiles = List.nil(); this.treesToClean = treesToClean; }
Example #3
Source File: Flow.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected Flow(Context context) { context.put(flowKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); types = Types.instance(context); chk = Check.instance(context); lint = Lint.instance(context); rs = Resolve.instance(context); diags = JCDiagnostic.Factory.instance(context); Source source = Source.instance(context); allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis(); allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis(); allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses(); enforceThisDotInit = source.enforceThisDotInit(); }
Example #4
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** Create the first round. */ Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols, Log.DeferredDiagnosticHandler deferredDiagnosticHandler) { this(context, 1, 0, 0, deferredDiagnosticHandler); this.roots = roots; genClassFiles = new HashMap<String,JavaFileObject>(); compiler.todo.clear(); // free the compiler's resources // The reverse() in the following line is to maintain behavioural // compatibility with the previous revision of the code. Strictly speaking, // it should not be necessary, but a javah golden file test fails without it. topLevelClasses = getTopLevelClasses(roots).prependList(classSymbols.reverse()); packageInfoFiles = getPackageInfoFiles(roots); findAnnotationsPresent(); }
Example #5
Source File: Start.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public Start(Context context) { context.getClass(); // null check this.context = context; apiMode = true; defaultDocletClassName = standardDocletClassName; docletParentClassLoader = null; Log log = context.get(Log.logKey); if (log instanceof Messager) messager = (Messager) log; else { PrintWriter out = context.get(Log.outKey); messager = (out == null) ? new Messager(context, javadocName) : new Messager(context, javadocName, out, out, out); } }
Example #6
Source File: Analyzer.java From lua-for-android with 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 #7
Source File: Option.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Composes the initial synopsis of one of the forms for this option. * @param name the name of this form of the option * @param log the log used to localize the description of the arguments * @return the synopsis */ private String helpSynopsis(String name, Log log) { StringBuilder sb = new StringBuilder(); sb.append(name); if (argsNameKey == null) { if (choices != null) { if (!name.endsWith(":")) sb.append(" "); String sep = "{"; for (String choice : choices) { sb.append(sep); sb.append(choice); sep = ","; } sb.append("}"); } } else { if (!name.matches(".*[=:]$") && argKind != ArgKind.ADJACENT) sb.append(" "); sb.append(log.localize(PrefixKind.JAVAC, argsNameKey)); } return sb.toString(); }
Example #8
Source File: Main.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Report a usage error. */ void error(String key, Object... args) { if (apiMode) { String msg = getLocalizedString(key, args); throw new PropagatedException(new IllegalStateException(msg)); } warning(key, args); Log.printLines(out, getLocalizedString("msg.usage", ownName)); }
Example #9
Source File: ScannerFactory.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** Create a new scanner factory. */ protected ScannerFactory(Context context) { context.put(scannerFactoryKey, this); this.log = Log.instance(context); this.names = Names.instance(context); this.source = Source.instance(context); this.tokens = Tokens.instance(context); }
Example #10
Source File: JNIWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
/** Construct a class writer, given an options table. */ private JNIWriter(Context context) { context.put(jniWriterKey, this); fileManager = context.get(JavaFileManager.class); log = Log.instance(context); Options options = Options.instance(context); verbose = options.isSet(VERBOSE); checkAll = options.isSet("javah:full"); this.context = context; // for lazyInit() syms = Symtab.instance(context); lineSep = System.getProperty("line.separator"); }
Example #11
Source File: JavacProcessingEnvironment.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Checks whether or not a processor's source version is * compatible with the compilation source version. The * processor's source version needs to be greater than or * equal to the source version of the compile. */ private void checkSourceVersionCompatibility(Source source, Log log) { SourceVersion procSourceVersion = processor.getSupportedSourceVersion(); if (procSourceVersion.compareTo(Source.toSourceVersion(source)) < 0 ) { log.warning("proc.processor.incompatible.source.version", procSourceVersion, processor.getClass().getName(), source.name); } }
Example #12
Source File: Messager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static void preRegister(Context context, final String programName, final PrintWriter errWriter, final PrintWriter warnWriter, final PrintWriter noticeWriter) { context.put(logKey, new Context.Factory<Log>() { public Log make(Context c) { return new Messager(c, programName, errWriter, warnWriter, noticeWriter); } }); }
Example #13
Source File: TypeAnnotations.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
protected TypeAnnotations(Context context) { context.put(typeAnnosKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); Options options = Options.instance(context); }
Example #14
Source File: T7116676.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public void testThroughFormatterFormat() throws IOException { final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); DiagnosticChecker dc = new DiagnosticChecker("compiler.err.prob.found.req"); JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(new JavaSource())); ct.analyze(); DiagnosticFormatter<JCDiagnostic> formatter = Log.instance(((JavacTaskImpl) ct).getContext()).getDiagnosticFormatter(); String msg = formatter.formatMessage(dc.diag, Locale.getDefault()); //no redundant package qualifiers Assert.check(msg.indexOf("java.") == -1, msg); }
Example #15
Source File: Arguments.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected Arguments(Context context) { context.put(argsKey, this); options = Options.instance(context); log = Log.instance(context); this.context = context; // Ideally, we could init this here and update/configure it as // needed, but right now, initializing a file manager triggers // initialization of other items in the context, such as Lint // and FSInfo, which should not be initialized until after // processArgs // fileManager = context.get(JavaFileManager.class); }
Example #16
Source File: JavacProcessingEnvironment.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Convert import-style string for supported annotations into a * regex matching that string. If the string is a valid * import-style string, return a regex that won't match anything. */ private static Pattern importStringToPattern(String s, Processor p, Log log) { if (isValidImportString(s)) { return validImportStringToPattern(s); } else { log.warning("proc.malformed.supported.string", s, p.getClass().getName()); return noMatches; // won't match any valid identifier } }
Example #17
Source File: ParserFactory.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
protected ParserFactory(Context context) { super(); context.put(parserFactoryKey, this); this.F = TreeMaker.instance(context); this.log = Log.instance(context); this.names = Names.instance(context); this.keywords = Keywords.instance(context); this.source = Source.instance(context); this.options = Options.instance(context); this.scannerFactory = ScannerFactory.instance(context); }
Example #18
Source File: TypeAnnotations.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected TypeAnnotations(Context context) { context.put(typeAnnosKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); Options options = Options.instance(context); }
Example #19
Source File: ModuleFinder.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Construct a new module finder. */ protected ModuleFinder(Context context) { context.put(moduleFinderKey, this); names = Names.instance(context); syms = Symtab.instance(context); fileManager = context.get(JavaFileManager.class); log = Log.instance(context); classFinder = ClassFinder.instance(context); diags = JCDiagnostic.Factory.instance(context); }
Example #20
Source File: JavacTurbineJavaCompiler.java From bazel with Apache License 2.0 | 5 votes |
public JavacTurbineJavaCompiler( Context context, @Nullable StrictJavaDepsPlugin strictJavaDeps, JavacTransitive transitive) { super(context); this.strictJavaDeps = strictJavaDeps; if (strictJavaDeps != null) { strictJavaDeps.init( context, Log.instance(context), this, context.get(BlazeJavacStatistics.Builder.class)); } this.transitive = transitive; }
Example #21
Source File: JavacProcessingEnvironment.java From hottub with GNU General Public License v2.0 | 5 votes |
private boolean checkOptionName(String optionName, Log log) { boolean valid = isValidOptionName(optionName); if (!valid) log.error("proc.processor.bad.option.name", optionName, processor.getClass().getName()); return valid; }
Example #22
Source File: JavacTrees.java From openjdk-jdk8u with 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 #23
Source File: MemberEnter.java From lua-for-android with 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 #24
Source File: JavacProcessingEnvironment.java From openjdk-8-source with GNU General Public License v2.0 | 5 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(XPRINTPROCESSORINFO); printRounds = options.isSet(XPRINTROUNDS); verbose = options.isSet(VERBOSE); lint = Lint.instance(context).isEnabled(PROCESSING); if (options.isSet(PROC, "only") || options.isSet(XPRINT)) { JavaCompiler compiler = JavaCompiler.instance(context); compiler.shouldStopPolicyIfNoError = CompileState.PROCESS; } fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(WERROR); 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); processorOptions = initProcessorOptions(context); unmatchedProcessorOptions = initUnmatchedProcessorOptions(); messages = JavacMessages.instance(context); taskListener = MultiTaskListener.instance(context); initProcessorClassLoader(); }
Example #25
Source File: ScannerFactory.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** Create a new scanner factory. */ protected ScannerFactory(Context context) { context.put(scannerFactoryKey, this); this.log = Log.instance(context); this.names = Names.instance(context); this.source = Source.instance(context); this.tokens = Tokens.instance(context); }
Example #26
Source File: JavacProcessingEnvironment.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
/** * Convert import-style string for supported annotations into a * regex matching that string. If the string is a valid * import-style string, return a regex that won't match anything. */ private static Pattern importStringToPattern(String s, Processor p, Log log) { if (isValidImportString(s)) { return validImportStringToPattern(s); } else { log.warning("proc.malformed.supported.string", s, p.getClass().getName()); return noMatches; // won't match any valid identifier } }
Example #27
Source File: Messager.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** Get the current messager, which is also the compiler log. */ public static Messager instance0(Context context) { Log instance = context.get(logKey); if (instance == null || !(instance instanceof Messager)) throw new InternalError("no messager instance!"); return (Messager)instance; }
Example #28
Source File: JavadocTool.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public StandardJavaFileManager getStandardFileManager( DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) { Context context = new Context(); context.put(Locale.class, locale); if (diagnosticListener != null) context.put(DiagnosticListener.class, diagnosticListener); PrintWriter pw = (charset == null) ? new PrintWriter(System.err, true) : new PrintWriter(new OutputStreamWriter(System.err, charset), true); context.put(Log.outKey, pw); return new JavacFileManager(context, true, charset); }
Example #29
Source File: TypeAnnotations.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected TypeAnnotations(Context context) { context.put(typeAnnosKey, this); names = Names.instance(context); log = Log.instance(context); syms = Symtab.instance(context); annotate = Annotate.instance(context); attr = Attr.instance(context); Options options = Options.instance(context); }
Example #30
Source File: T6597678.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); Log log = Log.instance(context); PrintWriter noteOut = log.getWriter(Log.WriterKind.NOTICE); PrintWriter warnOut = log.getWriter(Log.WriterKind.WARNING); PrintWriter errOut = log.getWriter(Log.WriterKind.ERROR); Locale locale = context.get(Locale.class); JavacMessages messages = context.get(JavacMessages.messagesKey); round++; if (round == 1) { initialLocale = locale; initialMessages = messages; initialNoteWriter = noteOut; initialWarnWriter = warnOut; initialErrWriter = errOut; String writerStringOpt = options.get("WriterString").intern(); checkEqual("noteWriterString", noteOut.toString().intern(), writerStringOpt); checkEqual("warnWriterString", warnOut.toString().intern(), writerStringOpt); checkEqual("errWriterString", errOut.toString().intern(), writerStringOpt); } else { checkEqual("locale", locale, initialLocale); checkEqual("messages", messages, initialMessages); checkEqual("noteWriter", noteOut, initialNoteWriter); checkEqual("warnWriter", warnOut, initialWarnWriter); checkEqual("errWriter", errOut, initialErrWriter); } return true; }