com.sun.tools.javac.comp.Annotate Java Examples

The following examples show how to use com.sun.tools.javac.comp.Annotate. 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: SymbolMetadata.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #2
Source File: SymbolMetadata.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #3
Source File: SymbolMetadata.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #4
Source File: ManTypes.java    From manifold with Apache License 2.0 6 votes vote down vote up
private void reassignEarlyHolders8( Context context )
{
  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( JavacTrees.instance( context ), TYPES_FIELD ).set( this );
  ReflectUtil.field( JavacTypes.instance( context ), TYPES_FIELD ).set( this );
  ReflectUtil.field( JavacElements.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( RichDiagnosticFormatter.instance( context ), TYPES_FIELD ).set( this );
  ReflectUtil.field( TransTypes.instance( context ), TYPES_FIELD ).set( this );
}
 
Example #5
Source File: SymbolMetadata.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #6
Source File: ManResolve.java    From manifold with Apache License 2.0 6 votes vote down vote up
private void reassignEarlyHolders( Context context )
{
  ReflectUtil.field( _attr, RESOLVE_FIELD ).set( this );
  ReflectUtil.field( DeferredAttr.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Check.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Infer.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Flow.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( LambdaToMethod.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Lower.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Gen.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field(
    ReflectUtil.method(
      ReflectUtil.type( "com.sun.tools.javac.jvm.StringConcat" ), "instance", Context.class )
      .invokeStatic( context ), RESOLVE_FIELD )
    .set( this );
  ReflectUtil.field( JavacTrees.instance( context ), "resolve" ).set( this );
  ReflectUtil.field( Annotate.instance( context ), "resolve" ).set( this );
  ReflectUtil.field( TransTypes.instance( context ), "resolve" ).set( this );
  ReflectUtil.field( JavacElements.instance( context ), "resolve" ).set( this );
}
 
Example #7
Source File: ReusableContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void clear() {
    drop(Arguments.argsKey);
    drop(DiagnosticListener.class);
    drop(Log.outKey);
    drop(Log.errKey);
    drop(JavaFileManager.class);
    drop(JavacTask.class);

    if (ht.get(Log.logKey) instanceof ReusableLog) {
        //log already inited - not first round
        ((ReusableLog)Log.instance(this)).clear();
        Enter.instance(this).newRound();
        ((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
        Types.instance(this).newRound();
        Check.instance(this).newRound();
        Modules.instance(this).newRound();
        Annotate.instance(this).newRound();
        CompileStates.instance(this).clear();
        MultiTaskListener.instance(this).clear();

        //find if any of the roots have redefined java.* classes
        Symtab syms = Symtab.instance(this);
        pollutionScanner.scan(roots, syms);
        roots.clear();
    }
}
 
Example #8
Source File: SymbolMetadata.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #9
Source File: SymbolMetadata.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private <T extends Attribute.Compound> T replaceOne(Placeholder<T> placeholder, Annotate.AnnotateRepeatedContext<T> ctx) {
    Log log = ctx.log;

    // Process repeated annotations
    T validRepeated = ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor(), sym);

    if (validRepeated != null) {
        // Check that the container isn't manually
        // present along with repeated instances of
        // its contained annotation.
        ListBuffer<T> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
        if (manualContainer != null) {
            log.error(ctx.pos.get(manualContainer.first()), "invalid.repeatable.annotation.repeated.and.container.present",
                    manualContainer.first().type.tsym);
        }
    }

    // A null return will delete the Placeholder
    return validRepeated;
}
 
Example #10
Source File: TypeAnnotations.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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 File: SymbolMetadata.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #12
Source File: ClassReader.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Construct a new class reader, optionally treated as the
 * definitive classreader for this invocation.
 */
protected ClassReader(Context context, boolean definitive) {
    if (definitive) context.put(classReaderKey, this);

    names = Names.instance(context);
    syms = Symtab.instance(context);
    types = Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    if (fileManager == null)
        throw new AssertionError("FileManager initialization error");
    diagFactory = JCDiagnostic.Factory.instance(context);

    init(syms, definitive);
    log = Log.instance(context);

    Options options = Options.instance(context);
    annotate = Annotate.instance(context);
    verbose = options.isSet(VERBOSE);
    checkClassFile = options.isSet("-checkclassfile");
    Source source = Source.instance(context);
    allowGenerics = source.allowGenerics();
    allowVarargs = source.allowVarargs();
    allowAnnotations = source.allowAnnotations();
    allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    saveParameterNames = options.isSet("save-parameter-names");
    cacheCompletionFailure = options.isUnset("dev");
    preferSource = "source".equals(options.get("-Xprefer"));

    completionFailureName =
            options.isSet("failcomplete")
                    ? names.fromString(options.get("failcomplete"))
                    : null;

    typevars = new Scope(syms.noSymbol);

    lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);

    initAttributeReaders();
}
 
Example #13
Source File: ClassReader.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
/**
 * Construct a new class reader, optionally treated as the
 * definitive classreader for this invocation.
 */
protected ClassReader(Context context, boolean definitive) {
    if (definitive) context.put(classReaderKey, this);

    names = Names.instance(context);
    syms = Symtab.instance(context);
    types = Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    if (fileManager == null)
        throw new AssertionError("FileManager initialization error");
    diagFactory = JCDiagnostic.Factory.instance(context);

    init(syms, definitive);
    log = Log.instance(context);

    Options options = Options.instance(context);
    annotate = Annotate.instance(context);
    verbose = options.isSet(VERBOSE);
    checkClassFile = options.isSet("-checkclassfile");
    Source source = Source.instance(context);
    allowGenerics = source.allowGenerics();
    allowVarargs = source.allowVarargs();
    allowAnnotations = source.allowAnnotations();
    allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    saveParameterNames = options.isSet("save-parameter-names");
    cacheCompletionFailure = options.isUnset("dev");
    preferSource = "source".equals(options.get("-Xprefer"));

    completionFailureName =
            options.isSet("failcomplete")
                    ? names.fromString(options.get("failcomplete"))
                    : null;

    typevars = new Scope(syms.noSymbol);

    lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);

    initAttributeReaders();
}
 
Example #14
Source File: SymbolMetadata.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #15
Source File: TypeAnnotations.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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 #16
Source File: SymbolMetadata.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #17
Source File: SymbolMetadata.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #18
Source File: SymbolMetadata.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #19
Source File: SymbolMetadata.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #20
Source File: ClassReader.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Construct a new class reader. */
protected ClassReader(Context context) {
    context.put(classReaderKey, this);
    annotate = Annotate.instance(context);
    names = Names.instance(context);
    syms = Symtab.instance(context);
    types = Types.instance(context);
    fileManager = context.get(JavaFileManager.class);
    if (fileManager == null)
        throw new AssertionError("FileManager initialization error");
    diagFactory = JCDiagnostic.Factory.instance(context);

    log = Log.instance(context);

    Options options = Options.instance(context);
    verbose         = options.isSet(Option.VERBOSE);

    Source source = Source.instance(context);
    allowSimplifiedVarargs = source.allowSimplifiedVarargs();
    allowModules     = source.allowModules();

    saveParameterNames = options.isSet(PARAMETERS);

    profile = Profile.instance(context);

    typevars = WriteableScope.create(syms.noSymbol);

    lintClassfile = Lint.instance(context).isEnabled(LintCategory.CLASSFILE);

    initAttributeReaders();
}
 
Example #21
Source File: JavacTaskPool.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void clear() {
    drop(Arguments.argsKey);
    drop(DiagnosticListener.class);
    drop(Log.outKey);
    drop(Log.errKey);
    drop(JavaFileManager.class);
    drop(JavacTask.class);
    drop(JavacTrees.class);
    drop(JavacElements.class);

    if (ht.get(Log.logKey) instanceof ReusableLog) {
        //log already inited - not first round
        ((ReusableLog)Log.instance(this)).clear();
        Enter.instance(this).newRound();
        ((ReusableJavaCompiler)ReusableJavaCompiler.instance(this)).clear();
        Types.instance(this).newRound();
        Check.instance(this).newRound();
        Modules.instance(this).newRound();
        Annotate.instance(this).newRound();
        CompileStates.instance(this).clear();
        MultiTaskListener.instance(this).clear();

        //find if any of the roots have redefined java.* classes
        Symtab syms = Symtab.instance(this);
        pollutionScanner.scan(roots, syms);
        roots.clear();
    }
}
 
Example #22
Source File: ClassFinder.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Construct a new class finder. */
protected ClassFinder(Context context) {
    context.put(classFinderKey, this);
    reader = ClassReader.instance(context);
    names = Names.instance(context);
    syms = Symtab.instance(context);
    fileManager = context.get(JavaFileManager.class);
    dependencies = Dependencies.instance(context);
    if (fileManager == null)
        throw new AssertionError("FileManager initialization error");
    diagFactory = JCDiagnostic.Factory.instance(context);

    log = Log.instance(context);
    annotate = Annotate.instance(context);

    Options options = Options.instance(context);
    verbose = options.isSet(Option.VERBOSE);
    cacheCompletionFailure = options.isUnset("dev");
    preferSource = "source".equals(options.get("-Xprefer"));
    userPathsFirst = options.isSet(Option.XXUSERPATHSFIRST);
    allowSigFiles = context.get(PlatformDescription.class) != null;

    completionFailureName =
        options.isSet("failcomplete")
        ? names.fromString(options.get("failcomplete"))
        : null;

    profile = Profile.instance(context);
}
 
Example #23
Source File: TypeAnnotations.java    From lua-for-android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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);
}
 
