Пример #1
0
 /* gets target VM version from the given VMVersionMismatchException.
  * Note that we need to reflectively call the method because of we may
  * have got this from different classloader's namespace */
 private static String getVMVersion(Throwable throwable)
     throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
   // assert isVMVersionMismatch(throwable), "not a VMVersionMismatch"
   Class expClass = throwable.getClass();
   Method targetVersionMethod = expClass.getMethod("getTargetVersion", new Class[0]);
   return (String) targetVersionMethod.invoke(throwable);
 }
Пример #2
0
 /**
  * If the causal chain has a sun.jvm.hotspot.runtime.VMVersionMismatchException, attempt to load
  * VirtualMachineImpl class for target VM version.
  */
 protected static Class handleVMVersionMismatch(InvocationTargetException ite) {
   Throwable cause = ite.getCause();
   if (DEBUG) {
     System.out.println("checking for version mismatch...");
   }
   while (cause != null) {
     try {
       if (isVMVersionMismatch(cause)) {
         if (DEBUG) {
           System.out.println("Triggering cross VM version support...");
         }
         return loadVirtualMachineImplClass(getVMVersion(cause));
       }
     } catch (Exception exp) {
       if (DEBUG) {
         System.out.println("failed to load VirtualMachineImpl class");
         exp.printStackTrace();
       }
       return null;
     }
     cause = cause.getCause();
   }
   return null;
 }
Пример #3
0
 /* Is the given throwable an instanceof VMVersionMismatchException?
  * Note that we can't do instanceof check because the exception
  * class might have been loaded by a different class loader.
  */
 private static boolean isVMVersionMismatch(Throwable throwable) {
   String className = throwable.getClass().getName();
   return className.equals("sun.jvm.hotspot.runtime.VMVersionMismatchException");
 }