diff options
author | Thomas Watson | 2011-06-08 15:58:22 +0000 |
---|---|---|
committer | Thomas Watson | 2011-06-08 15:58:22 +0000 |
commit | 3c0f3c6b4324b8b7a0b9edb6bfdefff7893627f5 (patch) | |
tree | b2e71d4c55638142b27c29a51f763ca8f3898f42 /bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse | |
parent | 1f99a7850a7a337635921be63a21100edd53a44f (diff) | |
download | rt.equinox.framework-3c0f3c6b4324b8b7a0b9edb6bfdefff7893627f5.tar.gz rt.equinox.framework-3c0f3c6b4324b8b7a0b9edb6bfdefff7893627f5.tar.xz rt.equinox.framework-3c0f3c6b4324b8b7a0b9edb6bfdefff7893627f5.zip |
Bug 348770 - weaving hook support creates an extra byte[] copy each class load when it is not necessary
Diffstat (limited to 'bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse')
2 files changed, 25 insertions, 23 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WeavingHookConfigurator.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WeavingHookConfigurator.java index 78b8f44dc..43aec13e2 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WeavingHookConfigurator.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WeavingHookConfigurator.java @@ -74,9 +74,6 @@ public class WeavingHookConfigurator implements HookConfigurator, ClassLoadingHo ClassFormatError error = new ClassFormatError("Unexpected error from weaving hook."); //$NON-NLS-1$ error.initCause(t); throw error; - } finally { - // ensure we always tell the woven class that we are done calling hooks. - wovenClass.setHooksComplete(); } } diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WovenClassImpl.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WovenClassImpl.java index 12f2a4b26..270f70593 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WovenClassImpl.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/weaving/WovenClassImpl.java @@ -88,7 +88,7 @@ public final class WovenClassImpl implements WovenClass, HookContext { return (hookFlags & FLAG_WEAVINGCOMPLETE) != 0; } - void setHooksComplete() { + private void setHooksComplete() { // create a copy of the bytes array that noone has a reference to byte[] original = bytes; bytes = new byte[bytes.length]; @@ -150,31 +150,35 @@ public final class WovenClassImpl implements WovenClass, HookContext { byte[] callHooks() throws Throwable { SecurityManager sm = System.getSecurityManager(); - if (sm == null) { - registry.notifyHooksPrivileged(this); - } else { - try { - AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { - public Object run() { - registry.notifyHooksPrivileged(WovenClassImpl.this); - return null; - } - }); - } catch (PrivilegedActionException e) { - throw (RuntimeException) e.getException(); + byte[] wovenBytes = null; + List<String> newImports = null; + try { + if (sm == null) { + registry.notifyHooksPrivileged(this); + } else { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { + public Object run() { + registry.notifyHooksPrivileged(WovenClassImpl.this); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw (RuntimeException) e.getException(); + } + } + } finally { + if ((hookFlags & FLAG_HOOKCALLED) != 0) { + wovenBytes = bytes; + newImports = dynamicImports; + setHooksComplete(); } } - if ((hookFlags & FLAG_HOOKCALLED) == 0) - return null; // we never handed this object to a hook; nothing else to do - - byte[] wovenBytes = bytes; - List<String> newImports = dynamicImports; - setHooksComplete(); if (error != null) throw error; - if (newImports.size() > 0) { + if (newImports != null) { // add any new dynamic imports for (String newImport : newImports) { try { @@ -185,6 +189,7 @@ public final class WovenClassImpl implements WovenClass, HookContext { } } } + return wovenBytes; } |