Remove unused methods etc. JEP-349-branch
authoregahlin
Wed, 18 Sep 2019 03:45:46 +0200
branchJEP-349-branch
changeset 58197 0ef79bd7fb5c
parent 58193 baf88aa4f5db
child 58200 2d147d680311
Remove unused methods etc.
src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java
src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java
src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java
src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java
src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriter.java
src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataWriter.java
src/jdk.jfr/share/classes/jdk/jfr/internal/RequestEngine.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkParser.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ConstantMap.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventParser.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Parser.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFactory.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFilter.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StringEncoding.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StringParser.java
src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/EventStream.java	Wed Sep 18 03:45:46 2019 +0200
@@ -43,6 +43,9 @@
 /**
  * Represents a stream of events.
  * <p>
+ * The EventStream interface is not to be implemented and future version may
+ * prevent this completely.
+ * <p>
  * A stream is a sequence of events and the way to interact with a stream is to
  * register actions.
  * <p>
@@ -174,7 +177,7 @@
      * @throws SecurityException if a security manager exists and its
      *         {@code checkRead} method denies read access to the file
      */
-    public static EventStream openFile(Path file) throws IOException {
+    static EventStream openFile(Path file) throws IOException {
         return new EventFileStream(AccessController.getContext(), file);
     }
 
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedEvent.java	Wed Sep 18 03:45:46 2019 +0200
@@ -138,10 +138,10 @@
     }
 
     private long getStartTimeNanos() {
-        return objectContext.timeConverter.convertTimestamp(startTimeTicks);
+        return objectContext.convertTimestamp(startTimeTicks);
     }
 
     private long getEndTimeNanos() {
-        return objectContext.timeConverter.convertTimestamp(endTimeTicks);
+        return objectContext.convertTimestamp(endTimeTicks);
     }
 }
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java	Wed Sep 18 03:45:46 2019 +0200
@@ -64,7 +64,7 @@
             }
 
             public boolean isLastEventInChunk(RecordingFile file) {
-                return file.isLastEventInChunk;
+                return file.isLastEventInChunk();
             }
 
             @Override
@@ -833,7 +833,7 @@
             case Timespan.NANOSECONDS:
                 return Duration.ofNanos(timespan);
             case Timespan.TICKS:
-                return Duration.ofNanos(objectContext.timeConverter.convertTimespan(timespan));
+                return Duration.ofNanos(objectContext.convertTimespan(timespan));
             }
             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value());
         }
@@ -906,7 +906,7 @@
             case Timestamp.MILLISECONDS_SINCE_EPOCH:
                 return Instant.ofEpochMilli(timestamp);
             case Timestamp.TICKS:
-                return Instant.ofEpochSecond(0, objectContext.timeConverter.convertTimestamp(timestamp));
+                return Instant.ofEpochSecond(0, objectContext.convertTimestamp(timestamp));
             }
             throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value());
         }
@@ -981,12 +981,12 @@
     }
 
     // package private for now. Used by EventWriter
-    OffsetDateTime getOffsetDateTime(String name) {
+    private OffsetDateTime getOffsetDateTime(String name) {
         Instant instant = getInstant(name);
         if (instant.equals(Instant.MIN)) {
             return OffsetDateTime.MIN;
         }
-        return OffsetDateTime.ofInstant(getInstant(name), objectContext.timeConverter.getZoneOffset());
+        return OffsetDateTime.ofInstant(getInstant(name), objectContext.getZoneOffset());
     }
 
     private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordingFile.java	Wed Sep 18 03:45:46 2019 +0200
@@ -63,7 +63,7 @@
  */
 public final class RecordingFile implements Closeable {
 
-    boolean isLastEventInChunk;
+    private boolean isLastEventInChunk;
     private final File file;
     private RecordingInput input;
     private ChunkParser chunkParser;
@@ -235,6 +235,12 @@
         return file;
     }
 
+    // package protected
+    boolean isLastEventInChunk() {
+        return isLastEventInChunk;
+    }
+
+
     // either sets next to an event or sets eof to true
     private void findNext() throws IOException {
         while (nextEvent == null) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventInstrumentation.java	Wed Sep 18 03:45:46 2019 +0200
@@ -121,7 +121,6 @@
     private final boolean untypedEventHandler;
     private boolean guardHandlerReference;
     private Class<?> superClass;
-    private final static boolean streamingCommit = false; //!SecuritySupport.getBooleanProperty("jfr.instrument.streaming");
 
     EventInstrumentation(Class<?> superClass, byte[] bytes, long id) {
         this.superClass = superClass;
@@ -364,160 +363,72 @@
             methodVisitor.visitMaxs(0, 0);
         });
 
-        // MyEvent#commit() - Java event writer
-        if (streamingCommit) {
-            updateMethod(METHOD_COMMIT, methodVisitor -> {
-                methodVisitor.visitCode();
-                // Labels
-                Label enabled = new Label();
-                Label end = new Label();
-                Label durationEvent = new Label();
-                Label writeToHandler = new Label();
-                Label timestampOnCommit = new Label();
-                // if (!isEnable()) {
-                // return;
-                // }
-                methodVisitor.visitCode();
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_IS_ENABLED.getName(), METHOD_IS_ENABLED.getDescriptor(), false);
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, enabled);
-                methodVisitor.visitInsn(Opcodes.RETURN);
-                methodVisitor.visitLabel(enabled);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-
-                // if (startTime == 0) {
-                // startTime = EventWriter.timestamp();
-                // } else {
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitInsn(Opcodes.LCONST_0);
-                methodVisitor.visitInsn(Opcodes.LCMP);
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, durationEvent);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
-                methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitJumpInsn(Opcodes.GOTO, writeToHandler);
-
-                // new
-                // if (duration == 0) {
-                methodVisitor.visitLabel(durationEvent);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J");
-                methodVisitor.visitInsn(Opcodes.LCONST_0);
-                methodVisitor.visitInsn(Opcodes.LCMP);
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, timestampOnCommit);
-
-                // startTime = EventWriter.timestamp() - duration;
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J");
-                methodVisitor.visitInsn(Opcodes.LSUB);
-                methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitJumpInsn(Opcodes.GOTO, writeToHandler);
-
-                // duration = EventWriter.timestamp() -timestamp
-                // }
-                methodVisitor.visitLabel(timestampOnCommit);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitInsn(Opcodes.LSUB);
-                methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_DURATION, "J");
+        updateMethod(METHOD_COMMIT, methodVisitor -> {
+            // if (!isEnable()) {
+            // return;
+            // }
+            methodVisitor.visitCode();
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_IS_ENABLED.getName(), METHOD_IS_ENABLED.getDescriptor(), false);
+            Label l0 = new Label();
+            methodVisitor.visitJumpInsn(Opcodes.IFNE, l0);
+            methodVisitor.visitInsn(Opcodes.RETURN);
+            methodVisitor.visitLabel(l0);
+            methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
+            // if (startTime == 0) {
+            // startTime = EventWriter.timestamp();
+            // } else {
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
+            methodVisitor.visitInsn(Opcodes.LCONST_0);
+            methodVisitor.visitInsn(Opcodes.LCMP);
+            Label durationalEvent = new Label();
+            methodVisitor.visitJumpInsn(Opcodes.IFNE, durationalEvent);
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
+            methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J");
+            Label commit = new Label();
+            methodVisitor.visitJumpInsn(Opcodes.GOTO, commit);
+            // if (duration == 0) {
+            // duration = EventWriter.timestamp() - startTime;
+            // }
+            // }
+            methodVisitor.visitLabel(durationalEvent);
+            methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J");
+            methodVisitor.visitInsn(Opcodes.LCONST_0);
+            methodVisitor.visitInsn(Opcodes.LCMP);
+            methodVisitor.visitJumpInsn(Opcodes.IFNE, commit);
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
+            methodVisitor.visitInsn(Opcodes.LSUB);
+            methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_DURATION, "J");
+            methodVisitor.visitLabel(commit);
+            // if (shouldCommit()) {
+            methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
+            methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
+            methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_EVENT_SHOULD_COMMIT.getName(), METHOD_EVENT_SHOULD_COMMIT.getDescriptor(), false);
+            Label end = new Label();
+            // eventHandler.write(...);
+            // }
+            methodVisitor.visitJumpInsn(Opcodes.IFEQ, end);
+            getEventHandler(methodVisitor);
 
