com.sun.tools.javac.tree.JCTree.TypeBoundKind Java Examples

The following examples show how to use com.sun.tools.javac.tree.JCTree.TypeBoundKind. 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: SourceTreeScannerTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #2
Source File: SourceTreeScannerTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #3
Source File: SourceTreeScannerTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #4
Source File: SourceTreeScannerTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #5
Source File: SourceTreeScannerTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                if (tree instanceof JCModuleDecl && f.getName().equals("mods")) {
                    // The modifiers will not found by TreeScanner,
                    // but the embedded annotations will be.
                    reflectiveScan(((JCModuleDecl) tree).mods.annotations);
                } else {
                    reflectiveScan(f.get(tree));
                }
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #6
Source File: SourceTreeScannerTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #7
Source File: SourceTreeScannerTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #8
Source File: SourceTreeScannerTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/** record all tree nodes found by reflection. */
public void reflectiveScan(Object o) {
    if (o == null)
        return;
    if (o instanceof JCTree) {
        JCTree tree = (JCTree) o;
        //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
        expect.add(tree);
        for (Field f: getFields(tree)) {
            if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
                // not part of public API
                continue;
            }
            try {
                //System.err.println("FIELD: " + f.getName());
                reflectiveScan(f.get(tree));
            } catch (IllegalAccessException e) {
                error(e.toString());
            }
        }
    } else if (o instanceof List) {
        List<?> list = (List<?>) o;
        for (Object item: list)
            reflectiveScan(item);
    } else
        error("unexpected item: " + o);
}
 
Example #9
Source File: PrettyCommentsPrinter.java    From EasyMPermission with MIT License 5 votes vote down vote up
public void visitTypeBoundKind(TypeBoundKind tree) {
	try {
		print(String.valueOf(tree.kind));
	} catch (IOException e) {
		throw new UncheckedIOException(e);
	}
}
 
Example #10
Source File: JavacTreeMaker.java    From EasyMPermission with MIT License 4 votes vote down vote up
public JCWildcard Wildcard(TypeBoundKind kind, JCTree type) {
	return invoke(Wildcard, kind, type);
}
 
Example #11
Source File: JavacTreeMaker.java    From EasyMPermission with MIT License 4 votes vote down vote up
public TypeBoundKind TypeBoundKind(BoundKind kind) {
	return invoke(TypeBoundKind, kind);
}
 
Example #12
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 4 votes vote down vote up
private static JCExpression cloneType0(JavacTreeMaker maker, JCTree in) {
	if (in == null) return null;
	
	if (in instanceof JCPrimitiveTypeTree) return (JCExpression) in;
	
	if (in instanceof JCIdent) {
		return maker.Ident(((JCIdent) in).name);
	}
	
	if (in instanceof JCFieldAccess) {
		JCFieldAccess fa = (JCFieldAccess) in;
		return maker.Select(cloneType0(maker, fa.selected), fa.name);
	}
	
	if (in instanceof JCArrayTypeTree) {
		JCArrayTypeTree att = (JCArrayTypeTree) in;
		return maker.TypeArray(cloneType0(maker, att.elemtype));
	}
	
	if (in instanceof JCTypeApply) {
		JCTypeApply ta = (JCTypeApply) in;
		ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>();
		for (JCExpression typeArg : ta.arguments) {
			lb.append(cloneType0(maker, typeArg));
		}
		return maker.TypeApply(cloneType0(maker, ta.clazz), lb.toList());
	}
	
	if (in instanceof JCWildcard) {
		JCWildcard w = (JCWildcard) in;
		JCExpression newInner = cloneType0(maker, w.inner);
		TypeBoundKind newKind;
		switch (w.getKind()) {
		case SUPER_WILDCARD:
			newKind = maker.TypeBoundKind(BoundKind.SUPER);
			break;
		case EXTENDS_WILDCARD:
			newKind = maker.TypeBoundKind(BoundKind.EXTENDS);
			break;
		default:
		case UNBOUNDED_WILDCARD:
			newKind = maker.TypeBoundKind(BoundKind.UNBOUND);
			break;
		}
		return maker.Wildcard(newKind, newInner);
	}
	
	// This is somewhat unsafe, but it's better than outright throwing an exception here. Returning null will just cause an exception down the pipeline.
	return (JCExpression) in;
}