Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSBundleFile.java4
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookConfigurator.java14
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookImpls.java56
-rw-r--r--bundles/org.eclipse.osgi/osgi/j9stubs.jarbin4081 -> 4732 bytes
4 files changed, 13 insertions, 61 deletions
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 f540a9eb5..39588afd4 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
@@ -34,6 +34,7 @@ import org.eclipse.osgi.storage.bundlefile.BundleFileWrapper;
* shared classes cache.
*/
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 SharedClassURLHelper urlHelper; // the url helper set by the classloader
private boolean primed = false;
@@ -67,12 +68,11 @@ public class CDSBundleFile extends BundleFileWrapper {
* shared classes cache. If found, the bytes representing the magic cookie are stored in CDSBundleEntry object.
*/
public BundleEntry getEntry(String path) {
- String classFileExt = ".class"; //$NON-NLS-1$
BundleEntry wrappedEntry = super.getEntry(path);
if (wrappedEntry == null) {
return null;
}
- if ((false == primed) || (false == path.endsWith(classFileExt))) {
+ if (!primed || !path.endsWith(classFileExt)) {
return wrappedEntry;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookConfigurator.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookConfigurator.java
index 42a71fc72..9891f4cb5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookConfigurator.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookConfigurator.java
@@ -22,18 +22,21 @@
package org.eclipse.osgi.internal.cds;
+import org.eclipse.osgi.framework.log.FrameworkLogEntry;
+import org.eclipse.osgi.internal.framework.EquinoxContainer;
import org.eclipse.osgi.internal.hookregistry.HookConfigurator;
import org.eclipse.osgi.internal.hookregistry.HookRegistry;
+import org.eclipse.osgi.internal.log.EquinoxLogServices;
public class CDSHookConfigurator implements HookConfigurator {
- private static final String SUPPRESS_ERRORS = "j9.cds.suppresserrors"; //$NON-NLS-1$
+ private static final String REPORT_ERRORS = "j9.cds.reporterrors"; //$NON-NLS-1$
private static final String DISABLE_CDS = "j9.cds.disable"; //$NON-NLS-1$
private static final String OLD_CDS_CONFIGURATOR = "com.ibm.cds.CDSHookConfigurator"; //$NON-NLS-1$
private static final String J9_SHARED_CLASS_HELPER_CLASS = "com.ibm.oti.shared.SharedClassHelperFactory"; //$NON-NLS-1$
public void addHooks(HookRegistry hookRegistry) {
- boolean disableCDS = "true".equals(hookRegistry.getConfiguration().getProperty(DISABLE_CDS)); //$NON-NLS-1$
+ boolean disableCDS = Boolean.valueOf(hookRegistry.getConfiguration().getProperty(DISABLE_CDS));
if (disableCDS) {
return;
}
@@ -48,11 +51,12 @@ public class CDSHookConfigurator implements HookConfigurator {
try {
Class.forName(J9_SHARED_CLASS_HELPER_CLASS);
} catch (ClassNotFoundException e) {
- boolean reportErrors = "false".equals(hookRegistry.getConfiguration().getProperty(SUPPRESS_ERRORS)); //$NON-NLS-1$
+ boolean reportErrors = Boolean.valueOf(hookRegistry.getConfiguration().getProperty(REPORT_ERRORS));
// not running on J9
if (reportErrors) {
- System.err.println("The J9 Class Sharing Adaptor will not work in this configuration."); //$NON-NLS-1$
- System.err.println("You are not running on a J9 Java VM."); //$NON-NLS-1$
+ EquinoxContainer container = hookRegistry.getContainer();
+ EquinoxLogServices logServices = container.getLogServices();
+ logServices.log(EquinoxContainer.NAME, FrameworkLogEntry.WARNING, "The J9 Class Sharing Adaptor will not work in this configuration. You are not running on a J9 Java VM.", null); //$NON-NLS-1$
}
return;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookImpls.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookImpls.java
index 2166d275a..3322768e9 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookImpls.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/cds/CDSHookImpls.java
@@ -43,8 +43,6 @@ import org.eclipse.osgi.storage.bundlefile.BundleFileWrapperChain;
public class CDSHookImpls extends ClassLoaderHook implements BundleFileWrapperFactoryHook {
private static SharedClassHelperFactory factory = Shared.getSharedClassHelperFactory();
- private static java.lang.reflect.Method minimizeMethod = null;
- private static boolean hasMinimizeMethod = true; /* Assume true to begin with */
// With Equinox bug 226038 (v3.4), the framework will now pass an instance
// of BundleFileWrapperChain rather than the wrapped BundleFile. This is
@@ -133,55 +131,6 @@ public class CDSHookImpls extends ClassLoaderHook implements BundleFileWrapperFa
}
}
- /* Calling setMinimizeUpdateChecks() on the urlHelper tells it to only check the plugin jar for updates
- * once on startup. This removes the need to "prime" plugins by always cacheing the first class from the jar.
- *
- * Java5 does not have a runMinimizeUpdateChecks method, but Java6 does. The text below explains why.
- *
- * Java6 has an improved jar update detection mechanism which is event-driven and listens for
- * real jar open and close events. It will check jar timestamps on every class-load for closed jars (when
- * loading cached classes from those jars) and not check them if it knows the jars are open.
- *
- * Java5 didn't know about jar open/close events so simply assumed that the first class to be stored by
- * a plugin implied that its jar was opened indefinitely. This is why it helps to "prime" a plugin when
- * running under Java5 - by storing a class, the jar is opened and the JVM stops checking its timestamp
- * which results in faster startup.
- *
- * While the Java6 behaviour is more correct (it will pick up changes if a jar is closed after having been opened),
- * if the jars are not opened or "primed", then it will perform constant checks on their timestamps which hurts startup times.
- * This is why setMinimizeUpdateChecks was introduced - it's a means of saying to the urlHelper - regardless of
- * whether my container(s) is open or closed, I only want you to check it once for updates.
- *
- * The consequence of this is that less file handles are open on startup in Java6.
- *
- * This has been written in such a way that this adaptor will continue to work exactly the same with Java5, but
- * will adapt its behaviour when used with Java6 to do the right thing.
- */
- private boolean runMinimizeMethod(SharedClassURLHelper urlHelper) {
- if (hasMinimizeMethod && (urlHelper != null)) {
- if (minimizeMethod == null) {
- hasMinimizeMethod = false; /* Assume failure - prove success below */
- try {
- Class<?> c = urlHelper.getClass();
- minimizeMethod = c.getMethod("setMinimizeUpdateChecks"); //$NON-NLS-1$
- minimizeMethod.setAccessible(true);
- hasMinimizeMethod = true;
- } catch (Exception e) {
- /* hasMinimizeMethod will be false and we won't try this again */
- }
- }
- if (minimizeMethod != null) {
- try {
- minimizeMethod.invoke(urlHelper);
- return true;
- } catch (Exception e) {
- hasMinimizeMethod = false;
- }
- }
- }
- return false;
- }
-
private boolean hasMagicClassNumber(byte[] classbytes) {
if (classbytes == null || classbytes.length < 4)
return false;
@@ -197,13 +146,12 @@ public class CDSHookImpls extends ClassLoaderHook implements BundleFileWrapperFa
CDSBundleFile hostFile = null;
try {
SharedClassURLHelper urlHelper = factory.getURLHelper(classLoader);
- boolean minimizeSucceeded = runMinimizeMethod(urlHelper);
// set the url helper for the host base CDSBundleFile
hostFile = getCDSBundleFile(classLoader.getClasspathManager().getGeneration().getBundleFile());
if (hostFile != null) {
hostFile.setURLHelper(urlHelper);
- if (minimizeSucceeded) {
- /* In Java6, there is no longer a requirement to "prime" plugins */
+ if (urlHelper.setMinimizeUpdateChecks()) {
+ // no need to prime if we were able to setsetMinimizeUpdateChecks
hostFile.setPrimed(true);
}
}
diff --git a/bundles/org.eclipse.osgi/osgi/j9stubs.jar b/bundles/org.eclipse.osgi/osgi/j9stubs.jar
index 597a2d4b6..4053e6cdc 100644
--- a/bundles/org.eclipse.osgi/osgi/j9stubs.jar
+++ b/bundles/org.eclipse.osgi/osgi/j9stubs.jar
Binary files differ

Back to the top