Java Code Examples for com.sun.tools.javac.code.Kinds#TYP
The following examples show how to use
com.sun.tools.javac.code.Kinds#TYP .
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: JNIWriter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 2
Source File: JNIWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 3
Source File: MutableFieldsAnalyzer.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override public void visitVarDef(JCVariableDecl tree) { boolean isJavacPack = tree.sym.outermostClass().fullname.toString() .contains(packageToCheck); if (isJavacPack && (tree.sym.flags() & SYNTHETIC) == 0 && tree.sym.owner.kind == Kinds.TYP) { if (!ignoreField(tree.sym.owner.flatName().toString(), tree.getName().toString())) { boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0; boolean nonFinalStaticEnumField = (tree.sym.flags() & (ENUM | FINAL)) == 0; boolean nonFinalStaticField = (tree.sym.flags() & STATIC) != 0 && (tree.sym.flags() & FINAL) == 0; if (enumClass ? nonFinalStaticEnumField : nonFinalStaticField) { messages.error(tree, "crules.err.var.must.be.final", tree); } } } super.visitVarDef(tree); }
Example 4
Source File: JNIWriter.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 5
Source File: JNIWriter.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 6
Source File: JNIWriter.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 7
Source File: JNIWriter.java From hottub with GNU General Public License v2.0 | 6 votes |
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) { if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0) return false; for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0) return true; for (Attribute.Compound a: i.sym.getDeclarationAttributes()) { if (a.type.tsym == syms.nativeHeaderType.tsym) return true; } } if (checkNestedClasses) { for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) { if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true)) return true; } } return false; }
Example 8
Source File: RichDiagnosticFormatter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound() && !s.type.isPrimitive()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 9
Source File: RichDiagnosticFormatter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound() && !s.type.isPrimitive()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 10
Source File: JavadocEnter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Override public void visitClassDef(JCClassDecl tree) { super.visitClassDef(tree); if (tree.sym == null) return; if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) { ClassSymbol c = tree.sym; docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree)); } }
Example 11
Source File: TypeVariableImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Return the class, interface, method, or constructor within * which this type variable is declared. */ public ProgramElementDoc owner() { Symbol osym = type.tsym.owner; if ((osym.kind & Kinds.TYP) != 0) { return env.getClassDoc((ClassSymbol)osym); } Names names = osym.name.table.names; if (osym.name == names.init) { return env.getConstructorDoc((MethodSymbol)osym); } else { return env.getMethodDoc((MethodSymbol)osym); } }
Example 12
Source File: RichDiagnosticFormatter.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound() && !s.type.isPrimitive()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 13
Source File: RichDiagnosticFormatter.java From java-n-IDE-for-Android with Apache License 2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.getEnclosingType().tag == CLASS && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 14
Source File: TypeVariableImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Return the class, interface, method, or constructor within * which this type variable is declared. */ public ProgramElementDoc owner() { Symbol osym = type.tsym.owner; if ((osym.kind & Kinds.TYP) != 0) { return env.getClassDoc((ClassSymbol)osym); } Names names = osym.name.table.names; if (osym.name == names.init) { return env.getConstructorDoc((MethodSymbol)osym); } else { return env.getMethodDoc((MethodSymbol)osym); } }
Example 15
Source File: TypeVariableImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Return the class, interface, method, or constructor within * which this type variable is declared. */ public ProgramElementDoc owner() { Symbol osym = type.tsym.owner; if ((osym.kind & Kinds.TYP) != 0) { return env.getClassDoc((ClassSymbol)osym); } Names names = osym.name.table.names; if (osym.name == names.init) { return env.getConstructorDoc((MethodSymbol)osym); } else { return env.getMethodDoc((MethodSymbol)osym); } }
Example 16
Source File: RichDiagnosticFormatter.java From hottub with GNU General Public License v2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound() && !s.type.isPrimitive()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 17
Source File: RichDiagnosticFormatter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public String simplify(Symbol s) { String name = s.getQualifiedName().toString(); if (!s.type.isCompound() && !s.type.isPrimitive()) { List<Symbol> conflicts = nameClashes.get(s.getSimpleName()); if (conflicts == null || (conflicts.size() == 1 && conflicts.contains(s))) { List<Name> l = List.nil(); Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && s2.owner.kind == Kinds.TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } l = l.prepend(s2.getSimpleName()); StringBuilder buf = new StringBuilder(); String sep = ""; for (Name n2 : l) { buf.append(sep); buf.append(n2); sep = "."; } name = buf.toString(); } } return name; }
Example 18
Source File: T6889255.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void test(String testName, boolean expectNames, String... opts) throws Exception { System.err.println("Test " + testName + ": expectNames:" + expectNames + " javacOpts:" + Arrays.asList(opts)); File outDir = new File(testName); outDir.mkdirs(); compile(outDir, opts); Context ctx = new Context(); JavacFileManager fm = new JavacFileManager(ctx, true, null); fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir)); ClassReader cr = ClassReader.instance(ctx); cr.saveParameterNames = true; Names names = Names.instance(ctx); Set<String> classes = getTopLevelClasses(outDir); Deque<String> work = new LinkedList<String>(classes); String classname; while ((classname = work.poll()) != null) { System.err.println("Checking class " + classname); ClassSymbol sym = cr.enterClass(names.table.fromString(classname)); sym.complete(); if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; for (Scope.Entry e = sym.members_field.elems; e != null; e = e.sibling) { System.err.println("Checking member " + e.sym); switch (e.sym.kind) { case Kinds.TYP: { String name = e.sym.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); } break; } case Kinds.MTH: verify((MethodSymbol) e.sym, expectNames); break; } } } }
Example 19
Source File: T6889255.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void test(String testName, boolean expectNames, String... opts) throws Exception { System.err.println("Test " + testName + ": expectNames:" + expectNames + " javacOpts:" + Arrays.asList(opts)); File outDir = new File(testName); outDir.mkdirs(); compile(outDir, opts); Context ctx = new Context(); JavacFileManager fm = new JavacFileManager(ctx, true, null); fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir)); ClassReader cr = ClassReader.instance(ctx); cr.saveParameterNames = true; Names names = Names.instance(ctx); Set<String> classes = getTopLevelClasses(outDir); Deque<String> work = new LinkedList<String>(classes); String classname; while ((classname = work.poll()) != null) { System.err.println("Checking class " + classname); ClassSymbol sym = cr.enterClass(names.table.fromString(classname)); sym.complete(); if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; for (Scope.Entry e = sym.members_field.elems; e != null; e = e.sibling) { System.err.println("Checking member " + e.sym); switch (e.sym.kind) { case Kinds.TYP: { String name = e.sym.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); } break; } case Kinds.MTH: verify((MethodSymbol) e.sym, expectNames); break; } } } }
Example 20
Source File: T6889255.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void test(String testName, boolean expectNames, String... opts) throws Exception { System.err.println("Test " + testName + ": expectNames:" + expectNames + " javacOpts:" + Arrays.asList(opts)); File outDir = new File(testName); outDir.mkdirs(); compile(outDir, opts); Context ctx = new Context(); JavacFileManager fm = new JavacFileManager(ctx, true, null); fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(outDir)); ClassReader cr = ClassReader.instance(ctx); cr.saveParameterNames = true; Names names = Names.instance(ctx); Set<String> classes = getTopLevelClasses(outDir); Deque<String> work = new LinkedList<String>(classes); String classname; while ((classname = work.poll()) != null) { System.err.println("Checking class " + classname); ClassSymbol sym = cr.enterClass(names.table.fromString(classname)); sym.complete(); if ((sym.flags() & Flags.INTERFACE) != 0 && !testInterfaces) continue; for (Scope.Entry e = sym.members_field.elems; e != null; e = e.sibling) { System.err.println("Checking member " + e.sym); switch (e.sym.kind) { case Kinds.TYP: { String name = e.sym.flatName().toString(); if (!classes.contains(name)) { classes.add(name); work.add(name); } break; } case Kinds.MTH: verify((MethodSymbol) e.sym, expectNames); break; } } } }