lbownik commented on code in PR #5317:
URL: https://github.com/apache/netbeans/pull/5317#discussion_r1081259499
##########
harness/o.n.insane/src/org/netbeans/insane/scanner/ScannerUtils.java:
##########
@@ -233,58 +231,22 @@ public void run() {
if (ret[0] != null) throw ret[0];
}
- private static Thread[] getAllThreads() {
- ThreadGroup act = Thread.currentThread().getThreadGroup();
- while (act.getParent() != null) act = act.getParent();
- Thread[] all = new Thread[2*act.activeCount()+5];
- int cnt = act.enumerate(all);
- Thread[] ret = new Thread[cnt];
- System.arraycopy(all, 0, ret, 0, cnt);
- return ret;
- }
-
- @SuppressWarnings("deprecation")
- private static void suspendAllThreads(Set<Thread> except) {
- Thread[] threads = getAllThreads();
-
- for (int i=0; i<threads.length; i++) {
- if (!except.contains(threads[i])) {
- if ((threads[i].getName().indexOf("VM") == -1) &&
- (threads[i].getName().indexOf("CompilerTh") == -1) &&
- (threads[i].getName().indexOf("Signal") == -1)) {
- System.out.println("suspending " + threads[i]);
- threads[i].suspend();
- }
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- private static void resumeAllThreads() {
- Thread[] threads = getAllThreads();
-
- for (int i=0; i<threads.length; i++) {
- threads[i].resume();
- }
- }
-
private static class ClassInfo {
- private static Map<Class, ClassInfo> classInfoRegistry = new
WeakHashMap<Class, ClassInfo>();
- private int size;
+ private static final Map<Class<?>, ClassInfo> classInfoRegistry = new
WeakHashMap<>();
+ private final int size;
- private ClassInfo(Class cls) {
-// this.cls = cls;
+ private ClassInfo(Class<?> cls) {
if (cls.isArray()) {
- Class base = cls.getComponentType();
+ Class<?> base = cls.getComponentType();
size = -getSize(base, true);
} else {
// iterate all fields and sum the sizes
int sum = 0;
- for (Class act = cls; act != null; act = act.getSuperclass()) {
- Field[] flds = act.getDeclaredFields();
- for (int i=0; i<flds.length; i++) { // count all nonstatic
fields
- if ((flds[i].getModifiers() & Modifier.STATIC) == 0) {
- sum += getSize(flds[i].getType(), false);
+ for (Class<?> act = cls; act != null; act =
act.getSuperclass()) {
+ // count all nonstatic fields
Review Comment:
I haven't modified the logic, just converted indexed loop with for-each loop
sum is used in line 291
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists