List of usage examples for org.eclipse.jdt.core Flags isSynthetic
public static boolean isSynthetic(int flags)
From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java
License:Open Source License
public static boolean isSynthetic(IMember member) throws JavaModelException { return Flags.isSynthetic(member.getFlags()); }
From source file:com.codenvy.ide.ext.java.server.SourcesFromBytecodeGenerator.java
License:Open Source License
private void generateType(IType type, StringBuilder builder, String indent) throws JavaModelException { int flags = 0; appendAnnotationLabels(type.getAnnotations(), flags, builder, indent.substring(TAB.length())); builder.append(indent.substring(TAB.length())); builder.append(getModifiers(type.getFlags(), type.getFlags())).append(' ').append(getJavaType(type)) .append(' ').append(type.getElementName()); if (type.isResolved()) { BindingKey key = new BindingKey(type.getKey()); if (key.isParameterizedType()) { String[] typeArguments = key.getTypeArguments(); appendTypeArgumentSignaturesLabel(type, typeArguments, flags, builder); } else {/* w w w .ja v a2 s .co m*/ String[] typeParameters = Signature.getTypeParameters(key.toSignature()); appendTypeParameterSignaturesLabel(typeParameters, builder); } } else { appendTypeParametersLabels(type.getTypeParameters(), flags, builder); } if (!"java.lang.Object".equals(type.getSuperclassName()) && !"java.lang.Enum".equals(type.getSuperclassName())) { builder.append(" extends "); if (type.getSuperclassTypeSignature() != null) { // appendTypeSignatureLabel(type, type.getSuperclassTypeSignature(), flags, builder); builder.append(Signature.toString(type.getSuperclassTypeSignature())); } else { builder.append(type.getSuperclassName()); } } if (!type.isAnnotation()) { if (type.getSuperInterfaceNames().length != 0) { builder.append(" implements "); String[] signatures = type.getSuperInterfaceTypeSignatures(); if (signatures.length == 0) { signatures = type.getSuperInterfaceNames(); } for (String interfaceFqn : signatures) { builder.append(Signature.toString(interfaceFqn)).append(", "); } builder.delete(builder.length() - 2, builder.length()); } } builder.append(" {\n"); List<IField> fields = new ArrayList<>(); if (type.isEnum()) { builder.append(indent); for (IField field : type.getFields()) { if (field.isEnumConstant()) { builder.append(field.getElementName()).append(", "); } else { fields.add(field); } } if (", ".equals(builder.substring(builder.length() - 2))) { builder.delete(builder.length() - 2, builder.length()); } builder.append(";\n"); } else { fields.addAll(Arrays.asList(type.getFields())); } for (IField field : fields) { if (Flags.isSynthetic(field.getFlags())) { continue; } appendAnnotationLabels(field.getAnnotations(), flags, builder, indent); builder.append(indent).append(getModifiers(field.getFlags(), type.getFlags())); if (builder.charAt(builder.length() - 1) != ' ') { builder.append(' '); } builder.append(Signature.toCharArray(field.getTypeSignature().toCharArray())).append(' ') .append(field.getElementName()); if (field.getConstant() != null) { builder.append(" = "); if (field.getConstant() instanceof String) { builder.append('"').append(field.getConstant()).append('"'); } else { builder.append(field.getConstant()); } } builder.append(";\n"); } builder.append('\n'); for (IMethod method : type.getMethods()) { if (method.getElementName().equals("<clinit>") || Flags.isSynthetic(method.getFlags())) { continue; } appendAnnotationLabels(method.getAnnotations(), flags, builder, indent); BindingKey resolvedKey = method.isResolved() ? new BindingKey(method.getKey()) : null; String resolvedSig = (resolvedKey != null) ? resolvedKey.toSignature() : null; builder.append(indent).append(getModifiers(method.getFlags(), type.getFlags())); if (builder.charAt(builder.length() - 1) != ' ') { builder.append(' '); } if (resolvedKey != null) { if (resolvedKey.isParameterizedMethod()) { String[] typeArgRefs = resolvedKey.getTypeArguments(); if (typeArgRefs.length > 0) { appendTypeArgumentSignaturesLabel(method, typeArgRefs, flags, builder); builder.append(' '); } } else { String[] typeParameterSigs = Signature.getTypeParameters(resolvedSig); if (typeParameterSigs.length > 0) { appendTypeParameterSignaturesLabel(typeParameterSigs, builder); builder.append(' '); } } } else if (method.exists()) { ITypeParameter[] typeParameters = method.getTypeParameters(); if (typeParameters.length > 0) { appendTypeParametersLabels(typeParameters, flags, builder); builder.append(' '); } } if (!method.isConstructor()) { String returnTypeSig = resolvedSig != null ? Signature.getReturnType(resolvedSig) : method.getReturnType(); appendTypeSignatureLabel(method, returnTypeSig, 0, builder); builder.append(' '); // builder.append(Signature.toCharArray(method.getReturnType().toCharArray())).append(' '); } builder.append(method.getElementName()); builder.append('('); for (ILocalVariable variable : method.getParameters()) { builder.append(Signature.toString(variable.getTypeSignature())); builder.append(' ').append(variable.getElementName()).append(", "); } if (builder.charAt(builder.length() - 1) == ' ') { builder.delete(builder.length() - 2, builder.length()); } builder.append(')'); String[] exceptionTypes = method.getExceptionTypes(); if (exceptionTypes != null && exceptionTypes.length != 0) { builder.append(' ').append("throws "); for (String exceptionType : exceptionTypes) { builder.append(Signature.toCharArray(exceptionType.toCharArray())).append(", "); } builder.delete(builder.length() - 2, builder.length()); } if (type.isInterface() || type.isAnnotation()) { builder.append(";\n\n"); } else { builder.append(" {").append(METHOD_BODY).append("}\n\n"); } } for (IType iType : type.getTypes()) { generateType(iType, builder, indent + indent); } builder.append(indent.substring(TAB.length())); builder.append("}\n"); }
From source file:edu.uci.ics.sourcerer.extractor.ast.ClassFileExtractor.java
License:Open Source License
private void extractIType(IType type) { try {//from w w w. j a v a 2 s . c o m String fqn = type.getFullyQualifiedName(); // Write the entity if (type.isClass()) { entityWriter.writeClass(fqn, type.getFlags(), path); // Write the superclass String superSig = type.getSuperclassTypeSignature(); if (superSig != null) { relationWriter.writeExtends(fqn, typeSignatureToFqn(superSig), path); } } else if (type.isAnnotation()) { entityWriter.writeAnnotation(fqn, type.getFlags(), path); } else if (type.isInterface()) { entityWriter.writeInterface(fqn, type.getFlags(), path); } else if (type.isEnum()) { entityWriter.writeEnum(fqn, type.getFlags(), path); } // Write the superinterfaces for (String superIntSig : type.getSuperInterfaceTypeSignatures()) { relationWriter.writeImplements(fqn, typeSignatureToFqn(superIntSig), path); } if (!fqnStack.isEmpty()) { relationWriter.writeInside(type.getFullyQualifiedName(), fqnStack.peek(), path); } fqnStack.push(type.getFullyQualifiedName()); for (IType child : type.getTypes()) { extractIType(child); } for (IField field : type.getFields()) { if (!Flags.isSynthetic(field.getFlags())) { extractIField(field); } } for (IMethod method : type.getMethods()) { if (!Flags.isSynthetic(method.getFlags()) || (Flags.isSynthetic(method.getFlags()) && method.isConstructor() && method.getParameterTypes().length == 0)) { extractIMethod(method, type.isAnnotation()); } } int pos = 0; for (ITypeParameter param : type.getTypeParameters()) { relationWriter.writeParametrizedBy(fqn, getTypeParam(param), pos++, path); } fqnStack.pop(); } catch (Exception e) { logger.log(Level.SEVERE, "Error in extracting class file", e); } }
From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ClassFileExtractor.java
License:Open Source License
private void extractIType(IType type) { try {//from ww w .ja va 2 s . c o m String fqn = type.getFullyQualifiedName(); Location location = new Location(fqn, path, null, null); // Write the entity if (type.isClass()) { entityWriter.writeEntity(Entity.CLASS, fqn, type.getFlags(), null, location); // Write the superclass String superSig = type.getSuperclassTypeSignature(); if (superSig != null) { relationWriter.writeRelation(Relation.EXTENDS, fqn, typeSignatureToFqn(superSig), location); } } else if (type.isAnnotation()) { entityWriter.writeEntity(Entity.ANNOTATION, fqn, type.getFlags(), null, location); } else if (type.isInterface()) { entityWriter.writeEntity(Entity.INTERFACE, fqn, type.getFlags(), null, location); } else if (type.isEnum()) { entityWriter.writeEntity(Entity.ENUM, fqn, type.getFlags(), null, location); } // Write the superinterfaces for (String superIntSig : type.getSuperInterfaceTypeSignatures()) { relationWriter.writeRelation(Relation.IMPLEMENTS, fqn, typeSignatureToFqn(superIntSig), location); } if (!fqnStack.isEmpty()) { relationWriter.writeRelation(Relation.CONTAINS, fqnStack.peek(), type.getFullyQualifiedName(), location); } fqnStack.push(type.getFullyQualifiedName()); // for (IType child : type.getTypes()) { // extractIType(child); // } for (IField field : type.getFields()) { if (!Flags.isSynthetic(field.getFlags())) { extractIField(field); } } for (IMethod method : type.getMethods()) { if (!Flags.isSynthetic(method.getFlags()) || (Flags.isSynthetic(method.getFlags()) && method.isConstructor() && method.getParameterTypes().length == 0)) { extractIMethod(method, type.isAnnotation()); } } for (ITypeParameter param : type.getTypeParameters()) { relationWriter.writeRelation(Relation.PARAMETRIZED_BY, fqn, getTypeParam(param), location); } fqnStack.pop(); } catch (Exception e) { logger.log(Level.SEVERE, "Error in extracting class file", e); } }
From source file:org.eclipse.modisco.java.discoverer.internal.io.library.ClassFileParser.java
License:Open Source License
/** * Visit a {@code IField}./*w w w . ja va 2s . co m*/ * * @param field * the {@code IField} * @return the {@link FieldDeclaration} object corresponding to the * {@code IField}, or {@code null} if the field does not exist or is * {@link org.eclipse.jdt.core.Flags#isSynthetic(int) synthetic} * @throws JavaModelException */ protected FieldDeclaration visitField(final IField field) throws JavaModelException { if (Flags.isSynthetic(field.getFlags())) { return null; } FieldDeclaration element = getFactory().createFieldDeclaration(); initializeNode(element); // type String type = field.getTypeSignature(); element.setType(getRefOnType(type)); // visibility modifier Modifier m = getFactory().createModifier(); element.setModifier(m); m.setBodyDeclaration(element); manageModifier(m, field.getFlags(), field); // the fragment of this field VariableDeclarationFragment fragment = getFactory().createVariableDeclarationFragment(); initializeNode(fragment); fragment.setExtraArrayDimensions(0); fragment.setName(field.getElementName()); fragment.setVariablesContainer(element); for (IAnnotation annotation : field.getAnnotations()) { Annotation anno = getFactory().createAnnotation(); element.getAnnotations().add(anno); visitAnnotation(annotation, anno); } ClassFileParserUtils.manageBindingDeclaration(fragment, field, this); return element; }
From source file:org.eclipse.modisco.java.discoverer.internal.io.library.ClassFileParser.java
License:Open Source License
/** * Visit a {@code IMethod}./* w ww . j a va 2 s . c o m*/ * * @param method * the {@code IMethod} * @return the {@link AbstractMethodDeclaration} object corresponding to the * {@code IMethod}, or {@code null} if the method does not exist or * is {@link org.eclipse.jdt.core.Flags#isSynthetic(int) synthetic} * or is {@link org.eclipse.jdt.core.Flags#isBridge(int) bridge} or * its name equals the special name <code>"<clinit>"</code> * @throws JavaModelException * @see org.eclipse.jdt.core.IMethod#getElementName() */ protected AbstractMethodDeclaration visitMethod(final IMethod method) throws JavaModelException { if (Flags.isSynthetic(method.getFlags()) || Flags.isBridge(method.getFlags()) || method.getElementName().equals("<clinit>")) { //$NON-NLS-1$ return null; } this.currentlyVisitedJavaElement = method; AbstractMethodDeclaration element = null; if (method.isConstructor()) { element = getFactory().createConstructorDeclaration(); } else { element = getFactory().createMethodDeclaration(); } initializeNode(element); element.setName(method.getElementName()); // throwns exceptions for (String exc : method.getExceptionTypes()) { element.getThrownExceptions().add(getRefOnType(exc)); } // return type if (!method.isConstructor()) { String returnType = method.getReturnType(); ((MethodDeclaration) element).setReturnType(getRefOnType(returnType)); } // type parameters ITypeParameter[] parameters = method.getTypeParameters(); for (ITypeParameter parameter : parameters) { TypeParameter t = getFactory().createTypeParameter(); element.getTypeParameters().add(t); visitTypeParameter(parameter, t); } // parameters for (int i = 0; i < method.getNumberOfParameters(); i++) { String parameterType = method.getParameterTypes()[i]; String parameterName = method.getRawParameterNames()[i]; SingleVariableDeclaration var = getFactory().createSingleVariableDeclaration(); initializeNode(var); element.getParameters().add(var); var.setMethodDeclaration(element); var.setName(parameterName); var.setExtraArrayDimensions(0); // varargs option for the last argument if (i == method.getNumberOfParameters() - 1) { boolean isMethodVarargs = Flags.isVarargs(method.getFlags()); var.setVarargs(isMethodVarargs); } var.setType(getRefOnType(parameterType)); } // annotations for (IAnnotation annotation : method.getAnnotations()) { Annotation anno = getFactory().createAnnotation(); element.getAnnotations().add(anno); visitAnnotation(annotation, anno); } // visibility modifier Modifier m = getFactory().createModifier(); element.setModifier(m); m.setBodyDeclaration(element); manageModifier(m, method.getFlags(), method); ClassFileParserUtils.manageBindingDeclaration(element, method, this); return element; }
From source file:org.eclipse.objectteams.otdt.internal.ui.packageview.PackageExplorerAdaptor.ContentProvider.java
License:Open Source License
@SuppressWarnings("nls") public static boolean isGenerated(IJavaElement elem) { // TODO (SH): check whether ViewerFilters can do the job better. // all kinds of generated features determined by name: String name = elem.getElementName(); final String[] patterns = new String[] { "_OT$", "TSuper__OT__", // general OT-prefix "class$", "access$", "val$", "this$" // std. java synthetics. };/* w w w .j a va 2s .com*/ for (int i = 0; i < patterns.length; i++) { if (name.indexOf(patterns[i]) >= 0) return true; } switch (elem.getElementType()) { case IJavaElement.TYPE: case IOTJavaElement.ROLE: // Predifined role types (non-overridable)? final String[] fullPatterns = new String[] { "IConfined", "Confined", "__OT__Confined", "ILowerable", // special OT types }; for (int i = 0; i < fullPatterns.length; i++) { if (name.equals(fullPatterns[i])) return true; } break; case IJavaElement.METHOD: // tsuper-method? IMethod method = (IMethod) elem; String[] paramTypes = method.getParameterTypes(); if (paramTypes.length > 0) { String lastType = Signature.getSimpleName(Signature.toString(paramTypes[paramTypes.length - 1])); if (lastType.startsWith("TSuper__OT__")) return true; } break; } // Synthetic role interface? if (elem.getElementType() == IOTJavaElement.ROLE) { IType type = (IType) elem; try { if (Flags.isSynthetic(type.getFlags())) return true; } catch (JavaModelException ex) { // nop } } return false; }
From source file:org.eclipse.objectteams.otdt.ui.Util.java
License:Open Source License
/** * Is the given java element generated by the compiler (i.e., synthetic)? * This function operates on all kinds of java elements applying appropriate * heuristics (mostly name based). //from w ww .j a va 2s.c o m * @param elem * @return */ @SuppressWarnings("nls") public static boolean isGenerated(IJavaElement elem) { // TODO (SH): check whether ViewerFilters can do the job better. // all kinds of generated features determined by name: String name = elem.getElementName(); final String[] patterns = new String[] { "_OT$", "TSuper__OT__", // general OT-prefix "class$", "access$", "val$", "this$" // std. java synthetics. }; for (int i = 0; i < patterns.length; i++) { if (name.indexOf(patterns[i]) >= 0) return true; } switch (elem.getElementType()) { case IJavaElement.TYPE: case IOTJavaElement.ROLE: // Predefined role types (non-overridable)? final String[] fullPatterns = new String[] { "IConfined", "Confined", "__OT__Confined", "ILowerable", // special OT types }; for (int i = 0; i < fullPatterns.length; i++) { if (name.equals(fullPatterns[i])) return true; } break; case IJavaElement.METHOD: // tsuper-method? IMethod method = (IMethod) elem; String[] paramTypes = method.getParameterTypes(); if (paramTypes.length > 0) { String lastType = Signature.getSimpleName(Signature.toString(paramTypes[paramTypes.length - 1])); if (lastType.startsWith("TSuper__OT__")) return true; } break; } // Synthetic role interface? if (elem.getElementType() == IOTJavaElement.ROLE) { IType type = (IType) elem; try { if (Flags.isSynthetic(type.getFlags())) return true; } catch (JavaModelException ex) { // nop } } return false; }
From source file:org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator.java
License:Open Source License
private void getDeltaForField(IApiField field) { int access = field.getModifiers(); if (Flags.isSynthetic(access)) { // we ignore synthetic fields return;/* w w w. j a v a2s.co m*/ } String name = field.getName(); IApiField field2 = this.type2.getField(name); if (field2 == null) { if (Flags.isPrivate(access) || Util.isDefault(access)) { this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.FIELD, this.currentDescriptorRestrictions, access, 0, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else { boolean found = false; if (this.component2 != null) { if (this.type1.isInterface()) { Set<?> interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null) { for (Iterator<?> iterator = interfacesSet.iterator(); iterator.hasNext();) { IApiType superTypeDescriptor = (IApiType) iterator.next(); IApiField field3 = superTypeDescriptor.getField(name); if (field3 == null) { continue; } else { // interface method can only be public // method has been move up in the hierarchy // - report the delta and abort loop this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.FIELD_MOVED_UP, this.currentDescriptorRestrictions, access, field3.getModifiers(), this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); found = true; break; } } } } else { List<IApiType> superclassList = getSuperclassList(this.type2); if (superclassList != null && isStatusOk()) { loop: for (Iterator<IApiType> iterator = superclassList.iterator(); iterator .hasNext();) { IApiType superTypeDescriptor = iterator.next(); IApiField field3 = superTypeDescriptor.getField(name); if (field3 == null) { continue; } else { int access3 = field3.getModifiers(); if (Flags.isPublic(access3) || Flags.isProtected(access3)) { // method has been move up in the // hierarchy - report the delta and // abort loop this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.FIELD_MOVED_UP, this.currentDescriptorRestrictions, access, field3.getModifiers(), this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); found = true; break loop; } } } } } } if (!found) { if ((this.visibilityModifiers == VisibilityModifiers.API) && component.hasApiDescription()) { // check if this field should be removed because it is // tagged as @noreference IApiDescription apiDescription = null; try { apiDescription = this.component.getApiDescription(); } catch (CoreException e) { reportStatus(e); } if (apiDescription != null) { IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(field.getHandle()); if (apiAnnotations != null) { int restrictions = apiAnnotations.getRestrictions(); if (RestrictionModifiers.isReferenceRestriction(restrictions)) { // if not found, but tagged as @noreference // in reference we don't need to report // a removed field return; } } } } if (field.isEnumConstant()) { // report delta (removal of an enum constant - not // compatible) this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.ENUM_CONSTANT, this.currentDescriptorRestrictions, this.type1.getModifiers(), this.type2.getModifiers(), this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); return; } // removing a public field is a breakage this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.FIELD, this.currentDescriptorRestrictions, access, 0, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } return; } int restrictions = RestrictionModifiers.NO_RESTRICTIONS; int referenceRestrictions = RestrictionModifiers.NO_RESTRICTIONS; int access2 = field2.getModifiers(); if (this.component2.hasApiDescription()) { try { IApiDescription apiDescription = this.component2.getApiDescription(); IApiAnnotations resolvedAPIDescription = apiDescription.resolveAnnotations(field2.getHandle()); if (resolvedAPIDescription != null) { restrictions = resolvedAPIDescription.getRestrictions(); } } catch (CoreException e) { // ignore } } if ((this.visibilityModifiers == VisibilityModifiers.API) && component.hasApiDescription()) { // check if this field should be removed because it is tagged as // @noreference IApiDescription apiDescription = null; try { apiDescription = this.component.getApiDescription(); } catch (CoreException e) { reportStatus(e); } if (apiDescription != null) { IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(field.getHandle()); if (apiAnnotations != null) { referenceRestrictions = apiAnnotations.getRestrictions(); } } if (RestrictionModifiers.isReferenceRestriction(referenceRestrictions)) { // tagged as @noreference in the reference component if (!RestrictionModifiers.isReferenceRestriction(restrictions)) { // no longer tagged as @noreference // report a field addition if (field2.isEnumConstant()) { // report delta (addition of an enum constant - // compatible this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.ENUM_CONSTANT, this.currentDescriptorRestrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type2), name }); } else { this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.FIELD, this.currentDescriptorRestrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type2), name }); } return; } } else if (RestrictionModifiers.isReferenceRestriction(restrictions)) { if (((Flags.isPublic(access2) || Flags.isProtected(access2)) && (Flags.isPublic(access) || Flags.isProtected(access))) && (this.visibilityModifiers == VisibilityModifiers.API)) { // report that it is no longer an API field this.addDelta(getElementType(this.type2), IDelta.REMOVED, field2.isEnumConstant() ? IDelta.API_ENUM_CONSTANT : IDelta.API_FIELD, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type2), name }); } return; } } restrictions |= this.currentDescriptorRestrictions; if (!field.getSignature().equals(field2.getSignature())) { // report delta this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.TYPE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else { // check type parameters String signature1 = field.getGenericSignature(); String signature2 = field2.getGenericSignature(); checkGenericSignature(signature1, signature2, field, field2); } boolean changeFinalToNonFinal = false; if (Flags.isProtected(access)) { if (Flags.isPrivate(access2) || Util.isDefault(access2)) { // report delta - decrease access: protected to default or // private this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else if (Flags.isPublic(access2)) { // report delta - increase access: protected to public this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } else if (Flags.isPublic(access) && (Flags.isProtected(access2) || Flags.isPrivate(access2) || Util.isDefault(access2))) { // report delta - decrease access: public to protected, default or // private this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else if (Flags.isPrivate(access) && (Flags.isProtected(access2) || Util.isDefault(access2) || Flags.isPublic(access2))) { this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else if (Util.isDefault(access) && (Flags.isProtected(access2) || Flags.isPublic(access2))) { this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (Flags.isFinal(access)) { if (!Flags.isFinal(access2)) { if (!Flags.isStatic(access2)) { // report delta - final to non-final for a non static field this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.FINAL_TO_NON_FINAL_NON_STATIC, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else if (field.getConstantValue() != null) { // report delta - final to non-final for a static field with // a compile time constant changeFinalToNonFinal = true; this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.FINAL_TO_NON_FINAL_STATIC_CONSTANT, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } else { // report delta - final to non-final for a static field with // no compile time constant this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.FINAL_TO_NON_FINAL_STATIC_NON_CONSTANT, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } } else if (Flags.isFinal(access2)) { // report delta - non-final to final this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.NON_FINAL_TO_FINAL, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (Flags.isStatic(access)) { if (!Flags.isStatic(access2)) { // report delta - static to non-static this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.STATIC_TO_NON_STATIC, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } else if (Flags.isStatic(access2)) { // report delta - non-static to static this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.NON_STATIC_TO_STATIC, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (Flags.isTransient(access)) { if (!Flags.isTransient(access2)) { // report delta - transient to non-transient this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.TRANSIENT_TO_NON_TRANSIENT, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } else if (Flags.isTransient(access2)) { // report delta - non-transient to transient this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.NON_TRANSIENT_TO_TRANSIENT, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (Flags.isVolatile(access)) { if (!Flags.isVolatile(access2)) { // report delta - volatile to non-volatile this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.VOLATILE_TO_NON_VOLATILE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } else if (Flags.isVolatile(access2)) { // report delta - non-volatile to volatile this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.NON_VOLATILE_TO_VOLATILE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (Flags.isDeprecated(access)) { if (!Flags.isDeprecated(access2)) { this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.REMOVED, IDelta.DEPRECATION, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } } else if (Flags.isDeprecated(access2)) { // report delta - non-volatile to volatile this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.ADDED, IDelta.DEPRECATION, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name }); } if (field.getConstantValue() != null) { if (field2.getConstantValue() == null) { if (!changeFinalToNonFinal) { // report delta - removal of constant value this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.REMOVED, IDelta.VALUE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name, String.valueOf(field.getConstantValue()) }); } } else if (!field.getConstantValue().equals(field2.getConstantValue())) { // report delta - modified constant value this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.CHANGED, IDelta.VALUE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name, String.valueOf(field.getConstantValue()) }); } } else if (field2.getConstantValue() != null) { // report delta this.addDelta(IDelta.FIELD_ELEMENT_TYPE, IDelta.ADDED, IDelta.VALUE, restrictions, access, access2, this.type1, name, new String[] { Util.getDescriptorName(this.type1), name, String.valueOf(field2.getConstantValue()) }); } }
From source file:org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator.java
License:Open Source License
private void getDeltaForMethod(IApiMethod method) { int access = method.getModifiers(); if (Flags.isSynthetic(access)) { // we ignore synthetic methods return;//from w w w . j ava2 s .c om } String name = method.getName(); String descriptor = method.getSignature(); String key = getKeyForMethod(method, this.type1); IApiMethod method2 = this.type2.getMethod(name, descriptor); String methodDisplayName = getMethodDisplayName(method, this.type1); if (method2 == null) { if (method.isClassInitializer()) { // report delta: removal of a clinit method this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.CLINIT, this.currentDescriptorRestrictions, access, 0, this.type1, this.type1.getName(), Util.getDescriptorName(type1)); return; } else if (Flags.isPrivate(access) || Util.isDefault(access)) { this.addDelta(getElementType(this.type1), IDelta.REMOVED, getTargetType(method), Flags.isAbstract(this.type2.getModifiers()) ? this.currentDescriptorRestrictions | RestrictionModifiers.NO_INSTANTIATE : this.currentDescriptorRestrictions, access, 0, this.type1, getKeyForMethod(method, this.type1), new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); return; } // if null we need to walk the hierarchy of descriptor2 boolean found = false; if (this.component2 != null && !method.isConstructor()) { if (this.type1.isInterface()) { Set<?> interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null && isStatusOk()) { for (Iterator<?> iterator = interfacesSet.iterator(); iterator.hasNext();) { IApiType superTypeDescriptor = (IApiType) iterator.next(); IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; } else { // interface method can only be public // method has been move up in the hierarchy - // report the delta and abort loop this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.METHOD_MOVED_UP, this.currentDescriptorRestrictions, access, method3.getModifiers(), this.type1, getKeyForMethod(method3, this.type1), new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); found = true; break; } } } } else { List<?> superclassList = getSuperclassList(this.type2, true); if (superclassList != null && isStatusOk()) { loop: for (Iterator<?> iterator = superclassList.iterator(); iterator.hasNext();) { IApiType superTypeDescriptor = (IApiType) iterator.next(); IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; } else { int access3 = method3.getModifiers(); if (Flags.isPublic(access3) || Flags.isProtected(access3)) { // method has been move up in the hierarchy // - report the delta and abort loop // TODO need to make the distinction between // methods that need to be re-implemented // and methods that don't this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.METHOD_MOVED_UP, this.currentDescriptorRestrictions, access, access3, this.type1, getKeyForMethod(method3, this.type1), new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); found = true; break loop; } } } } } } if (!found) { if ((this.visibilityModifiers == VisibilityModifiers.API) && component.hasApiDescription()) { // check if this method should be removed because it is // tagged as @noreference IApiDescription apiDescription = null; try { apiDescription = this.component.getApiDescription(); } catch (CoreException e) { reportStatus(e); } if (apiDescription != null) { IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(method.getHandle()); if (apiAnnotations != null) { int restrictions = apiAnnotations.getRestrictions(); if (RestrictionModifiers.isReferenceRestriction(restrictions)) { // if not found, but tagged as @noreference in // reference we don't need to report // a removed method return; } } } } if (this.type1.isAnnotation()) { this.addDelta(getElementType(this.type1), IDelta.REMOVED, method.getDefaultValue() != null ? IDelta.METHOD_WITH_DEFAULT_VALUE : IDelta.METHOD_WITHOUT_DEFAULT_VALUE, this.currentDescriptorRestrictions, access, 0, this.type1, getKeyForMethod(method, this.type1), new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } else { int restrictions = this.currentDescriptorRestrictions; if (RestrictionModifiers.isExtendRestriction(this.initialDescriptorRestrictions) && !RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions)) { restrictions = this.initialDescriptorRestrictions; } this.addDelta(getElementType(this.type1), IDelta.REMOVED, getTargetType(method), Flags.isAbstract(this.type2.getModifiers()) ? restrictions | RestrictionModifiers.NO_INSTANTIATE : restrictions, access, 0, this.type1, getKeyForMethod(method, this.type1), new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } return; } int restrictions = this.currentDescriptorRestrictions; if (component2.hasApiDescription()) { try { IApiDescription apiDescription = this.component2.getApiDescription(); IApiAnnotations resolvedAPIDescription = apiDescription.resolveAnnotations(method2.getHandle()); if (resolvedAPIDescription != null) { restrictions |= resolvedAPIDescription.getRestrictions(); } } catch (CoreException e) { // ignore } } int referenceRestrictions = this.initialDescriptorRestrictions; int access2 = method2.getModifiers(); if (this.component.hasApiDescription()) { // check if this method should be removed because it is tagged as // @noreference IApiDescription apiDescription = null; try { apiDescription = this.component.getApiDescription(); } catch (CoreException e) { reportStatus(e); } if (apiDescription != null) { IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(method.getHandle()); if (apiAnnotations != null) { referenceRestrictions |= apiAnnotations.getRestrictions(); } } } if ((this.visibilityModifiers == VisibilityModifiers.API) && this.component.hasApiDescription()) { if (RestrictionModifiers.isReferenceRestriction(referenceRestrictions)) { // tagged as @noreference in the reference component if (!RestrictionModifiers.isReferenceRestriction(restrictions)) { // no longer tagged as @noreference // report a method addition if (method.isConstructor()) { this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.CONSTRUCTOR, this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } else if (this.type2.isAnnotation()) { if (method.getDefaultValue() != null) { this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.METHOD_WITH_DEFAULT_VALUE, this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } else { this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.METHOD_WITHOUT_DEFAULT_VALUE, this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } } else { // check superclass // if null we need to walk the hierarchy of descriptor2 boolean found = false; if (this.component2 != null) { if (this.type1.isInterface()) { Set<?> interfacesSet = getInterfacesSet(this.type2); if (interfacesSet != null && isStatusOk()) { for (Iterator<?> iterator = interfacesSet.iterator(); iterator.hasNext();) { IApiType superTypeDescriptor = (IApiType) iterator.next(); IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; } else { // interface method can only be // public // method has been move up in the // hierarchy - report the delta and // abort loop found = true; break; } } } } else { List<IApiType> superclassList = getSuperclassList(this.type2, true); if (superclassList != null) { loop: for (Iterator<IApiType> iterator = superclassList.iterator(); iterator .hasNext();) { IApiType superTypeDescriptor = iterator.next(); IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor); if (method3 == null) { continue; } else { int access3 = method3.getModifiers(); if (Flags.isPublic(access3) || Flags.isProtected(access3)) { // method has been move up in // the hierarchy - report the // delta and abort loop // TODO need to make the // distinction between methods // that need to be // re-implemented and methods // that don't found = true; break loop; } } } } } } this.addDelta(getElementType(this.type2), IDelta.ADDED, found ? IDelta.OVERRIDEN_METHOD : IDelta.METHOD, this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } return; } } else if (RestrictionModifiers.isReferenceRestriction(restrictions)) { if (Flags.isPublic(access2) || Flags.isProtected(access2)) { // report that it is no longer an API method if (this.type2.isAnnotation()) { this.addDelta(getElementType(this.type2), IDelta.REMOVED, method.getDefaultValue() != null ? IDelta.API_METHOD_WITH_DEFAULT_VALUE : IDelta.API_METHOD_WITHOUT_DEFAULT_VALUE, this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method2, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } else if (Flags.isPublic(access) || Flags.isProtected(access)) { this.addDelta(getElementType(this.type2), IDelta.REMOVED, method.isConstructor() ? IDelta.API_CONSTRUCTOR : IDelta.API_METHOD, Flags.isAbstract(this.type2.getModifiers()) ? this.currentDescriptorRestrictions | RestrictionModifiers.NO_INSTANTIATE : this.currentDescriptorRestrictions, access, access2, this.type1, getKeyForMethod(method2, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } return; } } } if (this.component.hasApiDescription() && !method.isConstructor() && !method.isClassInitializer() && !(type1.isInterface() || type1.isAnnotation())) { if (restrictions != referenceRestrictions) { if (!Flags.isFinal(access2)) { if (RestrictionModifiers.isOverrideRestriction(restrictions) && !RestrictionModifiers.isOverrideRestriction(referenceRestrictions)) { this.addDelta(getElementType(method), IDelta.ADDED, IDelta.RESTRICTIONS, restrictions, referenceRestrictions, access, access2, this.type1, getKeyForMethod(method2, this.type2), new String[] { Util.getDescriptorName(this.type2), methodDisplayName }); } } } } String[] names1 = method.getExceptionNames(); List<String> list1 = null; if (names1 != null) { list1 = new ArrayList<String>(names1.length); for (int i = 0; i < names1.length; i++) { list1.add(names1[i]); } } String[] names2 = method2.getExceptionNames(); List<String> list2 = null; if (names2 != null) { list2 = new ArrayList<String>(names2.length); for (int i = 0; i < names2.length; i++) { list2.add(names2[i]); } } if (names1 != null) { if (names2 == null) { // check all exception in method descriptor to see if they are // checked or unchecked exceptions loop: for (Iterator<String> iterator = list1.iterator(); iterator.hasNext();) { String exceptionName = iterator.next().replace('/', '.'); if (isCheckedException(this.apiBaseline1, this.component, exceptionName)) { // report delta - removal of checked exception // TODO should we continue the loop for all remaining // exceptions this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.CHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); break loop; } else { // report delta - removal of unchecked exception this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.UNCHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); } } } else { // check if the exceptions are consistent for both descriptors List<String> removedExceptions = new ArrayList<String>(); for (Iterator<String> iterator = list1.iterator(); iterator.hasNext();) { String exceptionName = iterator.next().replace('/', '.'); if (!list2.remove(exceptionName)) { // this means that the exceptionName was not found // inside the new set of exceptions // so it has been removed removedExceptions.add(exceptionName); } } if (removedExceptions.size() != 0) { loop: for (Iterator<String> iterator = removedExceptions.iterator(); iterator.hasNext();) { String exceptionName = iterator.next().replace('/', '.'); if (isCheckedException(this.apiBaseline1, this.component, exceptionName)) { // report delta - removal of checked exception // TODO should we continue the loop for all // remaining exceptions this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.CHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); break loop; } else { // report delta - removal of unchecked exception this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.UNCHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); } } } loop: for (Iterator<String> iterator = list2.iterator(); iterator.hasNext();) { String exceptionName = iterator.next().replace('/', '.'); if (isCheckedException(this.apiBaseline2, this.component2, exceptionName)) { // report delta - addition of checked exception // TODO should we continue the loop for all remaining // exceptions this.addDelta(getElementType(method), IDelta.ADDED, IDelta.CHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); break loop; } else { // report delta - addition of unchecked exception this.addDelta(getElementType(method), IDelta.ADDED, IDelta.UNCHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); } } } } else if (names2 != null) { // check all exception in method descriptor to see if they are // checked or unchecked exceptions loop: for (Iterator<String> iterator = list2.iterator(); iterator.hasNext();) { String exceptionName = iterator.next().replace('/', '.'); if (isCheckedException(this.apiBaseline2, this.component2, exceptionName)) { // report delta - addition of checked exception this.addDelta(getElementType(method), IDelta.ADDED, IDelta.CHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); // TODO should we continue the loop for all remaining // exceptions break loop; } else { // report delta - addition of unchecked exception this.addDelta(getElementType(method), IDelta.ADDED, IDelta.UNCHECKED_EXCEPTION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName }); } } } if (Flags.isVarargs(access)) { if (!Flags.isVarargs(access2)) { // report delta: conversion from T... to T[] - break // compatibility this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.VARARGS_TO_ARRAY, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isVarargs(access2)) { // report delta: conversion from T[] to T... compatible this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ARRAY_TO_VARARGS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isProtected(access)) { if (Flags.isPrivate(access2) || Util.isDefault(access2)) { // report delta - decrease access: protected to default or // private this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } else if (Flags.isPublic(access2)) { // report delta - increase access: protected to public this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isPublic(access) && (Flags.isProtected(access2) || Flags.isPrivate(access2) || Util.isDefault(access2))) { // report delta - decrease access: public to protected, default or // private this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } else if (Util.isDefault(access) && (Flags.isPublic(access2) || Flags.isProtected(access2))) { this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } else if (Flags.isPrivate(access) && (Util.isDefault(access2) || Flags.isPublic(access2) || Flags.isProtected(access2))) { this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isAbstract(access)) { if (!Flags.isAbstract(access2)) { // report delta - changed from abstract to non-abstract this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ABSTRACT_TO_NON_ABSTRACT, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isAbstract(access2)) { // report delta - changed from non-abstract to abstract this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_ABSTRACT_TO_ABSTRACT, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isFinal(access)) { if (!Flags.isFinal(access2)) { // report delta - changed from final to non-final this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.FINAL_TO_NON_FINAL, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isFinal(access2)) { int res = restrictions; if (!RestrictionModifiers.isOverrideRestriction(res)) { if (RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions)) { res = this.currentDescriptorRestrictions; } else if (RestrictionModifiers.isExtendRestriction(this.initialDescriptorRestrictions)) { res = this.initialDescriptorRestrictions; } if (RestrictionModifiers.isOverrideRestriction(referenceRestrictions)) { // it is ok to remove @nooverride and add final at the same // time res = referenceRestrictions; } } // only report this delta is the method was visible this.addDelta(getElementType(method2), IDelta.CHANGED, IDelta.NON_FINAL_TO_FINAL, res, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type2), getMethodDisplayName(method2, this.type2) }); } if (Flags.isStatic(access)) { if (!Flags.isStatic(access2)) { // report delta: change from static to non-static this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.STATIC_TO_NON_STATIC, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isStatic(access2)) { // report delta: change from non-static to static this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_STATIC_TO_STATIC, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isNative(access)) { if (!Flags.isNative(access2)) { // report delta: change from native to non-native this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NATIVE_TO_NON_NATIVE, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isNative(access2)) { // report delta: change from non-native to native this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_NATIVE_TO_NATIVE, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isSynchronized(access)) { if (!Flags.isSynchronized(access2)) { // report delta: change from synchronized to non-synchronized this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.SYNCHRONIZED_TO_NON_SYNCHRONIZED, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isSynchronized(access2)) { // report delta: change from non-synchronized to synchronized this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_SYNCHRONIZED_TO_SYNCHRONIZED, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } if (Flags.isDeprecated(access)) { if (!Flags.isDeprecated(access2)) { this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.DEPRECATION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (Flags.isDeprecated(access2)) { // report delta - non-volatile to volatile this.addDelta(getElementType(method), IDelta.ADDED, IDelta.DEPRECATION, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } // check type parameters String signature1 = method.getGenericSignature(); String signature2 = method2.getGenericSignature(); checkGenericSignature(signature1, signature2, method, method2); if (method.getDefaultValue() == null) { if (method2.getDefaultValue() != null) { // report delta : default value has been added - compatible this.addDelta(getElementType(method), IDelta.ADDED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } } else if (method2.getDefaultValue() == null) { // report delta : default value has been removed - incompatible this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } else if (!method.getDefaultValue().equals(method2.getDefaultValue())) { // report delta: default value has changed this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions, access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName }); } }