From 2ce205487506cbd35568fe2edf490379261d61d3 Mon Sep 17 00:00:00 2001 From: jochen Date: Sat, 26 Jun 1999 15:57:10 +0000 Subject: [PATCH] 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 --- jode/jode/decompiler/FieldAnalyzer.java | 28 ++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/jode/jode/decompiler/FieldAnalyzer.java b/jode/jode/decompiler/FieldAnalyzer.java index ce8a96a..cf6dfea 100644 --- a/jode/jode/decompiler/FieldAnalyzer.java +++ b/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+" ");