-                // if (shouldCommit()) {
-                 methodVisitor.visitLabel(writeToHandler);
-                 methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                 methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                 methodVisitor.visitMethodInsn(Opcodes.INVOKESPECIAL, getInternalClassName(), METHOD_EVENT_SHOULD_COMMIT.getName(), METHOD_EVENT_SHOULD_COMMIT.getDescriptor(), false);
-                 methodVisitor.visitJumpInsn(Opcodes.IFEQ, end);
-                //
-                //   eventHandlerX.write(...);
-                getEventHandler(methodVisitor);
-                methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName);
-                for (FieldInfo fi : fieldInfos) {
-                   methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                   methodVisitor.visitFieldInsn(Opcodes.GETFIELD, fi.internalClassName, fi.fieldName, fi.fieldDescriptor);
-                }
-                methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, eventHandlerXInternalName, writeMethod.getName(), writeMethod.getDescriptor(), false);
-                // }
-                methodVisitor.visitLabel(end);
-                methodVisitor.visitInsn(Opcodes.RETURN);
-                methodVisitor.visitEnd();
-            });
-        }
-
-        if (!streamingCommit) {
-            updateMethod(METHOD_COMMIT, methodVisitor -> {
-                // if (!isEnable()) {
-                // return;
-                // }
-                methodVisitor.visitCode();
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_IS_ENABLED.getName(), METHOD_IS_ENABLED.getDescriptor(), false);
-                Label l0 = new Label();
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, l0);
-                methodVisitor.visitInsn(Opcodes.RETURN);
-                methodVisitor.visitLabel(l0);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                // if (startTime == 0) {
-                // startTime = EventWriter.timestamp();
-                // } else {
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitInsn(Opcodes.LCONST_0);
-                methodVisitor.visitInsn(Opcodes.LCMP);
-                Label durationalEvent = new Label();
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, durationalEvent);
+            methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName);
+            for (FieldInfo fi : fieldInfos) {
                 methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
-                methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                Label commit = new Label();
-                methodVisitor.visitJumpInsn(Opcodes.GOTO, commit);
-                // if (duration == 0) {
-                // duration = EventWriter.timestamp() - startTime;
-                // }
-                // }
-                methodVisitor.visitLabel(durationalEvent);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_DURATION, "J");
-                methodVisitor.visitInsn(Opcodes.LCONST_0);
-                methodVisitor.visitInsn(Opcodes.LCMP);
-                methodVisitor.visitJumpInsn(Opcodes.IFNE, commit);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, TYPE_EVENT_HANDLER.getInternalName(), METHOD_TIME_STAMP.getName(), METHOD_TIME_STAMP.getDescriptor(), false);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, getInternalClassName(), FIELD_START_TIME, "J");
-                methodVisitor.visitInsn(Opcodes.LSUB);
-                methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, getInternalClassName(), FIELD_DURATION, "J");
-                methodVisitor.visitLabel(commit);
-                // if (shouldCommit()) {
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, getInternalClassName(), METHOD_EVENT_SHOULD_COMMIT.getName(), METHOD_EVENT_SHOULD_COMMIT.getDescriptor(), false);
-                Label end = new Label();
-                // eventHandler.write(...);
-                // }
-                methodVisitor.visitJumpInsn(Opcodes.IFEQ, end);
-                getEventHandler(methodVisitor);
+                methodVisitor.visitFieldInsn(Opcodes.GETFIELD, fi.internalClassName, fi.fieldName, fi.fieldDescriptor);
+            }
 
