Skip to content

Commit 4fbec8c

Browse files
committed
Follow naming conventions of static final fields
1 parent 353c12e commit 4fbec8c

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/BundleSupport.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ final class BundleSupport {
9292
boolean loadBundle;
9393
boolean writeBundle;
9494

95-
private static final int bundleFileFormatVersionMajor = 0;
96-
private static final int bundleFileFormatVersionMinor = 9;
95+
private static final int BUNDLE_FILE_FORMAT_VERSION_MAJOR = 0;
96+
private static final int BUNDLE_FILE_FORMAT_VERSION_MINOR = 9;
9797

98-
private static final String bundleInfoMessagePrefix = "GraalVM Native Image Bundle Support: ";
99-
private static final String bundleTempDirPrefix = "bundleRoot-";
100-
private static final String originalDirExtension = ".orig";
98+
private static final String BUNDLE_INFO_MESSAGE_PREFIX = "GraalVM Native Image Bundle Support: ";
99+
private static final String BUNDLE_TEMP_DIR_PREFIX = "bundleRoot-";
100+
private static final String ORIGINAL_DIR_EXTENSION = ".orig";
101101

102102
private Path bundlePath;
103103
private String bundleName;
@@ -154,7 +154,7 @@ static BundleSupport create(NativeImage nativeImage, String bundleArg, NativeIma
154154
for (int i = buildArgs.size() - 1; i >= 0; i--) {
155155
args.push(buildArgs.get(i));
156156
}
157-
nativeImage.showVerboseMessage(nativeImage.isVerbose(), bundleInfoMessagePrefix + "Inject args: '" + String.join(" ", buildArgs) + "'");
157+
nativeImage.showVerboseMessage(nativeImage.isVerbose(), BUNDLE_INFO_MESSAGE_PREFIX + "Inject args: '" + String.join(" ", buildArgs) + "'");
158158
/* Snapshot args after in-place expansion (includes also args after this one) */
159159
bundleSupport.updatedBuildArgs = args.snapshot();
160160
break;
@@ -193,7 +193,7 @@ private BundleSupport(NativeImage nativeImage) {
193193
loadBundle = false;
194194
writeBundle = true;
195195
try {
196-
rootDir = Files.createTempDirectory(bundleTempDirPrefix);
196+
rootDir = Files.createTempDirectory(BUNDLE_TEMP_DIR_PREFIX);
197197
bundleProperties = new BundleProperties();
198198

199199
Path inputDir = rootDir.resolve("input");
@@ -222,11 +222,11 @@ private BundleSupport(NativeImage nativeImage, String bundleFilenameArg) {
222222
updateBundleLocation(Path.of(bundleFilenameArg), false);
223223

224224
try {
225-
rootDir = Files.createTempDirectory(bundleTempDirPrefix);
225+
rootDir = Files.createTempDirectory(BUNDLE_TEMP_DIR_PREFIX);
226226
bundleProperties = new BundleProperties();
227227

228228
outputDir = rootDir.resolve("output");
229-
String originalOutputDirName = outputDir.getFileName().toString() + originalDirExtension;
229+
String originalOutputDirName = outputDir.getFileName().toString() + ORIGINAL_DIR_EXTENSION;
230230

231231
Path bundleFilePath = bundlePath.resolve(bundleName + BUNDLE_FILE_EXTENSION);
232232
try (JarFile archive = new JarFile(bundleFilePath.toFile())) {
@@ -497,14 +497,14 @@ void complete() {
497497
Path externalOutputDir = bundlePath.resolve(bundleName + "." + outputDir.getFileName());
498498
copyFiles(outputDir, externalOutputDir, true);
499499
outputNewline.run();
500-
nativeImage.showMessage(bundleInfoMessagePrefix + "Bundle build output written to " + externalOutputDir);
500+
nativeImage.showMessage(BUNDLE_INFO_MESSAGE_PREFIX + "Bundle build output written to " + externalOutputDir);
501501
}
502502

503503
try {
504504
if (writeBundle) {
505505
Path bundleFilePath = writeBundle();
506506
outputNewline.run();
507-
nativeImage.showMessage(bundleInfoMessagePrefix + "Bundle written to " + bundleFilePath);
507+
nativeImage.showMessage(BUNDLE_INFO_MESSAGE_PREFIX + "Bundle written to " + bundleFilePath);
508508
}
509509
} finally {
510510
nativeImage.showNewline();
@@ -550,7 +550,7 @@ void updateBundleLocation(Path bundleFile, boolean redefine) {
550550
}
551551

552552
private Path writeBundle() {
553-
String originalOutputDirName = outputDir.getFileName().toString() + originalDirExtension;
553+
String originalOutputDirName = outputDir.getFileName().toString() + ORIGINAL_DIR_EXTENSION;
554554
Path originalOutputDir = rootDir.resolve(originalOutputDirName);
555555
if (Files.exists(originalOutputDir)) {
556556
nativeImage.deleteAllFiles(originalOutputDir);
@@ -589,10 +589,10 @@ private Path writeBundle() {
589589
if (buildArg.startsWith(nativeImage.oHPath)) {
590590
continue;
591591
}
592-
if (buildArg.equals(CmdLineOptionHandler.verboseOption)) {
592+
if (buildArg.equals(CmdLineOptionHandler.VERBOSE_OPTION)) {
593593
continue;
594594
}
595-
if (buildArg.equals(CmdLineOptionHandler.dryRunOption)) {
595+
if (buildArg.equals(CmdLineOptionHandler.DRY_RUN_OPTION)) {
596596
continue;
597597
}
598598
if (buildArg.startsWith("-Dllvm.bin.dir=")) {
@@ -737,11 +737,11 @@ private void loadAndVerify() {
737737
fileVersionKey = PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR;
738738
int minor = Integer.parseInt(properties.getOrDefault(fileVersionKey, "-1"));
739739
String message = String.format("The given bundle file %s was created with newer bundle-file-format version %d.%d" +
740-
" (current %d.%d). Update to the latest version of native-image.", bundleFileName, major, minor, bundleFileFormatVersionMajor, bundleFileFormatVersionMinor);
741-
if (major > bundleFileFormatVersionMajor) {
740+
" (current %d.%d). Update to the latest version of native-image.", bundleFileName, major, minor, BUNDLE_FILE_FORMAT_VERSION_MAJOR, BUNDLE_FILE_FORMAT_VERSION_MINOR);
741+
if (major > BUNDLE_FILE_FORMAT_VERSION_MAJOR) {
742742
throw NativeImage.showError(message);
743-
} else if (major == bundleFileFormatVersionMajor) {
744-
if (minor > bundleFileFormatVersionMinor) {
743+
} else if (major == BUNDLE_FILE_FORMAT_VERSION_MAJOR) {
744+
if (minor > BUNDLE_FILE_FORMAT_VERSION_MINOR) {
745745
NativeImage.showWarning(message);
746746
}
747747
}
@@ -761,14 +761,14 @@ private void loadAndVerify() {
761761
localDateStr = "unknown time";
762762
}
763763
nativeImage.showNewline();
764-
nativeImage.showMessage(String.format("%sLoaded Bundle from %s", bundleInfoMessagePrefix, bundleFileName));
765-
nativeImage.showMessage(String.format("%sBundle created at '%s'", bundleInfoMessagePrefix, localDateStr));
766-
nativeImage.showMessage(String.format("%sUsing version: '%s'%s on platform: '%s'%s", bundleInfoMessagePrefix, bundleVersion, currentVersion, bundlePlatform, currentPlatform));
764+
nativeImage.showMessage(String.format("%sLoaded Bundle from %s", BUNDLE_INFO_MESSAGE_PREFIX, bundleFileName));
765+
nativeImage.showMessage(String.format("%sBundle created at '%s'", BUNDLE_INFO_MESSAGE_PREFIX, localDateStr));
766+
nativeImage.showMessage(String.format("%sUsing version: '%s'%s on platform: '%s'%s", BUNDLE_INFO_MESSAGE_PREFIX, bundleVersion, currentVersion, bundlePlatform, currentPlatform));
767767
}
768768

769769
private void write() {
770-
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR, String.valueOf(bundleFileFormatVersionMajor));
771-
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR, String.valueOf(bundleFileFormatVersionMinor));
770+
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MAJOR, String.valueOf(BUNDLE_FILE_FORMAT_VERSION_MAJOR));
771+
properties.put(PROPERTY_KEY_BUNDLE_FILE_VERSION_MINOR, String.valueOf(BUNDLE_FILE_FORMAT_VERSION_MINOR));
772772
properties.put(PROPERTY_KEY_BUNDLE_FILE_CREATION_TIMESTAMP, ZonedDateTime.now().format(DateTimeFormatter.ISO_DATE_TIME));
773773
boolean imageBuilt = !nativeImage.isDryRun();
774774
properties.put(PROPERTY_KEY_IMAGE_BUILT, String.valueOf(imageBuilt));

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/CmdLineOptionHandler.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@
3838

3939
class CmdLineOptionHandler extends NativeImage.OptionHandler<NativeImage> {
4040

41-
private static final String helpText = NativeImage.getResource("/Help.txt");
42-
private static final String helpExtraText = NativeImage.getResource("/HelpExtra.txt");
41+
private static final String HELP_TEXT = NativeImage.getResource("/Help.txt");
42+
private static final String HELP_EXTRA_TEXT = NativeImage.getResource("/HelpExtra.txt");
4343

44-
static final String verboseOption = "--verbose";
45-
static final String dryRunOption = "--dry-run";
46-
static final String debugAttachOption = "--debug-attach";
44+
static final String VERBOSE_OPTION = "--verbose";
45+
static final String DRY_RUN_OPTION = "--dry-run";
46+
static final String DEBUG_ATTACH_OPTION = "--debug-attach";
4747
/* Defunct legacy options that we have to accept to maintain backward compatibility */
48-
private static final String verboseServerOption = "--verbose-server";
49-
private static final String serverOptionPrefix = "--server-";
48+
private static final String VERBOSE_SERVER_OPTION = "--verbose-server";
49+
private static final String SERVER_OPTION_PREFIX = "--server-";
5050

51-
private static final String javaRuntimeVersion = System.getProperty("java.runtime.version");
51+
private static final String JAVA_RUNTIME_VERSION = System.getProperty("java.runtime.version");
5252

5353
boolean useDebugAttach = false;
5454

@@ -73,7 +73,7 @@ private boolean consume(ArgumentQueue args, String headArg) {
7373
case "--help":
7474
args.poll();
7575
singleArgumentCheck(args, headArg);
76-
nativeImage.showMessage(helpText);
76+
nativeImage.showMessage(HELP_TEXT);
7777
nativeImage.showNewline();
7878
nativeImage.apiOptionHandler.printOptions(nativeImage::showMessage, false);
7979
nativeImage.showNewline();
@@ -85,14 +85,14 @@ private boolean consume(ArgumentQueue args, String headArg) {
8585
args.poll();
8686
singleArgumentCheck(args, headArg);
8787
String message = NativeImage.getNativeImageVersion();
88-
message += " (Java Version " + javaRuntimeVersion + ")";
88+
message += " (Java Version " + JAVA_RUNTIME_VERSION + ")";
8989
nativeImage.showMessage(message);
9090
System.exit(ExitStatus.OK.getValue());
9191
return true;
9292
case "--help-extra":
9393
args.poll();
9494
singleArgumentCheck(args, headArg);
95-
nativeImage.showMessage(helpExtraText);
95+
nativeImage.showMessage(HELP_EXTRA_TEXT);
9696
nativeImage.apiOptionHandler.printOptions(nativeImage::showMessage, true);
9797
nativeImage.showNewline();
9898
nativeImage.optionRegistry.showOptions(OptionUtils.MacroOptionKind.Macro, true, nativeImage::showMessage);
@@ -121,11 +121,11 @@ private boolean consume(ArgumentQueue args, String headArg) {
121121
}
122122
nativeImage.addExcludeConfig(Pattern.compile(excludeJar), Pattern.compile(excludeConfig));
123123
return true;
124-
case verboseOption:
124+
case VERBOSE_OPTION:
125125
args.poll();
126126
nativeImage.addVerbose();
127127
return true;
128-
case dryRunOption:
128+
case DRY_RUN_OPTION:
129129
args.poll();
130130
nativeImage.setDryRun(true);
131131
return true;
@@ -146,7 +146,7 @@ private boolean consume(ArgumentQueue args, String headArg) {
146146
args.poll();
147147
BundleSupport.allowBundleSupport = true;
148148
return true;
149-
case verboseServerOption:
149+
case VERBOSE_SERVER_OPTION:
150150
args.poll();
151151
NativeImage.showWarning("Ignoring server-mode native-image argument " + headArg + ".");
152152
return true;
@@ -157,13 +157,13 @@ private boolean consume(ArgumentQueue args, String headArg) {
157157
return true;
158158
}
159159

160-
if (headArg.startsWith(debugAttachOption)) {
160+
if (headArg.startsWith(DEBUG_ATTACH_OPTION)) {
161161
if (useDebugAttach) {
162-
throw NativeImage.showError("The " + debugAttachOption + " option can only be used once.");
162+
throw NativeImage.showError("The " + DEBUG_ATTACH_OPTION + " option can only be used once.");
163163
}
164164
useDebugAttach = true;
165165
String debugAttachArg = args.poll();
166-
String addressSuffix = debugAttachArg.substring(debugAttachOption.length());
166+
String addressSuffix = debugAttachArg.substring(DEBUG_ATTACH_OPTION.length());
167167
String address = addressSuffix.isEmpty() ? "8000" : addressSuffix.substring(1);
168168
/* Using agentlib to allow interoperability with other agents */
169169
nativeImage.addImageBuilderJavaArgs("-agentlib:jdwp=transport=dt_socket,server=y,address=" + address + ",suspend=y");
@@ -172,10 +172,10 @@ private boolean consume(ArgumentQueue args, String headArg) {
172172
return true;
173173
}
174174

175-
if (headArg.startsWith(serverOptionPrefix)) {
175+
if (headArg.startsWith(SERVER_OPTION_PREFIX)) {
176176
args.poll();
177177
NativeImage.showWarning("Ignoring server-mode native-image argument " + headArg + ".");
178-
String serverOptionCommand = headArg.substring(serverOptionPrefix.length());
178+
String serverOptionCommand = headArg.substring(SERVER_OPTION_PREFIX.length());
179179
if (!serverOptionCommand.startsWith("session=")) {
180180
/*
181181
* All but the --server-session=... option used to exit(0). We want to simulate that
@@ -198,7 +198,7 @@ private static void singleArgumentCheck(ArgumentQueue args, String arg) {
198198
@Override
199199
void addFallbackBuildArgs(List<String> buildArgs) {
200200
if (nativeImage.isVerbose()) {
201-
buildArgs.add(verboseOption);
201+
buildArgs.add(VERBOSE_OPTION);
202202
}
203203
}
204204
}

substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/NativeImage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ private List<String> getAgentArguments() {
12591259

12601260
if (!agentOptions.isEmpty()) {
12611261
if (useDebugAttach()) {
1262-
throw NativeImage.showError(CmdLineOptionHandler.debugAttachOption + " cannot be used with class initialization/object instantiation tracing (" + oHTraceClassInitialization +
1262+
throw NativeImage.showError(CmdLineOptionHandler.DEBUG_ATTACH_OPTION + " cannot be used with class initialization/object instantiation tracing (" + oHTraceClassInitialization +
12631263
"/ + " + oHTraceObjectInstantiation + ").");
12641264
}
12651265
args.add("-agentlib:native-image-diagnostics-agent=" + agentOptions);

0 commit comments

Comments
 (0)