Example #24
Source File: ManResolve.java    From manifold with Apache License 2.0 5 votes vote down vote up
private void reassignEarlyHolders8( Context context )
{
  ReflectUtil.field( Attr.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( DeferredAttr.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Check.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Infer.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Flow.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Lower.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Gen.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( Annotate.instance( context ), RESOLVE_FIELD ).set( this );
  ReflectUtil.field( JavacTrees.instance( context ), "resolve" ).set( this );
  ReflectUtil.field( TransTypes.instance( context ), "resolve" ).set( this );
}
 
Example #25
Source File: TypeAnnotations.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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 #26
Source File: TypeAnnotations.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
}
 
Example #27
Source File: SymbolMetadata.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public Placeholder(Annotate.AnnotateRepeatedContext<T> ctx, List<T> placeholderFor, Symbol on) {
    super(on.type, List.<Pair<Symbol.MethodSymbol, Attribute>>nil(),
            ctx.isTypeCompound ?
                    ((Attribute.TypeCompound)placeholderFor.head).position :
                        new TypeAnnotationPosition());
    this.ctx = ctx;
    this.placeholderFor = placeholderFor;
    this.on = on;
}
 
Example #28
Source File: TypeAnnotations.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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 #29
Source File: Symbol.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void appendTypeAttributesWithCompletion(final Annotate.AnnotateRepeatedContext<Attribute.TypeCompound> ctx) {
    initedMetadata().appendTypeAttributesWithCompletion(ctx);
}
 
Example #30
Source File: JavaCompiler.java    From javaide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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));
}