-                methodVisitor.visitTypeInsn(Opcodes.CHECKCAST, eventHandlerXInternalName);
-                for (FieldInfo fi : fieldInfos) {
-                    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
-                    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, fi.internalClassName, fi.fieldName, fi.fieldDescriptor);
-                }
-
-                methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, eventHandlerXInternalName, writeMethod.getName(), writeMethod.getDescriptor(), false);
-                methodVisitor.visitLabel(end);
-                methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
-                methodVisitor.visitInsn(Opcodes.RETURN);
-                methodVisitor.visitEnd();
-            });
-        }
+            methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, eventHandlerXInternalName, writeMethod.getName(), writeMethod.getDescriptor(), false);
+            methodVisitor.visitLabel(end);
+            methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
+            methodVisitor.visitInsn(Opcodes.RETURN);
+            methodVisitor.visitEnd();
+        });
 
         // MyEvent#shouldCommit()
         updateMethod(METHOD_EVENT_SHOULD_COMMIT, methodVisitor -> {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriter.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/EventWriter.java	Wed Sep 18 03:45:46 2019 +0200
@@ -26,7 +26,7 @@
 package jdk.jfr.internal;
 
 import jdk.internal.misc.Unsafe;
-import jdk.jfr.internal.consumer.StringEncoding;
+import jdk.jfr.internal.consumer.StringParser;
 
 /**
  * Class must reside in a package with package restriction.
@@ -115,18 +115,18 @@
 
     public void putString(String s, StringPool pool) {
         if (s == null) {
-            putByte(StringEncoding.STRING_ENCODING_NULL);
+            putByte(StringParser.Encoding.NULL.byteValue());
             return;
         }
         int length = s.length();
         if (length == 0) {
-            putByte(StringEncoding.STRING_ENCODING_EMPTY_STRING);
+            putByte(StringParser.Encoding.EMPTY_STRING.byteValue());
             return;
         }
         if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) {
             long l = StringPool.addString(s);
             if (l > 0) {
-                putByte(StringEncoding.STRING_ENCODING_CONSTANT_POOL);
+                putByte(StringParser.Encoding.CONSTANT_POOL.byteValue());
                 putLong(l);
                 return;
             }
@@ -138,7 +138,7 @@
     private void putStringValue(String s) {
         int length = s.length();
         if (isValidForSize(1 + 5 + 3 * length)) {
-            putUncheckedByte(StringEncoding.STRING_ENCODING_CHAR_ARRAY); // 1 byte
+            putUncheckedByte(StringParser.Encoding.CHAR_ARRAY.byteValue()); // 1 byte
             putUncheckedInt(length); // max 5 bytes
             for (int i = 0; i < length; i++) {
                 putUncheckedChar(s.charAt(i)); // max 3 bytes
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataWriter.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/MetadataWriter.java	Wed Sep 18 03:45:46 2019 +0200
@@ -53,7 +53,7 @@
 import jdk.jfr.ValueDescriptor;
 import jdk.jfr.internal.MetadataDescriptor.Attribute;
 import jdk.jfr.internal.MetadataDescriptor.Element;
-import jdk.jfr.internal.consumer.StringEncoding;
+import jdk.jfr.internal.consumer.StringParser;
 
 /**
  * Class responsible for converting a list of types into a format that can be
@@ -94,10 +94,10 @@
 
     private void writeString(DataOutput out, String s) throws IOException {
         if (s == null ) {
-            out.writeByte(StringEncoding.STRING_ENCODING_NULL);
+            out.writeByte(StringParser.Encoding.NULL.byteValue());
             return;
         }
-        out.writeByte(StringEncoding.STRING_ENCODING_CHAR_ARRAY); // encoding UTF-16
+        out.writeByte(StringParser.Encoding.CHAR_ARRAY.byteValue()); // encoding UTF-16
         int length = s.length();
         writeInt(out, length);
             for (int i = 0; i < length; i++) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RequestEngine.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RequestEngine.java	Wed Sep 18 03:45:46 2019 +0200
@@ -279,7 +279,9 @@
         return min;
     }
 
-    public static void setFlushInterval(long interval) {
+    static void setFlushInterval(long millis) {
+        // Don't accept shorter interval than 1 s.
+        long interval = millis < 1000 ? 1000  : millis;
         flushInterval = interval;
         if (interval < flushInterval) {
             synchronized (JVM.FILE_DELTA_CHANGE) {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/AbstractEventStream.java	Wed Sep 18 03:45:46 2019 +0200
@@ -54,7 +54,7 @@
  * - security
  *
  */
-public abstract class AbstractEventStream implements EventStream {
+abstract class AbstractEventStream implements EventStream {
     private final static AtomicLong counter = new AtomicLong(1);
 
     private final Object terminated = new Object();
@@ -68,7 +68,7 @@
 
     private volatile boolean closed;
 
-    public AbstractEventStream(AccessControlContext acc, boolean active) throws IOException {
+    AbstractEventStream(AccessControlContext acc, boolean active) throws IOException {
         this.accessControllerContext = Objects.requireNonNull(acc);
         this.active = active;
     }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkHeader.java	Wed Sep 18 03:45:46 2019 +0200
@@ -34,8 +34,7 @@
 import jdk.jfr.internal.Utils;
 
 public final class ChunkHeader {
-    public static final long HEADER_SIZE = 68;
-    public static final byte MARKED_FOR_DELETION = (byte) 255;
+    private static final long HEADER_SIZE = 68;
     private static final byte UPDATING_CHUNK_HEADER = (byte) 255;
     private static final long CHUNK_SIZE_POSITION = 8;
     private static final long DURATION_NANOS_POSITION = 40;
@@ -107,7 +106,8 @@
         refresh();
         input.position(absoluteEventStart);
     }
-    public void refresh() throws IOException {
+
+    void refresh() throws IOException {
         while (true) {
             byte fileState1;
             input.positionPhysical(absoluteChunkStart + FILE_STATE_POSITION);
@@ -279,4 +279,7 @@
         return absoluteEventStart;
     }
 
+    static long headerSize() {
+        return HEADER_SIZE;
+    }
 }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkParser.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ChunkParser.java	Wed Sep 18 03:45:46 2019 +0200
@@ -48,14 +48,14 @@
 public final class ChunkParser {
 
     static final class ParserConfiguration {
-        final boolean reuse;
-        final boolean ordered;
-        final ParserFilter eventFilter;
+        private final boolean reuse;
+        private final boolean ordered;
+        private final ParserFilter eventFilter;
 
         long filterStart;
         long filterEnd;
 
-        public ParserConfiguration(long filterStart, long filterEnd, boolean reuse, boolean ordered, ParserFilter filter) {
+        ParserConfiguration(long filterStart, long filterEnd, boolean reuse, boolean ordered, ParserFilter filter) {
             this.filterStart = filterStart;
             this.filterEnd = filterEnd;
             this.reuse = reuse;
@@ -66,16 +66,30 @@
         public ParserConfiguration() {
             this(0, Long.MAX_VALUE, false, false, ParserFilter.ACCEPT_ALL);
         }
+
+        public boolean isOrdered() {
+            return ordered;
+        }
     }
 
-    // Checkpoint that finishes a flush segment
-    static final byte CHECKPOINT_FLUSH_MASK = 1;
-    // Checkpoint contains chunk header information in the first pool
-    static final byte CHECKPOINT_CHUNK_HEADER_MASK = 2;
-    // Checkpoint contains only statics that will not change from chunk to chunk
-    static final byte CHECKPOINT_STATICS_MASK = 4;
-    // Checkpoint contains thread related information
-    static final byte CHECKPOINT_THREADS_MASK = 8;
+    private enum CheckPointType {
+        // Checkpoint that finishes a flush segment
+        FLUSH(1),
+        // Checkpoint contains chunk header information in the first pool
+        CHUNK_HEADER(2),
+        // Checkpoint contains only statics that will not change from chunk to chunk
+        STATICS(4),
+        // Checkpoint contains thread related information
+        THREAD(8);
+        private final int mask;
+        private CheckPointType(int mask) {
+            this.mask = mask;
+        }
+
+        private boolean is(int flags) {
+            return (mask & flags) != 0;
+        }
+    }
 
     private static final long CONSTANT_POOL_TYPE_ID = 1;
     private static final String CHUNKHEADER = "jdk.types.ChunkHeader";
@@ -98,11 +112,11 @@
         this(input, new ParserConfiguration());
     }
 
-    public ChunkParser(RecordingInput input, ParserConfiguration pc) throws IOException {
+    ChunkParser(RecordingInput input, ParserConfiguration pc) throws IOException {
        this(new ChunkHeader(input), null, pc);
     }
 
-    public ChunkParser(ChunkParser previous) throws IOException {
+    private ChunkParser(ChunkParser previous) throws IOException {
         this(new ChunkHeader(previous.input), previous, new ParserConfiguration());
      }
 
@@ -148,7 +162,7 @@
         updateConfiguration(configuration, false);
     }
 
-    public void updateConfiguration(ParserConfiguration configuration, boolean resetEventCache) {
+    void updateConfiguration(ParserConfiguration configuration, boolean resetEventCache) {
         this.configuration = configuration;
         parsers.forEach(p -> {
             if (p instanceof EventParser) {
@@ -178,7 +192,7 @@
      *
      * @param awaitNewEvents wait for new data.
      */
-    public RecordedEvent readStreamingEvent(boolean awaitNewEvents) throws IOException {
+    RecordedEvent readStreamingEvent(boolean awaitNewEvents) throws IOException {
         long absoluteChunkEnd = chunkHeader.getEnd();
         while (true) {
             RecordedEvent event = readEvent();
@@ -256,8 +270,8 @@
         input.readLong(); // timestamp
         input.readLong(); // duration
         input.readLong(); // delta
-        byte c = input.readByte();
-        if ((c & CHECKPOINT_FLUSH_MASK)== 1) {
+        byte typeFlags = input.readByte();
+        if (CheckPointType.FLUSH.is(typeFlags)) {
             flushOperation.run();
         }
     }
@@ -411,7 +425,7 @@
         return chunkHeader.isLastChunk();
     }
 
-    public ChunkParser newChunkParser() throws IOException {
+    ChunkParser newChunkParser() throws IOException {
         return new ChunkParser(this);
     }
 
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ConstantMap.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ConstantMap.java	Wed Sep 18 03:45:46 2019 +0200
@@ -181,11 +181,4 @@
     public void setAllResolved(boolean allResolved) {
         this.allResolved = allResolved;
     }
-
-    public boolean isResolved(long id) {
-        if (objects.hasKey(id)) {
-            return objects.isSetId(id, RESOLUTION_FINISHED);
-        }
-        return false;
-    }
 }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Dispatcher.java	Wed Sep 18 03:45:46 2019 +0200
@@ -12,34 +12,35 @@
 
 final class Dispatcher {
 
-    public final static class EventDispatcher {
-        final static EventDispatcher[] NO_DISPATCHERS = new EventDispatcher[0];
-        final String eventName;
-        public final Consumer<RecordedEvent> action;
+    final static class EventDispatcher {
+        private final static EventDispatcher[] NO_DISPATCHERS = new EventDispatcher[0];
 
-        public EventDispatcher(Consumer<RecordedEvent> action) {
-            this(null, action);
-        }
+        private final String eventName;
+        private final Consumer<RecordedEvent> action;
 
         public EventDispatcher(String eventName, Consumer<RecordedEvent> action) {
             this.eventName = eventName;
             this.action = action;
         }
 
-        public void offer(RecordedEvent event) {
+        private void offer(RecordedEvent event) {
             action.accept(event);
         }
 
-        public boolean accepts(EventType eventType) {
+        private boolean accepts(EventType eventType) {
             return (eventName == null || eventType.getName().equals(eventName));
         }
+
+        public Consumer<RecordedEvent> getAction() {
+            return action;
+        }
     }
 
-    final Consumer<Throwable>[] errorActions;
-    final Runnable[] flushActions;
-    final Runnable[] closeActions;
-    final EventDispatcher[] dispatchers;
-    final LongMap<EventDispatcher[]> dispatcherLookup = new LongMap<>();
+    private final Consumer<Throwable>[] errorActions;
+    private final Runnable[] flushActions;
+    private final Runnable[] closeActions;
+    private final EventDispatcher[] dispatchers;
+    private final LongMap<EventDispatcher[]> dispatcherLookup = new LongMap<>();
     final ParserConfiguration parserConfiguration;
     final Instant startTime;
     final Instant endTime;
@@ -63,6 +64,28 @@
         this.endNanos = c.endNanos;
     }
 
+    public void runFlushActions() {
+        Runnable[] flushActions = this.flushActions;
+        for (int i = 0; i < flushActions.length; i++) {
+            try {
+                flushActions[i].run();
+            } catch (Exception e) {
+                handleError(e);
+            }
+        }
+    }
+
+    public void runCloseActions() {
+        Runnable[] closeActions = this.closeActions;
+        for (int i = 0; i < closeActions.length; i++) {
+            try {
+                closeActions[i].run();
+            } catch (Exception e) {
+                handleError(e);
+            }
+        }
+    }
+
     private static ParserFilter buildFilter(EventDispatcher[] dispatchers) {
         ParserFilter ef = new ParserFilter();
         for (EventDispatcher ed : dispatchers) {
@@ -75,7 +98,7 @@
         return ef;
     }
 
-    protected final void dispatch(RecordedEvent event) {
+    void dispatch(RecordedEvent event) {
         EventType type = event.getEventType();
         EventDispatcher[] dispatchers = null;
         if (type == cacheEventType) {
@@ -121,7 +144,7 @@
         }
     }
 
-    public void handleError(Throwable e) {
+    private void handleError(Throwable e) {
         Consumer<?>[] consumers = this.errorActions;
         if (consumers.length == 0) {
             defaultErrorHandler(e);
@@ -134,29 +157,7 @@
         }
     }
 
-    public void runFlushActions() {
-        Runnable[] flushActions = this.flushActions;
-        for (int i = 0; i < flushActions.length; i++) {
-            try {
-                flushActions[i].run();
-            } catch (Exception e) {
-                handleError(e);
-            }
-        }
-    }
-
-    public void runCloseActions() {
-        Runnable[] closeActions = this.closeActions;
-        for (int i = 0; i < closeActions.length; i++) {
-            try {
-                closeActions[i].run();
-            } catch (Exception e) {
-                handleError(e);
-            }
-        }
-    }
-
-    void defaultErrorHandler(Throwable e) {
+    private void defaultErrorHandler(Throwable e) {
         e.printStackTrace();
     }
 }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventDirectoryStream.java	Wed Sep 18 03:45:46 2019 +0200
@@ -50,9 +50,9 @@
     private final boolean active;
     private final FileAccess fileAccess;
 
-    private ChunkParser chunkParser;
-    private long chunkStartNanos;
-    private RecordedEvent[] sortedList;
+    private ChunkParser currentParser;
+    private long currentChunkStartNanos;
+    private RecordedEvent[] sortedCache;
 
     public EventDirectoryStream(AccessControlContext acc, Path p, FileAccess fileAccess, boolean active) throws IOException {
         super(acc, active);
@@ -92,28 +92,28 @@
         if (path == null) { // closed
             return;
         }
-        chunkStartNanos = repositoryFiles.getTimestamp(path);
+        currentChunkStartNanos = repositoryFiles.getTimestamp(path);
         try (RecordingInput input = new RecordingInput(path.toFile(), fileAccess)) {
-            chunkParser = new ChunkParser(input, disp.parserConfiguration);
-            long segmentStart = chunkParser.getStartNanos() + chunkParser.getChunkDuration();
+            currentParser = new ChunkParser(input, disp.parserConfiguration);
+            long segmentStart = currentParser.getStartNanos() + currentParser.getChunkDuration();
             long filterStart = validStartTime ? disp.startNanos : segmentStart;
             long filterEnd = disp.endTime != null ? disp.endNanos: Long.MAX_VALUE;
 
             while (!isClosed()) {
                 boolean awaitnewEvent = false;
-                while (!isClosed() && !chunkParser.isChunkFinished()) {
+                while (!isClosed() && !currentParser.isChunkFinished()) {
                     disp = dispatcher();
                     ParserConfiguration pc = disp.parserConfiguration;
                     pc.filterStart = filterStart;
                     pc.filterEnd = filterEnd;
-                    chunkParser.updateConfiguration(pc, true);
-                    chunkParser.setFlushOperation(getFlushOperation());
-                    if (pc.ordered) {
+                    currentParser.updateConfiguration(pc, true);
+                    currentParser.setFlushOperation(getFlushOperation());
+                    if (pc.isOrdered()) {
                         awaitnewEvent = processOrdered(disp, awaitnewEvent);
                     } else {
                         awaitnewEvent = processUnordered(disp, awaitnewEvent);
                     }
-                    if (chunkParser.getStartNanos() + chunkParser.getChunkDuration() > filterEnd) {
+                    if (currentParser.getStartNanos() + currentParser.getChunkDuration() > filterEnd) {
                         close();
                         return;
                     }
@@ -122,14 +122,14 @@
                 if (isClosed()) {
                     return;
                 }
-                long durationNanos = chunkParser.getChunkDuration();
-                path = repositoryFiles.nextPath(chunkStartNanos + durationNanos);
+                long durationNanos = currentParser.getChunkDuration();
+                path = repositoryFiles.nextPath(currentChunkStartNanos + durationNanos);
                 if (path == null) {
                     return; // stream closed
                 }
-                chunkStartNanos = repositoryFiles.getTimestamp(path);
+                currentChunkStartNanos = repositoryFiles.getTimestamp(path);
                 input.setFile(path);
-                chunkParser = chunkParser.newChunkParser();
+                currentParser = currentParser.newChunkParser();
                 // TODO: Optimization. No need filter when we reach new chunk
                 // Could set start = 0;
             }
@@ -137,12 +137,12 @@
     }
 
     private boolean processOrdered(Dispatcher c, boolean awaitNewEvents) throws IOException {
-        if (sortedList == null) {
-            sortedList = new RecordedEvent[100_000];
+        if (sortedCache == null) {
+            sortedCache = new RecordedEvent[100_000];
         }
         int index = 0;
         while (true) {
-            RecordedEvent e = chunkParser.readStreamingEvent(awaitNewEvents);
+            RecordedEvent e = currentParser.readStreamingEvent(awaitNewEvents);
             if (e == null) {
                 // wait for new event with next call to
                 // readStreamingEvent()
@@ -150,29 +150,29 @@
                 break;
             }
             awaitNewEvents = false;
-            if (index == sortedList.length) {
-                sortedList = Arrays.copyOf(sortedList, sortedList.length * 2);
+            if (index == sortedCache.length) {
+                sortedCache = Arrays.copyOf(sortedCache, sortedCache.length * 2);
             }
-            sortedList[index++] = e;
+            sortedCache[index++] = e;
         }
 
         // no events found
-        if (index == 0 && chunkParser.isChunkFinished()) {
+        if (index == 0 && currentParser.isChunkFinished()) {
             return awaitNewEvents;
         }
         // at least 2 events, sort them
         if (index > 1) {
-            Arrays.sort(sortedList, 0, index, EVENT_COMPARATOR);
+            Arrays.sort(sortedCache, 0, index, EVENT_COMPARATOR);
         }
         for (int i = 0; i < index; i++) {
-            c.dispatch(sortedList[i]);
+            c.dispatch(sortedCache[i]);
         }
         return awaitNewEvents;
     }
 
     private boolean processUnordered(Dispatcher c, boolean awaitNewEvents) throws IOException {
         while (true) {
-            RecordedEvent e = chunkParser.readStreamingEvent(awaitNewEvents);
+            RecordedEvent e = currentParser.readStreamingEvent(awaitNewEvents);
             if (e == null) {
                 return true;
             } else {
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventFileStream.java	Wed Sep 18 03:45:46 2019 +0200
@@ -45,8 +45,9 @@
     private final static Comparator<? super RecordedEvent> EVENT_COMPARATOR = JdkJfrConsumer.instance().eventComparator();
 
     private final RecordingInput input;
-    private ChunkParser chunkParser;
-    private RecordedEvent[] sortedList;
+
+    private ChunkParser currentParser;
+    private RecordedEvent[] cacheSorted;
 
     public EventFileStream(AccessControlContext acc, Path path) throws IOException {
         super(acc, false);
@@ -87,56 +88,56 @@
             end = disp.endNanos;
         }
 
-        chunkParser = new ChunkParser(input, disp.parserConfiguration);
+        currentParser = new ChunkParser(input, disp.parserConfiguration);
         while (!isClosed()) {
-            if (chunkParser.getStartNanos() > end) {
+            if (currentParser.getStartNanos() > end) {
                 close();
                 return;
             }
             disp = dispatcher();
             disp.parserConfiguration.filterStart = start;
             disp.parserConfiguration.filterEnd = end;
-            chunkParser.updateConfiguration(disp.parserConfiguration, true);
-            chunkParser.setFlushOperation(getFlushOperation());
-            if (disp.parserConfiguration.ordered) {
+            currentParser.updateConfiguration(disp.parserConfiguration, true);
+            currentParser.setFlushOperation(getFlushOperation());
+            if (disp.parserConfiguration.isOrdered()) {
                 processOrdered(disp);
             } else {
                 processUnordered(disp);
             }
-            if (isClosed() || chunkParser.isLastChunk()) {
+            if (isClosed() || currentParser.isLastChunk()) {
                 return;
             }
-            chunkParser = chunkParser.nextChunkParser();
+            currentParser = currentParser.nextChunkParser();
         }
     }
 
     private void processOrdered(Dispatcher c) throws IOException {
-        if (sortedList == null) {
-            sortedList = new RecordedEvent[10_000];
+        if (cacheSorted == null) {
+            cacheSorted = new RecordedEvent[10_000];
         }
         RecordedEvent event;
         int index = 0;
         while (true) {
-            event = chunkParser.readEvent();
+            event = currentParser.readEvent();
             if (event == null) {
-                Arrays.sort(sortedList, 0, index, EVENT_COMPARATOR);
+                Arrays.sort(cacheSorted, 0, index, EVENT_COMPARATOR);
                 for (int i = 0; i < index; i++) {
-                    c.dispatch(sortedList[i]);
+                    c.dispatch(cacheSorted[i]);
                 }
                 return;
             }
-            if (index == sortedList.length) {
-                RecordedEvent[] tmp = sortedList;
-                sortedList = new RecordedEvent[2 * tmp.length];
-                System.arraycopy(tmp, 0, sortedList, 0, tmp.length);
+            if (index == cacheSorted.length) {
+                RecordedEvent[] tmp = cacheSorted;
+                cacheSorted = new RecordedEvent[2 * tmp.length];
+                System.arraycopy(tmp, 0, cacheSorted, 0, tmp.length);
             }
-            sortedList[index++] = event;
+            cacheSorted[index++] = event;
         }
     }
 
     private void processUnordered(Dispatcher c) throws IOException {
         while (!isClosed()) {
-            RecordedEvent event = chunkParser.readEvent();
+            RecordedEvent event = currentParser.readEvent();
             if (event == null) {
                 return;
             }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventParser.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/EventParser.java	Wed Sep 18 03:45:46 2019 +0200
@@ -40,7 +40,7 @@
  * Parses an event and returns a {@link RecordedEvent}.
  *
  */
-public final class EventParser extends Parser {
+final class EventParser extends Parser {
 
     private static final JdkJfrConsumer PRIVATE_ACCESS = JdkJfrConsumer.instance();
 
@@ -164,7 +164,7 @@
         cacheIndex = 0;
     }
 
-    public boolean hasReuse() {
+    private boolean hasReuse() {
         return cached != null;
     }
 
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectContext.java	Wed Sep 18 03:45:46 2019 +0200
@@ -24,6 +24,7 @@
  */
 package jdk.jfr.internal.consumer;
 
+import java.time.ZoneId;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -33,12 +34,12 @@
 
 public final class ObjectContext {
     private final Map<ValueDescriptor, ObjectContext> contextLookup;
+    private final TimeConverter timeConverter;
 
     public final EventType eventType;
     public final List<ValueDescriptor> fields;
-    public final TimeConverter timeConverter;
 
-    public ObjectContext(EventType eventType, List<ValueDescriptor> fields, TimeConverter timeConverter) {
+    ObjectContext(EventType eventType, List<ValueDescriptor> fields, TimeConverter timeConverter) {
         this.contextLookup = new HashMap<>();
         this.eventType = eventType;
         this.fields = fields;
@@ -60,4 +61,16 @@
         }
         return context;
     }
-}
+
+    public long convertTimestamp(long ticks) {
+        return timeConverter.convertTimestamp(ticks);
+    }
+
+    public long convertTimespan(long ticks) {
+        return timeConverter.convertTimespan(ticks);
+    }
+
+    public ZoneId getZoneOffset() {
+        return timeConverter.getZoneOffset();
+    }
+}
\ No newline at end of file
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ObjectFactory.java	Wed Sep 18 03:45:46 2019 +0200
@@ -40,12 +40,12 @@
 public abstract class ObjectFactory<T> {
     private static final JdkJfrConsumer PRIVATE_ACCESS = JdkJfrConsumer.instance();
 
-    public final static String TYPE_PREFIX_VERSION_1 = "com.oracle.jfr.types.";
-    public final static String TYPE_PREFIX_VERSION_2 = Type.TYPES_PREFIX;
+    private final static String TYPE_PREFIX_VERSION_1 = "com.oracle.jfr.types.";
+    private final static String TYPE_PREFIX_VERSION_2 = Type.TYPES_PREFIX;
     public final static String STACK_FRAME_VERSION_1 = TYPE_PREFIX_VERSION_1 + "StackFrame";
     public final static String STACK_FRAME_VERSION_2 = TYPE_PREFIX_VERSION_2 + "StackFrame";
 
-    public static ObjectFactory<?> create(Type type, TimeConverter timeConverter) {
+    static ObjectFactory<?> create(Type type, TimeConverter timeConverter) {
         switch (type.getName()) {
         case "java.lang.Thread":
             return createThreadFactory(type, timeConverter);
@@ -136,7 +136,7 @@
 
     private final ObjectContext objectContext;
 
-    ObjectFactory(Type type, TimeConverter timeConverter) {
+    private ObjectFactory(Type type, TimeConverter timeConverter) {
         this.objectContext = new ObjectContext(null, type.getFields(), timeConverter);
     }
 
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Parser.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/Parser.java	Wed Sep 18 03:45:46 2019 +0200
@@ -30,7 +30,7 @@
 /**
  * Base class for parsing data from a {@link RecordingInput}.
  */
-public abstract class Parser {
+abstract class Parser {
     /**
      * Parses data from a {@link RecordingInput} and return an object.
      *
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFactory.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFactory.java	Wed Sep 18 03:45:46 2019 +0200
@@ -53,6 +53,9 @@
         for (Type t : metadata.getTypes()) {
             types.put(t.getId(), t);
         }
+        // Add to separate list
+        // so createCompositeParser can throw
+        // IOException outside lambda
         List<Type> typeList = new ArrayList<>();
         types.forEach(typeList::add);
         for (Type t : typeList) {
@@ -61,7 +64,6 @@
                 if (t.isSimpleType()) { // Reduce to nested parser
                     parsers.put(t.getId(), cp.parsers[0]);
                 }
-
             }
         }
         // Override event types with event parsers
@@ -312,7 +314,7 @@
         }
     }
 
-    final static class CompositeParser extends Parser {
+    private final static class CompositeParser extends Parser {
         private final Parser[] parsers;
 
         public CompositeParser(Parser[] valueParsers) {
@@ -336,7 +338,7 @@
         }
     }
 
-    public static final class EventValueConstantParser extends Parser {
+    private static final class EventValueConstantParser extends Parser {
         private final ConstantLookup lookup;
         private Object lastValue = 0;
         private long lastKey = -1;
@@ -361,7 +363,7 @@
         }
     }
 
-    public static final class ConstantValueParser extends Parser {
+    private static final class ConstantValueParser extends Parser {
         private final ConstantLookup lookup;
         ConstantValueParser(ConstantLookup lookup) {
             this.lookup = lookup;
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFilter.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/ParserFilter.java	Wed Sep 18 03:45:46 2019 +0200
@@ -29,7 +29,7 @@
 import java.util.Map;
 import java.util.StringJoiner;
 
-public final class ParserFilter {
+final class ParserFilter {
     public static final ParserFilter ACCEPT_ALL = new ParserFilter(true, Map.of());
 
     private final Map<String, Long> thresholds;
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RecordingInput.java	Wed Sep 18 03:45:46 2019 +0200
@@ -74,7 +74,7 @@
     private long size = -1; // Fail fast if setSize(...) has not been called
                             // before parsing
 
-    public RecordingInput(File f, FileAccess fileAccess, int blockSize) throws IOException {
+    RecordingInput(File f, FileAccess fileAccess, int blockSize) throws IOException {
         this.blockSize = blockSize;
         this.fileAccess = fileAccess;
         initialize(f);
@@ -96,15 +96,15 @@
         this(f, fileAccess, DEFAULT_BLOCK_SIZE);
     }
 
-    public void positionPhysical(long position) throws IOException {
+    void positionPhysical(long position) throws IOException {
         file.seek(position);
     }
 
-    public final byte readPhysicalByte() throws IOException {
+    byte readPhysicalByte() throws IOException {
         return file.readByte();
     }
 
-    public long readPhysicalLong() throws IOException {
+    long readPhysicalLong() throws IOException {
         return file.readLong();
     }
 
@@ -130,7 +130,7 @@
         readFully(dst, 0, dst.length);
     }
 
-    public final short readRawShort() throws IOException {
+    short readRawShort() throws IOException {
         // copied from java.io.Bits
         byte b0 = readByte();
         byte b1 = readByte();
@@ -138,18 +138,18 @@
     }
 
     @Override
-    public final double readDouble() throws IOException {
+    public double readDouble() throws IOException {
         // copied from java.io.Bits
         return Double.longBitsToDouble(readRawLong());
     }
 
     @Override
-    public final float readFloat() throws IOException {
+    public float readFloat() throws IOException {
         // copied from java.io.Bits
         return Float.intBitsToFloat(readRawInt());
     }
 
-    public final int readRawInt() throws IOException {
+    int readRawInt() throws IOException {
         // copied from java.io.Bits
         byte b0 = readByte();
         byte b1 = readByte();
@@ -158,7 +158,7 @@
         return ((b3 & 0xFF)) + ((b2 & 0xFF) << 8) + ((b1 & 0xFF) << 16) + ((b0) << 24);
     }
 
-    public final long readRawLong() throws IOException {
+    long readRawLong() throws IOException {
         // copied from java.io.Bits
         byte b0 = readByte();
         byte b1 = readByte();
@@ -212,11 +212,12 @@
         return newPosition - blockSize / 2;
     }
 
-    public final long size() {
+    long size() {
         return size;
     }
 
-    public final void close() throws IOException {
+    @Override
+    public void close() throws IOException {
         file.close();
     }
 
@@ -284,69 +285,7 @@
         return (int) readLong();
     }
 
-    public long readLongExpanded() throws IOException {
-        final byte[] bytes = currentBlock.bytes;
-        final int index = (int) (position - currentBlock.blockPosition);
-
-        if (index + 8 < bytes.length && index >= 0) {
-            byte b0 = bytes[index];
-            if (b0 >= 0) {
-                position += 1;
-                return (b0 & 0x7FL);
-            }
-            int b1 = bytes[index + 1];
-            if (b1 >= 0) {
-                position += 2;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7);
-            }
-            int b2 = bytes[index + 2];
-            if (b2 >= 0) {
-                position += 3;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14);
-            }
-            int b3 = bytes[index + 3];
-            if (b3 >= 0) {
-                position += 4;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) + ((b3 & 0x7FL) << 21);
-            }
-            int b4 = bytes[index + 4];
-            if (b4 >= 0) {
-                position += 5;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) +
-                       ((b3 & 0x7FL) << 21) + ((b4 & 0x7FL) << 28);
-            }
-            int b5 = bytes[index + 5];
-            if (b5 >= 0) {
-                position += 6;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) +
-                       ((b3 & 0x7FL) << 21) + ((b4 & 0x7FL) << 28) + ((b5 & 0x7FL) << 35);
-            }
-            int b6 = bytes[index + 6];
-            if (b6 >= 0) {
-                position += 7;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) +
-                       ((b3 & 0x7FL) << 21) + ((b4 & 0x7FL) << 28) + ((b5 & 0x7FL) << 35) +
-                       ((b6 & 0x7FL) << 42);
-
-            }
-            int b7 = bytes[index + 7];
-            if (b7 >= 0) {
-                position += 8;
-                return (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) +
-                       ((b3 & 0x7FL) << 21) + ((b4 & 0x7FL) << 28) + ((b5 & 0x7FL) << 35) +
-                       ((b6 & 0x7FL) << 42) + ((b7 & 0x7FL) << 49);
-            }
-            int b8 = bytes[index + 8];// read last byte raw
-            position += 9;
-            long ret = (b0 & 0x7FL) + ((b1 & 0x7FL) << 7) + ((b2 & 0x7FL) << 14) +
-                   ((b3 & 0x7FL) << 21) + ((b4 & 0x7FL) << 28) + ((b5 & 0x7FL) << 35) +
-                   ((b6 & 0x7FL) << 42) + ((b7 & 0x7FL) << 49);
-            return ret + ((((long) (b8 & 0XFF)) << 56));
-        } else {
-            return readLongSlow();
-        }
-    }
-
+    @Override
     public long readLong() throws IOException {
         final byte[] bytes = currentBlock.bytes;
         final int index = (int) (position - currentBlock.blockPosition);
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/RepositoryFiles.java	Wed Sep 18 03:45:46 2019 +0200
@@ -59,24 +59,24 @@
     private volatile boolean closed;
     private final Object waitObject;
 
-    public RepositoryFiles(FileAccess fileAccess, Path repository) {
+    RepositoryFiles(FileAccess fileAccess, Path repository) {
         this.repository = repository;
         this.fileAccess = fileAccess;
         this.waitObject = repository == null ? WAIT_OBJECT : new Object();
     }
 
-    public long getTimestamp(Path p) {
+    long getTimestamp(Path p) {
         return pathLookup.get(p);
     }
 
-    public Path lastPath() {
+    Path lastPath() {
         if (waitForPaths()) {
             return pathSet.lastEntry().getValue();
         }
         return null; // closed
     }
 
-    public Path firstPath(long startTimeNanos) {
+    Path firstPath(long startTimeNanos) {
         if (waitForPaths()) {
             // Pick closest chunk before timestamp
             Long time = pathSet.floorKey(startTimeNanos);
@@ -106,7 +106,7 @@
         return !closed;
     }
 
-    public Path nextPath(long startTimeNanos) {
+    Path nextPath(long startTimeNanos) {
         return path(startTimeNanos);
     }
 
@@ -182,7 +182,7 @@
                 // Only add files that have a complete header
                 // as the JVM may be in progress writing the file
                 long size = fileAccess.fileSize(p);
-                if (size >= ChunkHeader.HEADER_SIZE) {
+                if (size >= ChunkHeader.headerSize()) {
                     long startNanos = readStartTime(p);
                     pathSet.put(startNanos, p);
                     pathLookup.put(p, startNanos);
@@ -200,7 +200,7 @@
         }
     }
 
-    public void close() {
+    void close() {
         synchronized (waitObject) {
             this.closed = true;
             waitObject.notify();
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StreamConfiguration.java	Wed Sep 18 03:45:46 2019 +0200
@@ -23,14 +23,14 @@
     long startNanos = 0;
     long endNanos = Long.MAX_VALUE;
 
-    volatile boolean changed = true;
+    private volatile boolean changed = true;
 
     public synchronized boolean remove(Object action) {
         boolean removed = false;
         removed |= flushActions.removeIf(e -> e == action);
         removed |= closeActions.removeIf(e -> e == action);
         removed |= errorActions.removeIf(e -> e == action);
-        removed |= eventActions.removeIf(e -> e.action == action);
+        removed |= eventActions.removeIf(e -> e.getAction() == action);
         if (removed) {
             changed = true;
         }
@@ -96,8 +96,4 @@
     public boolean hasChanged() {
         return changed;
     }
-
-    public synchronized void clearChanged() {
-        changed = false;
-    }
-}
+}
\ No newline at end of file
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StringEncoding.java	Tue Sep 17 19:37:49 2019 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2019, 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.
- *
- * 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 jdk.jfr.internal.consumer;
-
-public final class StringEncoding {
-    public final static byte STRING_ENCODING_NULL = (byte) 0;
-    public final static byte STRING_ENCODING_EMPTY_STRING = (byte) 1;
-    public final static byte STRING_ENCODING_CONSTANT_POOL = (byte) 2;
-    public final static byte STRING_ENCODING_UTF8_BYTE_ARRAY = (byte) 3;
-    public final static byte STRING_ENCODING_CHAR_ARRAY = (byte) 4;
-    public final static byte STRING_ENCODING_LATIN1_BYTE_ARRAY = (byte) 5;
-}
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StringParser.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/StringParser.java	Wed Sep 18 03:45:46 2019 +0200
@@ -28,15 +28,35 @@
 import java.io.IOException;
 import java.nio.charset.Charset;
 
-import jdk.jfr.internal.consumer.Parser;
-import jdk.jfr.internal.consumer.RecordingInput;
-import jdk.jfr.internal.consumer.StringEncoding;
+public final class StringParser extends Parser {
+
+    public enum Encoding {
+        NULL(0),
+        EMPTY_STRING(1),
+        CONSTANT_POOL(2),
+        UT8_BYTE_ARRAY(3),
+        CHAR_ARRAY(4),
+        LATIN1_BYTE_ARRAY(5);
+
+        private byte byteValue;
 
-public final class StringParser extends Parser {
+        private Encoding(int byteValue) {
+            this.byteValue = (byte) byteValue;
+        }
+
+        public byte byteValue() {
+            return byteValue;
+        }
+
+        public boolean is(byte value) {
+            return value == byteValue;
+        }
+
+    }
     private final static Charset UTF8 = Charset.forName("UTF-8");
     private final static Charset LATIN1 = Charset.forName("ISO-8859-1");
 
-    final static class CharsetParser extends Parser {
+    private final static class CharsetParser extends Parser {
         private final Charset charset;
         private int lastSize;
         private byte[] buffer = new byte[16];
@@ -86,7 +106,7 @@
         }
     }
 
-    final static class CharArrayParser extends Parser {
+    private final static class CharArrayParser extends Parser {
         private char[] buffer = new char[16];
         private int lastSize = -1;
         private String lastString = null;
@@ -146,7 +166,7 @@
     @Override
     public Object parse(RecordingInput input) throws IOException {
         byte encoding = input.readByte();
-        if (encoding == StringEncoding.STRING_ENCODING_CONSTANT_POOL) {
+        if (Encoding.CONSTANT_POOL.is(encoding)) {
             long key = input.readLong();
             if (event) {
                 return stringLookup.getCurrentResolved(key);
@@ -154,19 +174,19 @@
                 return stringLookup.getCurrent(key);
             }
         }
-        if (encoding == StringEncoding.STRING_ENCODING_NULL) {
+        if (Encoding.NULL.is(encoding)) {
             return null;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_EMPTY_STRING) {
+        if (Encoding.EMPTY_STRING.is(encoding)) {
             return "";
         }
-        if (encoding == StringEncoding.STRING_ENCODING_CHAR_ARRAY) {
+        if (Encoding.CHAR_ARRAY.is(encoding)) {
             return charArrayParser.parse(input);
         }
-        if (encoding == StringEncoding.STRING_ENCODING_UTF8_BYTE_ARRAY) {
+        if (Encoding.UT8_BYTE_ARRAY.is(encoding)) {
             return utf8parser.parse(input);
         }
-        if (encoding == StringEncoding.STRING_ENCODING_LATIN1_BYTE_ARRAY) {
+        if (Encoding.LATIN1_BYTE_ARRAY.is(encoding)) {
             return latin1parser.parse(input);
         }
         throw new IOException("Unknown string encoding " + encoding);
@@ -175,25 +195,25 @@
     @Override
     public void skip(RecordingInput input) throws IOException {
         byte encoding = input.readByte();
-        if (encoding == StringEncoding.STRING_ENCODING_CONSTANT_POOL) {
+        if (Encoding.CONSTANT_POOL.is(encoding)) {
             input.readLong();
             return;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_EMPTY_STRING) {
+        if (Encoding.EMPTY_STRING.is(encoding)) {
             return;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_NULL) {
+        if (Encoding.NULL.is(encoding)) {
             return;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_CHAR_ARRAY) {
+        if (Encoding.CHAR_ARRAY.is(encoding)) {
             charArrayParser.skip(input);
             return;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_UTF8_BYTE_ARRAY) {
+        if (Encoding.UT8_BYTE_ARRAY.is(encoding)) {
             utf8parser.skip(input);
             return;
         }
-        if (encoding == StringEncoding.STRING_ENCODING_LATIN1_BYTE_ARRAY) {
+        if (Encoding.LATIN1_BYTE_ARRAY.is(encoding)) {
             latin1parser.skip(input);
             return;
         }
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java	Tue Sep 17 19:37:49 2019 +0200
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/TimeConverter.java	Wed Sep 18 03:45:46 2019 +0200
@@ -36,7 +36,7 @@
 /**
  * Converts ticks to nanoseconds
  */
-public final class TimeConverter {
+final class TimeConverter {
     private final long startTicks;
     private final long startNanos;
     private final double divisor;