50 if (getDeclaredMethod(interfaceClass) == null) { 51 return "java.lang.NoSuchMethodError"; 52 } 53 54 // 9.1.5 Access to Interface Member Names 55 // "All interface members are implicitly public. They are 56 // accessible outside the package where the interface is 57 // declared if the interface is also declared public or 58 // protected, in accordance with the rules of 6.6." 59 60 // Search for method declaration in the hierarchy 61 Class klass = dynamicTargetClass; 62 63 while (klass != Object.class) { 64 Method method = getDeclaredMethod(klass); 65 66 if (method != null) { 67 int modifiers = method.getModifiers(); 68 69 // Check whether obtained method is public and isn't abstract 70 if ( Modifier.isPublic(modifiers)) 71 { 72 if (Modifier.isAbstract(modifiers)) { 73 return "java.lang.AbstractMethodError"; 74 } else { 75 return String.format("%s.%s" 76 , method.getDeclaringClass().getSimpleName() 77 , methodName 78 ); 79 } 80 } else { 81 // IAE is thrown when located method isn't PUBLIC 82 // or private. Private methods are skipped when 83 // looking for an interface method. 84 if (!Modifier.isPrivate(modifiers)) { 85 return "java.lang.IllegalAccessError"; 86 } 87 } 88 } 89 90 klass = klass.getSuperclass(); 91 } 92 93 // No method declaration is found 94 return "java.lang.AbstractMethodError"; 95 } 96 } | 50 if (getDeclaredMethod(interfaceClass) == null) { 51 return "java.lang.NoSuchMethodError"; 52 } 53 54 // 9.1.5 Access to Interface Member Names 55 // "All interface members are implicitly public. They are 56 // accessible outside the package where the interface is 57 // declared if the interface is also declared public or 58 // protected, in accordance with the rules of 6.6." 59 60 // Search for method declaration in the hierarchy 61 Class klass = dynamicTargetClass; 62 63 while (klass != Object.class) { 64 Method method = getDeclaredMethod(klass); 65 66 if (method != null) { 67 int modifiers = method.getModifiers(); 68 69 // Check whether obtained method is public and isn't abstract 70 if ( Modifier.isPublic(modifiers)) { 71 if (Modifier.isAbstract(modifiers)) { 72 return "java.lang.AbstractMethodError"; 73 } else { 74 return String.format("%s.%s", 75 method.getDeclaringClass().getSimpleName(), 76 methodName); 77 } 78 } else { 79 // IAE is thrown when located method isn't PUBLIC 80 // or private. Private methods are skipped when 81 // looking for an interface method. 82 if (!Modifier.isPrivate(modifiers)) { 83 return "java.lang.IllegalAccessError"; 84 } 85 } 86 } 87 88 klass = klass.getSuperclass(); 89 } 90 91 // No method declaration is found 92 return "java.lang.AbstractMethodError"; 93 } 94 } |