Skip to content

Commit

Permalink
allow default package
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@3772 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Sep 23, 2009
1 parent dcab14c commit c73bae1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions impl/src/main/java/org/jboss/webbeans/util/Reflections.java
Expand Up @@ -847,7 +847,7 @@ public static boolean isSerializable(Class<?> clazz)

public static Field ensureAccessible(Field field)
{
if (!field.isAccessible() && !field.getDeclaringClass().getPackage().getName().startsWith("java.util"))
if (!field.isAccessible() && !isIgnorePackage(field.getDeclaringClass().getPackage()))
{
field.setAccessible(true);
}
Expand All @@ -856,7 +856,7 @@ public static Field ensureAccessible(Field field)

public static Method ensureAccessible(Method method)
{
if (!method.isAccessible() && !method.getDeclaringClass().getPackage().getName().startsWith("java.util"))
if (!method.isAccessible() && !isIgnorePackage(method.getDeclaringClass().getPackage()))
{
method.setAccessible(true);
}
Expand All @@ -865,11 +865,25 @@ public static Method ensureAccessible(Method method)

public static <T> Constructor<T> ensureAccessible(Constructor<T> constructor)
{
if (!constructor.isAccessible() && !constructor.getDeclaringClass().getPackage().getName().startsWith("java.util"))
Class<?> c = constructor.getDeclaringClass();
Package p = c.getPackage();
if (!constructor.isAccessible() && !isIgnorePackage(p))
{
constructor.setAccessible(true);
}
return constructor;
}

private static boolean isIgnorePackage(Package pkg)
{
if (pkg != null)
{
return pkg.getName().startsWith("java.lang");
}
else
{
return false;
}
}

}

0 comments on commit c73bae1

Please sign in to comment.