You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2021/09/09 05:47:33 UTC

[GitHub] [netbeans] JaroslavTulach opened a new pull request #3159: Concentrating I/O access into two package private classes

JaroslavTulach opened a new pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159


   In the quest to [make the Heap library work without file access](https://github.com/apache/netbeans/pull/3148) I am refactoring the code logic to be `java.io.File` and `java.io.RandomAccessFile` free. The commit a69dca3 creates two package private classes `File` and `RandomAccessFile` (naming is chosen to minimize the size of the diff) and moves all the I/O code into them. The rest of the code stays untouched as much as possible.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707030431



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N

Review comment:
       I am using the _heap library_ outside of NetBeans. Right now it is completely standalone. Adding dependency on `BaseUtil` would increase the [weight of this module](http://wiki.apidesign.org/wiki/HeavyWeight). 




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach merged pull request #3159: Concentrating I/O access into JavaIoFile private class

Posted by GitBox <gi...@apache.org>.
JaroslavTulach merged pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159


   


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r706827040



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();
+    }
+
+    static void printStackTrace(String msg, Throwable t) {
+        System.err.println(msg);
+        t.printStackTrace(System.err);
+    }
+
+    static void debug(String msg) {

Review comment:
       This looks more like a job for `java.util.logging.Logger#fine` - seeing `System.err` or System.out` used for debugging of something serious feels strange.

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();
+    }
+
+    static void printStackTrace(String msg, Throwable t) {
+        System.err.println(msg);

Review comment:
       I suggest to used `java.util.logging.Logger#log(Level level, String message, Throwable t)`, without introducing a new helper. That way the exception is logged correctly, not spilled to STDERR (where it does not belong is not traceable).

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+enum Progress {
+    COMPUTE_INSTANCES,
+    COMPUTE_REFERENCES,
+    FILL_HEAP_TAG_BOUNDS,
+    COMPUTE_GC_ROOTS;
+
+    Handle start() {
+        return new Handle(this);
+    }
+
+    private static List<Listener> listeners = Collections.emptyList();
+    synchronized static void register(Listener onChange) {
+        if (listeners.isEmpty()) {
+            listeners = Collections.singletonList(onChange);
+        } else {
+            List<Listener> copy = new ArrayList<>(listeners);
+            copy.add(onChange);
+            listeners = copy;
+        }
+    }
+
+    synchronized static void notifyUpdates(Handle h, int type) {
+        for (Listener onChange : listeners) {
+            switch (type) {
+                case 1: onChange.started(h); break;
+                case 2: onChange.progress(h); break;
+                default: onChange.finished(h);
+            }
+        }
+    }
+
+    static interface Listener {
+        void started(Handle h);
+        void progress(Handle h);
+        void finished(Handle h);
+    }
+
+    static final class Handle implements AutoCloseable {
+        final Progress type;
+        private long value;
+        private long startOffset;
+        private long endOffset;
+
+        private Handle(Progress type) {
+            this.type = type;
+            notifyUpdates(this, 1);
+        }
+
+        void progress(long value, long endValue) {
+            progress(value, 0, value, endValue);
+        }
+
+        void progress(long counter, long startOffset, long value, long endOffset) {
+            // keep this method short so that it can be inlined
+            if (counter % 100000 == 0) {
+                doProgress(value, startOffset, endOffset);
+            }
+        }
+
+        @Override
+        public void close() {
+            notifyUpdates(this, 2);

Review comment:
       This should from my reading of `notifyUpdates` either be `notifyUpdates(this, 0)` or `notifyUpdates(this, 3)`

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N

Review comment:
       I suggest to use `org.openide.util.BaseUtil.getOperatingSystem() == OS_LINUX`

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+enum Progress {
+    COMPUTE_INSTANCES,
+    COMPUTE_REFERENCES,
+    FILL_HEAP_TAG_BOUNDS,
+    COMPUTE_GC_ROOTS;
+
+    Handle start() {
+        return new Handle(this);
+    }
+
+    private static List<Listener> listeners = Collections.emptyList();
+    synchronized static void register(Listener onChange) {
+        if (listeners.isEmpty()) {
+            listeners = Collections.singletonList(onChange);
+        } else {
+            List<Listener> copy = new ArrayList<>(listeners);
+            copy.add(onChange);
+            listeners = copy;
+        }
+    }
+
+    synchronized static void notifyUpdates(Handle h, int type) {
+        for (Listener onChange : listeners) {
+            switch (type) {
+                case 1: onChange.started(h); break;
+                case 2: onChange.progress(h); break;
+                default: onChange.finished(h);
+            }
+        }
+    }
+
+    static interface Listener {
+        void started(Handle h);
+        void progress(Handle h);
+        void finished(Handle h);
+    }
+
+    static final class Handle implements AutoCloseable {
+        final Progress type;
+        private long value;
+        private long startOffset;
+        private long endOffset;
+
+        private Handle(Progress type) {
+            this.type = type;
+            notifyUpdates(this, 1);
+        }
+
+        void progress(long value, long endValue) {
+            progress(value, 0, value, endValue);
+        }
+
+        void progress(long counter, long startOffset, long value, long endOffset) {
+            // keep this method short so that it can be inlined
+            if (counter % 100000 == 0) {
+                doProgress(value, startOffset, endOffset);
+            }
+        }
+
+        @Override
+        public void close() {
+            notifyUpdates(this, 2);
+        }
+
+        private void doProgress(long value, long startOffset, long endOffset) {
+            this.value = value;
+            this.endOffset = endOffset;
+            this.startOffset = startOffset;
+            notifyUpdates(this, 1);

Review comment:
       I think reading the code in `notifyUpdates` this should be `notifyUpdates(this, 2)`

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();

Review comment:
       See comment in `printStackTrace(String msg, Throwable t)` - the logger can be invoked with an empty or even null message).

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;

Review comment:
       This is not necessary - either the logger can be queries if it is loggable or the log call be be invoked directly. Last time I checked the first thing the log routines do is to check if a call can be discarded, because it will not yield visible output.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707042569



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+enum Progress {
+    COMPUTE_INSTANCES,
+    COMPUTE_REFERENCES,
+    FILL_HEAP_TAG_BOUNDS,
+    COMPUTE_GC_ROOTS;
+
+    Handle start() {
+        return new Handle(this);
+    }
+
+    private static List<Listener> listeners = Collections.emptyList();
+    synchronized static void register(Listener onChange) {
+        if (listeners.isEmpty()) {
+            listeners = Collections.singletonList(onChange);
+        } else {
+            List<Listener> copy = new ArrayList<>(listeners);
+            copy.add(onChange);
+            listeners = copy;
+        }
+    }
+
+    synchronized static void notifyUpdates(Handle h, int type) {
+        for (Listener onChange : listeners) {
+            switch (type) {
+                case 1: onChange.started(h); break;
+                case 2: onChange.progress(h); break;
+                default: onChange.finished(h);
+            }
+        }
+    }
+
+    static interface Listener {
+        void started(Handle h);
+        void progress(Handle h);
+        void finished(Handle h);
+    }
+
+    static final class Handle implements AutoCloseable {
+        final Progress type;
+        private long value;
+        private long startOffset;
+        private long endOffset;
+
+        private Handle(Progress type) {
+            this.type = type;
+            notifyUpdates(this, 1);
+        }
+
+        void progress(long value, long endValue) {
+            progress(value, 0, value, endValue);
+        }
+
+        void progress(long counter, long startOffset, long value, long endOffset) {
+            // keep this method short so that it can be inlined
+            if (counter % 100000 == 0) {
+                doProgress(value, startOffset, endOffset);
+            }
+        }
+
+        @Override
+        public void close() {
+            notifyUpdates(this, 2);

Review comment:
       Done in 01c307f




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707037330



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();
+    }
+
+    static void printStackTrace(String msg, Throwable t) {
+        System.err.println(msg);
+        t.printStackTrace(System.err);
+    }
+
+    static void debug(String msg) {

Review comment:
       Using `Logger` is good idea. It also [increases the weight](http://wiki.apidesign.org/wiki/HeavyWeight) as `java.util.logging` isn't part of `java.base` module, but be it: 938dcf0




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707037513



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();
+    }
+
+    static void printStackTrace(String msg, Throwable t) {
+        System.err.println(msg);

Review comment:
       Done in 938dcf0




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707038504



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;

Review comment:
       In 938dcf0 I decided to keep the `DEBUG` final field, but to initialize it from `Logger.isLoggable` value. That will keep the compiled code the same and allow the logging be customized by [typical log configuration](http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/doc-files/logging.html) methods.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r706841944



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */

Review comment:
       This header needs to be the default ALv2 header




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#issuecomment-917922447


   > Curious what will be the next step...
   
   a3162ad  is your answer. Full abstraction over `java.io.File` and `java.io.RandomAccessFile` with a pluggable `Factory` to specify when wiring `CacheDirectory` and `HprofHeap` together.
   
   An additional package private class can re-implement `File.Factory` and fully replace the I/O access with something different without changing the existing logic of the heap dump processing.


-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707042660



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */

Review comment:
       Of course. Updated.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] matthiasblaesing commented on a change in pull request #3159: Concentrating I/O access into JavaIoFile private class

Posted by GitBox <gi...@apache.org>.
matthiasblaesing commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707479187



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+final class Systems {
+    private static final Logger LOG = Logger.getLogger(System.class.getPackage().getName());

Review comment:
       I doubt, that the logger should be named `java.lang`. The normal name would be:
   
   ```suggestion
       private static final Logger LOG = Logger.getLogger(Systems.class.getName());
   ```

##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+final class Systems {
+    private static final Logger LOG = Logger.getLogger(System.class.getPackage().getName());
+    static final boolean DEBUG = LOG.isLoggable(Level.FINE);

Review comment:
       Configurable logging at runtime is one of the key benefits of the logging system to me. Yes there is overhead in the check at runtime, but so is overhead in virtual methods, the VM concept in itself, the interpreter, GC and so on.
   
   I'm not religious here, but reading such code feels strange to me.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707038633



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N

Review comment:
       I rather keep the simple property check.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707037715



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;
+
+    static boolean isLinux() {
+        String osName = System.getProperty("os.name"); // NOI18N
+        return osName.endsWith("Linux"); // NOI18N
+    }
+
+    private Systems() {
+    }
+    
+    static void printStackTrace(Throwable t) {
+        t.printStackTrace();

Review comment:
       Right. Done in 938dcf0




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into JavaIoFile private class

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707926836



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+final class Systems {
+    private static final Logger LOG = Logger.getLogger(System.class.getPackage().getName());
+    static final boolean DEBUG = LOG.isLoggable(Level.FINE);

Review comment:
       Let's keep the spirit of the code for now. If needed `DEBUG` can be replaced with `LOG::isLoggable` later.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707042415



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Progress.java
##########
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.netbeans.lib.profiler.heap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+enum Progress {
+    COMPUTE_INSTANCES,
+    COMPUTE_REFERENCES,
+    FILL_HEAP_TAG_BOUNDS,
+    COMPUTE_GC_ROOTS;
+
+    Handle start() {
+        return new Handle(this);
+    }
+
+    private static List<Listener> listeners = Collections.emptyList();
+    synchronized static void register(Listener onChange) {
+        if (listeners.isEmpty()) {
+            listeners = Collections.singletonList(onChange);
+        } else {
+            List<Listener> copy = new ArrayList<>(listeners);
+            copy.add(onChange);
+            listeners = copy;
+        }
+    }
+
+    synchronized static void notifyUpdates(Handle h, int type) {
+        for (Listener onChange : listeners) {
+            switch (type) {
+                case 1: onChange.started(h); break;
+                case 2: onChange.progress(h); break;
+                default: onChange.finished(h);
+            }
+        }
+    }
+
+    static interface Listener {
+        void started(Handle h);
+        void progress(Handle h);
+        void finished(Handle h);
+    }
+
+    static final class Handle implements AutoCloseable {
+        final Progress type;
+        private long value;
+        private long startOffset;
+        private long endOffset;
+
+        private Handle(Progress type) {
+            this.type = type;
+            notifyUpdates(this, 1);
+        }
+
+        void progress(long value, long endValue) {
+            progress(value, 0, value, endValue);
+        }
+
+        void progress(long counter, long startOffset, long value, long endOffset) {
+            // keep this method short so that it can be inlined
+            if (counter % 100000 == 0) {
+                doProgress(value, startOffset, endOffset);
+            }
+        }
+
+        @Override
+        public void close() {
+            notifyUpdates(this, 2);
+        }
+
+        private void doProgress(long value, long startOffset, long endOffset) {
+            this.value = value;
+            this.endOffset = endOffset;
+            this.startOffset = startOffset;
+            notifyUpdates(this, 1);

Review comment:
       Opps, thank you. Better to not be lazy: 01c307f 




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] JaroslavTulach commented on a change in pull request #3159: Concentrating I/O access into two package private classes

Posted by GitBox <gi...@apache.org>.
JaroslavTulach commented on a change in pull request #3159:
URL: https://github.com/apache/netbeans/pull/3159#discussion_r707029668



##########
File path: profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/Systems.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.profiler.heap;
+
+final class Systems {
+
+    //~ Static fields/initializers -----------------------------------------------------------------------------------------------
+    static final boolean DEBUG = false;

Review comment:
       That's not the same when the code gets compiled... `static final boolean` is treated as a constant by the C1/C2/Graal compilers and as such the whole  `if (DEBUG) { ... }` is completely left out of the compiled code (including the check). Using `LOG.isLoggable(...)` isn't constant and the check needs to be done all the time.




-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists