Initial attempt to reproduce FELIX-4347
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1549038 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
index a6f4e4c..e5f745e 100644
--- a/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
+++ b/ipojo/manipulator/manipulator/src/test/java/org/apache/felix/ipojo/manipulation/InnerClassAdapterTest.java
@@ -29,9 +29,11 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.concurrent.Callable;
import static junit.framework.Assert.assertEquals;
import static org.fest.assertions.Assertions.assertThat;
@@ -335,6 +337,18 @@
assertThat((String) bar.invoke(o)).isEqualTo("bar");
}
+// @Test
+// public void testThatAnonymousClassDeclaredInStaticFieldsAreNotManipulated() throws Exception {
+// Manipulator manipulator = new Manipulator();
+// String className = "test.inner.ComponentWithInnerClasses";
+// ManipulatedClassLoader classLoader = manipulate(className, manipulator);
+//
+// Class clazz = classLoader.findClass(className);
+// Method method = clazz.getMethod("call");
+// assertThat(method).isNotNull();
+// assertThat(method.invoke(null)).isEqualTo(1);
+// }
+
private Class findInnerClass(Class[] classes, String name) {
for (Class clazz : classes) {
if (clazz.getName().contains(name)) {
diff --git a/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java b/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
index 3e6544a..9b9bfbc 100644
--- a/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
+++ b/ipojo/manipulator/manipulator/src/test/java/test/inner/ComponentWithInnerClasses.java
@@ -21,6 +21,8 @@
import org.apache.felix.ipojo.annotations.Component;
+import java.util.concurrent.Callable;
+
/**
* A component containing inner classes.
*/
@@ -42,6 +44,7 @@
private void doSomethingPrivately() {
}
+
private boolean flag;
boolean getFlag() {
@@ -52,6 +55,16 @@
private String foo = "foo";
+ public static final Callable<Integer> callable = new Callable<Integer>() {
+ public Integer call() {
+ return 1;
+ }
+ };
+
+ public static int call() throws Exception {
+ return callable.call();
+ }
+
private class MyInnerWithANativeMethod {
public String foo() {