当前位置: 首页>>代码示例>>Java>>正文


Java Target类代码示例

本文整理汇总了Java中com.sun.tools.javac.jvm.Target的典型用法代码示例。如果您正苦于以下问题:Java Target类的具体用法?Java Target怎么用?Java Target使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Target类属于com.sun.tools.javac.jvm包,在下文中一共展示了Target类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Lower

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Lower(Context context) {
    context.put(lowerKey, this);
    names = Names.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    make = TreeMaker.instance(context);
    writer = ClassWriter.instance(context);
    reader = ClassReader.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    source = Source.instance(context);
    allowEnums = source.allowEnums();
    dollarAssertionsDisabled = names.
        fromString(target.syntheticNameChar() + "assertionsDisabled");
    classDollar = names.
        fromString("class" + target.syntheticNameChar());

    types = Types.instance(context);
    Options options = Options.instance(context);
    debugLower = options.isSet("debuglower");
    pkginfoOpt = PkgInfo.get(options);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:26,代码来源:Lower.java

示例2: Lower

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Lower(Context context) {
    context.put(lowerKey, this);
    names = Names.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    make = TreeMaker.instance(context);
    writer = ClassWriter.instance(context);
    reader = ClassReader.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    source = Source.instance(context);
    typeEnvs = TypeEnvs.instance(context);
    allowEnums = source.allowEnums();
    dollarAssertionsDisabled = names.
        fromString(target.syntheticNameChar() + "assertionsDisabled");
    classDollar = names.
        fromString("class" + target.syntheticNameChar());

    types = Types.instance(context);
    Options options = Options.instance(context);
    debugLower = options.isSet("debuglower");
    pkginfoOpt = PkgInfo.get(options);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:Lower.java

示例3: run

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
public void run() throws Exception {
    try (FileWriter out = new FileWriter("C.java")) {
        out.write("class C { }");
    }

    for (Source s: Source.values()) {
        test(s, null, "source", getKind(s, Source.MIN));
    }

    for (Target t: Target.values()) {
        test(Source.values()[0], t, "target", getKind(t, Target.MIN));
    }

    if (errors > 0)
        throw new Exception(errors + " errors occurred");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:SourceTargetTest.java

示例4: test

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
private static void test(String classname, String expected) throws Exception {
    File classfile = new File(System.getProperty("test.classes", "."), classname + ".class");
    ClassFile cf = ClassFile.read(classfile);

    cf = new ClassFile(cf.magic, Target.JDK1_7.minorVersion,
             Target.JDK1_7.majorVersion, cf.constant_pool, cf.access_flags,
            cf.this_class, cf.super_class, cf.interfaces, cf.fields,
            cf.methods, cf.attributes);

    new ClassWriter().write(cf, classfile);

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    JavacTaskImpl task = (JavacTaskImpl) c.getTask(null, null, null, Arrays.asList("-classpath", System.getProperty("test.classes", ".")), null, null);

    try {
        Symbol clazz = com.sun.tools.javac.main.JavaCompiler.instance(task.getContext()).resolveIdent(classname);

        clazz.complete();
    } catch (BadClassFile f) {
        JCDiagnostic embeddedDiag = (JCDiagnostic) f.diag.getArgs()[1];
        assertEquals(expected, embeddedDiag.getCode());
        assertEquals(Integer.toString(Target.JDK1_7.majorVersion), embeddedDiag.getArgs()[0]);
        assertEquals(Integer.toString(Target.JDK1_7.minorVersion), embeddedDiag.getArgs()[1]);
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:26,代码来源:BadClassfile.java

示例5: Lower

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Lower(Context context) {
    context.put(lowerKey, this);
    names = Name.Table.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    make = TreeMaker.instance(context);
    writer = ClassWriter.instance(context);
    reader = ClassReader.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    source = Source.instance(context);
    allowEnums = source.allowEnums();
    dollarAssertionsDisabled = names.
        fromString(target.syntheticNameChar() + "assertionsDisabled");
    classDollar = names.
        fromString("class" + target.syntheticNameChar());

    types = Types.instance(context);
    Options options = Options.instance(context);
    debugLower = options.get("debuglower") != null;
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:25,代码来源:Lower.java

示例6: MemberEnter

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected MemberEnter(Context context) {
    context.put(memberEnterKey, this);
    names = Names.instance(context);
    enter = Enter.instance(context);
    log = Log.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    syms = Symtab.instance(context);
    make = TreeMaker.instance(context);
    reader = ClassReader.instance(context);
    todo = Todo.instance(context);
    annotate = Annotate.instance(context);
    types = Types.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    target = Target.instance(context);
    deferredLintHandler = DeferredLintHandler.instance(context);
    Options options = Options.instance(context);
    skipAnnotations = options.isSet("skipAnnotations");
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:20,代码来源:MemberEnter.java

示例7: Lower

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Lower(Context context) {
    context.put(lowerKey, this);
    names = Names.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    make = TreeMaker.instance(context);
    writer = ClassWriter.instance(context);
    reader = ClassReader.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    source = Source.instance(context);
    allowEnums = source.allowEnums();
    dollarAssertionsDisabled = names.fromString(target.syntheticNameChar() + "assertionsDisabled");
    classDollar = names.fromString("class" + target.syntheticNameChar());

    types = Types.instance(context);
    Options options = Options.instance(context);
    debugLower = options.isSet("debuglower");
    pkginfoOpt = PkgInfo.get(options);
}
 
开发者ID:antoinebourget,项目名称:INF5000-StaticProxy,代码行数:24,代码来源:Lower.java

示例8: getQualifiedName

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
/**
 * Returns a qualified name of the {@link TypeElement} represented by this
 * {@link ElementHandle}. When the {@link ElementHandle} doesn't represent
 * a {@link TypeElement} it throws a {@link IllegalStateException}
 * @return the qualified name
 * @throws an {@link IllegalStateException} when this {@link ElementHandle} 
 * isn't creatred for the {@link TypeElement}.
 */
public @NonNull String getQualifiedName () throws IllegalStateException {
    if ((this.kind.isClass() && !isArray(signatures[0])) ||
            this.kind.isInterface() ||
            this.kind == ElementKind.MODULE ||
            this.kind == ElementKind.OTHER) {
        return this.signatures[0].replace (Target.DEFAULT.syntheticNameChar(),'.');    //NOI18N
    }
    else {
        throw new IllegalStateException ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ElementHandle.java

示例9: TryTreeTranslator

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
TryTreeTranslator(Context context) {
	this.context = context;
	// util
	make = TreeMaker.instance(context);
	symtab = Symtab.instance(context);
	names = Names.instance(context);
	rs = Resolve.instance(context);
	target = Target.instance(context);
	types = Types.instance(context);
	twrVars = new Scope(symtab.noSymbol);
	this.envs = Util.getEnvs(context);
}
 
开发者ID:prestongarno,项目名称:trywithres-compat,代码行数:13,代码来源:TryTreeTranslator.java

示例10: Attr

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Attr(Context context) {
    context.put(attrKey, this);

    names = Names.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    chk = Check.instance(context);
    memberEnter = MemberEnter.instance(context);
    make = TreeMaker.instance(context);
    enter = Enter.instance(context);
    infer = Infer.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    types = Types.instance(context);
    diags = JCDiagnostic.Factory.instance(context);
    annotate = Annotate.instance(context);
    deferredLintHandler = DeferredLintHandler.instance(context);

    Options options = Options.instance(context);

    Source source = Source.instance(context);
    allowGenerics = source.allowGenerics();
    allowVarargs = source.allowVarargs();
    allowEnums = source.allowEnums();
    allowBoxing = source.allowBoxing();
    allowCovariantReturns = source.allowCovariantReturns();
    allowAnonOuterThis = source.allowAnonOuterThis();
    allowStringsInSwitch = source.allowStringsInSwitch();
    sourceName = source.name;
    relax = (options.isSet("-retrofit") ||
             options.isSet("-relax"));
    findDiamonds = options.get("findDiamond") != null &&
             source.allowDiamond();
    useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:37,代码来源:Attr.java

示例11: Lower

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
protected Lower(Context context) {
    context.put(lowerKey, this);
    names = Names.instance(context);
    log = Log.instance(context);
    syms = Symtab.instance(context);
    rs = Resolve.instance(context);
    operators = Operators.instance(context);
    chk = Check.instance(context);
    attr = Attr.instance(context);
    make = TreeMaker.instance(context);
    writer = ClassWriter.instance(context);
    cfolder = ConstFold.instance(context);
    target = Target.instance(context);
    source = Source.instance(context);
    typeEnvs = TypeEnvs.instance(context);
    dollarAssertionsDisabled = names.
        fromString(target.syntheticNameChar() + "assertionsDisabled");
    classDollar = names.
        fromString("class" + target.syntheticNameChar());
    dollarCloseResource = names.
        fromString(target.syntheticNameChar() + "closeResource");

    types = Types.instance(context);
    Options options = Options.instance(context);
    debugLower = options.isSet("debuglower");
    pkginfoOpt = PkgInfo.get(options);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:Lower.java

示例12: testUnsafe

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
@Test
public void testUnsafe(Path base) throws IOException {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src,
                      "module m { requires jdk.unsupported; }",
                      "package test; public class Test { sun.misc.Unsafe unsafe; } ");
    Path classes = base.resolve("classes");
    tb.createDirectories(classes);

    List<String> log;
    List<String> expected = Arrays.asList(
            "Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe",
            "1 warning"
    );

    log = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(classes)
            .files(tb.findJavaFiles(src))
            .run(Expect.SUCCESS)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    if (!expected.equals(log)) {
        throw new AssertionError("Unexpected output: " + log);
    }

    log = new JavacTask(tb)
            .options("-XDrawDiagnostics",
                     "--release", Target.DEFAULT.multiReleaseValue())
            .outdir(classes)
            .files(tb.findJavaFiles(src))
            .run(Expect.SUCCESS)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    if (!expected.equals(log)) {
        throw new AssertionError("Unexpected output: " + log);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:41,代码来源:ReleaseOptionUnsupported.java

示例13: testUnsafeUnnamed

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
@Test
public void testUnsafeUnnamed(Path base) throws IOException {
    Path src = base.resolve("src");
    tb.writeJavaFiles(src,
                      "package test; public class Test { sun.misc.Unsafe unsafe; } ");
    Path classes = base.resolve("classes");
    tb.createDirectories(classes);

    List<String> log;
    List<String> expected = Arrays.asList(
            "Test.java:1:43: compiler.warn.sun.proprietary: sun.misc.Unsafe",
            "1 warning"
    );

    log = new JavacTask(tb)
            .options("-XDrawDiagnostics")
            .outdir(classes)
            .files(tb.findJavaFiles(src))
            .run(Expect.SUCCESS)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    if (!expected.equals(log)) {
        throw new AssertionError("Unexpected output: " + log);
    }

    log = new JavacTask(tb)
            .options("-XDrawDiagnostics",
                     "--release", Target.DEFAULT.multiReleaseValue())
            .outdir(classes)
            .files(tb.findJavaFiles(src))
            .run(Expect.SUCCESS)
            .writeAll()
            .getOutputLines(Task.OutputKind.DIRECT);

    if (!expected.equals(log)) {
        throw new AssertionError("Unexpected output: " + log);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ReleaseOptionUnsupported.java

示例14: test

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
void test(Source s, Target t, String select, Kind kind) {
    System.err.println("Test: source:" + s + ", target:" + t + " " + select + " " + kind);
    List<String> args = new ArrayList<>();
    args.add("-XDrawDiagnostics");
    args.add("-source");
    args.add(s.name);
    if (t != null) {
        args.add("-target");
        args.add(t.name);
    }
    args.add("C.java");

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
    pw.close();
    String out = sw.toString();
    System.err.print(out);

    switch (kind) {
        case INVALID:
            check(out, "removed." + select, true);
            check(out, "obsolete." + select, false);
            break;

        case OBSOLETE:
            check(out, "removed." + select, false);
            check(out, "obsolete." + select, true);
            break;

        case VALID:
            check(out, "removed." + select, false);
            check(out, "obsolete." + select, false);
            break;
    }

    System.err.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:SourceTargetTest.java

示例15: test

import com.sun.tools.javac.jvm.Target; //导入依赖的package包/类
private static void test(String classname, String expected) throws Exception {
    File classfile = new File(System.getProperty("test.classes", "."), classname + ".class");
    ClassFile cf = ClassFile.read(classfile);

    cf = new ClassFile(cf.magic, Target.JDK1_7.minorVersion,
             Target.JDK1_7.majorVersion, cf.constant_pool, cf.access_flags,
            cf.this_class, cf.super_class, cf.interfaces, cf.fields,
            cf.methods, cf.attributes);

    new ClassWriter().write(cf, classfile);

    JavaCompiler c = ToolProvider.getSystemJavaCompiler();
    JavacTaskImpl task = (JavacTaskImpl) c.getTask(null, null, null, Arrays.asList("-classpath", System.getProperty("test.classes", ".")), null, null);
    Symtab syms = Symtab.instance(task.getContext());

    task.ensureEntered();

    try {
        Symbol clazz = com.sun.tools.javac.main.JavaCompiler.instance(task.getContext()).resolveIdent(syms.unnamedModule, classname);

        clazz.complete();
    } catch (BadClassFile f) {
        JCDiagnostic embeddedDiag = (JCDiagnostic) f.diag.getArgs()[1];
        assertEquals(expected, embeddedDiag.getCode());
        assertEquals(Integer.toString(Target.JDK1_7.majorVersion), embeddedDiag.getArgs()[0]);
        assertEquals(Integer.toString(Target.JDK1_7.minorVersion), embeddedDiag.getArgs()[1]);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:BadClassfile.java


注:本文中的com.sun.tools.javac.jvm.Target类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。