本文整理汇总了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);
}
示例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);
}
示例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");
}
示例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]);
}
}
示例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;
}
示例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");
}
示例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);
}
示例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 ();
}
}
示例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);
}
示例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");
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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]);
}
}