Author: arne
Date: Thu Apr 18 06:29:41 2013
New Revision: 1469185
URL: http://svn.apache.org/r1469185
Log:
OWB-828: Fixed proxy creation for bridge methods
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericInterface.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/SpecificClass.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java?rev=1469185&r1=1469184&r2=1469185&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/proxy/AbstractProxyFactory.java
Thu Apr 18 06:29:41 2013
@@ -275,7 +275,7 @@ public abstract class AbstractProxyFacto
//X TODO how to deal with native functions?
return (modifiers & (Modifier.PRIVATE | Modifier.STATIC |
Modifier.FINAL | Modifier.NATIVE)) > 0 ||
- "finalize".equals(delegatedMethod.getName());
+ "finalize".equals(delegatedMethod.getName()) ||
delegatedMethod.isBridge();
}
/**
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java?rev=1469185&r1=1469184&r2=1469185&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/ClassUtil.java
Thu Apr 18 06:29:41 2013
@@ -1061,7 +1061,9 @@ public final class ClassUtil
*/
public static boolean isOverridden(Method subClassMethod, Method
superClassMethod)
{
- if (subClassMethod.getName().equals(superClassMethod.getName()) &&
Arrays.equals(subClassMethod.getParameterTypes(),
superClassMethod.getParameterTypes()))
+ if (isSuperClass(superClassMethod.getDeclaringClass(),
subClassMethod.getDeclaringClass())
+ && subClassMethod.getName().equals(superClassMethod.getName())
+ && Arrays.equals(subClassMethod.getParameterTypes(),
superClassMethod.getParameterTypes()))
{
int modifiers = superClassMethod.getModifiers();
if(Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers))
@@ -1087,4 +1089,8 @@ public final class ClassUtil
return false;
}
+ private static boolean isSuperClass(Class<?> superClass, Class<?> subClass)
+ {
+ return superClass.isAssignableFrom(subClass) &&
!superClass.equals(subClass);
+ }
}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java?rev=1469185&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/ClassUtilTest.java
Thu Apr 18 06:29:41 2013
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.util;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+
+import junit.framework.Assert;
+
+public class ClassUtilTest {
+
+ @Test
+ public void testGetAllNonPrivateMethods()
+ {
+ List<Method> nonPrivateMethods =
ClassUtil.getNonPrivateMethods(SpecificClass.class, false);
+
nonPrivateMethods.removeAll(Arrays.asList(Object.class.getDeclaredMethods()));
+ Assert.assertEquals(SpecificClass.class.getDeclaredMethods().length,
nonPrivateMethods.size());
+ }
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericInterface.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericInterface.java?rev=1469185&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericInterface.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/GenericInterface.java
Thu Apr 18 06:29:41 2013
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.util;
+
+public interface GenericInterface<T> {
+
+ T newInstance();
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/SpecificClass.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/SpecificClass.java?rev=1469185&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/SpecificClass.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/util/SpecificClass.java
Thu Apr 18 06:29:41 2013
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.webbeans.util;
+
+public class SpecificClass implements GenericInterface<String> {
+
+ @Override
+ public String newInstance() {
+ return "";
+ }
+}