diff options
author | nickl- <github@jigsoft.co.za> | 2017-11-11 22:34:34 +0200 |
---|---|---|
committer | nickl- <github@jigsoft.co.za> | 2017-11-12 23:55:35 +0200 |
commit | d7e4f9937234239c43a4a01e3e3c06c063186bd7 (patch) | |
tree | 0e488ebeb2836739c70937d273c9605e4fb0bc67 /src/test | |
parent | e1f0bba5de4dc03a9debfab333683f07cfbcb594 (diff) | |
download | javassist-d7e4f9937234239c43a4a01e3e3c06c063186bd7.tar.gz javassist-d7e4f9937234239c43a4a01e3e3c06c063186bd7.zip |
Fix #152 inner class modifiers.
Applied fix for #152 "Wrong modifiers returned for nested classes" as suggested by @pietrobraione.
Includes unit tests for all access modifiers and static.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/javassist/JvstTest5.java | 46 | ||||
-rw-r--r-- | src/test/test5/InnerModifier2.java | 13 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/test/javassist/JvstTest5.java b/src/test/javassist/JvstTest5.java index 578abfb2..346263cb 100644 --- a/src/test/javassist/JvstTest5.java +++ b/src/test/javassist/JvstTest5.java @@ -344,6 +344,52 @@ public class JvstTest5 extends JvstTestRoot { assertEquals(Modifier.PUBLIC, ica4.accessFlags(i5)); } + public void testInnerClassModifiers2() throws Exception { + CtClass cc = sloader.get("test5.InnerModifier2$Protected"); + Class<?> ccc = Class.forName("test5.InnerModifier2$Protected"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isProtected(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$Public"); + ccc = Class.forName("test5.InnerModifier2$Public"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPublic(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$Private"); + ccc = Class.forName("test5.InnerModifier2$Private"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPrivate(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$Package"); + ccc = Class.forName("test5.InnerModifier2$Package"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPackage(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$ProtectedStatic"); + ccc = Class.forName("test5.InnerModifier2$ProtectedStatic"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isProtected(cc.getModifiers())); + assertTrue(Modifier.isStatic(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$PublicStatic"); + ccc = Class.forName("test5.InnerModifier2$PublicStatic"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPublic(cc.getModifiers())); + assertTrue(Modifier.isStatic(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$PrivateStatic"); + ccc = Class.forName("test5.InnerModifier2$PrivateStatic"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPrivate(cc.getModifiers())); + assertTrue(Modifier.isStatic(cc.getModifiers())); + + cc = sloader.get("test5.InnerModifier2$PackageStatic"); + ccc = Class.forName("test5.InnerModifier2$PackageStatic"); + assertEquals(cc.getModifiers(), ccc.getModifiers()); + assertTrue(Modifier.isPackage(cc.getModifiers())); + assertTrue(Modifier.isStatic(cc.getModifiers())); + } + private InnerClassesAttribute getInnerClassAttr(CtClass cc) { return (InnerClassesAttribute)cc.getClassFile2().getAttribute(InnerClassesAttribute.tag); } diff --git a/src/test/test5/InnerModifier2.java b/src/test/test5/InnerModifier2.java new file mode 100644 index 00000000..009a0321 --- /dev/null +++ b/src/test/test5/InnerModifier2.java @@ -0,0 +1,13 @@ +package test5; + +@SuppressWarnings("unused") +public class InnerModifier2 { + public class Public {} + protected class Protected {} + private class Private {} + class Package {} + public static class PublicStatic {} + protected static class ProtectedStatic {} + private static class PrivateStatic {} + static class PackageStatic {} +} |