Skip to content

Commit 6de4fd7

Browse files
committed
[GR-70786] Fix style issues in Native Image source code
PullRequest: graal/22385
2 parents 08b8054 + 7bdf2ae commit 6de4fd7

File tree

9 files changed

+25
-19
lines changed

9 files changed

+25
-19
lines changed

compiler/mx.compiler/suite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@
574574
"jdk.graal.compiler.nodes.graphbuilderconf to org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport",
575575
"jdk.graal.compiler.options to org.graalvm.nativeimage.driver,org.graalvm.nativeimage.junitsupport",
576576
"jdk.graal.compiler.phases.common to org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.configure",
577-
"jdk.graal.compiler.serviceprovider to org.graalvm.nativeimage.driver,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.diagnostics",
577+
"jdk.graal.compiler.serviceprovider to org.graalvm.nativeimage.driver,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.diagnostics,org.graalvm.nativeimage.objectfile",
578578
"jdk.graal.compiler.util.json to org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.configure,org.graalvm.nativeimage.driver",
579579
],
580580
"uses" : [

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/CheckGraalInvariants.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,6 @@ public static void main(String[] args) {
154154

155155
}
156156

157-
public static String relativeFileName(String absolutePath) {
158-
int lastFileSeparatorIndex = absolutePath.lastIndexOf(File.separator);
159-
return absolutePath.substring(Math.max(lastFileSeparatorIndex, 0));
160-
}
161-
162157
public static class InvariantsTool {
163158

164159
protected boolean shouldProcess(String classpathEntry) {

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/VerifyAArch64RegisterUsages.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
*/
2525
package jdk.graal.compiler.core.test;
2626

27+
import java.util.Arrays;
28+
import java.util.List;
29+
2730
import jdk.graal.compiler.nodes.StructuredGraph;
2831
import jdk.graal.compiler.nodes.java.LoadFieldNode;
2932
import jdk.graal.compiler.nodes.spi.CoreProviders;
@@ -35,9 +38,6 @@
3538
import jdk.vm.ci.meta.ResolvedJavaMethod;
3639
import jdk.vm.ci.meta.ResolvedJavaType;
3740

38-
import java.util.Arrays;
39-
import java.util.List;
40-
4141
/**
4242
* Verify that scratch registers are not used in AArch64 specific code. We use a different set for
4343
* HotSpot (r8/r9) and SubstrateVM (r9/r10).
@@ -63,6 +63,7 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
6363
case "jdk.graal.compiler.hotspot.aarch64.AArch64HotSpotBackend.emitCodePrefix":
6464
case "com.oracle.svm.core.aarch64.SubstrateAArch64MacroAssembler.<clinit>":
6565
case "com.oracle.svm.core.graal.aarch64.SubstrateAArch64RegisterConfig.getCallingConvention":
66+
case "com.oracle.objectfile.elf.dwarf.DwarfLocSectionImpl$DwarfRegEncodingAArch64.<clinit>":
6667
// Exempted cases
6768
return;
6869
default:
@@ -80,7 +81,7 @@ protected void verify(StructuredGraph graph, CoreProviders context) {
8081

8182
if (potentialScratchRegisters.contains(f.getName())) {
8283
throw new VerificationError("Access to %s register at callsite %s is prohibited.",
83-
f, method.format("%H.%n(%p)"), f);
84+
f.format("%H.%n"), method.format("%H.%n(%p)"), f);
8485
}
8586
}
8687
}

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/ObjectFile.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import com.oracle.objectfile.pecoff.PECoffObjectFile;
5353

5454
import jdk.graal.compiler.debug.DebugContext;
55+
import jdk.graal.compiler.serviceprovider.GraalServices;
5556
import sun.nio.ch.DirectBuffer;
5657

5758
/**
@@ -172,7 +173,7 @@ public static <E extends Enum<E> & ValueEnum> EnumSet<E> flagSetFromLong(long fl
172173
// FIXME: replace OS string with enum (or just get rid of the concept,
173174
// perhaps merging with getFilenameSuffix).
174175
private static String getHostOS() {
175-
final String osName = System.getProperty("os.name");
176+
final String osName = GraalServices.getSavedProperty("os.name");
176177
if (osName.startsWith("Linux")) {
177178
return "Linux";
178179
} else if (osName.startsWith("Mac OS X")) {

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/elf/ELFMachine.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525

2626
package com.oracle.objectfile.elf;
2727

28+
import java.util.Locale;
29+
2830
import com.oracle.objectfile.ObjectFile.RelocationKind;
2931
import com.oracle.objectfile.ObjectFile.RelocationMethod;
3032
import com.oracle.objectfile.elf.ELFRelocationSection.ELFRelocationMethod;
3133

32-
import java.util.Locale;
34+
import jdk.graal.compiler.serviceprovider.GraalServices;
3335

3436
/**
3537
* ELF machine type (incomplete). Each machine type also defines its set of relocation types.
@@ -209,7 +211,7 @@ public short toShort() {
209211
}
210212

211213
public static ELFMachine getSystemNativeValue() {
212-
String arch = System.getProperty("os.arch");
214+
String arch = GraalServices.getSavedProperty("os.arch");
213215
return switch (arch) {
214216
case "aarch64", "arm64" -> AArch64;
215217
case "amd64", "x86_64" -> X86_64;

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffHeaderStruct.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@
2929

3030
import com.oracle.objectfile.pecoff.PECoff.IMAGE_FILE_HEADER;
3131

32+
import jdk.graal.compiler.serviceprovider.GraalServices;
33+
3234
public class PECoffHeaderStruct {
3335
private final ByteBuffer header;
3436

3537
public PECoffHeaderStruct() {
3638
header = PECoffByteBuffer.allocate(IMAGE_FILE_HEADER.totalsize);
3739

3840
header.putChar(IMAGE_FILE_HEADER.Machine.off, IMAGE_FILE_HEADER.IMAGE_FILE_MACHINE_AMD64);
39-
header.putInt(IMAGE_FILE_HEADER.TimeDateStamp.off, (int) (System.currentTimeMillis() / 1000));
41+
header.putInt(IMAGE_FILE_HEADER.TimeDateStamp.off, (int) (GraalServices.milliTimeStamp() / 1000));
4042
header.putInt(IMAGE_FILE_HEADER.PointerToSymbolTable.off, 0);
4143
header.putInt(IMAGE_FILE_HEADER.NumberOfSymbols.off, 0);
4244
header.putChar(IMAGE_FILE_HEADER.SizeOfOptionalHeader.off, (char) 0);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/PECoffMachine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
import com.oracle.objectfile.pecoff.PECoff.IMAGE_RELOCATION;
3232
import com.oracle.objectfile.pecoff.PECoffRelocationTable.PECoffRelocationMethod;
3333

34+
import jdk.graal.compiler.serviceprovider.GraalServices;
35+
3436
/**
3537
* PECoff machine type (incomplete). Each machine type also defines its set of relocation types.
3638
*/
@@ -87,7 +89,7 @@ public short toShort() {
8789
}
8890

8991
public static PECoffMachine getSystemNativeValue() {
90-
String arch = System.getProperty("os.arch");
92+
String arch = GraalServices.getSavedProperty("os.arch");
9193
return switch (arch) {
9294
case "amd64", "x86_64" -> X86_64;
9395
default -> throw new IllegalArgumentException("Unsupported PECoff machine type: " + arch);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/pecoff/cv/CVSymbolSubrecord.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626

2727
package com.oracle.objectfile.pecoff.cv;
2828

29-
import com.oracle.objectfile.debugentry.ClassEntry;
30-
3129
import java.util.HashMap;
3230
import java.util.Map;
3331

32+
import com.oracle.objectfile.debugentry.ClassEntry;
33+
34+
import jdk.graal.compiler.serviceprovider.GraalServices;
35+
3436
/*
3537
* A CVSymbolSubrecord is a record in a DEBUG_S_SYMBOL record within a .debug$S section within a PECOFF file.
3638
*/
@@ -198,7 +200,7 @@ public static final class CVEnvBlockRecord extends CVSymbolSubrecord {
198200
super(cvDebugInfo, CVDebugConstants.S_ENVBLOCK);
199201

200202
/* Current directory. */
201-
map.put("cwd", System.getProperty("user.dir"));
203+
map.put("cwd", GraalServices.getSystemProperties("user.dir is not available via GraalServices.getSavedProperties()").getProperty("user.dir"));
202204

203205
/*
204206
* Define the primary source file - ideally, the source file containing main(). (Note

substratevm/src/com.oracle.svm.util/src/com/oracle/svm/util/ModuleSupport.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.Arrays;
2828
import java.util.HashSet;
2929
import java.util.List;
30+
import java.util.Locale;
3031
import java.util.Objects;
3132
import java.util.Optional;
3233
import java.util.Set;
@@ -141,7 +142,7 @@ public static void accessPackagesToClass(Access access, Class<?> accessingClass,
141142
return;
142143
}
143144
String accessor = accessingClass != null ? "class " + accessingClass.getTypeName() : "ALL-UNNAMED";
144-
String message = access.name().toLowerCase() + " of packages from module " + moduleName + " to " +
145+
String message = access.name().toLowerCase(Locale.ROOT) + " of packages from module " + moduleName + " to " +
145146
accessor + " failed. No module named " + moduleName + " in boot layer.";
146147
throw new ModuleSupportError(message);
147148
}

0 commit comments

Comments
 (0)