From 32b247d1dc0209faa5cb79b3db72ccc54ebb8991 Mon Sep 17 00:00:00 2001 From: syev Date: Fri, 24 Oct 2014 12:01:39 +0200 Subject: Add access permissions checks --- api/src/main/java/org/osjava/jardiff/Tools.java | 48 ++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'api/src/main/java') diff --git a/api/src/main/java/org/osjava/jardiff/Tools.java b/api/src/main/java/org/osjava/jardiff/Tools.java index 7ac6a42..41ba63c 100644 --- a/api/src/main/java/org/osjava/jardiff/Tools.java +++ b/api/src/main/java/org/osjava/jardiff/Tools.java @@ -65,6 +65,18 @@ public final class Tools return (value & mask) == 0; } + private static boolean isLessAccessPermitted(int oldAccess, int newAccess) { + if (has(newAccess, Opcodes.ACC_PUBLIC)) { + return false; + } else if (has(newAccess, Opcodes.ACC_PROTECTED)) { + return has(oldAccess, Opcodes.ACC_PUBLIC); + } else if (has(newAccess, Opcodes.ACC_PRIVATE)) { + return not(oldAccess, Opcodes.ACC_PRIVATE); + } else { + return has(oldAccess, Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED); + } + } + /** * @deprecated Use {@link #isClassAccessChange(int, int)}. */ @@ -118,6 +130,14 @@ public final class Tools * Returns whether a field's newAccess is incompatible with oldAccess * following Java Language Specification, Java SE 7 Edition: *