Handling of certain loop types in a finally block

This commit is contained in:
Stiver 2014-07-08 23:50:14 +02:00
parent b668038ed9
commit b3a1c41244
3 changed files with 28 additions and 17 deletions

View File

@ -165,13 +165,14 @@ public class ClassesProcessor {
HashSet<String> setNestedClasses = mapNestedClassReferences.get(superClass); HashSet<String> setNestedClasses = mapNestedClassReferences.get(superClass);
if(setNestedClasses != null) { if(setNestedClasses != null) {
StructClass scl = supernode.classStruct;
StructInnerClassesAttribute inner = (StructInnerClassesAttribute)scl.getAttributes().getWithKey("InnerClasses"); StructClass scl = supernode.classStruct;
for(int i=0;i<inner.getStringentries().size();i++) { StructInnerClassesAttribute inner = (StructInnerClassesAttribute) scl.getAttributes().getWithKey("InnerClasses");
String nestedClass = inner.getStringentries().get(i)[0]; for(int i = 0; i < inner.getStringentries().size(); i++) {
if(!setNestedClasses.contains(nestedClass)) { String nestedClass = inner.getStringentries().get(i)[0];
continue; if (!setNestedClasses.contains(nestedClass)) {
} continue;
}
if(setVisited.contains(nestedClass)) { if(setVisited.contains(nestedClass)) {
continue; continue;

View File

@ -35,15 +35,15 @@ public class PrintStreamLogger implements IFernflowerLogger {
public void writeMessage(String message, int severity) { public void writeMessage(String message, int severity) {
if(severity >= this.severity) { if (severity >= this.severity) {
stream.println(InterpreterUtil.getIndentString(indent)+names[severity]+": "+message); stream.println(InterpreterUtil.getIndentString(indent) + names[severity] + ": " + message);
} }
} }
public void writeMessage(String message, Throwable t) { public void writeMessage(String message, Throwable t) {
t.printStackTrace(stream); t.printStackTrace(stream);
writeMessage(message, ERROR); writeMessage(message, ERROR);
} }
public void startClass(String classname) { public void startClass(String classname) {
stream.println(InterpreterUtil.getIndentString(indent++)+"Processing class "+classname+" ..."); stream.println(InterpreterUtil.getIndentString(indent++)+"Processing class "+classname+" ...");

View File

@ -129,9 +129,11 @@ public class ExprProcessor implements CodeConstants {
FlattenStatementsHelper flatthelper = new FlattenStatementsHelper(); FlattenStatementsHelper flatthelper = new FlattenStatementsHelper();
DirectGraph dgraph = flatthelper.buildDirectGraph(root); DirectGraph dgraph = flatthelper.buildDirectGraph(root);
// try { // try {
// DotExporter.toDotFile(dgraph, new File("c:\\Temp\\gr12_my.dot")); // DotExporter.toDotFile(dgraph, new File("c:\\Temp\\gr12_my.dot"));
// } catch(Exception ex) {ex.printStackTrace();} // } catch (Exception ex) {
// ex.printStackTrace();
// }
// collect finally entry points // collect finally entry points
Set<String> setFinallyShortRangeEntryPoints = new HashSet<String>(); Set<String> setFinallyShortRangeEntryPoints = new HashSet<String>();
@ -212,6 +214,14 @@ public class ExprProcessor implements CodeConstants {
// not be null at this point // not be null at this point
} }
// handling of entry point loops
int succ_entry_index = ndentrypoints.indexOf(nd.id);
if(succ_entry_index >= 0) { // we are in a loop (e.g. continue in a finally block), drop all entry points in the list beginning with succ_entry_index
for(int elements_to_remove = ndentrypoints.size() - succ_entry_index; elements_to_remove > 0; elements_to_remove--) {
ndentrypoints.removeLast();
}
}
String ndentrykey = buildEntryPointKey(ndentrypoints); String ndentrykey = buildEntryPointKey(ndentrypoints);
if (!mapSucc.containsKey(ndentrykey)) { if (!mapSucc.containsKey(ndentrykey)) {