Java Code Examples for javax.lang.model.element.Element#equals()
The following examples show how to use
javax.lang.model.element.Element#equals() .
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: DeclaredIBindingsAnalyzer.java From netbeans with Apache License 2.0 | 6 votes |
private boolean isSame( AnnotationMirror first, AnnotationMirror second , CompilationController controller ) { Element firstElement = first.getAnnotationType().asElement(); Element secondElement = second.getAnnotationType().asElement(); if ( !firstElement.equals(secondElement)){ return false; } Map<? extends ExecutableElement, ? extends AnnotationValue> firstValues = first.getElementValues(); Map<? extends ExecutableElement, ? extends AnnotationValue> secondValues = second.getElementValues(); if ( firstValues.size() != secondValues.size() ){ return false; } for (Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : firstValues.entrySet()) { AnnotationValue secondValue = secondValues.get(entry.getKey()); AnnotationValue firstValue = entry.getValue(); if ( !isSame( firstValue, secondValue, controller )){ return false; } } return true; }
Example 2
Source File: DecoratorsPanel.java From netbeans with Apache License 2.0 | 6 votes |
private boolean hasDelegate( Element element , CompilationController controller){ List<? extends AnnotationMirror> allAnnotationMirrors = controller. getElements().getAllAnnotationMirrors( element); TypeElement delegate = controller.getElements().getTypeElement( DELEGATE); if( delegate == null ){ return false; } for (AnnotationMirror annotationMirror : allAnnotationMirrors) { Element annotation = controller.getTypes().asElement( annotationMirror.getAnnotationType()); if ( annotation!= null && annotation.equals( delegate )){ return true; } } return false; }
Example 3
Source File: ELOccurrencesFinder.java From netbeans with Apache License 2.0 | 6 votes |
private Map<OffsetRange, ColoringAttributes> findMatchingTypes(CompilationContext info, ELParserResult parserResult, Pair<ELElement,Node> target, List<Pair<ELElement,Node>> candidates) { Element targetType = ELTypeUtilities.resolveElement(info, target.first(), target.second()); Map<OffsetRange, ColoringAttributes> result = new HashMap<>(); for (Pair<ELElement,Node> candidate : candidates) { if (checkAndResetCancel()) { return result; } Element type = ELTypeUtilities.resolveElement(info, candidate.first(), candidate.second()); if (type != null && type.equals(targetType)) { OffsetRange range = candidate.first().getOriginalOffset(candidate.second()); result.put(range, ColoringAttributes.MARK_OCCURRENCES); } } return result; }
Example 4
Source File: JavaRefactoringUtils.java From netbeans with Apache License 2.0 | 6 votes |
private void addIfMatch(TreePath path, Tree tree, Element elementToFind) { if (cc.getTreeUtilities().isSynthetic(path)) { return; } Element el = cc.getTrees().getElement(path); if (el==null) { return; } if (elementToFind.getKind() == ElementKind.METHOD && el.getKind() == ElementKind.METHOD) { if (el.equals(elementToFind) || cc.getElements().overrides(((ExecutableElement) el), (ExecutableElement) elementToFind, (TypeElement) elementToFind.getEnclosingElement())) { addUsage(getCurrentPath()); } } else if (el.equals(elementToFind)) { addUsage(getCurrentPath()); } }
Example 5
Source File: InlineVariableTransformer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public Tree visitVariable(VariableTree node, Element p) { Element el = workingCopy.getTrees().getElement(getCurrentPath()); if (p.equals(el)) { Tree parent = getCurrentPath().getParentPath().getLeaf(); switch(el.getKind()) { case LOCAL_VARIABLE: Tree newOne = null; if(parent.getKind() == Tree.Kind.CASE) { newOne = make.removeCaseStatement((CaseTree) parent, node); } else { newOne = make.removeBlockStatement((BlockTree) parent, node); } if (newOne != null) { rewrite(parent, newOne); } break; case FIELD: ClassTree removeClassMember = make.removeClassMember((ClassTree)parent, node); if (removeClassMember != null) { rewrite(parent, removeClassMember); } break; } } return super.visitVariable(node, p); }
Example 6
Source File: ValidationReport.java From paperparcel with Apache License 2.0 | 5 votes |
private static boolean isEnclosedIn(Element parent, Element child) { Element current = child; while (current != null) { if (current.equals(parent)) { return true; } current = current.getEnclosingElement(); } return false; }
Example 7
Source File: CopyFinder.java From netbeans with Apache License 2.0 | 4 votes |
private @NonNull VerifyResult fullVerifyElements(TreePath node, TreePath p) { Element nodeEl = info.getTrees().getElement(node); Element pEl = info.getTrees().getElement(p); if (nodeEl == null) { return pEl == null ? VerifyResult.MATCH : VerifyResult.NO_MATCH_CONTINUE; //TODO: correct? shouldn't be MATCH_CHECK_DEEPER? } VerifyResult matchingResult; if (!nodeEl.getModifiers().contains(Modifier.STATIC)) { if ((nodeEl.getKind().isClass() || nodeEl.getKind().isInterface())) { //class: matchingResult = VerifyResult.MATCH; } else { matchingResult = VerifyResult.MATCH_CHECK_DEEPER; } } else { matchingResult = VerifyResult.MATCH; // defect #241261; if the current pattern is a member-select and the selector is a variable, it cannot match // a static member of node: if (p.getLeaf().getKind() == Tree.Kind.MEMBER_SELECT && node.getLeaf().getKind() == Tree.Kind.MEMBER_SELECT) { Tree selector = ((MemberSelectTree)p.getLeaf()).getExpression(); if (getWildcardTreeName(selector) != null) { // className.this/super refer to an instance and can be matched to a variable. They resolve to a variable Element, so exclude them Element nodeSelector = info.getTrees().getElement(new TreePath(node, ((MemberSelectTree)node.getLeaf()).getExpression())); if (nodeSelector != null && (nodeSelector.getKind().isClass() || nodeSelector.getKind().isInterface())) { matchingResult = VerifyResult.NO_MATCH; } else { matchingResult = VerifyResult.MATCH_CHECK_DEEPER; } } } } if (nodeEl == pEl) { return matchingResult; } if (nodeEl == null || pEl == null) return VerifyResult.NO_MATCH; if (nodeEl.getKind() == pEl.getKind() && nodeEl.getKind() == ElementKind.FIELD && CLASS.contentEquals(((VariableElement)nodeEl).getSimpleName()) && CLASS.contentEquals(((VariableElement)pEl).getSimpleName())) { return VerifyResult.MATCH_CHECK_DEEPER; } if (nodeEl.getKind() == pEl.getKind() && nodeEl.getKind() == ElementKind.METHOD) { if (info.getElements().overrides((ExecutableElement) nodeEl, (ExecutableElement) pEl, (TypeElement) nodeEl.getEnclosingElement())) { return VerifyResult.MATCH_CHECK_DEEPER; } } if (nodeEl.equals(pEl)) { return matchingResult; } if (allowVariablesRemap && nodeEl.equals(bindState.variablesRemapToElement.get(pEl))) { return matchingResult; } TypeMirror nodeTM = info.getTrees().getTypeMirror(node); if (nodeTM == null || nodeTM.getKind() == TypeKind.ERROR) { return VerifyResult.NO_MATCH_CONTINUE; } TypeMirror pTM = info.getTrees().getTypeMirror(p); if (pTM == null || pTM.getKind() == TypeKind.ERROR) { return VerifyResult.NO_MATCH_CONTINUE; } return VerifyResult.NO_MATCH; }
Example 8
Source File: LLNI.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 9
Source File: OverridableMethodCallInConstructor.java From netbeans with Apache License 2.0 | 4 votes |
@TriggerTreeKind(Tree.Kind.METHOD_INVOCATION) public static ErrorDescription hint(HintContext ctx) { MethodInvocationTree mit = (MethodInvocationTree) ctx.getPath().getLeaf(); CompilationInfo info = ctx.getInfo(); TreePath enclosingMethod = Utilities.findOwningExecutable(ctx, ctx.getPath(), false); if (enclosingMethod == null) { return null; } Element enclosingMethodElement = ctx.getInfo().getTrees().getElement(enclosingMethod); if (enclosingMethodElement == null || enclosingMethodElement.getKind() != ElementKind.CONSTRUCTOR) { return null; } Element methodInvocationElement = info.getTrees().getElement(new TreePath(ctx.getPath(), mit.getMethodSelect())); if (methodInvocationElement == null || methodInvocationElement.getKind() != ElementKind.METHOD) { return null; } Element classElement = methodInvocationElement.getEnclosingElement(); if (classElement == null || classElement.getKind() != ElementKind.CLASS) { return null; } Element classEl = enclosingMethodElement.getEnclosingElement(); if (classEl == null || classEl.getKind() != ElementKind.CLASS) { return null; } boolean sameClass = classElement.equals(enclosingMethodElement.getEnclosingElement()); if (!info.getTypes().isSubtype(classEl.asType(), classElement.asType())) { return null; } // classEl exts classElemenet - either classElement == classEl, or classElement cannot be final anyway if (classEl.getModifiers().contains(Modifier.FINAL)) { return null; } Set<Modifier> modifiers = methodInvocationElement.getModifiers(); if (modifiers.contains(Modifier.PRIVATE) || modifiers.contains(Modifier.FINAL) || modifiers.contains(Modifier.STATIC)) { return null; } if (!invocationOnThis(mit)) { return null; } TreePath methodDeclaration = ctx.getInfo().getTrees().getPath(methodInvocationElement); if (methodDeclaration == null || ctx.getInfo().getTreeUtilities().isSynthetic(methodDeclaration)) return null; return ErrorDescriptionFactory.forName(ctx, mit, NbBundle.getMessage( OverridableMethodCallInConstructor.class, "MSG_org.netbeans.modules.java.hints.OverridableMethodCallInConstructor"), sameClass ? computeFixes((MethodTree) methodDeclaration.getLeaf(), classElement, ctx) : null); }
Example 10
Source File: JNIWriter.java From hottub with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) { TypeElement throwable = elements.getTypeElement("java.lang.Throwable"); TypeElement jClass = elements.getTypeElement("java.lang.Class"); TypeElement jString = elements.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } Assert.check(false, "jni unknown type"); return null; /* dead code. */ }
Example 11
Source File: JNI.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 12
Source File: LLNI.java From hottub with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 13
Source File: LLNI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 14
Source File: Utilities.java From netbeans with Apache License 2.0 | 4 votes |
private static void addAnnotationArgument(WorkingCopy workingCopy, Element element, Element annotationElement, String argumentName, Object argumentValue) throws IOException { Parameters.javaIdentifierOrNull("argumentName", argumentName); // NOI18N Parameters.notNull("argumentValue", argumentValue); // NOI18N ModifiersTree oldTree = null; if (element instanceof TypeElement) { oldTree = workingCopy.getTrees().getTree((TypeElement) element). getModifiers(); } else if (element instanceof ExecutableElement) { oldTree = workingCopy.getTrees().getTree((ExecutableElement) element). getModifiers(); } else if (element instanceof VariableElement) { oldTree = ((VariableTree) workingCopy.getTrees().getTree(element)). getModifiers(); } if (oldTree == null) { return; } AnnotationMirror annMirror = null; for( AnnotationMirror annotationMirror : element.getAnnotationMirrors() ){ if ( annotationElement.equals(annotationMirror.getAnnotationType(). asElement())) { annMirror = annotationMirror; } } if ( annMirror == null ){ return; } AnnotationTree annotation = (AnnotationTree) workingCopy.getTrees(). getTree(element, annMirror); TreeMaker make = workingCopy.getTreeMaker(); ExpressionTree oldArgTree = getAnnotationArgumentTree(annotation, argumentName); if(oldArgTree!=null) annotation = make.removeAnnotationAttrValue(annotation, oldArgTree); ExpressionTree argumentValueTree = null; if(argumentValue instanceof Enum) { argumentValueTree = make.MemberSelect(make.QualIdent( argumentValue.getClass().getCanonicalName()), ((Enum)argumentValue).name()); } else { try { argumentValueTree = make.Literal(argumentValue); } catch (IllegalArgumentException iae) { // dont do anything for now return ; } } if (argumentName != null) { argumentValueTree = make.Assignment(make.Identifier(argumentName), argumentValueTree); } AnnotationTree modifiedAnnotation = make.addAnnotationAttrValue(annotation, argumentValueTree); workingCopy.rewrite(annotation, modifiedAnnotation); }
Example 15
Source File: JNIWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) { TypeElement throwable = elements.getTypeElement("java.lang.Throwable"); TypeElement jClass = elements.getTypeElement("java.lang.Class"); TypeElement jString = elements.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } Assert.check(false, "jni unknown type"); return null; /* dead code. */ }
Example 16
Source File: JNI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 17
Source File: LLNI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 18
Source File: LLNI.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 19
Source File: LLNI.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
protected final String jniType(TypeMirror t) throws Util.Exit { TypeElement throwable = elems.getTypeElement("java.lang.Throwable"); TypeElement jClass = elems.getTypeElement("java.lang.Class"); TypeElement jString = elems.getTypeElement("java.lang.String"); Element tclassDoc = types.asElement(t); switch (t.getKind()) { case ARRAY: { TypeMirror ct = ((ArrayType) t).getComponentType(); switch (ct.getKind()) { case BOOLEAN: return "jbooleanArray"; case BYTE: return "jbyteArray"; case CHAR: return "jcharArray"; case SHORT: return "jshortArray"; case INT: return "jintArray"; case LONG: return "jlongArray"; case FLOAT: return "jfloatArray"; case DOUBLE: return "jdoubleArray"; case ARRAY: case DECLARED: return "jobjectArray"; default: throw new Error(ct.toString()); } } case VOID: return "void"; case BOOLEAN: return "jboolean"; case BYTE: return "jbyte"; case CHAR: return "jchar"; case SHORT: return "jshort"; case INT: return "jint"; case LONG: return "jlong"; case FLOAT: return "jfloat"; case DOUBLE: return "jdouble"; case DECLARED: { if (tclassDoc.equals(jString)) return "jstring"; else if (types.isAssignable(t, throwable.asType())) return "jthrowable"; else if (types.isAssignable(t, jClass.asType())) return "jclass"; else return "jobject"; } } util.bug("jni.unknown.type"); return null; /* dead code. */ }
Example 20
Source File: ManagedAttributeValueTypeValidator.java From qpid-broker-j with Apache License 2.0 | 4 votes |
private boolean isContent(final Element e) { return e.equals(processingEnv.getElementUtils().getTypeElement("org.apache.qpid.server.model.Content")); }