Skip to content

Commit

Permalink
WELD-477 private final methods are ignored when checking proxiability
Browse files Browse the repository at this point in the history
  • Loading branch information
mbogoevici committed Apr 13, 2010
1 parent d47490f commit 9e64a76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion impl/src/main/java/org/jboss/weld/util/Proxies.java
Expand Up @@ -326,7 +326,7 @@ else if (Modifier.isPrivate(constructor.getModifiers()))
}
else if (Reflections.isTypeOrAnyMethodFinal(clazz))
{
return new UnproxyableResolutionException(NOT_PROXYABLE_FINAL_TYPE_OR_METHOD, clazz, Reflections.getFinalMethodOrType(clazz));
return new UnproxyableResolutionException(NOT_PROXYABLE_FINAL_TYPE_OR_METHOD, clazz, Reflections.getNonPrivateFinalMethodOrType(clazz));
}
else if (clazz.isPrimitive())
{
Expand Down
17 changes: 14 additions & 3 deletions impl/src/main/java/org/jboss/weld/util/reflection/Reflections.java
Expand Up @@ -147,6 +147,17 @@ public static boolean isFinal(Member member)
return Modifier.isFinal(member.getModifiers());
}

/**
* Checks if member is private
*
* @param member The member to check
* @return True if final, false otherwise
*/
public static boolean isPrivate(Member member)
{
return Modifier.isPrivate(member.getModifiers());
}

/**
* Checks if type or member is final
*
Expand All @@ -155,18 +166,18 @@ public static boolean isFinal(Member member)
*/
public static boolean isTypeOrAnyMethodFinal(Class<?> type)
{
return getFinalMethodOrType(type) != null;
return getNonPrivateFinalMethodOrType(type) != null;
}

public static Object getFinalMethodOrType(Class<?> type)
public static Object getNonPrivateFinalMethodOrType(Class<?> type)
{
if (isFinal(type))
{
return type;
}
for (Method method : type.getDeclaredMethods())
{
if (isFinal(method))
if (isFinal(method) && !isPrivate(method))
{
return method;
}
Expand Down
Expand Up @@ -28,7 +28,7 @@
public class ProxiabilityTest extends AbstractWeldTest
{

@Test(description = "https://jira.jboss.org/jira/browse/WELD-477", groups="broken")
@Test(description = "https://jira.jboss.org/jira/browse/WELD-477")
public void testClassWithPrivateFinalMethodsProxyable()
{
InjectedClass injectedClassInstance = getReference(InjectedClass.class);
Expand Down

0 comments on commit 9e64a76

Please sign in to comment.