8310335: JFR: Modernize collections and switch statements

Reviewed-by: mgronlun
This commit is contained in:
Erik Gahlin 2023-06-21 15:07:42 +00:00
parent 826dcb5424
commit 59c6c0e1b7
91 changed files with 275 additions and 400 deletions

View File

@ -251,7 +251,7 @@ public final class ValueDescriptor {
*/
public String getTypeName() {
if (type.isSimpleType()) {
return type.getFields().get(0).getTypeName();
return type.getFields().getFirst().getTypeName();
}
return type.getName();
}

View File

@ -464,7 +464,6 @@ public sealed class RecordedObject
if (o instanceof Character c) {
return c;
}
throw newIllegalArgumentException(name, "char");
}
@ -495,23 +494,13 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final short getShort(String name) {
Object o = getValue(name, true);
if (o instanceof Short s) {
return s;
}
if (o instanceof Byte b) {
return b;
}
if (o instanceof UnsignedValue unsigned) {
Object u = unsigned.value();
if (u instanceof Short s) {
return s;
}
if (u instanceof Byte b) {
return (short) Byte.toUnsignedInt(b);
}
}
throw newIllegalArgumentException(name, "short");
return switch (getValue(name, true)) {
case Short s -> s;
case Byte b -> b;
case UnsignedValue(Short s) -> s;
case UnsignedValue(Byte b) -> (short) Byte.toUnsignedInt(b);
case null, default -> throw newIllegalArgumentException(name, "short");
};
}
/**
@ -542,32 +531,16 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final int getInt(String name) {
Object o = getValue(name, true);
if (o instanceof Integer i) {
return i;
}
if (o instanceof Short s) {
return s;
}
if (o instanceof Character c) {
return c;
}
if (o instanceof Byte b) {
return b;
}
if (o instanceof UnsignedValue unsigned) {
Object u = unsigned.value();
if (u instanceof Integer i) {
return i;
}
if (u instanceof Short s) {
return Short.toUnsignedInt(s);
}
if (u instanceof Byte b) {
return Byte.toUnsignedInt(b);
}
}
throw newIllegalArgumentException(name, "int");
return switch(getValue(name, true)) {
case Integer i -> i;
case Short s -> s;
case Character c -> c;
case Byte b -> b;
case UnsignedValue(Integer i) -> i;
case UnsignedValue(Short s) -> Short.toUnsignedInt(s);
case UnsignedValue(Byte b) -> Byte.toUnsignedInt(b);
case null, default -> throw newIllegalArgumentException(name, "short");
};
}
/**
@ -595,26 +568,15 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final float getFloat(String name) {
Object o = getValue(name);
if (o instanceof Float f) {
return f;
}
if (o instanceof Long l) {
return l;
}
if (o instanceof Integer i) {
return i;
}
if (o instanceof Short s) {
return s;
}
if (o instanceof Byte b) {
return b;
}
if (o instanceof Character c) {
return c;
}
throw newIllegalArgumentException(name, "float");
return switch(getValue(name)) {
case Float f -> f;
case Long l -> l;
case Integer i -> i;
case Short s -> s;
case Character c -> c;
case Byte b -> b;
case null, default -> throw newIllegalArgumentException(name, "float");
};
}
/**
@ -645,35 +607,17 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final long getLong(String name) {
Object o = getValue(name, true);
if (o instanceof Long l) {
return l;
}
if (o instanceof Integer i) {
return i;
}
if (o instanceof Short s) {
return s;
}
if (o instanceof Character c) {
return c;
}
if (o instanceof Byte b) {
return b.longValue();
}
if (o instanceof UnsignedValue unsigned) {
Object u = unsigned.value();
if (u instanceof Integer i) {
return Integer.toUnsignedLong(i);
}
if (u instanceof Short s) {
return Short.toUnsignedLong(s);
}
if (u instanceof Byte b) {
return Byte.toUnsignedLong(b);
}
}
throw newIllegalArgumentException(name, "long");
return switch(getValue(name, true)) {
case Long l -> l;
case Integer i -> i;
case Short s -> s;
case Character c -> c;
case Byte b -> b;
case UnsignedValue(Integer i) -> Integer.toUnsignedLong(i);
case UnsignedValue(Short s) -> Short.toUnsignedLong(s);
case UnsignedValue(Byte b) -> Byte.toUnsignedLong(b);
case null, default -> throw newIllegalArgumentException(name, "long");
};
}
/**
@ -701,29 +645,16 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final double getDouble(String name) {
Object o = getValue(name);
if (o instanceof Double d) {
return d.doubleValue();
}
if (o instanceof Float f) {
return f.doubleValue();
}
if (o instanceof Long l) {
return l.doubleValue();
}
if (o instanceof Integer i) {
return i.doubleValue();
}
if (o instanceof Short s) {
return s.doubleValue();
}
if (o instanceof Byte b) {
return b.doubleValue();
}
if (o instanceof Character c) {
return c;
}
throw newIllegalArgumentException(name, "double");
return switch(getValue(name)) {
case Double d -> d;
case Float f -> f;
case Long l -> l.doubleValue();
case Integer i -> i.doubleValue();
case Short s -> s.doubleValue();
case Character c -> c;
case Byte b -> b.doubleValue();
case null, default -> throw newIllegalArgumentException(name, "double");
};
}
/**
@ -777,35 +708,17 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final Duration getDuration(String name) {
Object o = getValue(name);
if (o instanceof Long l) {
return getDuration(l, name);
}
if (o instanceof Integer i) {
return getDuration(i, name);
}
if (o instanceof Short s) {
return getDuration(s, name);
}
if (o instanceof Character c) {
return getDuration(c, name);
}
if (o instanceof Byte b) {
return getDuration(b, name);
}
if (o instanceof UnsignedValue unsigned) {
Object u = unsigned.value();
if (u instanceof Integer i) {
return getDuration(Integer.toUnsignedLong(i), name);
}
if (u instanceof Short s) {
return getDuration(Short.toUnsignedLong(s), name);
}
if (u instanceof Byte b) {
return getDuration(Short.toUnsignedLong(b), name);
}
}
throw newIllegalArgumentException(name, "java.time.Duration");
return switch (getValue(name, true)) {
case Long l -> getDuration(l, name);
case Integer i -> getDuration(i,name);
case Short s -> getDuration(s, name);
case Character c -> getDuration(c, name);
case Byte b -> getDuration(b, name);
case UnsignedValue(Integer i) -> getDuration(Integer.toUnsignedLong(i), name);
case UnsignedValue(Short s) -> getDuration(Short.toUnsignedLong(s), name);
case UnsignedValue(Byte b) -> getDuration(Short.toUnsignedLong(b), name);
case null, default -> throw newIllegalArgumentException(name, "java.time.Duration");
};
}
private Duration getDuration(long timespan, String name) {
@ -821,19 +734,14 @@ public sealed class RecordedObject
}
Timespan ts = v.getAnnotation(Timespan.class);
if (ts != null) {
switch (ts.value()) {
case Timespan.MICROSECONDS:
return Duration.ofNanos(1000 * timespan);
case Timespan.SECONDS:
return Duration.ofSeconds(timespan);
case Timespan.MILLISECONDS:
return Duration.ofMillis(timespan);
case Timespan.NANOSECONDS:
return Duration.ofNanos(timespan);
case Timespan.TICKS:
return Duration.ofNanos(objectContext.convertTimespan(timespan));
}
throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value());
return switch (ts.value()) {
case Timespan.MICROSECONDS -> Duration.ofNanos(1000 * timespan);
case Timespan.SECONDS -> Duration.ofSeconds(timespan);
case Timespan.MILLISECONDS -> Duration.ofMillis(timespan);
case Timespan.NANOSECONDS -> Duration.ofNanos(timespan);
case Timespan.TICKS -> Duration.ofNanos(objectContext.convertTimespan(timespan));
default -> throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timespan unit " + ts.value());
};
}
throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timespan");
}
@ -862,35 +770,17 @@ public sealed class RecordedObject
* @see #getValue(String)
*/
public final Instant getInstant(String name) {
Object o = getValue(name, true);
if (o instanceof Long l) {
return getInstant(l, name);
}
if (o instanceof Integer i) {
return getInstant(i, name);
}
if (o instanceof Short s) {
return getInstant(s, name);
}
if (o instanceof Character c) {
return getInstant(c, name);
}
if (o instanceof Byte b) {
return getInstant(b, name);
}
if (o instanceof UnsignedValue unsigned) {
Object u = unsigned.value();
if (u instanceof Integer i) {
return getInstant(Integer.toUnsignedLong(i), name);
}
if (u instanceof Short s) {
return getInstant(Short.toUnsignedLong(s), name);
}
if (u instanceof Byte b) {
return getInstant(Short.toUnsignedLong(b), name);
}
}
throw newIllegalArgumentException(name, "java.time.Instant");
return switch (getValue(name, true)) {
case Long l -> getInstant(l, name);
case Integer i -> getInstant(i, name);
case Short s -> getInstant(s, name);
case Character c -> getInstant(c, name);
case Byte b -> getInstant(b, name);
case UnsignedValue(Integer i) -> getInstant(Integer.toUnsignedLong(i), name);
case UnsignedValue(Short s) -> getInstant(Short.toUnsignedLong(s), name);
case UnsignedValue(Byte b) -> getInstant(Short.toUnsignedLong(b), name);
case null, default -> throw newIllegalArgumentException(name, "java.time.Instant");
};
}
private Instant getInstant(long timestamp, String name) {
@ -900,13 +790,11 @@ public sealed class RecordedObject
if (timestamp == Long.MIN_VALUE) {
return Instant.MIN;
}
switch (ts.value()) {
case Timestamp.MILLISECONDS_SINCE_EPOCH:
return Instant.ofEpochMilli(timestamp);
case Timestamp.TICKS:
return Instant.ofEpochSecond(0, objectContext.convertTimestamp(timestamp));
}
throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value());
return switch (ts.value()) {
case Timestamp.MILLISECONDS_SINCE_EPOCH -> Instant.ofEpochMilli(timestamp);
case Timestamp.TICKS -> Instant.ofEpochSecond(0, objectContext.convertTimestamp(timestamp));
default -> throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with illegal timestamp unit " + ts.value());
};
}
throw new IllegalArgumentException("Attempt to get " + v.getTypeName() + " field \"" + name + "\" with missing @Timestamp");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, 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
@ -54,7 +54,7 @@ public class Snippets {
.filter(e -> e.getEventType().getName().equals("jdk.ExecutionSample"))
.map(e -> e.getStackTrace())
.filter(s -> s != null)
.map(s -> s.getFrames().get(0))
.map(s -> s.getFrames().getFirst())
.filter(f -> f.isJavaFrame())
.map(f -> f.getMethod())
.collect(

View File

@ -227,7 +227,7 @@ public final class EventInstrumentation {
for (AnnotationNode nameCandidate : m.visibleAnnotations) {
if (ANNOTATION_NAME_DESCRIPTOR.equals(nameCandidate.desc)) {
List<Object> values = nameCandidate.values;
if (values.size() == 1 && values.get(0)instanceof String s) {
if (values.size() == 1 && values.getFirst() instanceof String s) {
name = Utils.validJavaIdentifier(s, name);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
@ -28,7 +28,7 @@ package jdk.jfr.internal;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.SequencedSet;
import jdk.jfr.internal.SecuritySupport.SafePath;
@ -36,7 +36,7 @@ import jdk.jfr.internal.SecuritySupport.SafePath;
// so they can a later staged be removed.
final class FilePurger {
private static final Set<SafePath> paths = new LinkedHashSet<>();
private static final SequencedSet<SafePath> paths = new LinkedHashSet<>();
public static synchronized void add(SafePath p) {
paths.add(p);
@ -58,8 +58,7 @@ final class FilePurger {
}
private static void removeOldest() {
SafePath oldest = paths.iterator().next();
paths.remove(oldest);
paths.removeFirst();
}
private static boolean delete(SafePath p) {

View File

@ -75,12 +75,12 @@ final class MetadataReader {
}
descriptor = new MetadataDescriptor();
Element root = createElement();
Element metadata = root.elements("metadata").get(0);
Element metadata = root.elements("metadata").getFirst();
declareTypes(metadata);
defineTypes(metadata);
annotateTypes(metadata);
buildEvenTypes();
Element time = root.elements("region").get(0);
Element time = root.elements("region").getFirst();
descriptor.gmtOffset = time.attribute(MetadataDescriptor.ATTRIBUTE_GMT_OFFSET, 1);
descriptor.dst = time.attribute(MetadataDescriptor.ATTRIBUTE_DST, 0L);
descriptor.locale = time.attribute(MetadataDescriptor.ATTRIBUTE_LOCALE, "");

View File

@ -100,7 +100,7 @@ public final class PlatformRecorder {
jvm.exclude(t);
t.start();
t.join();
return result.get(0);
return result.getFirst();
} catch (InterruptedException e) {
throw new IllegalStateException("Not able to create timer task. " + e.getMessage(), e);
}

View File

@ -797,7 +797,7 @@ public final class PlatformRecording implements AutoCloseable {
}
// always keep at least one chunk
if (result.isEmpty()) {
result.add(input.get(0));
result.add(input.getFirst());
}
return result;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -67,7 +67,7 @@ public final class CompositeParser extends Parser {
return null;
}
if (refs.size() == 1) {
return refs.get(0);
return refs.getFirst();
}
return refs.toArray();
}

View File

@ -110,14 +110,14 @@ final class ArgumentParser {
sb.append("s ");
StringJoiner sj = new StringJoiner(", ");
while (conflictedOptions.size() > 1) {
sj.add(conflictedOptions.remove(0));
sj.add(conflictedOptions.removeFirst());
}
sb.append(sj);
sb.append(" and");
}
sb.append(" ");
sb.append(conflictedOptions.remove(0));
sb.append(conflictedOptions.removeFirst());
sb.append(" can only be specified once.");
throw new IllegalArgumentException(sb.toString());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -303,18 +303,13 @@ public final class JFC {
}
private static String exceptionToVerb(Exception e) {
if (e instanceof FileNotFoundException || e instanceof NoSuchFileException) {
return "find";
}
if (e instanceof ParseException) {
return "parse";
}
if (e instanceof JFCModelException) {
return "use";
}
if (e instanceof AccessDeniedException) {
return "access";
}
return "open"; // InvalidPath, IOException
return switch (e) {
case FileNotFoundException f -> "find";
case NoSuchFileException n -> "find";
case ParseException p -> "parse";
case JFCModelException j -> "use";
case AccessDeniedException a -> "access";
default -> "open"; // InvalidPath, IOException
};
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -175,7 +175,7 @@ class XmlElement {
if (producers.size() != 1) {
throw new Error("Unsure how to evaluate multiple producers " + getClass());
}
return producers.get(0).evaluate();
return producers.getFirst().evaluate();
}
protected void validateAttributes() throws JFCModelException {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -45,7 +45,7 @@ final class XmlNot extends XmlExpression {
protected Result evaluate() {
List<XmlElement> producers = getProducers();
if (!producers.isEmpty()) {
Result r = producers.get(0).evaluate();
Result r = producers.getFirst().evaluate();
if (!r.isNull()) {
return r.isTrue() ? Result.FALSE : Result.TRUE;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -121,6 +121,6 @@ final class XmlSelection extends XmlInput {
return optionElement;
}
}
return options.isEmpty() ? null : options.get(0);
return options.isEmpty() ? null : options.getFirst();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -71,7 +71,7 @@ final class XmlTest extends XmlExpression {
Result ret = Result.NULL;
List<XmlElement> producers = getProducers();
if (!producers.isEmpty()) {
XmlElement producer = producers.get(0);
XmlElement producer = producers.getFirst();
Result r = producer.evaluate();
if (!r.isNull()) {
ret = getValue().equals(r.value()) ? Result.TRUE : Result.FALSE;

View File

@ -254,15 +254,11 @@ final class FieldBuilder {
private void configureNumericTypes() {
switch (descriptor.getTypeName()) {
case "int":
case "long":
case "short":
case "byte":
case "int", "long", "short", "byte":
field.integralType = true;
field.alignLeft = false;
break;
case "float":
case "double":
case "float", "double":
field.fractionalType = true;
field.alignLeft = false;
break;

View File

@ -331,7 +331,7 @@ final class TableRenderer {
for (TableCell cell : tableCells) {
maxHeight = Math.max(cell.getHeight(), maxHeight);
}
TableCell lastCell = tableCells.get(tableCells.size() - 1);
TableCell lastCell = tableCells.getLast();
for (int rowIndex = 0; rowIndex < maxHeight; rowIndex++) {
for (TableCell cell : tableCells) {
if (rowIndex < cell.getHeight()) {

View File

@ -110,8 +110,7 @@ final class ViewFile {
String key = tokenizer.next();
tokenizer.expect("=");
String value = tokenizer.next();
ViewConfiguration view = views.get(views.size() - 1);
view.properties().put(key, value);
views.getLast().properties().put(key, value);
}
}
return views;

View File

@ -122,7 +122,7 @@ abstract class Command {
StringBuilder sb = new StringBuilder();
if (aliases.size() == 1) {
sb.append(" (alias ");
sb.append(aliases.get(0));
sb.append(aliases.getFirst());
sb.append(")");
return sb.toString();
}

View File

@ -181,7 +181,7 @@ final class Disassemble extends Command {
private List<Long> combineChunkSizes(List<Long> sizes, int maxChunks, long maxSize) {
List<Long> reduced = new ArrayList<Long>();
int chunks = 1;
long fileSize = sizes.get(0);
long fileSize = sizes.getFirst();
for (int i = 1; i < sizes.size(); i++) {
long size = sizes.get(i);
if (fileSize + size > maxSize || chunks == maxChunks) {

View File

@ -96,7 +96,7 @@ public class Filters {
return t -> true;
}
if (filters.size() == 1) {
return filters.get(0);
return filters.getFirst();
}
return t -> {
for (Predicate<T> p : filters) {

View File

@ -418,7 +418,7 @@ public final class PrettyWriter extends EventPrintWriter {
if (clazz != null) {
String className = clazz.getName();
if (className!= null && className.startsWith("[")) {
className = decodeDescriptors(className, arraySize > 0 ? Long.toString(arraySize) : "").get(0);
className = decodeDescriptors(className, arraySize > 0 ? Long.toString(arraySize) : "").getFirst();
}
print(className);
String description = object.getString("description");
@ -484,7 +484,7 @@ public final class PrettyWriter extends EventPrintWriter {
}
String className = clazz.getName();
if (className.startsWith("[")) {
className = decodeDescriptors(className, "").get(0);
className = decodeDescriptors(className, "").getFirst();
}
println(className + " (classLoader = " + classLoaderName + ")" + postFix);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -65,7 +65,7 @@ public class TestFieldAccess {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
testHasField(event);
testGetField(event, myEvent);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -57,7 +57,7 @@ public final class TestMethodGetModifiers {
List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
Events.hasEvents(recordedEvents);
RecordedEvent recordedEvent = recordedEvents.get(0);
RecordedEvent recordedEvent = recordedEvents.getFirst();
System.out.println(recordedEvent);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -66,7 +66,7 @@ public class TestRecordedEvent {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
Asserts.assertEquals(events.size(), 1);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
List<ValueDescriptor> descriptors = event.getFields();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -56,7 +56,7 @@ public class TestRecordedEventGetThread {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
RecordedThread recordedThread = event.getThread();
Asserts.assertNotNull(recordedThread);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -85,7 +85,7 @@ public class TestRecordedEventGetThreadOther {
List<RecordedEvent> events = RecordingFile.readAllEvents(dumpFilePath);
Asserts.assertEquals(events.size(), 1);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
RecordedThread recordedThread = event.getThread();
Asserts.assertNotNull(recordedThread);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -68,7 +68,7 @@ public final class TestRecordedFrame {
List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
Events.hasEvents(recordedEvents);
RecordedEvent recordedEvent = recordedEvents.get(0);
RecordedEvent recordedEvent = recordedEvents.getFirst();
RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
List<RecordedFrame> frames = stacktrace.getFrames();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -151,7 +151,7 @@ public class TestRecordedFullStackTrace {
boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);
String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
String firstMethod = frames.getLast().getMethod().getName();
boolean isFullTrace = "run".equals(firstMethod);
String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
Asserts.assertTrue(isTruncated != isFullTrace, msg);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -50,7 +50,7 @@ public class TestRecordedInstantEventTimestamp {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
Asserts.assertEquals(event.getStartTime(), event.getEndTime());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -65,7 +65,7 @@ public final class TestRecordedMethodDescriptor {
List<RecordedEvent> recordedEvents = Events.fromRecording(recording);
assertEquals(1, recordedEvents.size(), "Expected one event");
RecordedEvent recordedEvent = recordedEvents.get(0);
RecordedEvent recordedEvent = recordedEvents.getFirst();
RecordedStackTrace stacktrace = recordedEvent.getStackTrace();
List<RecordedFrame> frames = stacktrace.getFrames();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -392,7 +392,7 @@ public class TestRecordedObject {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
return events.get(0);
return events.getFirst();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -58,7 +58,7 @@ public class TestSingleRecordedEvent {
// Should be 1 event only
Asserts.assertEquals(events.size(), 1);
RecordedEvent recordedEvent = events.get(0);
RecordedEvent recordedEvent = events.getFirst();
Asserts.assertEquals(recordedEvent.getEventType().getDescription(), "MyDescription");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -61,7 +61,7 @@ public class TestToString {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
Events.hasEvents(events);
RecordedEvent e = events.get(0);
RecordedEvent e = events.getFirst();
String toString = e.toString();
System.out.println(toString);
Asserts.assertTrue(toString.contains("hello, world"), "Missing String field value in RecordedEvent#toString()");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -61,7 +61,7 @@ public class TestValueDescriptorRecorded {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent recordedEvent = events.get(0);
RecordedEvent recordedEvent = events.getFirst();
for (ValueDescriptor desc : recordedEvent.getFields()) {
if ("myValue".equals(desc.getName())) {
Asserts.assertEquals(desc.getLabel(), "myLabel");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -67,7 +67,7 @@ public class TestOnMetadata {
AtomicBoolean fail = new AtomicBoolean();
try (RecordingStream r = new RecordingStream()) {
r.onMetadata(m -> {
EventType t = FlightRecorder.getFlightRecorder().getEventTypes().get(0);
EventType t = FlightRecorder.getFlightRecorder().getEventTypes().getFirst();
try {
m.getEventTypes().add(t);
System.out.println("Should not be able to modify getEventTypes()");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
@ -47,7 +47,7 @@ public class TestStoppedRecording {
CountDownLatch latch = new CountDownLatch(1);
try (RecordingStream rs = new RecordingStream()) {
rs.onEvent(e -> {
FlightRecorder.getFlightRecorder().getRecordings().get(0).stop();
FlightRecorder.getFlightRecorder().getRecordings().getFirst().stop();
});
rs.onClose(() -> {
latch.countDown();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2023, 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
@ -55,7 +55,7 @@ public class TestEventDuration {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
if (events.get(0).getDuration().toNanos() < 1) {
if (events.getFirst().getDuration().toNanos() < 1) {
throw new AssertionError("Expected a duration");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -138,7 +138,7 @@ public class TestDynamicAnnotations {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
Events.assertField(events.get(0), "ecid").equal(ecidValue);
Events.assertField(events.getFirst(), "ecid").equal(ecidValue);
}
EventType type = f.getEventType();
ECID e = type.getAnnotation(ECID.class);
@ -175,7 +175,7 @@ public class TestDynamicAnnotations {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent re = events.get(0);
RecordedEvent re = events.getFirst();
Array arrayAnnotation = re.getEventType().getAnnotation(Array.class);
if (arrayAnnotation== null) {
throw new Exception("Missing array annotation");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -72,7 +72,7 @@ public class TestSnapshot {
}
try (Recording snapshot = recorder.takeSnapshot()) {
Asserts.assertEquals(snapshot.getSize(), size);
Asserts.assertGreaterThanOrEqual(snapshot.getStartTime(), recordings.get(0).getStartTime());
Asserts.assertGreaterThanOrEqual(snapshot.getStartTime(), recordings.getFirst().getStartTime());
Asserts.assertLessThanOrEqual(snapshot.getStopTime(), recordings.get(RECORDING_COUNT - 1).getStopTime());
Asserts.assertGreaterThanOrEqual(snapshot.getDuration(), Duration.ZERO);
assertStaticOptions(snapshot);
@ -122,7 +122,7 @@ public class TestSnapshot {
List<RecordedEvent> events = Events.fromRecording(snapshot);
Events.hasEvents(events);
Asserts.assertEquals(events.size(), 1);
Asserts.assertEquals(events.get(0).getEventType().getName(), SimpleEvent.class.getName());
Asserts.assertEquals(events.getFirst().getEventType().getName(), SimpleEvent.class.getName());
}
r.stop();
@ -162,7 +162,7 @@ public class TestSnapshot {
List<RecordedEvent> events = Events.fromRecording(snapshot);
Events.hasEvents(events);
Asserts.assertEquals(events.size(), 1);
Asserts.assertEquals(events.get(0).getEventType().getName(), SimpleEvent.class.getName());
Asserts.assertEquals(events.getFirst().getEventType().getName(), SimpleEvent.class.getName());
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -269,7 +269,7 @@ public class TestName {
private static void assertIllegalFieldName(Class<? extends Event> eventClass) throws Exception {
EventType type = EventType.getEventType(eventClass);
if (type.getField("field") == null) {
String illegal = type.getFields().get(type.getFields().size() - 1).getName();
String illegal = type.getFields().getLast().getName();
throw new Exception("Expected default field name 'field' for event " + type.getName() + ", not illegal name " + illegal);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -98,12 +98,12 @@ public class TestGetAnnotationElements {
EventFactory f = EventFactory.create(eventAnnotations, fields);
EventType type = f.getEventType();
List<AnnotationElement> aes = type.getAnnotationElements().get(0).getAnnotationElements();
List<AnnotationElement> aes = type.getAnnotationElements().getFirst().getAnnotationElements();
Asserts.assertEquals(0, aes.size());
EventType et = EventType.getEventType(MyEvent.class);
ValueDescriptor field = et.getField("transactionRate");
aes = field.getAnnotationElements().get(0).getAnnotationElements();
aes = field.getAnnotationElements().getFirst().getAnnotationElements();
Asserts.assertEquals(3, aes.size());
assertContainsAnnotation(aes, Description.class);
assertContainsAnnotation(aes, Label.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -45,7 +45,7 @@ public class TestGetCategory {
List<String> noCategory = EventType.getEventType(NoCategory.class).getCategoryNames();
System.out.println("noCategory=" + noCategory);
Asserts.assertEquals(noCategory.size(), 1, "Wrong default category");
Asserts.assertEquals(noCategory.get(0), "Uncategorized", "Wrong default category");
Asserts.assertEquals(noCategory.getFirst(), "Uncategorized", "Wrong default category");
List<String> withCategory = EventType.getEventType(WithCategory.class).getCategoryNames();
Asserts.assertEquals(withCategory.size(), 4, "Wrong category");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -46,7 +46,7 @@ public class TestGetSettings {
// test immutability
try {
settings.add(settings.get(0));
settings.add(settings.getFirst());
Asserts.fail("Should not be able to modify list returned by getSettings()");
} catch (UnsupportedOperationException uoe) {
// OK, as expected

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -59,7 +59,7 @@ public class TestConstructor {
// Get labelA from getAnnotations() list
Asserts.assertEquals(1, vdComplex.getAnnotationElements().size(), "Expected getAnnotations().size() == 1");
final AnnotationElement outAnnotation = vdComplex.getAnnotationElements().get(0);
final AnnotationElement outAnnotation = vdComplex.getAnnotationElements().getFirst();
Asserts.assertNotNull(outAnnotation, "outAnnotation was null");
System.out.printf("Annotation: %s = %s%n", outAnnotation.getTypeName(), outAnnotation.getValue("value"));
Asserts.assertEquals(outAnnotation, labelA, "Expected firstAnnotation == labelA");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -94,7 +94,7 @@ public class MainTest {
private static void assertMetaAnnotation(List<AnnotationElement> aes) {
assertEquals(aes.size(), 1, "@ModularizedAnnotation should only have one meta-annotation");
AnnotationElement ae = aes.get(0);
AnnotationElement ae = aes.getFirst();
assertEquals(ae.getTypeName(), ModularizedAnnotation.class.getName(), "Incorrect meta-annotation");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -59,7 +59,7 @@ public class TestDestFileExist {
r.stop();
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No events found");
System.out.println(events.iterator().next());
System.out.println(events.getFirst());
r.close();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -92,7 +92,7 @@ public class TestDestInvalid {
Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest);
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s in %s%n", events.get(0).getEventType().getName(), dest.toString());
System.out.printf("Found event %s in %s%n", events.getFirst().getEventType().getName(), dest.toString());
}
private static void verifyException(VoidFunction f, String msg, Class<?> exceptionClass) throws Throwable {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -58,7 +58,7 @@ public class TestDestLongPath {
Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest);
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -72,7 +72,7 @@ public class TestDestReadOnly {
Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest);
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s in %s%n", events.get(0).getEventType().getName(), dest.toString());
System.out.printf("Found event %s in %s%n", events.getFirst().getEventType().getName(), dest.toString());
}
private static void verifyException(VoidFunction f, String msg) throws Throwable {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -70,7 +70,7 @@ public class TestDestState {
Asserts.assertTrue(Files.exists(runningDest), "No recording file: " + runningDest);
List<RecordedEvent> events = RecordingFile.readAllEvents(runningDest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
r.close();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -66,7 +66,7 @@ public class TestDestToDiskFalse {
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
assertEquals(r.getSize(), 0L, "getSize() should return 0, chunks should have been released at stop");
// getDestination() should return null after recording have been written to file.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -61,7 +61,7 @@ public class TestDestToDiskTrue {
Asserts.assertTrue(Files.exists(dest), "No recording file: " + dest);
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
System.out.printf("File size=%d, getSize()=%d%n", Files.size(dest), r.getSize());
assertEquals(r.getSize(), 0L, "getSize() should return 0, chunks should have be released at stop");
Asserts.assertNotEquals(Files.size(dest), 0L, "File length 0. Should at least be some bytes");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -68,7 +68,7 @@ public class TestDestWithDuration {
List<RecordedEvent> events = RecordingFile.readAllEvents(dest);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -60,7 +60,7 @@ public class TestDumpLongPath {
Asserts.assertTrue(Files.exists(path), "Recording file does not exist: " + path);
List<RecordedEvent> events = RecordingFile.readAllEvents(path);
Asserts.assertFalse(events.isEmpty(), "No events found");
String foundEventPath = events.get(0).getEventType().getName();
String foundEventPath = events.getFirst().getEventType().getName();
System.out.printf("Found event: %s%n", foundEventPath);
Asserts.assertEquals(foundEventPath, eventPath, "Wrong event");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -68,7 +68,7 @@ public class TestChunkPeriod {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Asserts.assertEquals(events.size(), 1, "Expected one event with beginChunk");
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
Asserts.assertGreaterThanOrEqual(event.getStartTime(), beforeStart);
Asserts.assertGreaterThanOrEqual(afterStart, event.getStartTime());
r.close();
@ -83,7 +83,7 @@ public class TestChunkPeriod {
Instant afterStop = Instant.now().plus(MARGIN_OF_ERROR);
List<RecordedEvent> events = Events.fromRecording(r);
Asserts.assertEquals(events.size(), 1, "Expected one event with endChunk");
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
Asserts.assertGreaterThanOrEqual(event.getStartTime(), beforeStop);
Asserts.assertGreaterThanOrEqual(afterStop, event.getStartTime());
r.close();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -126,7 +126,7 @@ public class TestRecordingCopy {
Events.hasEvents(recordedEvents);
Asserts.assertEquals(1, recordedEvents.size(), "Expected exactly one event");
RecordedEvent re = recordedEvents.get(0);
RecordedEvent re = recordedEvents.getFirst();
Asserts.assertEquals(EVENT_ID, re.getValue("id"));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -60,7 +60,7 @@ public class TestCodeCacheConfig {
List<RecordedEvent> events = Events.fromRecording(recording);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
long initialSize = (long) event.getValue("initialSize");
long reservedSize = (long) event.getValue("reservedSize");
long nonNMethodSize = (long) event.getValue("nonNMethodSize");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -67,7 +67,7 @@ public class TestCodeCacheFull {
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
String codeBlobType = Events.assertField(event, "codeBlobType").notNull().getValue();
BlobType blobType = blobTypeFromName(codeBlobType);

View File

@ -60,7 +60,7 @@ public class TestHeapDump {
if (events.size() != 1) {
throw new Exception("Expected one event, got " + events.size());
}
RecordedEvent e = events.get(0);
RecordedEvent e = events.getFirst();
Events.assertField(e, "destination").equal(path.toString());
Events.assertField(e, "gcBeforeDump").equal(true);
Events.assertField(e, "onOutOfMemoryError").equal(false);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -60,7 +60,7 @@ public class TestSystemGC {
Asserts.assertEquals(3, events.size(), "Expected 3 SystemGC events");
RecordedEvent event1 = events.get(0);
RecordedEvent event1 = events.getFirst();
Events.assertFrame(event1, System.class, "gc");
Events.assertEventThread(event1, Thread.currentThread());
Events.assertField(event1, "invokedConcurrent").isEqual(concurrent);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -42,7 +42,7 @@ public abstract class GCHeapConfigurationEventTester {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
EventVerifier v = createVerifier(events.get(0));
EventVerifier v = createVerifier(events.getFirst());
v.verify();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -41,7 +41,7 @@ public abstract class GCYoungGenerationConfigurationEventTester {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
EventVerifier v = createVerifier(events.get(0));
EventVerifier v = createVerifier(events.getFirst());
v.verify();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -50,7 +50,7 @@ public class TestGCConfigurationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
GCConfigurationEventVerifier verifier = new GCConfigurationEventVerifier(events.get(0));
GCConfigurationEventVerifier verifier = new GCConfigurationEventVerifier(events.getFirst());
verifier.verify();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -48,7 +48,7 @@ public class TestGCConfigurationEventWithDefaultPauseTarget {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
DefaultGCConfigurationVerifier verifier = new DefaultGCConfigurationVerifier(events.get(0));
DefaultGCConfigurationVerifier verifier = new DefaultGCConfigurationVerifier(events.getFirst());
verifier.verify();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -49,7 +49,7 @@ public class TestGCSurvivorConfigurationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
GCSurvivorConfigurationEventVerifier verifier = new GCSurvivorConfigurationEventVerifier(events.get(0));
GCSurvivorConfigurationEventVerifier verifier = new GCSurvivorConfigurationEventVerifier(events.getFirst());
verifier.verify();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -49,7 +49,7 @@ public class TestGCTLABConfigurationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertGreaterThanOrEqual(events.size(), 1, "Expected at least 1 event");
GCTLABConfigurationEventVerifier verifier = new GCTLABConfigurationEventVerifier(events.get(0));
GCTLABConfigurationEventVerifier verifier = new GCTLABConfigurationEventVerifier(events.getFirst());
verifier.verify();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -157,7 +157,7 @@ public class StressAllocationGCEvents {
List<RecordedFrame> frames = stackTrace.getFrames();
//String[] stacktrace = StackTraceHelper.buildStackTraceFromFrames(frames);
if (!(frames.get(0).getMethod().getName().equals(DIVER_FRAME_NAME))) {
if (!(frames.getFirst().getMethod().getName().equals(DIVER_FRAME_NAME))) {
System.out.println("Skip stacktrace check for: \n"
+ String.join("\n", threadName));
return;

View File

@ -50,7 +50,7 @@ public class TestGCHeapMemoryPoolUsageEvent {
System.out.println(events);
assertFalse(events.isEmpty());
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
Events.assertField(event, "name").notNull();
Events.assertField(event, "used").atLeast(0L);
Events.assertField(event, "committed").atLeast(0L);

View File

@ -49,7 +49,7 @@ public class TestGCHeapMemoryUsageEvent {
List<RecordedEvent> events = Events.fromRecording(recording);
System.out.println(events);
assertFalse(events.isEmpty());
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
Events.assertField(event, "used").above(0L);
Events.assertField(event, "committed").above(0L);
Events.assertField(event, "max").above(0L);

View File

@ -88,7 +88,7 @@ public class TestGCLockerEvent {
// Verify recording
var all = Events.fromRecording(recording);
Events.hasEvents(all);
var event = all.get(0);
var event = all.getFirst();
assertTrue(Events.isEventType(event, EVENT_NAME));
Events.assertField(event, "lockCount").equal(CRITICAL_THREAD_COUNT);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -175,9 +175,9 @@ public class TestDeserializationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertEquals(events.size(), 1);
assertEquals(events.get(0).getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.get(0));
assertFilterStatus(expectedValue).accept(events.get(0));
assertEquals(events.getFirst().getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.getFirst());
assertFilterStatus(expectedValue).accept(events.getFirst());
}
}
@ -202,9 +202,9 @@ public class TestDeserializationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertEquals(events.size(), 1);
assertEquals(events.get(0).getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.get(0));
assertFilterStatus(expectedValue).accept(events.get(0));
assertEquals(events.getFirst().getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.getFirst());
assertFilterStatus(expectedValue).accept(events.getFirst());
}
}
@ -224,10 +224,10 @@ public class TestDeserializationEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
assertEquals(events.size(), 1);
assertEquals(events.get(0).getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.get(0));
assertExceptionType(XYZException.class).accept(events.get(0));
assertExceptionMessage("I am a bad filter!!!").accept(events.get(0));
assertEquals(events.getFirst().getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.getFirst());
assertExceptionType(XYZException.class).accept(events.getFirst());
assertExceptionMessage("I am a bad filter!!!").accept(events.getFirst());
}
}
@ -428,8 +428,8 @@ public class TestDeserializationEvent {
List<RecordedEvent> events = Events.fromRecording(recording);
assertEquals(events.size(), 1);
assertEquals(events.get(0).getEventType().getName(), "jdk.Deserialization");
assertFilterConfigured(true).accept(events.get(0));
assertFilterStatus("REJECTED").accept(events.get(0));
assertFilterConfigured(true).accept(events.getFirst());
assertFilterStatus("REJECTED").accept(events.getFirst());
assertFalse(initializedFoo);
assertType(Foo.class);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -121,7 +121,7 @@ public class TestFullStackTrace {
public static String getTopMethodName(RecordedEvent event) {
List<RecordedFrame> frames = event.getStackTrace().getFrames();
Asserts.assertFalse(frames.isEmpty(), "JavaFrames was empty");
return frames.get(0).getMethod().getName();
return frames.getFirst().getMethod().getName();
}
private static void checkEvent(RecordedEvent event, int expectedDepth) throws Throwable {
@ -144,7 +144,7 @@ public class TestFullStackTrace {
boolean isTruncateExpected = expectedDepth > MAX_DEPTH;
Asserts.assertEquals(isTruncated, isTruncateExpected, "Wrong value for isTruncated. Expected:" + isTruncateExpected);
String firstMethod = frames.get(frames.size() - 1).getMethod().getName();
String firstMethod = frames.getLast().getMethod().getName();
boolean isFullTrace = "run".equals(firstMethod);
String msg = String.format("Wrong values for isTruncated=%b, isFullTrace=%b", isTruncated, isFullTrace);
Asserts.assertTrue(isTruncated != isFullTrace, msg);

View File

@ -89,7 +89,7 @@ public final class TestActiveRecordingEvent {
List<RecordedEvent> events = Events.fromRecording(recording);
Events.hasEvents(events);
RecordedEvent ev = events.get(0);
RecordedEvent ev = events.getFirst();
// Duration must be kept in milliseconds
assertEquals(REC_DURATION.toMillis(), ev.getValue("recordingDuration"));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -116,7 +116,7 @@ public class TestClassLoadingStatisticsEvent {
recording.stop();
List<RecordedEvent> events = Events.fromRecording(recording);
Asserts.assertFalse(events.isEmpty(), "No events in recording");
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
return event;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -81,7 +81,7 @@ public class TestClassRedefinition {
List<RecordedEvent> events = RecordingFile.readAllEvents(DUMP_PATH);
Asserts.assertEquals(events.size(), 2, "Expected exactly two ClassRedefinition event");
RecordedEvent e1 = events.get(0);
RecordedEvent e1 = events.getFirst();
System.out.println(e1);
RecordedEvent e2 = events.get(1);
System.out.println(e2);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -102,7 +102,7 @@ public class TestExceptionEvents {
RecordedStackTrace rs = e.getStackTrace();
RecordedClass rc = e.getValue("thrownClass");
List<RecordedFrame> frames = rs.getFrames();
RecordedFrame topFrame = frames.get(0);
RecordedFrame topFrame = frames.getFirst();
System.out.println(rc.getName() + " Top frame: " + topFrame.getMethod().getName());
if (!topFrame.getMethod().getName().equals("<init>")) {
throw new Exception("Expected name of top frame to be <init>");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2023, 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
@ -150,8 +150,8 @@ public class TestNativeMemoryUsageEvents {
.toList();
// Verify that the heap has grown between the first and last sample.
long firstSample = javaHeapCommitted.get(0);
long lastSample = javaHeapCommitted.get(javaHeapCommitted.size() - 1);
long firstSample = javaHeapCommitted.getFirst();
long lastSample = javaHeapCommitted.getLast();
assertGreaterThan(lastSample, firstSample, "heap should have grown and NMT should show that");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -79,7 +79,7 @@ public class TestRedefineClasses {
public static void main(String[] args) throws Throwable {
List<RecordedEvent> events = RecordingFile.readAllEvents(DUMP_PATH);
Asserts.assertEquals(events.size(), 1, "Expected one RedefineClasses event");
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
System.out.println(event);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2023, 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
@ -84,7 +84,7 @@ public class TestRetransformClasses {
public static void main(String[] args) throws Throwable {
List<RecordedEvent> events = RecordingFile.readAllEvents(DUMP_PATH);
Asserts.assertEquals(events.size(), 1, "Expected one RetransformClasses event");
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
System.out.println(event);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2023, 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
@ -114,7 +114,7 @@ public class TestShutdownEvent {
.collect(Collectors.toList());
Asserts.assertEquals(filteredEvents.size(), 1);
RecordedEvent event = filteredEvents.get(0);
RecordedEvent event = filteredEvents.getFirst();
subTests[subTestIndex].verifyEvents(event, exitCode);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -88,7 +88,7 @@ public class TestJcmdConfigure {
for (Exception e : testExceptions) {
System.out.println("Error: " + e.getMessage());
}
throw testExceptions.get(0);
throw testExceptions.getFirst();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -110,9 +110,7 @@ public class TestJcmdDumpLimited {
recs.add(new TestRecording(i, 100));
}
int last = 0;
List<TestRecording> reversed = new ArrayList<>(recs);
Collections.reverse(reversed);
for (TestRecording r : reversed) {
for (TestRecording r : recs.reversed()) {
r.total = r.size + last;
last += r.size;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, 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
@ -66,7 +66,7 @@ public class TestJcmdStartPathToGCRoots {
}
String settingName = EventNames.OldObjectSample + "#" + "cutoff";
Recording r = recordings.get(0);
Recording r = recordings.getFirst();
String cutoff = r.getSettings().get(settingName);
System.out.println(settingName + "=" + cutoff);
if (!expected.equals(cutoff)) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -48,7 +48,7 @@ public class TestPredefinedConfigurationInvalid {
setInvalidConfigName(recId, "invalidname");
// Verify we can set named config after failed attempts.
Configuration config = Configuration.getConfigurations().get(0);
Configuration config = Configuration.getConfigurations().getFirst();
bean.setPredefinedConfiguration(recId, config.getName());
JmxHelper.verifyMapEquals(bean.getRecordingSettings(recId), config.getSettings());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -58,7 +58,7 @@ public class TestSnapshot {
r.close();
FlightRecorderMXBean mxBean = JmxHelper.getFlighteRecorderMXBean();
List<RecordingInfo> recs = mxBean.getRecordings();
JmxHelper.verifyEquals(recs.get(0), snapshot);
JmxHelper.verifyEquals(recs.getFirst(), snapshot);
}
}
}
@ -67,7 +67,7 @@ public class TestSnapshot {
try (Recording snapshot = FlightRecorder.getFlightRecorder().takeSnapshot()) {
FlightRecorderMXBean mxBean = JmxHelper.getFlighteRecorderMXBean();
List<RecordingInfo> recs = mxBean.getRecordings();
JmxHelper.verifyEquals(recs.get(0), snapshot);
JmxHelper.verifyEquals(recs.getFirst(), snapshot);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, 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
@ -153,7 +153,7 @@ public class TestDumpOnCrash {
List<RecordedEvent> events = RecordingFile.readAllEvents(file);
Asserts.assertFalse(events.isEmpty(), "No event found");
System.out.printf("Found event %s%n", events.get(0).getEventType().getName());
System.out.printf("Found event %s%n", events.getFirst().getEventType().getName());
Files.delete(file);
} else {

View File

@ -62,7 +62,7 @@ public class TestPrimitiveClasses {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
RecordedEvent event = events.get(0);
RecordedEvent event = events.getFirst();
System.out.println(event);
testField(event, "booleanClass", boolean.class);
testField(event, "charClass", char.class);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2023, 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
@ -60,7 +60,7 @@ public class StartupHelper {
searchPaths.add(root);
while (!searchPaths.isEmpty()) {
Path currRoot = searchPaths.remove(searchPaths.size() - 1);
Path currRoot = searchPaths.removeLast();
DirectoryStream<Path> contents = Files.newDirectoryStream(currRoot);
for (Path path : contents) {
paths.add(path);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, 2023, 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
@ -84,7 +84,7 @@ public class TestEventSettings {
if (rs.size() != 1) {
throw new Exception("Expected only one recording");
}
Map<String, String> currentSettings = rs.get(0).getSettings();
Map<String, String> currentSettings = rs.getFirst().getSettings();
String s = currentSettings.get(key);
if (!Objects.equals(s, value)) {
System.out.println("Key:" + key);

View File

@ -70,8 +70,8 @@ public class TestNestedVirtualThreads {
r.stop();
List<RecordedEvent> events = Events.fromRecording(r);
Events.hasEvents(events);
System.out.println(events.get(0));
RecordedEvent e = events.get(0);
System.out.println(events.getFirst());
RecordedEvent e = events.getFirst();
RecordedThread t = e.getThread();
Asserts.assertTrue(t.isVirtual());
Asserts.assertEquals(t.getJavaName(), ""); // vthreads default name is the empty string.