make use of collection classes

conflicting reworked
get bundle from Main


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@982 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent a9eeef15dd
commit 09e72e0daa
  1. 59
      jode/jode/obfuscator/FieldIdentifier.java

@ -20,8 +20,20 @@
package jode.obfuscator; package jode.obfuscator;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import jode.bytecode.*; import jode.bytecode.*;
import java.io.*; ///#ifdef JDK12
import java.util.*; ///import java.util.Collection;
///import java.util.Collections;
///import java.util.Iterator;
///import java.util.HashSet;
///import java.util.Map;
///#else
import jode.util.Collection;
import jode.util.Collections;
import jode.util.Iterator;
import jode.util.HashSet;
import jode.util.Map;
///#endif
public class FieldIdentifier extends Identifier{ public class FieldIdentifier extends Identifier{
FieldInfo info; FieldInfo info;
@ -40,7 +52,7 @@ public class FieldIdentifier extends Identifier{
* The FieldChangeListener that should be notified if a * The FieldChangeListener that should be notified if a
* write to this field is found. * write to this field is found.
*/ */
private Vector fieldListeners = new Vector(); private Collection fieldListeners = new HashSet();
public FieldIdentifier(ClassIdentifier clazz, FieldInfo info) { public FieldIdentifier(ClassIdentifier clazz, FieldInfo info) {
super(info.getName()); super(info.getName());
@ -60,7 +72,7 @@ public class FieldIdentifier extends Identifier{
public void setSingleReachable() { public void setSingleReachable() {
super.setSingleReachable(); super.setSingleReachable();
clazz.bundle.analyzeIdentifier(this); Main.getClassBundle().analyzeIdentifier(this);
} }
public void analyze() { public void analyze() {
@ -68,8 +80,8 @@ public class FieldIdentifier extends Identifier{
int index = type.indexOf('L'); int index = type.indexOf('L');
if (index != -1) { if (index != -1) {
int end = type.indexOf(';', index); int end = type.indexOf(';', index);
clazz.bundle.reachableIdentifier(type.substring(index+1, end), Main.getClassBundle().reachableIdentifier
false); (type.substring(index+1, end), false);
} }
} }
@ -93,6 +105,10 @@ public class FieldIdentifier extends Identifier{
return type; return type;
} }
public Iterator getChilds() {
return Collections.EMPTY_LIST.iterator();
}
public boolean isNotConstant() { public boolean isNotConstant() {
return notConstant; return notConstant;
} }
@ -103,7 +119,7 @@ public class FieldIdentifier extends Identifier{
public void addFieldListener(Identifier ident) { public void addFieldListener(Identifier ident) {
if (!fieldListeners.contains(ident)) if (!fieldListeners.contains(ident))
fieldListeners.addElement(ident); fieldListeners.add(ident);
} }
public void setNotConstant() { public void setNotConstant() {
@ -111,9 +127,8 @@ public class FieldIdentifier extends Identifier{
return; return;
notConstant = true; notConstant = true;
Enumeration enum = fieldListeners.elements(); for (Iterator i = fieldListeners.iterator(); i.hasNext(); )
while (enum.hasMoreElements()) Main.getClassBundle().analyzeIdentifier((Identifier) i.next());
clazz.bundle.analyzeIdentifier((Identifier) enum.nextElement());
fieldListeners = null; fieldListeners = null;
} }
@ -121,7 +136,7 @@ public class FieldIdentifier extends Identifier{
return "FieldIdentifier "+getFullName()+"."+getType(); return "FieldIdentifier "+getFullName()+"."+getType();
} }
public void readTable(Hashtable table) { public void readTable(Map table) {
String alias = (String) table.get(getFullName() + "." + getType()); String alias = (String) table.get(getFullName() + "." + getType());
if (alias == null) if (alias == null)
alias = (String) table.get(getFullName()); alias = (String) table.get(getFullName());
@ -129,27 +144,17 @@ public class FieldIdentifier extends Identifier{
setAlias(alias); setAlias(alias);
} }
public void writeTable(Hashtable table) { public void writeTable(Map table) {
table.put(getFullAlias() table.put(getFullAlias() + "."
+ "." + clazz.bundle.getTypeAlias(getType()), getName()); + Main.getClassBundle().getTypeAlias(getType()), getName());
} }
public boolean conflicting(String newAlias, boolean strong) { public boolean conflicting(String newAlias) {
String typeSig = strong ? getType() : ""; return clazz.fieldConflicts(this, newAlias);
if (clazz.containFieldAlias(newAlias, typeSig))
return true;
Enumeration enum = clazz.knownSubClasses.elements();
while (enum.hasMoreElements()) {
ClassIdentifier ci = (ClassIdentifier) enum.nextElement();
if (ci.containsFieldAliasDirectly(newAlias, typeSig))
return true;
}
return false;
} }
public void doTransformations() { public void doTransformations() {
info.setName(getAlias()); info.setName(getAlias());
info.setType(clazz.bundle.getTypeAlias(type)); info.setType(Main.getClassBundle().getTypeAlias(type));
} }
} }

Loading…
Cancel
Save