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 Project: lua-for-android Author: qtiuto 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 #2
Source Project: lua-for-android Author: qtiuto File: Option.java License: 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 #3
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: JavacProcessingEnvironment.java License: 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 #4
Source Project: openjdk-8 Author: bpupadhyaya File: Start.java License: 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 #5
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: JavacProcessingEnvironment.java License: 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 #6
Source Project: lua-for-android Author: qtiuto File: Flow.java License: 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 #7
Source Project: bazel Author: bazelbuild File: StrictJavaDepsPlugin.java License: 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 #8
Source Project: lua-for-android Author: qtiuto File: ClassWriter.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** Construct a class writer, given an options table. */ protected ClassWriter(Context context) { context.put(classWriterKey, this); log = Log.instance(context); names = Names.instance(context); options = Options.instance(context); target = Target.instance(context); source = Source.instance(context); types = Types.instance(context); fileManager = context.get(JavaFileManager.class); signatureGen = new CWSignatureGenerator(types); verbose = options.isSet(VERBOSE); genCrt = options.isSet(XJCOV); debugstackmap = options.isSet("debug.stackmap"); emitSourceFile = options.isUnset(G_CUSTOM) || options.isSet(G_CUSTOM, "source"); String modifierFlags = options.get("debug.dumpmodifiers"); if (modifierFlags != null) { dumpClassModifiers = modifierFlags.indexOf('c') != -1; dumpFieldModifiers = modifierFlags.indexOf('f') != -1; dumpInnerClassModifiers = modifierFlags.indexOf('i') != -1; dumpMethodModifiers = modifierFlags.indexOf('m') != -1; } }
Example #9
Source Project: openjdk-jdk8u Author: AdoptOpenJDK 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 #10
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: TypeAnnotations.java License: 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 #11
Source Project: TencentKona-8 Author: Tencent File: Messager.java License: 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 #12
Source Project: openjdk-8 Author: bpupadhyaya 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 #13
Source Project: hottub Author: dsrg-uoft File: TypeAnnotations.java License: 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 Project: manifold Author: manifold-systems File: JavaDynamicJdk_8.java License: Apache License 2.0 | 5 votes |
@Override public <T> void report( Log issueLogger, Diagnostic<? extends T> diagnostic ) { // Adapted from JavacMessager.printMessage. Following same basic routine regarding use of Log JavaFileObject oldSource = issueLogger.useSource( (JavaFileObject)diagnostic.getSource() ); boolean oldMultipleErrors = issueLogger.multipleErrors; issueLogger.multipleErrors = true; try { switch( diagnostic.getKind() ) { case ERROR: issueLogger.error( new IssueReporter.Position( diagnostic ), "proc.messager", diagnostic.getMessage( Locale.getDefault() ) ); break; case WARNING: issueLogger.warning( new IssueReporter.Position( diagnostic ), "proc.messager", diagnostic.getMessage( Locale.getDefault() ) ); break; case MANDATORY_WARNING: issueLogger.mandatoryWarning( new IssueReporter.Position( diagnostic ), "proc.messager", diagnostic.getMessage( Locale.getDefault() ) ); break; case NOTE: case OTHER: issueLogger.note( new IssueReporter.Position( diagnostic ), "proc.messager", diagnostic.getMessage( Locale.getDefault() ) ); break; } } finally { issueLogger.useSource( oldSource ); issueLogger.multipleErrors = oldMultipleErrors; } }
Example #15
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: ArgumentAttr.java License: GNU General Public License v2.0 | 5 votes |
protected ArgumentAttr(Context context) { context.put(methodAttrKey, this); deferredAttr = DeferredAttr.instance(context); attr = Attr.instance(context); syms = Symtab.instance(context); log = Log.instance(context); }
Example #16
Source Project: openjdk-8-source Author: keerath File: JavacProcessingEnvironment.java License: GNU General Public License v2.0 | 5 votes |
ServiceIterator(ClassLoader classLoader, Log log) { this.log = log; try { try { loader = ServiceLoader.load(Processor.class, classLoader); this.iterator = loader.iterator(); } catch (Exception e) { // Fail softly if a loader is not actually needed. this.iterator = handleServiceLoaderUnavailability("proc.no.service", null); } } catch (Throwable t) { log.error("proc.service.problem"); throw new Abort(t); } }
Example #17
Source Project: java-n-IDE-for-Android Author: shenghuntianlang File: JavacProcessingEnvironment.java License: Apache License 2.0 | 5 votes |
ProcessorState(Processor p, Log log, Source source, ProcessingEnvironment env) { processor = p; contributed = false; try { processor.init(env); checkSourceVersionCompatibility(source, log); supportedAnnotationPatterns = new ArrayList<Pattern>(); for (String importString : processor.getSupportedAnnotationTypes()) { supportedAnnotationPatterns.add(importStringToPattern(importString, processor, log)); } supportedOptionNames = new ArrayList<String>(); for (String optionName : processor.getSupportedOptions() ) { if (checkOptionName(optionName, log)) supportedOptionNames.add(optionName); } } catch (ClientCodeException e) { throw e; } catch (Throwable t) { throw new AnnotationProcessingError(t); } }
Example #18
Source Project: lua-for-android Author: qtiuto File: JavaCompiler.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Check if we should process annotations. * If so, and if no scanner is yet registered, then set up the DocCommentScanner * to catch doc comments, and set keepComments so the parser records them in * the compilation unit. * * @param processors user provided annotation processors to bypass * discovery, {@code null} means that no processors were provided */ public void initProcessAnnotations(Iterable<? extends Processor> processors, Collection<? extends JavaFileObject> initialFiles, Collection<String> initialClassNames) { // Process annotations if processing is not disabled and there // is at least one Processor available. if (options.isSet(PROC, "none")) { processAnnotations = false; } else if (procEnvImpl == null) { procEnvImpl = JavacProcessingEnvironment.instance(context); procEnvImpl.setProcessors(processors); processAnnotations = procEnvImpl.atLeastOneProcessor(); if (processAnnotations) { options.put("parameters", "parameters"); reader.saveParameterNames = true; keepComments = true; genEndPos = true; if (!taskListener.isEmpty()) taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING)); deferredDiagnosticHandler = new Log.DeferredDiagnosticHandler(log); procEnvImpl.getFiler().setInitialState(initialFiles, initialClassNames); } else { // free resources procEnvImpl.close(); } } }
Example #19
Source Project: TencentKona-8 Author: Tencent File: JavacProcessingEnvironment.java License: 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 #20
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: JavacProcessingEnvironment.java License: GNU General Public License v2.0 | 5 votes |
ServiceIterator(ClassLoader classLoader, Log log) { this.log = log; try { try { loader = ServiceLoader.load(Processor.class, classLoader); this.iterator = loader.iterator(); } catch (Exception e) { // Fail softly if a loader is not actually needed. this.iterator = handleServiceLoaderUnavailability("proc.no.service", null); } } catch (Throwable t) { log.error("proc.service.problem"); throw new Abort(t); } }
Example #21
Source Project: openjdk-8-source Author: keerath File: JavacTool.java License: GNU General Public License v2.0 | 5 votes |
public JavacFileManager 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 #22
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: JNIWriter.java License: 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 #23
Source Project: lua-for-android Author: qtiuto File: BaseFileManager.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Set the context for JavacPathFileManager. * @param context the context containing items to be associated with the file manager */ public void setContext(Context context) { log = Log.instance(context); options = Options.instance(context); classLoaderClass = options.get("procloader"); // Avoid initializing Lint boolean warn = options.isLintSet("path"); locations.update(log, warn, FSInfo.instance(context)); // Setting this option is an indication that close() should defer actually closing // the file manager until after a specified period of inactivity. // This is to accomodate clients which save references to Symbols created for use // within doclets or annotation processors, and which then attempt to use those // references after the tool exits, having closed any internally managed file manager. // Ideally, such clients should run the tool via the javax.tools API, providing their // own file manager, which can be closed by the client when all use of that file // manager is complete. // If the option has a numeric value, it will be interpreted as the duration, // in seconds, of the period of inactivity to wait for, before the file manager // is actually closed. // See also deferredClose(). String s = options.get("fileManager.deferClose"); if (s != null) { try { deferredCloseTimeout = (int) (Float.parseFloat(s) * 1000); } catch (NumberFormatException e) { deferredCloseTimeout = 60 * 1000; // default: one minute, in millis } } }
Example #24
Source Project: lua-for-android Author: qtiuto File: JavacProcessingEnvironment.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
ServiceIterator(ClassLoader classLoader, Log log) { this.log = log; try { try { loader = ServiceLoader.load(Processor.class, classLoader); this.iterator = loader.iterator(); } catch (Exception e) { // Fail softly if a loader is not actually needed. this.iterator = handleServiceLoaderUnavailability("proc.no.service", null); } } catch (Throwable t) { log.error(Errors.ProcServiceProblem); throw new Abort(t); } }
Example #25
Source Project: openjdk-jdk8u Author: AdoptOpenJDK File: TestLog.java License: GNU General Public License v2.0 | 5 votes |
static void test(boolean genEndPos) throws IOException { Context context = new Context(); Options options = Options.instance(context); options.put("diags", "%b:%s/%o/%e:%_%t%m|%p%m"); Log log = Log.instance(context); log.multipleErrors = true; JavacFileManager.preRegister(context); ParserFactory pfac = ParserFactory.instance(context); final String text = "public class Foo {\n" + " public static void main(String[] args) {\n" + " if (args.length == 0)\n" + " System.out.println(\"no args\");\n" + " else\n" + " System.out.println(args.length + \" args\");\n" + " }\n" + "}\n"; JavaFileObject fo = new StringJavaFileObject("Foo", text); log.useSource(fo); CharSequence cs = fo.getCharContent(true); Parser parser = pfac.newParser(cs, false, genEndPos, false); JCTree.JCCompilationUnit tree = parser.parseCompilationUnit(); log.setEndPosTable(fo, tree.endPositions); TreeScanner ts = new LogTester(log, tree.endPositions); ts.scan(tree); check(log.nerrors, 4, "errors"); check(log.nwarnings, 4, "warnings"); }
Example #26
Source Project: javaide Author: tranleduy2000 File: JavacProcessingEnvironment.java License: GNU General Public License v3.0 | 5 votes |
public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) { this.context = context; 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); procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT); fatalErrors = options.isSet("fatalEnterError"); showResolveErrors = options.isSet("showResolveErrors"); werror = options.isSet(WERROR); platformAnnotations = initPlatformAnnotations(); foundTypeProcessors = false; // 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); initProcessorIterator(context, processors); }
Example #27
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Start.java License: GNU General Public License v2.0 | 5 votes |
public Start(Context context) { this.context = Objects.requireNonNull(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.errKey); messager = (out == null) ? new Messager(context, javadocName) : new Messager(context, javadocName, out, out, out); } }
Example #28
Source Project: java-n-IDE-for-Android Author: shenghuntianlang File: Main.java License: Apache License 2.0 | 5 votes |
/** * Print a string that explains usage. */ void help() { Log.printLines(out, getLocalizedString("msg.usage.header", ownName)); for (int i = 0; i < recognizedOptions.length; i++) { recognizedOptions[i].help(out); } out.println(); }
Example #29
Source Project: openjdk-jdk9 Author: AdoptOpenJDK File: Messager.java License: 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 #30
Source Project: TencentKona-8 Author: Tencent File: T7116676.java License: 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); }