Skip to content

Commit

Permalink
[WFLY-13647] Annotation processing error sun.reflect.annotation.TypeN…
Browse files Browse the repository at this point in the history
…otPresentExceptionProxy does not indicate issue

- Fix case of missing classes referenced by Remote or Local in session bean

Signed-off-by: Lin Gao <lgao@redhat.com>
  • Loading branch information
gaol committed Jul 21, 2020
1 parent d47f0aa commit 13cb591
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Expand Up @@ -153,7 +153,14 @@ private void processViewAnnotations(final DeploymentUnit deploymentUnit, final C
}

private Collection<Class<?>> getRemoteBusinessInterfaces(final DeploymentUnit deploymentUnit, final Class<?> sessionBeanClass) throws DeploymentUnitProcessingException {
final Remote remoteViewAnnotation = sessionBeanClass.getAnnotation(Remote.class);
final Remote remoteViewAnnotation;
try {
remoteViewAnnotation = sessionBeanClass.getAnnotation(Remote.class);
} catch (ArrayStoreException e) {
// https://bugs.openjdk.java.net/browse/JDK-7183985
// Class.findAnnotation() has a bug under JDK < 11 which throws ArrayStoreException
throw EjbLogger.ROOT_LOGGER.missingClassInAnnotation(Remote.class.getSimpleName(), sessionBeanClass.getName());
}
if (remoteViewAnnotation == null) {
Collection<Class<?>> interfaces = getBusinessInterfacesFromInterfaceAnnotations(sessionBeanClass, Remote.class);
if (!interfaces.isEmpty()) {
Expand All @@ -175,7 +182,14 @@ private Collection<Class<?>> getRemoteBusinessInterfaces(final DeploymentUnit de
}

private Collection<Class<?>> getLocalBusinessInterfaces(final DeploymentUnit deploymentUnit, final Class<?> sessionBeanClass) throws DeploymentUnitProcessingException {
final Local localViewAnnotation = sessionBeanClass.getAnnotation(Local.class);
final Local localViewAnnotation;
try {
localViewAnnotation = sessionBeanClass.getAnnotation(Local.class);
} catch (ArrayStoreException e) {
// https://bugs.openjdk.java.net/browse/JDK-7183985
// Class.findAnnotation() has a bug under JDK < 11 which throws ArrayStoreException
throw EjbLogger.ROOT_LOGGER.missingClassInAnnotation(Local.class.getSimpleName(), sessionBeanClass.getName());
}
if (localViewAnnotation == null) {
Collection<Class<?>> interfaces = getBusinessInterfacesFromInterfaceAnnotations(sessionBeanClass, Local.class);
if (!interfaces.isEmpty()) {
Expand All @@ -197,12 +211,18 @@ private Collection<Class<?>> getLocalBusinessInterfaces(final DeploymentUnit dep
return Arrays.asList(localViews);
}

private static Collection<Class<?>> getBusinessInterfacesFromInterfaceAnnotations(Class<?> sessionBeanClass, Class<? extends Annotation> annotation) {
private static Collection<Class<?>> getBusinessInterfacesFromInterfaceAnnotations(Class<?> sessionBeanClass, Class<? extends Annotation> annotation) throws DeploymentUnitProcessingException {
final Set<Class<?>> potentialBusinessInterfaces = getPotentialBusinessInterfaces(sessionBeanClass);
final Set<Class<?>> businessInterfaces = new HashSet<Class<?>>();
for (Class<?> iface : potentialBusinessInterfaces) {
if (iface.getAnnotation(annotation) != null) {
businessInterfaces.add(iface);
try {
if (iface.getAnnotation(annotation) != null) {
businessInterfaces.add(iface);
}
} catch (ArrayStoreException e) {
// https://bugs.openjdk.java.net/browse/JDK-7183985
// Class.findAnnotation() has a bug under JDK < 11 which throws ArrayStoreException
throw EjbLogger.ROOT_LOGGER.missingClassInAnnotation(annotation.getSimpleName(), iface.getName());
}
}
return businessInterfaces;
Expand Down
3 changes: 3 additions & 0 deletions ejb3/src/main/java/org/jboss/as/ejb3/logging/EjbLogger.java
Expand Up @@ -3222,4 +3222,7 @@ public interface EjbLogger extends BasicLogger {

@Message(id = 520, value = "Legacy host does not support multiple values for attributes: %s")
String multipleValuesNotSupported(Set<String> attributes);

@Message(id = 521, value = "Some classes referenced by annotation: %s in class: %s are missing.")
DeploymentUnitProcessingException missingClassInAnnotation(String anCls, String resCls);
}

0 comments on commit 13cb591

Please sign in to comment.