Skip to content

Commit

Permalink
feat(objectionary#540): accuratly handle try-with-resources blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Oct 10, 2024
1 parent 7f43c43 commit dd76e0e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -701,9 +701,9 @@ private int computeLocalsWithCFG2() {
continue;
}

catches(current).stream().forEach(ind -> {
worklist.put(ind, new Variables(curr.getValue()));
});
// catches(current).stream().forEach(ind -> {
// worklist.put(ind, new Variables(curr.getValue()));
// });


currentVars = new Variables(curr.getValue());
Expand Down Expand Up @@ -738,6 +738,9 @@ private int computeLocalsWithCFG2() {
}
}
final Variables value = new Variables(currentVars);
this.catches(current).stream().forEach(ind -> {
worklist.put(ind, new Variables(value));
});
all.put(current, value);
current++;
}
Expand Down
35 changes: 35 additions & 0 deletions src/test/resources/maxs/Maxs.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Locale;
import java.util.function.Function;
import java.util.stream.Stream;
import java.util.ArrayList;


/**
Expand Down Expand Up @@ -793,6 +794,40 @@ public long contentLength(int x) throws IOException, URISyntaxException {
return connection.getContentLengthLong();
}
}
private final Object statusListenerListLock = new Object();
private final List<Object> statusListenerList = new ArrayList<>();

public boolean add(Object listener) {
synchronized (this.statusListenerListLock) {
if (listener instanceof String) {
boolean isPresent = this.checkForPresence(this.statusListenerList, listener.getClass());
if (isPresent) {
return false;
}
}
this.statusListenerList.add(listener);
return true;
}
}

private boolean checkForPresence(List<Object> list, Class<?> cls) {
for (Object obj : list) {
if (obj.getClass().equals(cls)) {
return true;
}
}
return false;
}

public void displayListeners() {
synchronized (this.statusListenerListLock) {
System.out.println("Current Listeners:");
for (Object listener : statusListenerList) {
System.out.println(" - " + listener + " (" + listener.getClass().getSimpleName() + ")");
}
}
}


// Inner class to add complexity
private class Inner {
Expand Down

0 comments on commit dd76e0e

Please sign in to comment.