Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java')
-rw-r--r--bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java
new file mode 100644
index 000000000..0259d4fd2
--- /dev/null
+++ b/bundles/org.eclipse.osgi.tests/bundles_src/classloader.hooks.a/org/eclipse/osgi/tests/classloader/hooks/a/TestHookConfigurator.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013, 2016 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osgi.tests.classloader.hooks.a;
+
+import org.eclipse.osgi.internal.hookregistry.*;
+import org.eclipse.osgi.internal.loader.classpath.ClasspathEntry;
+import org.eclipse.osgi.internal.loader.classpath.ClasspathManager;
+import org.eclipse.osgi.storage.bundlefile.BundleEntry;
+
+public class TestHookConfigurator implements HookConfigurator {
+ private static final String REJECT_PROP = "classloader.hooks.a.reject";
+ private static final String BAD_TRANSFORM_PROP = "classloader.hooks.a.bad.transform";
+
+ public void addHooks(HookRegistry hookRegistry) {
+ hookRegistry.addClassLoaderHook(new ClassLoaderHook() {
+
+ @Override
+ public boolean rejectTransformation(String name, byte[] transformedBytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {
+ return Boolean.getBoolean(REJECT_PROP);
+ }
+
+ @Override
+ public byte[] processClass(String name, byte[] classbytes, ClasspathEntry classpathEntry, BundleEntry entry, ClasspathManager manager) {
+ if (Boolean.getBoolean(BAD_TRANSFORM_PROP)) {
+ return new byte[] {'b', 'a', 'd', 'b', 'y', 't', 'e', 's'};
+ }
+ return null;
+ }
+
+ });
+ }
+}

Back to the top