private static Value convertToWrapper( EvaluationContextImpl context, PrimitiveValue value, String wrapperTypeName) throws EvaluateException { final DebugProcessImpl process = context.getDebugProcess(); final ClassType wrapperClass = (ClassType) process.findClass(context, wrapperTypeName, null); final String methodSignature = "(" + JVMNameUtil.getPrimitiveSignature(value.type().name()) + ")L" + wrapperTypeName.replace('.', '/') + ";"; List<Method> methods = wrapperClass.methodsByName("valueOf", methodSignature); if (methods.size() == 0) { // older JDK version methods = wrapperClass.methodsByName(JVMNameUtil.CONSTRUCTOR_NAME, methodSignature); } if (methods.size() == 0) { throw new EvaluateException( "Cannot construct wrapper object for value of type " + value.type() + ": Unable to find either valueOf() or constructor method"); } return process.invokeMethod( context, wrapperClass, methods.get(0), Collections.singletonList(value)); }
private void updateCaches(DebugProcessImpl debugProcess) { myIcon = calcIcon(debugProcess); myClassName = JVMNameUtil.getSourcePositionClassDisplayName(debugProcess, getSourcePosition()); myPackageName = JVMNameUtil.getSourcePositionPackageDisplayName(debugProcess, getSourcePosition()); }