give hints to local that are assigned to an val$ field.

remove public,static,final modifiers in interface fields, as suggested
by JLS  (I'm not sure if this is really a good idea)


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@882 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 6a709898c8
commit 2ce2054875
  1. 28
      jode/jode/decompiler/FieldAnalyzer.java

@ -25,6 +25,7 @@ import jode.expr.Expression;
import jode.expr.ThisOperator;
import jode.expr.LocalLoadOperator;
import jode.expr.ConstOperator;
import jode.expr.OuterLocalOperator;
public class FieldAnalyzer implements Analyzer {
ClassAnalyzer clazz;
@ -86,9 +87,14 @@ public class FieldAnalyzer implements Analyzer {
if (isSynthetic && isFinal()
&& (fieldName.startsWith("this$")
|| fieldName.startsWith("val$")))
|| fieldName.startsWith("val$"))) {
if (fieldName.startsWith("val$") && fieldName.length() > 4
&& expr instanceof OuterLocalOperator) {
LocalInfo li = ((OuterLocalOperator) expr).getLocalInfo();
li.addHint(fieldName.substring(4), type);
}
analyzedSynthetic();
else
} else
expr.makeInitializer();
constant = expr;
@ -108,6 +114,9 @@ public class FieldAnalyzer implements Analyzer {
public void analyze() {
imports.useType(type);
}
public void makeDeclaration() {
if (constant != null)
constant = constant.simplify();
}
@ -126,7 +135,20 @@ public class FieldAnalyzer implements Analyzer {
}
if (isSynthetic)
writer.print("/*synthetic*/ ");
String modif = Modifier.toString(modifiers);
int modifiedModifiers = modifiers;
/*
* JLS-1.0, section 9.3:
*
* Every field declaration in the body of an interface is
* implicitly public, static, and final. It is permitted, but
* strongly discouraged as a matter of style, to redundantly
* specify any or all of these modifiers for such fields.
*/
if (clazz.getClazz().isInterface())
modifiedModifiers &= ~(Modifier.PUBLIC
| Modifier.STATIC
| Modifier.FINAL);
String modif = Modifier.toString(modifiedModifiers);
if (modif.length() > 0)
writer.print(modif+" ");

Loading…
Cancel
Save