View | Details | Raw Unified | Return to bug 150244 | Differences between
and this patch

Collapse All | Expand All

(-)model/org/eclipse/jdt/core/IClassFile.java (-1 / +9 lines)
Lines 78-84 Link Here
78
 * @since 3.2
78
 * @since 3.2
79
 */
79
 */
80
ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
80
ICompilationUnit becomeWorkingCopy(IProblemRequestor problemRequestor, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException;
81
81
/**
82
 * Returns the bytes contained in this class file.
83
 *
84
 * @return the bytes contained in this class file
85
 *
86
 * @exception JavaModelException if this element does not exist or if an
87
 *      exception occurs while accessing its corresponding resource
88
 */
89
byte[] getBytes() throws JavaModelException;
82
/**
90
/**
83
 * Returns the type contained in this class file.
91
 * Returns the type contained in this class file.
84
 *
92
 *
(-)model/org/eclipse/jdt/internal/core/ClassFile.java (+30 lines)
Lines 298-303 Link Here
298
		}
298
		}
299
	}
299
	}
300
}
300
}
301
302
public byte[] getBytes() throws JavaModelException {
303
	JavaElement pkg = (JavaElement) getParent();
304
	if (pkg instanceof JarPackageFragment) {
305
		JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
306
		ZipFile zip = null;
307
		try {
308
			zip = root.getJar();
309
			String entryName = Util.concatWith(((PackageFragment) pkg).names, getElementName(), '/');
310
			ZipEntry ze = zip.getEntry(entryName);
311
			if (ze != null) {
312
				return org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip);
313
			}
314
			throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST, this));
315
		} catch (IOException ioe) {
316
			throw new JavaModelException(ioe, IJavaModelStatusConstants.IO_EXCEPTION);
317
		} catch (CoreException e) {
318
			if (e instanceof JavaModelException) {
319
				throw (JavaModelException)e;
320
			} else {
321
				throw new JavaModelException(e);
322
			}
323
		} finally {
324
			JavaModelManager.getJavaModelManager().closeZipFile(zip);
325
		}
326
	} else {
327
		IFile file = (IFile) getResource();
328
		return Util.getResourceContentsAsByteArray(file);
329
	}
330
}
301
private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg) throws CoreException, IOException, ClassFormatException {
331
private IBinaryType getJarBinaryTypeInfo(PackageFragment pkg) throws CoreException, IOException, ClassFormatException {
302
	JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
332
	JarPackageFragmentRoot root = (JarPackageFragmentRoot) pkg.getParent();
303
	ZipFile zip = null;
333
	ZipFile zip = null;

Return to bug 150244