Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-09-03 19:08:11 +0000
committerThomas Watson2019-09-12 15:58:41 +0000
commit88af5b2416b3acc3730299b7af45bac958ebaf25 (patch)
tree7f4f9b5781a2800db4c09528534aae58f396c3e5
parentd313383de36e6d619cce98d940bf9c3efbb1e724 (diff)
downloadrt.equinox.framework-I20190912-1800.tar.gz
rt.equinox.framework-I20190912-1800.tar.xz
rt.equinox.framework-I20190912-1800.zip
Bug 550605 - Check class cache before wrapped bundle fileI20190912-1800
If a class exists in the j9 class cache for a given bundle content URL then just use it and do not first check for an entry from the wrapped bundle file. This avoids doing an unneeded zip file lookup each class load Change-Id: I0f34305fa9e2f88c089d0888db732e8d3647dc9d Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleEntry.java33
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java19
2 files changed, 29 insertions, 23 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleEntry.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleEntry.java
index be275411d..6293fb0e6 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleEntry.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleEntry.java
@@ -31,21 +31,29 @@ import org.eclipse.osgi.storage.bundlefile.BundleEntry;
* A bundle entry for a class that is found in the shared classes cache
*/
public class CDSBundleEntry extends BundleEntry {
- String path;
- byte[] classbytes;
- BundleEntry wrapped;
+ final String path;
+ final byte[] classbytes;
+ final CDSBundleFile bundleFile;
/**
* The constructor
* @param path the path to the class file
* @param classbytes the magic cookie bytes for the class in the shared cache
- * @param wrapped the actual bundleEntry where the class comes from
+ * @param bundleFile the bundle file where the class comes from
*/
- public CDSBundleEntry(String path, byte[] classbytes, BundleEntry wrapped) {
+ public CDSBundleEntry(String path, byte[] classbytes, CDSBundleFile bundleFile) {
super();
this.path = path;
this.classbytes = classbytes;
- this.wrapped = wrapped;
+ this.bundleFile = bundleFile;
+ }
+
+ private BundleEntry getEntry() {
+ BundleEntry entry = bundleFile.getEntry(path);
+ if (entry == null) {
+ throw new IllegalStateException("Could not find original entry for the class: " + path); //$NON-NLS-1$
+ }
+ return entry;
}
/*
@@ -58,7 +66,7 @@ public class CDSBundleEntry extends BundleEntry {
*/
@Override
public URL getFileURL() {
- return wrapped.getFileURL();
+ return getEntry().getFileURL();
}
/*
@@ -71,7 +79,7 @@ public class CDSBundleEntry extends BundleEntry {
public InputStream getInputStream() throws IOException {
// someone is trying to get the real bytes of the class file!!
// just return the entry from the wrapped file instead of the magic cookie
- return wrapped.getInputStream();
+ return getEntry().getInputStream();
}
/*
@@ -83,9 +91,6 @@ public class CDSBundleEntry extends BundleEntry {
*/
@Override
public byte[] getBytes() throws IOException {
- if (classbytes == null) {
- classbytes = wrapped.getBytes();
- }
return classbytes;
}
@@ -99,7 +104,7 @@ public class CDSBundleEntry extends BundleEntry {
*/
@Override
public URL getLocalURL() {
- return wrapped.getLocalURL();
+ return getEntry().getLocalURL();
}
@Override
@@ -109,11 +114,11 @@ public class CDSBundleEntry extends BundleEntry {
@Override
public long getSize() {
- return wrapped.getSize();
+ return getEntry().getSize();
}
@Override
public long getTime() {
- return wrapped.getTime();
+ return getEntry().getTime();
}
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java
index b6cdf28d0..ff7256a88 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java
@@ -35,7 +35,7 @@ import org.eclipse.osgi.storage.bundlefile.BundleFileWrapper;
*/
public class CDSBundleFile extends BundleFileWrapper {
private final static String classFileExt = ".class"; //$NON-NLS-1$
- private URL url; // the URL to the content of the real bundle file
+ private final URL url; // the URL to the content of the real bundle file
private SharedClassURLHelper urlHelper; // the url helper set by the classloader
private boolean primed = false;
@@ -46,11 +46,13 @@ public class CDSBundleFile extends BundleFileWrapper {
public CDSBundleFile(BundleFile wrapped) {
super(wrapped);
// get the url to the content of the real bundle file
+ URL content = null;
try {
- this.url = new URL("file", "", wrapped.getBaseFile().getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+ content = new URL("file", "", wrapped.getBaseFile().getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
} catch (MalformedURLException e) {
// do nothing
}
+ this.url = content;
}
public CDSBundleFile(BundleFile bundleFile, SharedClassURLHelper urlHelper) {
@@ -69,16 +71,15 @@ public class CDSBundleFile extends BundleFileWrapper {
*/
@Override
public BundleEntry getEntry(String path) {
- BundleEntry wrappedEntry = super.getEntry(path);
- if (wrappedEntry == null) {
- return null;
- }
if (!primed || !path.endsWith(classFileExt)) {
- return wrappedEntry;
+ return super.getEntry(path);
}
-
byte[] classbytes = getClassBytes(path.substring(0, path.length() - classFileExt.length()));
- BundleEntry be = new CDSBundleEntry(path, classbytes, wrappedEntry);
+ if (classbytes == null) {
+ return super.getEntry(path);
+ }
+
+ BundleEntry be = new CDSBundleEntry(path, classbytes, this);
return be;
}

Back to the top