/** * Returns the <code>ClassFileReader</code>specific for this IClassFile, based * on its underlying resource, or <code>null</code> if unable to create * the diet class file. * There are two cases to consider:<ul> * <li>a class file corresponding to an IFile resource</li> * <li>a class file corresponding to a zip entry in a JAR</li> * </ul> * * @exception JavaModelException when the IFile resource or JAR is not available * or when this class file is not present in the JAR */ public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException { return getBinaryTypeInfo(file, true/*fully initialize so as to not keep a reference to the byte array*/); } public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
/** * Returns the <code>ClassFileReader</code>specific for this IClassFile, based * on its underlying resource, or <code>null</code> if unable to create * the diet class file. * There are two cases to consider:<ul> * <li>a class file corresponding to an IFile resource</li> * <li>a class file corresponding to a zip entry in a JAR</li> * </ul> * * @exception JavaModelException when the IFile resource or JAR is not available * or when this class file is not present in the JAR */ public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException { return getBinaryTypeInfo(file, true/*fully initialize so as to not keep a reference to the byte array*/); } public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
/** * Returns the <code>ClassFileReader</code>specific for this IClassFile, based * on its underlying resource, or <code>null</code> if unable to create * the diet class file. * There are two cases to consider:<ul> * <li>a class file corresponding to an IFile resource</li> * <li>a class file corresponding to a zip entry in a JAR</li> * </ul> * * @exception JavaModelException when the IFile resource or JAR is not available * or when this class file is not present in the JAR */ public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException { return getBinaryTypeInfo(file, true/*fully initialize so as to not keep a reference to the byte array*/); } public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
/** * Returns the <code>ClassFileReader</code>specific for this IClassFile, based * on its underlying resource, or <code>null</code> if unable to create * the diet class file. * There are two cases to consider:<ul> * <li>a class file corresponding to an IFile resource</li> * <li>a class file corresponding to a zip entry in a JAR</li> * </ul> * * @exception JavaModelException when the IFile resource or JAR is not available * or when this class file is not present in the JAR */ public IBinaryType getBinaryTypeInfo(IFile file) throws JavaModelException { return getBinaryTypeInfo(file, true/*fully initialize so as to not keep a reference to the byte array*/); } public IBinaryType getBinaryTypeInfo(IFile file, boolean fullyInitialize) throws JavaModelException {
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ @Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo(); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(JavaElement.NO_ELEMENTS); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; }
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo((IFile) underlyingResource); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; } /**
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo((IFile) underlyingResource); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; } /**
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo((IFile) underlyingResource); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; } /**
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ @Override protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo(); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; } /* (non-Javadoc)
/** * Creates the children elements for this class file adding the resulting * new handles and info objects to the newElements table. Returns true * if successful, or false if an error is encountered parsing the class file. * * @see Openable * @see Signature */ protected boolean buildStructure(OpenableElementInfo info, IProgressMonitor pm, Map newElements, IResource underlyingResource) throws JavaModelException { IBinaryType typeInfo = getBinaryTypeInfo((IFile) underlyingResource); if (typeInfo == null) { // The structure of a class file is unknown if a class file format errors occurred //during the creation of the diet class file representative of this ClassFile. info.setChildren(new IJavaElement[] {}); return false; } // Make the type IType type = getType(); info.setChildren(new IJavaElement[] {type}); newElements.put(type, typeInfo); // Read children ((ClassFileInfo) info).readBinaryChildren(this, (HashMap) newElements, typeInfo); return true; } /**
public IBuffer getBuffer() throws JavaModelException { IStatus status = validateClassFile(); if (status.isOK()) { return super.getBuffer(); } else { // .class file not on classpath, create a new buffer to be nice (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=41444) Object info = ((ClassFile) getClassFile()).getBinaryTypeInfo((IFile) resource()); IBuffer buffer = openBuffer(null, info); if (buffer != null && !(buffer instanceof NullBuffer)) return buffer; switch (status.getCode()) { case IJavaModelStatusConstants.ELEMENT_NOT_ON_CLASSPATH: // don't throw a JavaModelException to be able to open .class file outside the classpath (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=138507 ) case IJavaModelStatusConstants.INVALID_ELEMENT_TYPES: // don't throw a JavaModelException to be able to open .class file in proj==src case without source (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=221904 ) return null; default: throw new JavaModelException((IJavaModelStatus) status); } } } /**
ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/); CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit); parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/); CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit); parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/); CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit); parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
ClassFileReader reader = (ClassFileReader) classFile.getBinaryTypeInfo((IFile) classFile.resource(), false/*don't fully initialize so as to keep constant pool (used below)*/); CompilationResult result = new CompilationResult(reader.getFileName(), 1, 1, this.compilerOptions.maxProblemsPerUnit); parsedUnit = new CompilationUnitDeclaration(this.parser.problemReporter(), result, 0);
ClassFileReader reader = null; if (classFile.getPackageFragmentRoot() instanceof JrtPackageFragmentRoot) { IBinaryType binaryTypeInfo = classFile.getBinaryTypeInfo(); if (binaryTypeInfo instanceof ClassFileReader) { reader = (ClassFileReader) binaryTypeInfo;