src/jdk.jfr/share/classes/jdk/jfr/consumer/RecordedObject.java
changeset 52981 4eff16f47ae2
parent 52850 f527b24990d7
child 57360 5d043a159d5c
child 58863 c16ac7a2eba4
equal deleted inserted replaced
52980:24525070d934 52981:4eff16f47ae2
   724         throw newIllegalArgumentException(name, "java,time.Duration");
   724         throw newIllegalArgumentException(name, "java,time.Duration");
   725     }
   725     }
   726 
   726 
   727     private Duration getDuration(long timespan, String name) throws InternalError {
   727     private Duration getDuration(long timespan, String name) throws InternalError {
   728         ValueDescriptor v = getValueDescriptor(descriptors, name, null);
   728         ValueDescriptor v = getValueDescriptor(descriptors, name, null);
       
   729         if (timespan == Long.MIN_VALUE) {
       
   730             return Duration.ofSeconds(Long.MIN_VALUE, 0);
       
   731         }
   729         Timespan ts = v.getAnnotation(Timespan.class);
   732         Timespan ts = v.getAnnotation(Timespan.class);
   730         if (ts != null) {
   733         if (ts != null) {
   731             switch (ts.value()) {
   734             switch (ts.value()) {
   732             case Timespan.MICROSECONDS:
   735             case Timespan.MICROSECONDS:
   733                 return Duration.ofNanos(1000 * timespan);
   736                 return Duration.ofNanos(1000 * timespan);
   795             }
   798             }
   796             if (u instanceof Byte) {
   799             if (u instanceof Byte) {
   797                 return getInstant(Short.toUnsignedLong((Byte) u), name);
   800                 return getInstant(Short.toUnsignedLong((Byte) u), name);
   798             }
   801             }
   799         }
   802         }
   800         throw newIllegalArgumentException(name, "java,time.Instant");
   803         throw newIllegalArgumentException(name, "java.time.Instant");
   801     }
   804     }
   802 
   805 
   803     private Instant getInstant(long timestamp, String name) {
   806     private Instant getInstant(long timestamp, String name) {
   804         ValueDescriptor v = getValueDescriptor(descriptors, name, null);
   807         ValueDescriptor v = getValueDescriptor(descriptors, name, null);
   805         Timestamp ts = v.getAnnotation(Timestamp.class);
   808         Timestamp ts = v.getAnnotation(Timestamp.class);
   806         if (ts != null) {
   809         if (ts != null) {
       
   810             if (timestamp == Long.MIN_VALUE) {
       
   811                 return Instant.MIN;
       
   812             }
   807             switch (ts.value()) {
   813             switch (ts.value()) {
   808             case Timestamp.MILLISECONDS_SINCE_EPOCH:
   814             case Timestamp.MILLISECONDS_SINCE_EPOCH:
   809                 return Instant.ofEpochMilli(timestamp);
   815                 return Instant.ofEpochMilli(timestamp);
   810             case Timestamp.TICKS:
   816             case Timestamp.TICKS:
   811                 return Instant.ofEpochSecond(0, timeConverter.convertTimestamp(timestamp));
   817                 return Instant.ofEpochSecond(0, timeConverter.convertTimestamp(timestamp));
   882         return s.toString();
   888         return s.toString();
   883     }
   889     }
   884 
   890 
   885     // package private for now. Used by EventWriter
   891     // package private for now. Used by EventWriter
   886     OffsetDateTime getOffsetDateTime(String name) {
   892     OffsetDateTime getOffsetDateTime(String name) {
       
   893         Instant instant = getInstant(name);
       
   894         if (instant.equals(Instant.MIN)) {
       
   895             return OffsetDateTime.MIN;
       
   896         }
   887         return OffsetDateTime.ofInstant(getInstant(name), timeConverter.getZoneOffset());
   897         return OffsetDateTime.ofInstant(getInstant(name), timeConverter.getZoneOffset());
   888     }
   898     }
   889 
   899 
   890     private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) {
   900     private static IllegalArgumentException newIllegalArgumentException(String name, String typeName) {
   891         return new IllegalArgumentException("Attempt to get field \"" + name + "\" with illegal data type conversion " + typeName);
   901         return new IllegalArgumentException("Attempt to get field \"" + name + "\" with illegal data type conversion " + typeName);