8284933: Improve debug in jdk.crypto.cryptoki

Reviewed-by: valeriep
This commit is contained in:
Xue-Lei Andrew Fan 2022-04-20 04:36:12 +00:00
parent 72726c4182
commit 0f81d8fcc3

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,12 +87,6 @@ final class Config {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static void debug(Object o) {
if (DEBUG) {
System.out.println(o);
}
}
// file name containing this configuration // file name containing this configuration
private String filename; private String filename;
@ -548,7 +542,9 @@ final class Config {
private int nextToken() throws IOException { private int nextToken() throws IOException {
int token = st.nextToken(); int token = st.nextToken();
debug(st); if (DEBUG) {
System.out.println(st);
}
return token; return token;
} }
@ -595,7 +591,9 @@ final class Config {
} }
String value = st.sval; String value = st.sval;
debug(keyword + ": " + value); if (DEBUG) {
System.out.println(keyword + ": " + value);
}
return value; return value;
} }
@ -603,7 +601,9 @@ final class Config {
checkDup(keyword); checkDup(keyword);
parseEquals(); parseEquals();
boolean value = parseBoolean(); boolean value = parseBoolean();
debug(keyword + ": " + value); if (DEBUG) {
System.out.println(keyword + ": " + value);
}
return value; return value;
} }
@ -611,7 +611,9 @@ final class Config {
checkDup(keyword); checkDup(keyword);
parseEquals(); parseEquals();
int value = decodeNumber(parseWord()); int value = decodeNumber(parseWord());
debug(keyword + ": " + value); if (DEBUG) {
System.out.println(keyword + ": " + value);
}
return value; return value;
} }
@ -716,7 +718,9 @@ final class Config {
String suffix = lib.substring(i + 5); String suffix = lib.substring(i + 5);
lib = prefix + suffix; lib = prefix + suffix;
} }
debug(keyword + ": " + lib); if (DEBUG) {
System.out.println(keyword + ": " + lib);
}
// Check to see if full path is specified to prevent the DLL // Check to see if full path is specified to prevent the DLL
// preloading attack // preloading attack
@ -731,7 +735,9 @@ final class Config {
checkDup(keyword); checkDup(keyword);
parseEquals(); parseEquals();
description = parseLine(); description = parseLine();
debug("description: " + description); if (DEBUG) {
System.out.println("description: " + description);
}
} }
private void parseSlotID(String keyword) throws IOException { private void parseSlotID(String keyword) throws IOException {
@ -745,7 +751,9 @@ final class Config {
parseEquals(); parseEquals();
String slotString = parseWord(); String slotString = parseWord();
slotID = decodeNumber(slotString); slotID = decodeNumber(slotString);
debug("slot: " + slotID); if (DEBUG) {
System.out.println("slot: " + slotID);
}
} }
private void parseSlotListIndex(String keyword) throws IOException { private void parseSlotListIndex(String keyword) throws IOException {
@ -759,7 +767,9 @@ final class Config {
parseEquals(); parseEquals();
String slotString = parseWord(); String slotString = parseWord();
slotListIndex = decodeNumber(slotString); slotListIndex = decodeNumber(slotString);
debug("slotListIndex: " + slotListIndex); if (DEBUG) {
System.out.println("slotListIndex: " + slotListIndex);
}
} }
private void parseEnabledMechanisms(String keyword) throws IOException { private void parseEnabledMechanisms(String keyword) throws IOException {
@ -1021,7 +1031,9 @@ final class Config {
throw excToken("Expected quoted string"); throw excToken("Expected quoted string");
} }
nssArgs = expand(st.sval); nssArgs = expand(st.sval);
debug("nssArgs: " + nssArgs); if (DEBUG) {
System.out.println("nssArgs: " + nssArgs);
}
} }
private void parseHandleStartupErrors(String keyword) throws IOException { private void parseHandleStartupErrors(String keyword) throws IOException {
@ -1037,7 +1049,9 @@ final class Config {
} else { } else {
throw excToken("Invalid value for handleStartupErrors:"); throw excToken("Invalid value for handleStartupErrors:");
} }
debug("handleStartupErrors: " + handleStartupErrors); if (DEBUG) {
System.out.println("handleStartupErrors: " + handleStartupErrors);
}
} }
} }