protected byte[] getClassFileContent(JarPackageFragmentRoot root, String className) throws CoreException, IOException { byte[] contents = null; String rootPath = root.getPath().toOSString(); if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) { try { contents = org.eclipse.jdt.internal.compiler.util.JRTUtil.getClassfileContent( new File(rootPath), className, root.getElementName()); } catch (ClassFormatException e) { e.printStackTrace(); } } else { ZipFile zip = root.getJar(); try { ZipEntry ze = zip.getEntry(className); if (ze != null) { contents = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); } } finally { JavaModelManager.getJavaModelManager().closeZipFile(zip); } } if (contents == null && Thread.interrupted()) // reading from JRT is interruptible throw new OperationCanceledException(); return contents; }
protected byte[] getClassFileContent(JarPackageFragmentRoot root, String className) throws CoreException, IOException { byte[] contents = null; String rootPath = root.getPath().toOSString(); if (org.eclipse.jdt.internal.compiler.util.Util.isJrt(rootPath)) { try { contents = org.eclipse.jdt.internal.compiler.util.JRTUtil.getClassfileContent( new File(rootPath), className, root.getElementName()); } catch (ClassFormatException e) { e.printStackTrace(); } } else { ZipFile zip = root.getJar(); try { ZipEntry ze = zip.getEntry(className); if (ze != null) { contents = org.eclipse.jdt.internal.compiler.util.Util.getZipEntryByteContent(ze, zip); } } finally { JavaModelManager.getJavaModelManager().closeZipFile(zip); } } return contents; }