aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/main/java
diff options
context:
space:
mode:
authorTimo Westkämper <[email protected]>2014-07-30 22:28:05 +0300
committerTimo Westkämper <[email protected]>2014-07-30 22:28:05 +0300
commitb7f165affed6259a40dc7394a19b9e29db501108 (patch)
treeb2150ab907ba3375d8f795e4b12b234ddeb8650c /api/src/main/java
parentd671469f08c8714f75f0d2a198e8f94f2ff441b3 (diff)
Improve access comparison
Diffstat (limited to 'api/src/main/java')
-rw-r--r--api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java6
-rw-r--r--api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java6
-rw-r--r--api/src/main/java/org/osjava/jardiff/Tools.java19
3 files changed, 25 insertions, 6 deletions
diff --git a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
index 102d9f6..9940255 100644
--- a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
+++ b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
@@ -71,7 +71,7 @@ public class PublicDiffCriteria implements DiffCriteria
* @return True if the classes differ, false otherwise.
*/
public boolean differs(ClassInfo oldInfo, ClassInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
// Yes classes can have a null supername, e.g. java.lang.Object !
if(oldInfo.getSupername() == null) {
@@ -100,7 +100,7 @@ public class PublicDiffCriteria implements DiffCriteria
* @return True if the methods differ, false otherwise.
*/
public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getExceptions() == null
|| newInfo.getExceptions() == null) {
@@ -127,7 +127,7 @@ public class PublicDiffCriteria implements DiffCriteria
* @return True if the fields differ, false otherwise.
*/
public boolean differs(FieldInfo oldInfo, FieldInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getValue() == null || newInfo.getValue() == null) {
if (oldInfo.getValue() != newInfo.getValue())
diff --git a/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java b/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java
index 3d9c7ca..5b82266 100644
--- a/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java
+++ b/api/src/main/java/org/osjava/jardiff/SimpleDiffCriteria.java
@@ -71,7 +71,7 @@ public class SimpleDiffCriteria implements DiffCriteria
* @return True if the classes differ, false otherwise.
*/
public boolean differs(ClassInfo oldInfo, ClassInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
// Yes classes can have a null supername, e.g. java.lang.Object !
if(oldInfo.getSupername() == null) {
@@ -100,7 +100,7 @@ public class SimpleDiffCriteria implements DiffCriteria
* @return True if the methods differ, false otherwise.
*/
public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getExceptions() == null
|| newInfo.getExceptions() == null) {
@@ -127,7 +127,7 @@ public class SimpleDiffCriteria implements DiffCriteria
* @return True if the fields differ, false otherwise.
*/
public boolean differs(FieldInfo oldInfo, FieldInfo newInfo) {
- if (oldInfo.getAccess() != newInfo.getAccess())
+ if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getValue() == null || newInfo.getValue() == null) {
if (oldInfo.getValue() != newInfo.getValue())
diff --git a/api/src/main/java/org/osjava/jardiff/Tools.java b/api/src/main/java/org/osjava/jardiff/Tools.java
index 4a32ef7..0a8f5f1 100644
--- a/api/src/main/java/org/osjava/jardiff/Tools.java
+++ b/api/src/main/java/org/osjava/jardiff/Tools.java
@@ -16,6 +16,8 @@
*/
package org.osjava.jardiff;
+import org.objectweb.asm.Opcodes;
+
/**
* A set of Tools which do not belong anywhere else in the API at this time.
* This is nasty, but for now, useful.
@@ -55,4 +57,21 @@ public final class Tools
}
return ret.toString();
}
+
+ /**
+ * Returns whether newAccess is incompatible with oldAccess
+ *
+ * @param oldAccess
+ * @param newAccess
+ * @return
+ */
+ public static boolean isAccessChange(int oldAccess, int newAccess) {
+ if ((oldAccess & Opcodes.ACC_FINAL) == 0 && (newAccess & Opcodes.ACC_FINAL) > 0) {
+ return true;
+ } else {
+ oldAccess = oldAccess & ~Opcodes.ACC_FINAL;
+ newAccess = newAccess & ~Opcodes.ACC_FINAL;
+ }
+ return oldAccess != newAccess;
+ }
}