4
4
*/
5
5
package net .minecraftforge .mappingverifier ;
6
6
7
+ import java .lang .reflect .Modifier ;
7
8
import java .util .ArrayDeque ;
8
9
import java .util .Deque ;
9
10
import java .util .HashSet ;
12
13
import java .util .function .Function ;
13
14
import java .util .stream .Collectors ;
14
15
15
- import org .objectweb .asm .Opcodes ;
16
16
import org .objectweb .asm .tree .AbstractInsnNode ;
17
17
import org .objectweb .asm .tree .ClassNode ;
18
18
import org .objectweb .asm .tree .FieldInsnNode ;
21
21
import org .objectweb .asm .tree .TypeInsnNode ;
22
22
import net .minecraftforge .mappingverifier .InheratanceMap .Class ;
23
23
import net .minecraftforge .mappingverifier .InheratanceMap .Node ;
24
- import net .minecraftforge .srgutils .IMappingFile ;
25
24
26
25
public class AccessLevels extends SimpleVerifier {
27
26
protected AccessLevels (MappingVerifier verifier ) {
@@ -30,12 +29,12 @@ protected AccessLevels(MappingVerifier verifier) {
30
29
31
30
@ Override
32
31
public boolean process () {
32
+ Main .LOG .info ("AccessLevels:" );
33
33
InheratanceMap inh = verifier .getInheratance ();
34
- IMappingFile map = verifier .getMappings ();
35
34
36
35
boolean success = true ;
37
36
for (Class cls : inh .getOwned ()) {
38
- Main .LOG .fine (" Processing: " + map . remapClass (cls .name ));
37
+ Main .LOG .fine (" Processing: " + mapClass (cls .name ));
39
38
ClassNode node = inh .getNode (cls .name );
40
39
41
40
if (node == null ) {
@@ -46,7 +45,7 @@ public boolean process() {
46
45
47
46
Set <String > warned = new HashSet <>();
48
47
49
- String newCls = map . remapClass (cls .name );
48
+ String newCls = mapClass (cls .name );
50
49
String pkg = packageName (newCls );
51
50
52
51
List <MethodNode > methods = node .methods .stream ().sequential ()
@@ -78,8 +77,8 @@ public boolean process() {
78
77
continue ;
79
78
}
80
79
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 );
83
82
84
83
boolean isPackage = pkg .equals (packageName (newOwner ));
85
84
boolean isSubclass = cls .getStack ().contains (target .owner );
@@ -97,7 +96,7 @@ public boolean process() {
97
96
continue ;
98
97
99
98
Node target = findNode (owner , c -> c .getMethod (method .name , method .desc ));
100
- String newDesc = map . remapDescriptor (method .desc );
99
+ String newDesc = mapDescriptor (method .desc );
101
100
102
101
if (target == null ) { //We can't find it in the inheritance tree... So not in our reobfed code, assume correct.
103
102
/*
@@ -109,8 +108,8 @@ public boolean process() {
109
108
continue ;
110
109
}
111
110
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 );
114
113
115
114
boolean isPackage = pkg .equals (packageName (newOwner ));
116
115
boolean isSubclass = cls .getStack ().contains (target .owner );
@@ -126,7 +125,7 @@ public boolean process() {
126
125
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.
127
126
continue ;
128
127
129
- String newOwner = map . remapClass (obfed );
128
+ String newOwner = mapClass (obfed );
130
129
boolean isPackage = pkg .equals (packageName (newOwner ));
131
130
boolean isSubclass = cls .getStack ().contains (inh .getClass (obfed ));
132
131
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
148
147
if (warned .contains (key ))
149
148
return false ;
150
149
151
- if ((access & Opcodes . ACC_PUBLIC ) != 0 ) {
150
+ if (Modifier . isPublic (access ) ) {
152
151
return true ; //Public anyone can access;
153
- } else if ((access & Opcodes . ACC_PROTECTED ) != 0 ) {
152
+ } else if (Modifier . isProtected (access ) ) {
154
153
if (!isPackage && !isSubclass ) {
155
154
warned .add (key );
156
155
error (" Invalid Access: %s -> %s PROTECTED" , source , target );
157
156
return false ;
158
157
}
159
- } else if ((access & Opcodes . ACC_PRIVATE ) != 0 ) {
158
+ } else if (Modifier . isPrivate (access ) ) {
160
159
if (!isSelf ) {
161
160
warned .add (key );
162
161
error (" Invalid Access: %s -> %s PRIVATE" , source , target );
0 commit comments