Bug 537647

Summary: JDIClassType cannot be cast to IJavaValue
Product: [Eclipse Project] Platform Reporter: Filippo Monti <filippo.monti>
Component: DebugAssignee: Platform-Debug-Inbox <platform-debug-inbox>
Status: NEW --- QA Contact:
Severity: major    
Priority: P3 Keywords: test
Version: 4.8   
Target Milestone: ---   
Hardware: PC   
OS: Windows 10   
Whiteboard:

Description Filippo Monti CLA 2018-08-03 04:32:14 EDT
When I try to execute with Wildfly 11 in Debug mode this instruction:

private static final String entity = MasUtil.getAnnotationValue(Anagrafica.class, "TipoRecord", "code");

I receive this error
org.eclipse.jdt.internal.debug.core.model.JDIClassType cannot be cast to org.eclipse.jdt.debug.core.IJavaValue

no error when running in start "not debug" mode
The above method is this:

/*
     * Return the annotation value of a class
     * @param clazz: class to extract the annotation
     * @param annotationName: name of the annotation
     * @param annotationMethod: method of the annotation
     */
    public static String getAnnotationValue(Class<?> clazz, String annotationName, String annotationMethod) {
    	Object value = "";
    	
    	if (annotationName == null || annotationMethod == null) {
    		return value.toString();
    	}
    
    	for (Annotation annotation : clazz.getAnnotations()) {
    		Class<? extends Annotation> type = annotation.annotationType();
    		
    		String[] parts = type.getName().split(Pattern.quote("."));
    		String name = parts[parts.length-1];
    		if (annotationName.equals(name)) {
    			for (Method method : type.getDeclaredMethods()) {
    				if (method.getName() == annotationMethod) {
    					try {
							value = method.invoke(annotation, (Object[])null);
						} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
							return value.toString();
						}
    				}
    			}
    		}
    	}
    	return value.toString();
    }
Comment 1 Till Brychcy CLA 2018-08-03 04:50:46 EDT
Can you provide a stacktrace?