44 */
55package net .minecraftforge .mappingverifier ;
66
7+ import java .lang .reflect .Modifier ;
78import java .util .ArrayDeque ;
89import java .util .Deque ;
910import java .util .HashSet ;
1213import java .util .function .Function ;
1314import java .util .stream .Collectors ;
1415
15- import org .objectweb .asm .Opcodes ;
1616import org .objectweb .asm .tree .AbstractInsnNode ;
1717import org .objectweb .asm .tree .ClassNode ;
1818import org .objectweb .asm .tree .FieldInsnNode ;
2121import org .objectweb .asm .tree .TypeInsnNode ;
2222import net .minecraftforge .mappingverifier .InheratanceMap .Class ;
2323import net .minecraftforge .mappingverifier .InheratanceMap .Node ;
24- import net .minecraftforge .srgutils .IMappingFile ;
2524
2625public class AccessLevels extends SimpleVerifier {
2726 protected AccessLevels (MappingVerifier verifier ) {
@@ -30,12 +29,12 @@ protected AccessLevels(MappingVerifier verifier) {
3029
3130 @ Override
3231 public boolean process () {
32+ Main .LOG .info ("AccessLevels:" );
3333 InheratanceMap inh = verifier .getInheratance ();
34- IMappingFile map = verifier .getMappings ();
3534
3635 boolean success = true ;
3736 for (Class cls : inh .getOwned ()) {
38- Main .LOG .fine (" Processing: " + map . remapClass (cls .name ));
37+ Main .LOG .fine (" Processing: " + mapClass (cls .name ));
3938 ClassNode node = inh .getNode (cls .name );
4039
4140 if (node == null ) {
@@ -46,7 +45,7 @@ public boolean process() {
4645
4746 Set <String > warned = new HashSet <>();
4847
49- String newCls = map . remapClass (cls .name );
48+ String newCls = mapClass (cls .name );
5049 String pkg = packageName (newCls );
5150
5251 List <MethodNode > methods = node .methods .stream ().sequential ()
@@ -78,8 +77,8 @@ public boolean process() {
7877 continue ;
7978 }
8079
81- String newOwner = map . remapClass (target .owner .name );
82- String newField = map . getClass (target .owner .name ). remapField ( field .name );
80+ String newOwner = mapClass (target .owner .name );
81+ String newField = mapField (target .owner .name , field .name );
8382
8483 boolean isPackage = pkg .equals (packageName (newOwner ));
8584 boolean isSubclass = cls .getStack ().contains (target .owner );
@@ -97,7 +96,7 @@ public boolean process() {
9796 continue ;
9897
9998 Node target = findNode (owner , c -> c .getMethod (method .name , method .desc ));
100- String newDesc = map . remapDescriptor (method .desc );
99+ String newDesc = mapDescriptor (method .desc );
101100
102101 if (target == null ) { //We can't find it in the inheritance tree... So not in our reobfed code, assume correct.
103102 /*
@@ -109,8 +108,8 @@ public boolean process() {
109108 continue ;
110109 }
111110
112- String newOwner = map . remapClass (target .owner .name );
113- String newMethod = map . getClass (target .owner .name ). remapMethod ( method .name , method .desc );
111+ String newOwner = mapClass (target .owner .name );
112+ String newMethod = mapMethod (target .owner .name , method .name , method .desc );
114113
115114 boolean isPackage = pkg .equals (packageName (newOwner ));
116115 boolean isSubclass = cls .getStack ().contains (target .owner );
@@ -126,7 +125,7 @@ public boolean process() {
126125 if (!owner .wasRead ()) //If it wasn't read, we don't have the access levels, so we can't check anything, just assume its right.
127126 continue ;
128127
129- String newOwner = map . remapClass (obfed );
128+ String newOwner = mapClass (obfed );
130129 boolean isPackage = pkg .equals (packageName (newOwner ));
131130 boolean isSubclass = cls .getStack ().contains (inh .getClass (obfed ));
132131 success &= canAccess (newCls , newOwner , owner .getAccess (), isPackage , isSubclass , isSelf , warned );
@@ -148,15 +147,15 @@ private boolean canAccess(String source, String target, int access, boolean isPa
148147 if (warned .contains (key ))
149148 return false ;
150149
151- if ((access & Opcodes . ACC_PUBLIC ) != 0 ) {
150+ if (Modifier . isPublic (access ) ) {
152151 return true ; //Public anyone can access;
153- } else if ((access & Opcodes . ACC_PROTECTED ) != 0 ) {
152+ } else if (Modifier . isProtected (access ) ) {
154153 if (!isPackage && !isSubclass ) {
155154 warned .add (key );
156155 error (" Invalid Access: %s -> %s PROTECTED" , source , target );
157156 return false ;
158157 }
159- } else if ((access & Opcodes . ACC_PRIVATE ) != 0 ) {
158+ } else if (Modifier . isPrivate (access ) ) {
160159 if (!isSelf ) {
161160 warned .add (key );
162161 error (" Invalid Access: %s -> %s PRIVATE" , source , target );
0 commit comments