public static void testType(IBinaryType expected, IBinaryType actual) { String contextPrefix = safeString(actual.getName()); IBinaryTypeAnnotation[] expectedTypeAnnotations = expected.getTypeAnnotations(); IBinaryTypeAnnotation[] actualTypeAnnotations = actual.getTypeAnnotations(); IBinaryAnnotation[] expectedBinaryAnnotations = expected.getAnnotations(); IBinaryAnnotation[] actualBinaryAnnotations = actual.getAnnotations(); expected.getGenericSignature(), actual.getGenericSignature()); assertEquals(contextPrefix + ": The enclosing method name did not match", expected.getEnclosingMethod(), //$NON-NLS-1$ actual.getEnclosingMethod()); assertEquals(contextPrefix + ": The enclosing method name did not match", expected.getEnclosingTypeName(), //$NON-NLS-1$ actual.getEnclosingTypeName()); IBinaryField[] expectedFields = expected.getFields(); IBinaryField[] actualFields = actual.getFields(); assertEquals("The file name did not match", expected.getFileName(), actual.getFileName()); //$NON-NLS-1$ assertEquals("The interface names did not match", expected.getInterfaceNames(), actual.getInterfaceNames()); //$NON-NLS-1$ IBinaryMethod[] expectedMethods = expected.getMethods(); IBinaryMethod[] actualMethods = actual.getMethods(); assertEquals("The missing type names did not match", expected.getMissingTypeNames(), //$NON-NLS-1$ actual.getMissingTypeNames()); assertEquals("The modifiers don't match", expected.getModifiers(), actual.getModifiers()); //$NON-NLS-1$ assertEquals("The names don't match.", expected.getName(), actual.getName()); //$NON-NLS-1$ assertEquals("The source name doesn't match", expected.getSourceName(), actual.getSourceName()); //$NON-NLS-1$
@Override public IBinaryNestedType[] getMemberTypes() { return this.inputType.getMemberTypes(); }
@Override public IAnnotation[] getAnnotations() throws JavaModelException { IBinaryType info = (IBinaryType) getElementInfo(); IBinaryAnnotation[] binaryAnnotations = info.getAnnotations(); return getAnnotations(binaryAnnotations, info.getTagBits()); }
char[] fieldDescriptorFromClass = JavaNames.binaryNameToFieldDescriptor(binaryType.getName()); logInfo("adding binary type " + new String(fieldDescriptor)); //$NON-NLS-1$ IBinaryTypeAnnotation[] typeAnnotations = binaryType.getTypeAnnotations(); if (typeAnnotations != null) { type.allocateTypeAnnotations(typeAnnotations.length); char[][] interfaces = binaryType.getInterfaceNames(); if (interfaces == null) { interfaces = EMPTY_CHAR_ARRAY_ARRAY; if (binaryType.getGenericSignature() != null) { type.setFlag(NdType.FLG_GENERIC_SIGNATURE_PRESENT, true); type.setModifiers(binaryType.getModifiers()); type.setDeclaringType(createTypeIdFromBinaryName(binaryType.getEnclosingTypeName())); char[] superclassBinaryName = binaryType.getSuperclassName(); if (superclassBinaryName == null) { superclassFieldDescriptor = JAVA_LANG_OBJECT_FIELD_DESCRIPTOR; IBinaryAnnotation[] annotations = binaryType.getAnnotations(); attachAnnotations(type, annotations); type.setDeclaringMethod(binaryType.getEnclosingMethod()); IBinaryField[] fields = binaryType.getFields(); IBinaryMethod[] methods = binaryType.getMethods();
updateInt(classFile.getModifiers()); updateLong(classFile.getTagBits() & OnlyStructuralTagBits); updateAnnotations(classFile.getAnnotations()); updateTypeAnnotations(classFile.getTypeAnnotations()); updateChars(classFile.getGenericSignature()); updateChars(classFile.getSuperclassName()); char[][] interfacesNames = classFile.getInterfaceNames(); if (interfacesNames != null) { for (int i = 0; i < interfacesNames.length; i++) { IBinaryNestedType[] memberTypes = classFile.getMemberTypes(); if (memberTypes != null) { for (int i = 0; i < memberTypes.length; i++) { FieldInfo[] fieldInfos = (FieldInfo[]) classFile.getFields(); if (fieldInfos != null) { for (int i = 0; i < fieldInfos.length; i++) { MethodInfo[] methodInfos = (MethodInfo[]) classFile.getMethods(); if (methodInfos != null) { for (int i = 0; i < methodInfos.length; i++) { char[][][] missingTypes = classFile.getMissingTypeNames(); if (missingTypes != null) {
IBinaryNestedType[] memberTypeStructures = binaryType.getMemberTypes(); if (memberTypeStructures != null) { int size = memberTypeStructures.length; char[] typeSignature = null; if (sourceLevel >= ClassFileConstants.JDK1_5) { typeSignature = binaryType.getGenericSignature(); this.tagBits |= binaryType.getTagBits(); char[][][] missingTypeNames = binaryType.getMissingTypeNames(); if (typeSignature == null) { char[] superclassName = binaryType.getSuperclassName(); if (superclassName != null) { char[][] interfaceNames = binaryType.getInterfaceNames(); if (interfaceNames != null) { int size = interfaceNames.length; char[] methodDescriptor = binaryType.getEnclosingMethod(); if (methodDescriptor != null) { MethodBinding enclosingMethod = findMethod(methodDescriptor, missingTypeNames); createFields(binaryType.getFields(), sourceLevel, missingTypeNames); createMethods(binaryType.getMethods(), sourceLevel, missingTypeNames); setAnnotations(createAnnotations(binaryType.getAnnotations(), this.environment, missingTypeNames)); } finally {
IBinaryAnnotation[] annotations = binaryType.getAnnotations(); BinaryType classFileBinaryType = (BinaryType) classFile.getType(); BinaryTypeBinding binaryTypeBinding = null; if (checkAnnotations(typeReferencePattern, annotations, binaryType.getTagBits())) { classFileBinaryType = new ResolvedBinaryType((JavaElement) classFileBinaryType.getParent(), classFileBinaryType.getElementName(), classFileBinaryType.getKey()); TypeReferenceMatch match = new TypeReferenceMatch(classFileBinaryType, SearchMatch.A_ACCURATE, -1, 0, false, locator.getParticipant(), locator.currentPossibleMatch.resource); IBinaryMethod[] methods = binaryType.getMethods(); if (methods != null) { for (int i = 0, max = methods.length; i < max; i++) { IBinaryField[] fields = binaryType.getFields(); if (fields != null) { for (int i = 0, max = fields.length; i < max; i++) {
/** * Creates the handles for <code>BinaryMember</code>s defined in this * <code>ClassFile</code> and adds them to the * <code>JavaModelManager</code>'s cache. */ protected void readBinaryChildren(ClassFile classFile, HashMap newElements, IBinaryType typeInfo) { ArrayList childrenHandles = new ArrayList(); BinaryType type = (BinaryType) classFile.getType(); ArrayList typeParameterHandles = new ArrayList(); if (typeInfo != null) { //may not be a valid class file generateAnnotationsInfos(type, typeInfo.getAnnotations(), typeInfo.getTagBits(), newElements); generateTypeParameterInfos(type, typeInfo.getGenericSignature(), newElements, typeParameterHandles); generateFieldInfos(type, typeInfo, newElements, childrenHandles); generateMethodInfos(type, typeInfo, newElements, childrenHandles, typeParameterHandles); generateInnerClassHandles(type, typeInfo, childrenHandles); // Note inner class are separate openables that are not opened here: no need to pass in newElements } this.binaryChildren = new JavaElement[childrenHandles.size()]; childrenHandles.toArray(this.binaryChildren); int typeParameterHandleSize = typeParameterHandles.size(); if (typeParameterHandleSize == 0) { this.typeParameters = TypeParameter.NO_TYPE_PARAMETERS; } else { this.typeParameters = new ITypeParameter[typeParameterHandleSize]; typeParameterHandles.toArray(this.typeParameters); } } /**
if (answer != null && answer.isBinaryType()) { IBinaryType type = answer.getBinaryType(); char[][][] missingTypeNames = type.getMissingTypeNames(); IBinaryAnnotation[] binaryAnnotations = type.getAnnotations(); org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] binaryInstances = BinaryTypeBinding.createAnnotations(binaryAnnotations, this.binding.environment, missingTypeNames); org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding[] allInstances = org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding.addStandardAnnotations(binaryInstances, type.getTagBits(), this.binding.environment); int total = allInstances.length; IAnnotationBinding[] domInstances = new AnnotationBinding[total];
/** * Add an additional binary type */ public void accept(IBinaryType binaryType, PackageBinding packageBinding, AccessRestriction accessRestriction) { if (this.options.verbose) { this.out.println( Messages.bind(Messages.compilation_loadBinary, new String(binaryType.getName()))); // new Exception("TRACE BINARY").printStackTrace(System.out); // System.out.println(); } this.lookupEnvironment.createBinaryTypeFrom(binaryType, packageBinding, accessRestriction); }
boolean matchSuperTypeReference(SuperTypeReferencePattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) { if (!(binaryInfo instanceof IBinaryType)) return false; IBinaryType type = (IBinaryType) binaryInfo; if (pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_INTERFACES) { char[] vmName = type.getSuperclassName(); if (vmName != null) { char[] superclassName = convertClassFileFormat(vmName); if (checkTypeName(pattern.superSimpleName, pattern.superQualification, superclassName, pattern.isCaseSensitive(), pattern.isCamelCase())) return true; } } if (pattern.superRefKind != SuperTypeReferencePattern.ONLY_SUPER_CLASSES) { char[][] superInterfaces = type.getInterfaceNames(); if (superInterfaces != null) { for (int i = 0, max = superInterfaces.length; i < max; i++) { char[] superInterfaceName = convertClassFileFormat(superInterfaces[i]); if (checkTypeName(pattern.superSimpleName, pattern.superQualification, superInterfaceName, pattern.isCaseSensitive(), pattern.isCamelCase())) return true; } } } return false; } boolean matchTypeDeclaration(TypeDeclarationPattern pattern, Object binaryInfo, IBinaryType enclosingBinaryType) {
public int getFlags() throws JavaModelException { IBinaryType info = (IBinaryType) getElementInfo(); return info.getModifiers() & ~ClassFileConstants.AccSuper; } /*
@Override public char[] getSuperclassName() { return this.inputType.getSuperclassName(); }
@Override public char[] getGenericSignature() { return this.inputType.getGenericSignature(); }
@Override public char[][] getInterfaceNames() { return this.inputType.getInterfaceNames(); }
@Override public IBinaryField[] getFields() { return this.inputType.getFields(); }
@Override public IBinaryAnnotation[] getAnnotations() { return this.inputType.getAnnotations(); }
@Override public IBinaryMethod[] getMethods() { return this.inputType.getMethods(); }
@Override public char[][][] getMissingTypeNames() { return this.inputType.getMissingTypeNames(); }
updateInt(classFile.getModifiers()); updateLong(classFile.getTagBits() & OnlyStructuralTagBits); updateAnnotations(classFile.getAnnotations()); updateTypeAnnotations(classFile.getTypeAnnotations()); updateChars(classFile.getGenericSignature()); updateChars(classFile.getSuperclassName()); char[][] interfacesNames = classFile.getInterfaceNames(); if (interfacesNames != null) { for (int i = 0; i < interfacesNames.length; i++) { IBinaryNestedType[] memberTypes = classFile.getMemberTypes(); if (memberTypes != null) { for (int i = 0; i < memberTypes.length; i++) { FieldInfo[] fieldInfos = (FieldInfo[]) classFile.getFields(); if (fieldInfos != null) { for (int i = 0; i < fieldInfos.length; i++) { MethodInfo[] methodInfos = (MethodInfo[]) classFile.getMethods(); if (methodInfos != null) { for (int i = 0; i < methodInfos.length; i++) { char[][][] missingTypes = classFile.getMissingTypeNames(); if (missingTypes != null) {