Bug 537647 - JDIClassType cannot be cast to IJavaValue
Summary: JDIClassType cannot be cast to IJavaValue
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.8   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Platform-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2018-08-03 04:32 EDT by Filippo Monti CLA
Modified: 2020-06-04 11:16 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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?