From: hansonr Date: Tue, 21 Aug 2018 05:00:16 +0000 (-0500) Subject: JAL-3026 JSONObject: removing annotation sensing X-Git-Tag: Release_2_11_4_0~45^2~18^2~476 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=f7b41ebc40bc96cd3ced4b22fc45c6f99ac00739;p=jalview.git JAL-3026 JSONObject: removing annotation sensing --- diff --git a/libjs/json-site.zip b/libjs/json-site.zip index b78d588..f2e1e96 100644 Binary files a/libjs/json-site.zip and b/libjs/json-site.zip differ diff --git a/srcjar/org/json/JSONObject.java b/srcjar/org/json/JSONObject.java index 8deb6ba..d2ea0f9 100644 --- a/srcjar/org/json/JSONObject.java +++ b/srcjar/org/json/JSONObject.java @@ -1517,19 +1517,19 @@ public class JSONObject { } private String getKeyNameFromMethod(Method method) { - final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class); - if (ignoreDepth > 0) { - final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class); - if (forcedNameDepth < 0 || ignoreDepth <= forcedNameDepth) { - // the hierarchy asked to ignore, and the nearest name override - // was higher or non-existent - return null; - } - } - JSONPropertyName annotation = getAnnotation(method, JSONPropertyName.class); - if (annotation != null && annotation.value() != null && !annotation.value().isEmpty()) { - return annotation.value(); - } + final int ignoreDepth = -1;//getAnnotationDepth(method, JSONPropertyIgnore.class); +// if (ignoreDepth > 0) { +// final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class); +// if (forcedNameDepth < 0 || ignoreDepth <= forcedNameDepth) { +// // the hierarchy asked to ignore, and the nearest name override +// // was higher or non-existent +// return null; +// } +// } +// JSONPropertyName annotation = getAnnotation(method, JSONPropertyName.class); +// if (annotation != null && annotation.value() != null && !annotation.value().isEmpty()) { +// return annotation.value(); +// } String key; final String name = method.getName(); if (name.startsWith("get") && name.length() > 3) { @@ -1569,41 +1569,41 @@ public class JSONObject { */ private static A getAnnotation(final Method m, final Class annotationClass) { // if we have invalid data the result is null - if (m == null || annotationClass == null) { - return null; - } - - if (m.isAnnotationPresent(annotationClass)) { - return m.getAnnotation(annotationClass); - } - - // if we've already reached the Object class, return null; - Class c = m.getDeclaringClass(); - if (c.getSuperclass() == null) { + if (true || m == null || annotationClass == null) { return null; } - // check directly implemented interfaces for the method being checked - for (Class i : c.getInterfaces()) { - try { - Method im = i.getMethod(m.getName(), m.getParameterTypes()); - return getAnnotation(im, annotationClass); - } catch (final SecurityException ex) { - continue; - } catch (final NoSuchMethodException ex) { - continue; - } - } - - try { - return getAnnotation( - c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), - annotationClass); - } catch (final SecurityException ex) { - return null; - } catch (final NoSuchMethodException ex) { - return null; - } +// if (m.isAnnotationPresent(annotationClass)) { +// return m.getAnnotation(annotationClass); +// } +// +// // if we've already reached the Object class, return null; +// Class c = m.getDeclaringClass(); +// if (c.getSuperclass() == null) { +// return null; +// } +// +// // check directly implemented interfaces for the method being checked +// for (Class i : c.getInterfaces()) { +// try { +// Method im = i.getMethod(m.getName(), m.getParameterTypes()); +// return getAnnotation(im, annotationClass); +// } catch (final SecurityException ex) { +// continue; +// } catch (final NoSuchMethodException ex) { +// continue; +// } +// } +// +// try { +// return getAnnotation( +// c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), +// annotationClass); +// } catch (final SecurityException ex) { +// return null; +// } catch (final NoSuchMethodException ex) { +// return null; +// } } /** @@ -1622,50 +1622,50 @@ public class JSONObject { */ private static int getAnnotationDepth(final Method m, final Class annotationClass) { // if we have invalid data the result is -1 - if (m == null || annotationClass == null) { + if (true || m == null || annotationClass == null) { return -1; } - if (m.isAnnotationPresent(annotationClass)) { - return 1; - } - - // if we've already reached the Object class, return -1; - Class c = m.getDeclaringClass(); - if (c.getSuperclass() == null) { - return -1; - } - - // check directly implemented interfaces for the method being checked - for (Class i : c.getInterfaces()) { - try { - Method im = i.getMethod(m.getName(), m.getParameterTypes()); - int d = getAnnotationDepth(im, annotationClass); - if (d > 0) { - // since the annotation was on the interface, add 1 - return d + 1; - } - } catch (final SecurityException ex) { - continue; - } catch (final NoSuchMethodException ex) { - continue; - } - } - - try { - int d = getAnnotationDepth( - c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), - annotationClass); - if (d > 0) { - // since the annotation was on the superclass, add 1 - return d + 1; - } - return -1; - } catch (final SecurityException ex) { - return -1; - } catch (final NoSuchMethodException ex) { - return -1; - } +// if (m.isAnnotationPresent(annotationClass)) { +// return 1; +// } +// +// // if we've already reached the Object class, return -1; +// Class c = m.getDeclaringClass(); +// if (c.getSuperclass() == null) { +// return -1; +// } +// +// // check directly implemented interfaces for the method being checked +// for (Class i : c.getInterfaces()) { +// try { +// Method im = i.getMethod(m.getName(), m.getParameterTypes()); +// int d = getAnnotationDepth(im, annotationClass); +// if (d > 0) { +// // since the annotation was on the interface, add 1 +// return d + 1; +// } +// } catch (final SecurityException ex) { +// continue; +// } catch (final NoSuchMethodException ex) { +// continue; +// } +// } +// +// try { +// int d = getAnnotationDepth( +// c.getSuperclass().getMethod(m.getName(), m.getParameterTypes()), +// annotationClass); +// if (d > 0) { +// // since the annotation was on the superclass, add 1 +// return d + 1; +// } +// return -1; +// } catch (final SecurityException ex) { +// return -1; +// } catch (final NoSuchMethodException ex) { +// return -1; +// } } /**