Skip to content

Commit b1c03c7

Browse files
authored
Merge pull request #50448 from rsvoboda/cleanup-2025-10-07
Cleanup/simplification in core module
2 parents 079558d + 4661cdd commit b1c03c7

File tree

21 files changed

+28
-55
lines changed

21 files changed

+28
-55
lines changed

core/builder/src/main/java/io/quarkus/builder/Json.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
import java.util.ArrayList;
55
import java.util.Collection;
66
import java.util.HashMap;
7-
import java.util.Iterator;
87
import java.util.List;
9-
import java.util.ListIterator;
108
import java.util.Map;
119
import java.util.Map.Entry;
1210
import java.util.Objects;
@@ -230,8 +228,7 @@ String build() throws IOException {
230228
public void appendTo(Appendable appendable) throws IOException {
231229
appendable.append(ARRAY_START);
232230
int idx = 0;
233-
for (ListIterator<Object> iterator = values.listIterator(); iterator.hasNext();) {
234-
Object value = iterator.next();
231+
for (Object value : values) {
235232
if (isIgnored(value)) {
236233
continue;
237234
}
@@ -346,8 +343,7 @@ String build() throws IOException {
346343
public void appendTo(Appendable appendable) throws IOException {
347344
appendable.append(OBJECT_START);
348345
int idx = 0;
349-
for (Iterator<Entry<String, Object>> iterator = properties.entrySet().iterator(); iterator.hasNext();) {
350-
Entry<String, Object> entry = iterator.next();
346+
for (Entry<String, Object> entry : properties.entrySet()) {
351347
if (isIgnored(entry.getValue())) {
352348
continue;
353349
}
@@ -368,8 +364,7 @@ protected JsonObjectBuilder self() {
368364

369365
@Override
370366
void add(JsonValue element) {
371-
if (element instanceof JsonMember) {
372-
final JsonMember member = (JsonMember) element;
367+
if (element instanceof JsonMember member) {
373368
final String attribute = member.attribute().value();
374369
final JsonValue value = member.value();
375370
if (value instanceof JsonString) {

core/deployment/src/main/java/io/quarkus/deployment/ConstructorPropertiesProcessor.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ void build(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedInde
2929

3030
private void registerInstance(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, AnnotationInstance instance) {
3131
AnnotationTarget annotationTarget = instance.target();
32-
if (annotationTarget instanceof MethodInfo) {
33-
MethodInfo methodInfo = (MethodInfo) annotationTarget;
32+
if (annotationTarget instanceof MethodInfo methodInfo) {
3433
String classname = methodInfo.declaringClass().toString();
3534
reflectiveClass.produce(asReflectiveClassBuildItem(classname));
3635
}

core/deployment/src/main/java/io/quarkus/deployment/ExtensionLoader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,8 +621,7 @@ private static Consumer<BuildChainBuilder> loadStepsFromClass(Class<?> clazz,
621621
for (var type : ctor.getGenericParameterTypes()) {
622622
Class<?> theType;
623623
boolean isRuntimeValue = false;
624-
if (type instanceof ParameterizedType) {
625-
ParameterizedType pt = (ParameterizedType) type;
624+
if (type instanceof ParameterizedType pt) {
626625
if (pt.getRawType().equals(RuntimeValue.class)) {
627626
theType = (Class<?>) pt.getActualTypeArguments()[0];
628627
isRuntimeValue = true;
@@ -853,8 +852,7 @@ public void execute(final BuildContext bc) {
853852
return runTimeProxies.get(s);
854853
}
855854
// TODO - Remove once we disallow the injection of runtime objects in build steps
856-
if (s instanceof ParameterizedType) {
857-
ParameterizedType p = (ParameterizedType) s;
855+
if (s instanceof ParameterizedType p) {
858856
if (p.getRawType() == RuntimeValue.class) {
859857
Object object = runTimeProxies.get(p.getActualTypeArguments()[0]);
860858
if (object == null) {

core/deployment/src/main/java/io/quarkus/deployment/configuration/tracker/ConfigTrackingValueTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ public static String sha512(String value) {
125125
public static String sha512(byte[] value) {
126126
final byte[] digest = getSHA512().digest(value);
127127
final StringBuilder sb = new StringBuilder(40);
128-
for (int i = 0; i < digest.length; ++i) {
129-
sb.append(Integer.toHexString((digest[i] & 0xFF) | 0x100).substring(1, 3));
128+
for (byte b : digest) {
129+
sb.append(Integer.toHexString((b & 0xFF) | 0x100).substring(1, 3));
130130
}
131131
return sb.toString();
132132
}

core/deployment/src/main/java/io/quarkus/deployment/dev/testing/TestClassUsages.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ public FilterResult apply(TestDescriptor testDescriptor) {
8585
} else {
8686
return FilterResult.excluded("Has no tests");
8787
}
88-
} else if (source instanceof MethodSource) {
89-
MethodSource ms = (MethodSource) source;
88+
} else if (source instanceof MethodSource ms) {
9089
ClassAndMethod cm = new ClassAndMethod(ms.getClassName(), testDescriptor.getUniqueId());
9190
if (!classNames.containsKey(cm)) {
9291
return FilterResult.included("No test information");

core/deployment/src/main/java/io/quarkus/deployment/steps/ConfigDescriptionBuildStep.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ private void processMappings(List<ConfigClass> mappings, List<ConfigDescriptionB
5757
Method method = property.getMethod();
5858

5959
String defaultValue = null;
60-
if (property instanceof PrimitiveProperty) {
61-
PrimitiveProperty primitiveProperty = (PrimitiveProperty) property;
60+
if (property instanceof PrimitiveProperty primitiveProperty) {
6261
if (primitiveProperty.hasDefaultValue()) {
6362
defaultValue = primitiveProperty.getDefaultValue();
6463
} else if (primitiveProperty.getPrimitiveType() == boolean.class) {
6564
defaultValue = "false";
6665
} else if (primitiveProperty.getPrimitiveType() != char.class) {
6766
defaultValue = "0";
6867
}
69-
} else if (property instanceof LeafProperty) {
70-
LeafProperty leafProperty = (LeafProperty) property;
68+
} else if (property instanceof LeafProperty leafProperty) {
7169
if (leafProperty.hasDefaultValue()) {
7270
defaultValue = leafProperty.getDefaultValue();
7371
}

core/deployment/src/main/java/io/quarkus/deployment/steps/ReflectiveHierarchyStep.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,14 @@ private void addReflectiveHierarchy(CombinedIndexBuildItem combinedIndexBuildIte
160160
type.asArrayType().constituent(),
161161
processedReflectiveHierarchies,
162162
unindexedClasses, reflectiveClass, visits));
163-
} else if (type instanceof ParameterizedType) {
163+
} else if (type instanceof ParameterizedType parameterizedType) {
164164
if (!reflectiveHierarchyBuildItem.getIgnoreTypePredicate().test(type.name())) {
165165
addClassTypeHierarchy(combinedIndexBuildItem, capabilities, reflectiveHierarchyBuildItem, newSource,
166166
type.name(),
167167
type.name(),
168168
processedReflectiveHierarchies,
169169
unindexedClasses, reflectiveClass, visits);
170170
}
171-
final ParameterizedType parameterizedType = (ParameterizedType) type;
172171
for (Type typeArgument : parameterizedType.arguments()) {
173172
visits.addLast(
174173
() -> addReflectiveHierarchy(combinedIndexBuildItem, capabilities, reflectiveHierarchyBuildItem,

core/deployment/src/main/java/io/quarkus/runner/bootstrap/AugmentActionImpl.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.File;
44
import java.io.IOException;
55
import java.lang.reflect.InvocationTargetException;
6-
import java.nio.charset.StandardCharsets;
76
import java.nio.file.Files;
87
import java.nio.file.Path;
98
import java.nio.file.StandardOpenOption;
@@ -230,7 +229,7 @@ private void writeDebugSourceFile(BuildResult result) {
230229
}
231230
File sourceFile = new File(debugPath, i.getName() + ".zig");
232231
sourceFile.getParentFile().mkdirs();
233-
Files.write(sourceFile.toPath(), i.getSource().getBytes(StandardCharsets.UTF_8),
232+
Files.writeString(sourceFile.toPath(), i.getSource(),
234233
StandardOpenOption.CREATE);
235234
log.infof("Wrote source: %s", sourceFile.getAbsolutePath());
236235
} else {

core/deployment/src/main/java/io/quarkus/runner/bootstrap/StartupActionImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import java.io.IOException;
99
import java.lang.reflect.InvocationTargetException;
1010
import java.lang.reflect.Method;
11-
import java.nio.charset.StandardCharsets;
1211
import java.nio.file.Files;
1312
import java.nio.file.StandardOpenOption;
1413
import java.util.ArrayList;
@@ -486,8 +485,7 @@ private static Map<String, byte[]> extractGeneratedResources(BuildResult buildRe
486485
}
487486
File sourceFile = new File(debugPath, i.internalName() + ".zig");
488487
sourceFile.getParentFile().mkdirs();
489-
Files.write(sourceFile.toPath(), i.getSource().getBytes(StandardCharsets.UTF_8),
490-
StandardOpenOption.CREATE);
488+
Files.writeString(sourceFile.toPath(), i.getSource(), StandardOpenOption.CREATE);
491489
log.infof("Wrote source %s", sourceFile.getAbsolutePath());
492490
} else {
493491
log.infof("Source not available: %s", i.binaryName());

core/deployment/src/test/java/io/quarkus/deployment/pkg/steps/BannerProcessorTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static org.junit.jupiter.api.Assertions.assertFalse;
55
import static org.junit.jupiter.api.Assertions.assertTrue;
66

7-
import java.nio.charset.StandardCharsets;
87
import java.nio.file.FileSystem;
98
import java.nio.file.Files;
109
import java.nio.file.Path;
@@ -43,7 +42,7 @@ public void checkQuarkusCoreBannerOnFilesystemWithSpecialCharacters(@TempDir Pat
4342
try (final FileSystem fs = ZipUtils.newFileSystem(zipPath)) {
4443
Path classFile = fs.getPath(fromClassNameToResourceName(MyBannerProcessor.class.getName()));
4544
Files.createDirectories(classFile.getParent());
46-
Files.write(classFile, "".getBytes(StandardCharsets.UTF_8));
45+
Files.writeString(classFile, "");
4746
}
4847

4948
try (FileSystem fs = ZipUtils.newFileSystem(zipPath)) {

0 commit comments

Comments
 (0)