aboutsummaryrefslogtreecommitdiffstats
path: root/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-09-24 01:08:38 +0200
committerSven Gothel <[email protected]>2014-09-24 01:08:38 +0200
commit616f566cfe60638eb97823e1f63cf203161502da (patch)
tree01dbf7117632cfae1584376b1f44c6e931953f95 /api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
parentad4cc1c77559a6d0138acd320cb1dfd638a0f86f (diff)
Fix jardiff's Tools.isAccessChange(..): Differentiate between Class, Field and Method and apply all rules of the Java Language Specification
Class, Field and Methods have different binary backward compatibility rules as specified in the Java Language Specification, Java SE 7 Edition: - http://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html For Field 'volatile' the Java Language Specification, first edition has been used: - http://www.wsu.edu/UNIX_Systems/java/langspec-1.0/13.doc.html#45194 For each type separate method have been created, i.e. Tools.is<Type>AccessChange(). Each new method has the rules referenced and partially copied into the method for better documentation. The now deprecated method Tools.isAccessChange(..) calls Tools.isClassAccessChange(..) and shall be removed. Unit test ToolsTest has been expanded for each type and its rules.
Diffstat (limited to 'api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java')
-rw-r--r--api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java24
1 files changed, 12 insertions, 12 deletions
diff --git a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
index 9940255..90fb382 100644
--- a/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
+++ b/api/src/main/java/org/osjava/jardiff/PublicDiffCriteria.java
@@ -38,7 +38,7 @@ public class PublicDiffCriteria implements DiffCriteria
public boolean validClass(ClassInfo info) {
return !info.isSynthetic() && info.isPublic();
}
-
+
/**
* Check if a method is valid.
* If the method is not synthetic and public, return true.
@@ -49,7 +49,7 @@ public class PublicDiffCriteria implements DiffCriteria
public boolean validMethod(MethodInfo info) {
return !info.isSynthetic() && info.isPublic();
}
-
+
/**
* Check if a field is valid.
* If the method is not synthetic and public, return true.
@@ -60,7 +60,7 @@ public class PublicDiffCriteria implements DiffCriteria
public boolean validField(FieldInfo info) {
return !info.isSynthetic() && info.isPublic();
}
-
+
/**
* Check if there is a change between two versions of a class.
* Returns true if the access flags differ, or if the superclass differs
@@ -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 (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
+ if (Tools.isClassAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
// Yes classes can have a null supername, e.g. java.lang.Object !
if(oldInfo.getSupername() == null) {
@@ -81,15 +81,15 @@ public class PublicDiffCriteria implements DiffCriteria
} else if (!oldInfo.getSupername().equals(newInfo.getSupername())) {
return true;
}
- Set<String> oldInterfaces
+ final Set<String> oldInterfaces
= new HashSet(Arrays.asList(oldInfo.getInterfaces()));
- Set<String> newInterfaces
+ final Set<String> newInterfaces
= new HashSet(Arrays.asList(newInfo.getInterfaces()));
if (!oldInterfaces.equals(newInterfaces))
return true;
return false;
}
-
+
/**
* Check if there is a change between two versions of a method.
* Returns true if the access flags differ, or if the thrown
@@ -100,23 +100,23 @@ public class PublicDiffCriteria implements DiffCriteria
* @return True if the methods differ, false otherwise.
*/
public boolean differs(MethodInfo oldInfo, MethodInfo newInfo) {
- if (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
+ if (Tools.isMethodAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getExceptions() == null
|| newInfo.getExceptions() == null) {
if (oldInfo.getExceptions() != newInfo.getExceptions())
return true;
} else {
- Set<String> oldExceptions
+ final Set<String> oldExceptions
= new HashSet(Arrays.asList(oldInfo.getExceptions()));
- Set<String> newExceptions
+ final Set<String> newExceptions
= new HashSet(Arrays.asList(newInfo.getExceptions()));
if (!oldExceptions.equals(newExceptions))
return true;
}
return false;
}
-
+
/**
* Check if there is a change between two versions of a field.
* Returns true if the access flags differ, or if the inital value
@@ -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 (Tools.isAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
+ if (Tools.isFieldAccessChange(oldInfo.getAccess(), newInfo.getAccess()))
return true;
if (oldInfo.getValue() == null || newInfo.getValue() == null) {
if (oldInfo.getValue() != newInfo.getValue())