提交 9d9b09b8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Simplify array initialization.

上级 0d2befdf
...@@ -922,7 +922,7 @@ public class Parser { ...@@ -922,7 +922,7 @@ public class Parser {
} }
if (readIf("DEFAULT")) { if (readIf("DEFAULT")) {
read("VALUES"); read("VALUES");
Expression[] expr = new Expression[0]; Expression[] expr = { };
command.addRow(expr); command.addRow(expr);
} else if (readIf("VALUES")) { } else if (readIf("VALUES")) {
do { do {
...@@ -4721,7 +4721,7 @@ public class Parser { ...@@ -4721,7 +4721,7 @@ public class Parser {
Column column = parseColumnForTable(columnName); Column column = parseColumnForTable(columnName);
if (column.isAutoIncrement() && column.isPrimaryKey()) { if (column.isAutoIncrement() && column.isPrimaryKey()) {
column.setPrimaryKey(false); column.setPrimaryKey(false);
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()}; IndexColumn[] cols = { new IndexColumn() };
cols[0].columnName = column.getName(); cols[0].columnName = column.getName();
AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false); AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false);
pk.setType(AlterTableAddConstraint.PRIMARY_KEY); pk.setType(AlterTableAddConstraint.PRIMARY_KEY);
...@@ -4737,7 +4737,7 @@ public class Parser { ...@@ -4737,7 +4737,7 @@ public class Parser {
if (readIf("PRIMARY")) { if (readIf("PRIMARY")) {
read("KEY"); read("KEY");
boolean hash = readIf("HASH"); boolean hash = readIf("HASH");
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()}; IndexColumn[] cols = { new IndexColumn() };
cols[0].columnName = column.getName(); cols[0].columnName = column.getName();
AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false); AlterTableAddConstraint pk = new AlterTableAddConstraint(session, schema, false);
pk.setPrimaryKeyHash(hash); pk.setPrimaryKeyHash(hash);
...@@ -4752,7 +4752,7 @@ public class Parser { ...@@ -4752,7 +4752,7 @@ public class Parser {
AlterTableAddConstraint unique = new AlterTableAddConstraint(session, schema, false); AlterTableAddConstraint unique = new AlterTableAddConstraint(session, schema, false);
unique.setConstraintName(constraintName); unique.setConstraintName(constraintName);
unique.setType(AlterTableAddConstraint.UNIQUE); unique.setType(AlterTableAddConstraint.UNIQUE);
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()}; IndexColumn[] cols = { new IndexColumn() };
cols[0].columnName = columnName; cols[0].columnName = columnName;
unique.setIndexColumns(cols); unique.setIndexColumns(cols);
unique.setTableName(tableName); unique.setTableName(tableName);
...@@ -4772,7 +4772,7 @@ public class Parser { ...@@ -4772,7 +4772,7 @@ public class Parser {
AlterTableAddConstraint ref = new AlterTableAddConstraint(session, schema, false); AlterTableAddConstraint ref = new AlterTableAddConstraint(session, schema, false);
ref.setConstraintName(constraintName); ref.setConstraintName(constraintName);
ref.setType(AlterTableAddConstraint.REFERENTIAL); ref.setType(AlterTableAddConstraint.REFERENTIAL);
IndexColumn[] cols = new IndexColumn[]{new IndexColumn()}; IndexColumn[] cols = { new IndexColumn() };
cols[0].columnName = columnName; cols[0].columnName = columnName;
ref.setIndexColumns(cols); ref.setIndexColumns(cols);
ref.setTableName(tableName); ref.setTableName(tableName);
......
...@@ -76,8 +76,7 @@ public class Call extends Prepared { ...@@ -76,8 +76,7 @@ public class Call extends Prepared {
return result; return result;
} }
LocalResult result = new LocalResult(session, expressions, 1); LocalResult result = new LocalResult(session, expressions, 1);
Value[] row = new Value[1]; Value[] row = { v };
row[0] = v;
result.addRow(row); result.addRow(row);
result.done(); result.done();
return result; return result;
......
...@@ -44,9 +44,7 @@ public class ExplainPlan extends Prepared { ...@@ -44,9 +44,7 @@ public class ExplainPlan extends Prepared {
public ResultInterface query(int maxrows) { public ResultInterface query(int maxrows) {
Column column = new Column("PLAN", Value.STRING); Column column = new Column("PLAN", Value.STRING);
ExpressionColumn expr = new ExpressionColumn(session.getDatabase(), column); ExpressionColumn expr = new ExpressionColumn(session.getDatabase(), column);
Expression[] expressions = new Expression[] { Expression[] expressions = { expr };
expr
};
result = new LocalResult(session, expressions, 1); result = new LocalResult(session, expressions, 1);
if (maxrows >= 0) { if (maxrows >= 0) {
String plan = command.getPlanSQL(); String plan = command.getPlanSQL();
...@@ -57,9 +55,7 @@ public class ExplainPlan extends Prepared { ...@@ -57,9 +55,7 @@ public class ExplainPlan extends Prepared {
} }
private void add(String text) { private void add(String text) {
Value[] row = new Value[1]; Value[] row = { ValueString.get(text) };
Value value = ValueString.get(text);
row[0] = value;
result.addRow(row); result.addRow(row);
} }
......
...@@ -111,7 +111,7 @@ public class ScriptCommand extends ScriptBase { ...@@ -111,7 +111,7 @@ public class ScriptCommand extends ScriptBase {
} }
private LocalResult createResult() { private LocalResult createResult() {
Expression[] expressions = new Expression[] { new ExpressionColumn(session.getDatabase(), new Column("SCRIPT", Expression[] expressions = { new ExpressionColumn(session.getDatabase(), new Column("SCRIPT",
Value.STRING)) }; Value.STRING)) };
return new LocalResult(session, expressions, 1); return new LocalResult(session, expressions, 1);
} }
...@@ -547,13 +547,11 @@ public class ScriptCommand extends ScriptBase { ...@@ -547,13 +547,11 @@ public class ScriptCommand extends ScriptBase {
} }
out.write(buffer, 0, len); out.write(buffer, 0, len);
if (!insert) { if (!insert) {
Value[] row = new Value[1]; Value[] row = { ValueString.get(s) };
row[0] = ValueString.get(s);
result.addRow(row); result.addRow(row);
} }
} else { } else {
Value[] row = new Value[1]; Value[] row = { ValueString.get(s) };
row[0] = ValueString.get(s);
result.addRow(row); result.addRow(row);
} }
} }
......
...@@ -464,8 +464,7 @@ public class Select extends Query { ...@@ -464,8 +464,7 @@ public class Select extends Query {
first = topTableFilter.getTable().getTemplateSimpleRow(true); first = topTableFilter.getTable().getTemplateSimpleRow(true);
} }
first.setValue(columnIndex, value); first.setValue(columnIndex, value);
Value[] row = new Value[1]; Value[] row = { value };
row[0] = value;
result.addRow(row); result.addRow(row);
rowNumber++; rowNumber++;
if ((sort == null || sortUsingIndex) && limitRows != 0 && result.getRowCount() >= limitRows) { if ((sort == null || sortUsingIndex) && limitRows != 0 && result.getRowCount() >= limitRows) {
......
...@@ -75,7 +75,7 @@ public class ConnectionInfo implements Cloneable { ...@@ -75,7 +75,7 @@ public class ConnectionInfo implements Cloneable {
ArrayList<String> list = SetTypes.getTypes(); ArrayList<String> list = SetTypes.getTypes();
HashSet<String> set = KNOWN_SETTINGS; HashSet<String> set = KNOWN_SETTINGS;
set.addAll(list); set.addAll(list);
String[] connectionTime = new String[] { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER", String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "DB_CLOSE_ON_EXIT", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "IFEXISTS", "CREATE", "CACHE_TYPE", "DB_CLOSE_ON_EXIT", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "IFEXISTS",
"INIT", "PASSWORD", "RECOVER", "USER", "AUTO_SERVER", "INIT", "PASSWORD", "RECOVER", "USER", "AUTO_SERVER",
"AUTO_RECONNECT", "OPEN_NEW" }; "AUTO_RECONNECT", "OPEN_NEW" };
......
...@@ -1467,7 +1467,7 @@ public class Function extends Expression implements FunctionCall { ...@@ -1467,7 +1467,7 @@ public class Function extends Expression implements FunctionCall {
private static String getSoundex(String s) { private static String getSoundex(String s) {
int len = s.length(); int len = s.length();
char[] chars = new char[] { '0', '0', '0', '0' }; char[] chars = { '0', '0', '0', '0' };
char lastDigit = '0'; char lastDigit = '0';
for (int i = 0, j = 0; i < len && j < 4; i++) { for (int i = 0, j = 0; i < len && j < 4; i++) {
char c = s.charAt(i); char c = s.charAt(i);
......
...@@ -421,9 +421,7 @@ public class FullText { ...@@ -421,9 +421,7 @@ public class FullText {
columns.toArray(col); columns.toArray(col);
Object[] dat = new Object[columns.size()]; Object[] dat = new Object[columns.size()];
data.toArray(dat); data.toArray(dat);
Object[][] columnData = new Object[][] { Object[][] columnData = { col, dat };
col, dat
};
return columnData; return columnData;
} }
......
...@@ -70,7 +70,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref ...@@ -70,7 +70,7 @@ implements XADataSource, DataSource, ConnectionPoolDataSource, Serializable, Ref
private transient PrintWriter logWriter; private transient PrintWriter logWriter;
private int loginTimeout; private int loginTimeout;
private String userName = ""; private String userName = "";
private char[] passwordChars = new char[0]; private char[] passwordChars = { };
private String url = ""; private String url = "";
private String description; private String description;
......
...@@ -56,7 +56,7 @@ public class ResultTempTable implements ResultExternal { ...@@ -56,7 +56,7 @@ public class ResultTempTable implements ResultExternal {
indexColumn.columnName = COLUMN_NAME; indexColumn.columnName = COLUMN_NAME;
IndexType indexType; IndexType indexType;
indexType = IndexType.createPrimaryKey(true, false); indexType = IndexType.createPrimaryKey(true, false);
IndexColumn[] indexCols = new IndexColumn[]{indexColumn}; IndexColumn[] indexCols = { indexColumn };
index = new PageBtreeIndex(table, indexId, data.tableName, indexCols, indexType, true, session); index = new PageBtreeIndex(table, indexId, data.tableName, indexCols, indexType, true, session);
index.setTemporary(true); index.setTemporary(true);
table.getIndexes().add(index); table.getIndexes().add(index);
......
...@@ -171,7 +171,7 @@ public class CipherFactory { ...@@ -171,7 +171,7 @@ public class CipherFactory {
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec( PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(
Utils.convertStringToBytes("30820277020100300d06092a864886f70d0101010500048202613082025d02010002818100dc0a13c602b7141110eade2f051b54777b060d0f74e6a110f9cce81159f271ebc88d8e8aa1f743b505fc2e7dfe38d33b8d3f64d1b363d1af4d877833897954cbaec2fa384c22a415498cf306bb07ac09b76b001cd68bf77ea0a628f5101959cf2993a9c23dbee79b19305977f8715ae78d023471194cc900b231eecb0aaea98d02030100010281810099aa4ff4d0a09a5af0bd953cb10c4d08c3d98df565664ac5582e494314d5c3c92dddedd5d316a32a206be4ec084616fe57be15e27cad111aa3c21fa79e32258c6ca8430afc69eddd52d3b751b37da6b6860910b94653192c0db1d02abcfd6ce14c01f238eec7c20bd3bb750940004bacba2880349a9494d10e139ecb2355d101024100ffdc3defd9c05a2d377ef6019fa62b3fbd5b0020a04cc8533bca730e1f6fcf5dfceea1b044fbe17d9eababfbc7d955edad6bc60f9be826ad2c22ba77d19a9f65024100dc28d43fdbbc93852cc3567093157702bc16f156f709fb7db0d9eec028f41fd0edcd17224c866e66be1744141fb724a10fd741c8a96afdd9141b36d67fff6309024077b1cddbde0f69604bdcfe33263fb36ddf24aa3b9922327915b890f8a36648295d0139ecdf68c245652c4489c6257b58744fbdd961834a4cab201801a3b1e52d024100b17142e8991d1b350a0802624759d48ae2b8071a158ff91fabeb6a8f7c328e762143dc726b8529f42b1fab6220d1c676fdc27ba5d44e847c72c52064afd351a902407c6e23fe35bcfcd1a662aa82a2aa725fcece311644d5b6e3894853fd4ce9fe78218c957b1ff03fc9e5ef8ffeb6bd58235f6a215c97d354fdace7e781e4a63e8b")); Utils.convertStringToBytes("30820277020100300d06092a864886f70d0101010500048202613082025d02010002818100dc0a13c602b7141110eade2f051b54777b060d0f74e6a110f9cce81159f271ebc88d8e8aa1f743b505fc2e7dfe38d33b8d3f64d1b363d1af4d877833897954cbaec2fa384c22a415498cf306bb07ac09b76b001cd68bf77ea0a628f5101959cf2993a9c23dbee79b19305977f8715ae78d023471194cc900b231eecb0aaea98d02030100010281810099aa4ff4d0a09a5af0bd953cb10c4d08c3d98df565664ac5582e494314d5c3c92dddedd5d316a32a206be4ec084616fe57be15e27cad111aa3c21fa79e32258c6ca8430afc69eddd52d3b751b37da6b6860910b94653192c0db1d02abcfd6ce14c01f238eec7c20bd3bb750940004bacba2880349a9494d10e139ecb2355d101024100ffdc3defd9c05a2d377ef6019fa62b3fbd5b0020a04cc8533bca730e1f6fcf5dfceea1b044fbe17d9eababfbc7d955edad6bc60f9be826ad2c22ba77d19a9f65024100dc28d43fdbbc93852cc3567093157702bc16f156f709fb7db0d9eec028f41fd0edcd17224c866e66be1744141fb724a10fd741c8a96afdd9141b36d67fff6309024077b1cddbde0f69604bdcfe33263fb36ddf24aa3b9922327915b890f8a36648295d0139ecdf68c245652c4489c6257b58744fbdd961834a4cab201801a3b1e52d024100b17142e8991d1b350a0802624759d48ae2b8071a158ff91fabeb6a8f7c328e762143dc726b8529f42b1fab6220d1c676fdc27ba5d44e847c72c52064afd351a902407c6e23fe35bcfcd1a662aa82a2aa725fcece311644d5b6e3894853fd4ce9fe78218c957b1ff03fc9e5ef8ffeb6bd58235f6a215c97d354fdace7e781e4a63e8b"));
PrivateKey privateKey = keyFactory.generatePrivate(keySpec); PrivateKey privateKey = keyFactory.generatePrivate(keySpec);
Certificate[] certs = new Certificate[] { CertificateFactory Certificate[] certs = { CertificateFactory
.getInstance("X.509") .getInstance("X.509")
.generateCertificate( .generateCertificate(
new ByteArrayInputStream( new ByteArrayInputStream(
......
...@@ -102,7 +102,7 @@ public class SHA256 { ...@@ -102,7 +102,7 @@ public class SHA256 {
buff[intLen - 2] = byteLen >>> 29; buff[intLen - 2] = byteLen >>> 29;
buff[intLen - 1] = byteLen << 3; buff[intLen - 1] = byteLen << 3;
int[] w = new int[64]; int[] w = new int[64];
int[] hh = new int[] { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, int[] hh = { 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 }; 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 };
for (int block = 0; block < intLen; block += 16) { for (int block = 0; block < intLen; block += 16) {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
......
...@@ -130,7 +130,7 @@ public class DbContents { ...@@ -130,7 +130,7 @@ public class DbContents {
defaultSchema = schema; defaultSchema = schema;
} }
schemas[i] = schema; schemas[i] = schema;
String[] tableTypes = new String[] { "TABLE", "SYSTEM TABLE", "VIEW", "SYSTEM VIEW", String[] tableTypes = { "TABLE", "SYSTEM TABLE", "VIEW", "SYSTEM VIEW",
"TABLE LINK", "SYNONYM" }; "TABLE LINK", "SYNONYM" };
schema.readTables(meta, tableTypes); schema.readTables(meta, tableTypes);
} }
......
...@@ -67,7 +67,7 @@ public class WebServer implements Service { ...@@ -67,7 +67,7 @@ public class WebServer implements Service {
{ "zh_TW", "\u4e2d\u6587 (\u7e41\u9ad4)"}, { "zh_TW", "\u4e2d\u6587 (\u7e41\u9ad4)"},
}; };
private static final String[] GENERIC = new String[] { private static final String[] GENERIC = {
"Generic JNDI Data Source|javax.naming.InitialContext|java:comp/env/jdbc/Test|sa", "Generic JNDI Data Source|javax.naming.InitialContext|java:comp/env/jdbc/Test|sa",
"Generic Firebird Server|org.firebirdsql.jdbc.FBDriver|jdbc:firebirdsql:localhost:c:/temp/firebird/test|sysdba", "Generic Firebird Server|org.firebirdsql.jdbc.FBDriver|jdbc:firebirdsql:localhost:c:/temp/firebird/test|sysdba",
"Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa", "Generic OneDollarDB|in.co.daffodil.db.jdbc.DaffodilDBDriver|jdbc:daffodilDB_embedded:school;path=C:/temp;create=true|sa",
......
...@@ -18,7 +18,7 @@ public class FileStoreOutputStream extends OutputStream { ...@@ -18,7 +18,7 @@ public class FileStoreOutputStream extends OutputStream {
private Data page; private Data page;
private String compressionAlgorithm; private String compressionAlgorithm;
private CompressTool compress; private CompressTool compress;
private byte[] buffer = new byte[1]; private byte[] buffer = { 0 };
public FileStoreOutputStream(FileStore store, DataHandler handler, String compressionAlgorithm) { public FileStoreOutputStream(FileStore store, DataHandler handler, String compressionAlgorithm) {
this.store = store; this.store = store;
......
...@@ -29,7 +29,7 @@ public class PageInputStream extends InputStream { ...@@ -29,7 +29,7 @@ public class PageInputStream extends InputStream {
private int dataPos; private int dataPos;
private boolean endOfFile; private boolean endOfFile;
private int remaining; private int remaining;
private byte[] buffer = new byte[1]; private byte[] buffer = { 0 };
private int logKey; private int logKey;
PageInputStream(PageStore store, int logKey, int firstTrunkPage, int dataPage) { PageInputStream(PageStore store, int logKey, int firstTrunkPage, int dataPage) {
......
...@@ -143,7 +143,7 @@ public class PageStore implements CacheWriter { ...@@ -143,7 +143,7 @@ public class PageStore implements CacheWriter {
private static final int META_TYPE_BTREE_INDEX = 1; private static final int META_TYPE_BTREE_INDEX = 1;
private static final int META_TABLE_ID = -1; private static final int META_TABLE_ID = -1;
private static final SearchRow[] EMPTY_SEARCH_ROW = new SearchRow[0]; private static final SearchRow[] EMPTY_SEARCH_ROW = { };
private Database database; private Database database;
private final Trace trace; private final Trace trace;
......
...@@ -15,7 +15,7 @@ import java.io.InputStream; ...@@ -15,7 +15,7 @@ import java.io.InputStream;
public class FileObjectInputStream extends InputStream { public class FileObjectInputStream extends InputStream {
private FileObject file; private FileObject file;
private byte[] buffer = new byte[1]; private byte[] buffer = { 0 };
/** /**
* Create a new file object input stream from the file object. * Create a new file object input stream from the file object.
......
...@@ -15,7 +15,7 @@ import java.io.OutputStream; ...@@ -15,7 +15,7 @@ import java.io.OutputStream;
public class FileObjectOutputStream extends OutputStream { public class FileObjectOutputStream extends OutputStream {
private FileObject file; private FileObject file;
private byte[] buffer = new byte[1]; private byte[] buffer = { 0 };
/** /**
* Create a new file object output stream from the file object. * Create a new file object output stream from the file object.
......
...@@ -821,7 +821,7 @@ public class MetaTable extends Table { ...@@ -821,7 +821,7 @@ public class MetaTable extends Table {
add(rows, "info.VERSION_MINOR", "" + Constants.VERSION_MINOR); add(rows, "info.VERSION_MINOR", "" + Constants.VERSION_MINOR);
add(rows, "info.VERSION", "" + Constants.getFullVersion()); add(rows, "info.VERSION", "" + Constants.getFullVersion());
if (session.getUser().isAdmin()) { if (session.getUser().isAdmin()) {
String[] settings = new String[]{ String[] settings = {
"java.runtime.version", "java.runtime.version",
"java.vm.name", "java.vendor", "java.vm.name", "java.vendor",
"os.name", "os.arch", "os.version", "sun.os.patch.level", "os.name", "os.arch", "os.version", "sun.os.patch.level",
......
...@@ -40,9 +40,7 @@ public class RangeTable extends Table { ...@@ -40,9 +40,7 @@ public class RangeTable extends Table {
*/ */
public RangeTable(Schema schema, Expression min, Expression max) { public RangeTable(Schema schema, Expression min, Expression max) {
super(schema, 0, NAME, true, true); super(schema, 0, NAME, true, true);
Column[] cols = new Column[]{ Column[] cols = { new Column("X", Value.LONG) };
new Column("X", Value.LONG)
};
this.min = min; this.min = min;
this.max = max; this.max = max;
setColumns(cols); setColumns(cols);
......
...@@ -75,7 +75,7 @@ public class TableLink extends Table { ...@@ -75,7 +75,7 @@ public class TableLink extends Table {
if (!force) { if (!force) {
throw e; throw e;
} }
Column[] cols = new Column[0]; Column[] cols = { };
setColumns(cols); setColumns(cols);
linkedIndex = new LinkedIndex(this, id, IndexColumn.wrap(cols), IndexType.createNonUnique(false)); linkedIndex = new LinkedIndex(this, id, IndexColumn.wrap(cols), IndexType.createNonUnique(false));
indexes.add(linkedIndex); indexes.add(linkedIndex);
......
...@@ -246,7 +246,7 @@ public class MultiDimension implements Comparator<long[]> { ...@@ -246,7 +246,7 @@ public class MultiDimension implements Comparator<long[]> {
} }
long range = high - low + 1; long range = high - low + 1;
if (range == size) { if (range == size) {
long[] item = new long[] { low, high }; long[] item = { low, high };
list.add(item); list.add(item);
} else { } else {
int middle = findMiddle(min[largest], max[largest]); int middle = findMiddle(min[largest], max[largest]);
......
...@@ -648,7 +648,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -648,7 +648,7 @@ public class Recover extends Tool implements DataHandler {
} }
public int read() { public int read() {
byte[] b = new byte[1]; byte[] b = { 0 };
int len = read(b); int len = read(b);
return len < 0 ? -1 : (b[0] & 255); return len < 0 ? -1 : (b[0] & 255);
} }
......
...@@ -29,17 +29,17 @@ public class Utils { ...@@ -29,17 +29,17 @@ public class Utils {
/** /**
* An 0-size byte array. * An 0-size byte array.
*/ */
public static final byte[] EMPTY_BYTES = new byte[0]; public static final byte[] EMPTY_BYTES = {};
/** /**
* An 0-size int array. * An 0-size int array.
*/ */
public static final int[] EMPTY_INT_ARRAY = new int[0]; public static final int[] EMPTY_INT_ARRAY = {};
/** /**
* An 0-size long array. * An 0-size long array.
*/ */
private static final long[] EMPTY_LONG_ARRAY = new long[0]; private static final long[] EMPTY_LONG_ARRAY = {};
private static final int GC_DELAY = 50; private static final int GC_DELAY = 50;
private static final int MAX_GC = 8; private static final int MAX_GC = 8;
......
...@@ -21,9 +21,9 @@ import java.sql.Types; ...@@ -21,9 +21,9 @@ import java.sql.Types;
*/ */
public class BenchC implements Bench { public class BenchC implements Bench {
private static final String[] TABLES = new String[] { "WAREHOUSE", "DISTRICT", "CUSTOMER", "HISTORY", "ORDERS", private static final String[] TABLES = { "WAREHOUSE", "DISTRICT", "CUSTOMER", "HISTORY", "ORDERS",
"NEW_ORDER", "ITEM", "STOCK", "ORDER_LINE", "RESULTS" }; "NEW_ORDER", "ITEM", "STOCK", "ORDER_LINE", "RESULTS" };
private static final String[] CREATE_SQL = new String[] { private static final String[] CREATE_SQL = {
"CREATE TABLE WAREHOUSE(\n" + "CREATE TABLE WAREHOUSE(\n" +
" W_ID INT NOT NULL PRIMARY KEY,\n" + " W_ID INT NOT NULL PRIMARY KEY,\n" +
" W_NAME VARCHAR(10),\n" + " W_NAME VARCHAR(10),\n" +
......
...@@ -44,7 +44,7 @@ public class BenchCThread { ...@@ -44,7 +44,7 @@ public class BenchCThread {
* Process the list of operations (a 'deck') in random order. * Process the list of operations (a 'deck') in random order.
*/ */
void process() throws SQLException { void process() throws SQLException {
int[] deck = new int[] { OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, int[] deck = { OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER,
OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER,
OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_PAYMENT, OP_NEW_ORDER, OP_NEW_ORDER, OP_NEW_ORDER, OP_PAYMENT,
OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT, OP_PAYMENT,
......
...@@ -381,7 +381,7 @@ public class TestCases extends TestBase { ...@@ -381,7 +381,7 @@ public class TestCases extends TestBase {
for (int i = 0; i < 1000; i++) { for (int i = 0; i < 1000; i++) {
stat.execute("INSERT INTO TEST() VALUES()"); stat.execute("INSERT INTO TEST() VALUES()");
} }
final SQLException[] stopped = new SQLException[1]; final SQLException[] stopped = { null };
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
public void run() { public void run() {
try { try {
......
...@@ -66,7 +66,7 @@ public class TestCompatibility extends TestBase { ...@@ -66,7 +66,7 @@ public class TestCompatibility extends TestBase {
private void testColumnAlias() throws SQLException { private void testColumnAlias() throws SQLException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String[] modes = new String[] { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" }; String[] modes = { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" };
String columnAlias; String columnAlias;
columnAlias = "MySQL,Regular"; columnAlias = "MySQL,Regular";
stat.execute("CREATE TABLE TEST(ID INT)"); stat.execute("CREATE TABLE TEST(ID INT)");
...@@ -89,7 +89,7 @@ public class TestCompatibility extends TestBase { ...@@ -89,7 +89,7 @@ public class TestCompatibility extends TestBase {
private void testUniqueIndexSingleNull() throws SQLException { private void testUniqueIndexSingleNull() throws SQLException {
Statement stat = conn.createStatement(); Statement stat = conn.createStatement();
String[] modes = new String[] { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" }; String[] modes = { "PostgreSQL", "MySQL", "HSQLDB", "MSSQLServer", "Derby", "Oracle", "Regular" };
String multiNull = "PostgreSQL,MySQL,Oracle,Regular"; String multiNull = "PostgreSQL,MySQL,Oracle,Regular";
for (String mode : modes) { for (String mode : modes) {
stat.execute("SET MODE " + mode); stat.execute("SET MODE " + mode);
......
...@@ -43,7 +43,7 @@ public class TestExclusive extends TestBase { ...@@ -43,7 +43,7 @@ public class TestExclusive extends TestBase {
Connection conn2 = getConnection("exclusive"); Connection conn2 = getConnection("exclusive");
final Statement stat2 = conn2.createStatement(); final Statement stat2 = conn2.createStatement();
stat.execute("set exclusive true"); stat.execute("set exclusive true");
final int[] state = new int[1]; final int[] state = { 0 };
Thread t = new Thread() { Thread t = new Thread() {
public void run() { public void run() {
try { try {
......
...@@ -98,8 +98,8 @@ public class TestFullText extends TestBase { ...@@ -98,8 +98,8 @@ public class TestFullText extends TestBase {
private void testMultiThreaded() throws Exception { private void testMultiThreaded() throws Exception {
deleteDb("fullText"); deleteDb("fullText");
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
final Exception[] exception = new Exception[1]; final Exception[] exception = { null };
int len = 2; int len = 2;
Thread[] threads = new Thread[len]; Thread[] threads = new Thread[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
......
...@@ -69,13 +69,13 @@ public class TestFunctions extends TestBase implements AggregateFunction { ...@@ -69,13 +69,13 @@ public class TestFunctions extends TestBase implements AggregateFunction {
stat.execute(createSQL); stat.execute(createSQL);
stat.execute("insert into testGreatest values (1)"); stat.execute("insert into testGreatest values (1)");
String query = "SELECT GREATEST(id, " + ((long)Integer.MAX_VALUE) + ") FROM testGreatest"; String query = "SELECT GREATEST(id, " + ((long) Integer.MAX_VALUE) + ") FROM testGreatest";
ResultSet rs = stat.executeQuery(query); ResultSet rs = stat.executeQuery(query);
rs.next(); rs.next();
Object o = rs.getObject(1); Object o = rs.getObject(1);
assertEquals(Long.class.getName(), o.getClass().getName()); assertEquals(Long.class.getName(), o.getClass().getName());
String query2 = "SELECT GREATEST(id, " + ((long)Integer.MAX_VALUE + 1) + ") FROM testGreatest"; String query2 = "SELECT GREATEST(id, " + ((long) Integer.MAX_VALUE + 1) + ") FROM testGreatest";
ResultSet rs2 = stat.executeQuery(query2); ResultSet rs2 = stat.executeQuery(query2);
rs2.next(); rs2.next();
Object o2 = rs2.getObject(1); Object o2 = rs2.getObject(1);
......
...@@ -59,7 +59,7 @@ public class TestIndex extends TestBase { ...@@ -59,7 +59,7 @@ public class TestIndex extends TestBase {
if (config.big) { if (config.big) {
for (int i = 0; i < 2000; i++) { for (int i = 0; i < 2000; i++) {
if ((i % 100) == 0) { if ((i % 100) == 0) {
System.out.println("width: " + i); println("width: " + i);
} }
testWideIndex(i); testWideIndex(i);
} }
......
...@@ -44,7 +44,7 @@ public class TestLargeBlob extends TestBase { ...@@ -44,7 +44,7 @@ public class TestLargeBlob extends TestBase {
prep.setBinaryStream(1, new InputStream() { prep.setBinaryStream(1, new InputStream() {
long remaining = testLength; long remaining = testLength;
int p; int p;
byte[] oneByte = new byte[1]; byte[] oneByte = { 0 };
public void close() { public void close() {
// ignore // ignore
} }
......
...@@ -221,12 +221,12 @@ public class TestLinkedTable extends TestBase { ...@@ -221,12 +221,12 @@ public class TestLinkedTable extends TestBase {
Statement sb = cb.createStatement(); Statement sb = cb.createStatement();
sa.execute("CREATE TABLE TEST(ID INT)"); sa.execute("CREATE TABLE TEST(ID INT)");
sa.execute("INSERT INTO TEST VALUES(1)"); sa.execute("INSERT INTO TEST VALUES(1)");
String[] suffix = new String[]{"", "READONLY", "EMIT UPDATES"}; String[] suffix = {"", "READONLY", "EMIT UPDATES"};
for (int i = 0; i < suffix.length; i++) { for (int i = 0; i < suffix.length; i++) {
String sql = "CREATE LINKED TABLE T(NULL, 'jdbc:h2:mem:one', 'sa', 'sa', 'TEST')" + suffix[i]; String sql = "CREATE LINKED TABLE T(NULL, 'jdbc:h2:mem:one', 'sa', 'sa', 'TEST')" + suffix[i];
sb.execute(sql); sb.execute(sql);
sb.executeQuery("SELECT * FROM T"); sb.executeQuery("SELECT * FROM T");
String[] update = new String[]{"DELETE FROM T", "INSERT INTO T VALUES(2)", "UPDATE T SET ID = 3"}; String[] update = {"DELETE FROM T", "INSERT INTO T VALUES(2)", "UPDATE T SET ID = 3"};
for (String u : update) { for (String u : update) {
try { try {
sb.execute(u); sb.execute(u);
......
...@@ -101,7 +101,7 @@ public class TestSessionsLocks extends TestBase { ...@@ -101,7 +101,7 @@ public class TestSessionsLocks extends TestBase {
assertTrue(otherId != sessionId); assertTrue(otherId != sessionId);
assertFalse(rs.next()); assertFalse(rs.next());
stat2.execute("set throttle 1"); stat2.execute("set throttle 1");
final boolean[] done = new boolean[1]; final boolean[] done = { false };
Runnable runnable = new Runnable() { Runnable runnable = new Runnable() {
public void run() { public void run() {
try { try {
......
...@@ -34,7 +34,7 @@ public class Customer { ...@@ -34,7 +34,7 @@ public class Customer {
//## Java 1.5 begin ## //## Java 1.5 begin ##
public static List<Customer> getList() { public static List<Customer> getList() {
Customer[] list = new Customer[] { Customer[] list = {
new Customer("ALFKI", "WA"), new Customer("ALFKI", "WA"),
new Customer("ANATR", "WA"), new Customer("ANATR", "WA"),
new Customer("ANTON", "CA") }; new Customer("ANTON", "CA") };
......
...@@ -46,7 +46,7 @@ public class Order implements Table { ...@@ -46,7 +46,7 @@ public class Order implements Table {
} }
public static List<Order> getList() { public static List<Order> getList() {
Order[] list = new Order[] { Order[] list = {
new Order("ALFKI", 10702, "330.00", "2007-01-02"), new Order("ALFKI", 10702, "330.00", "2007-01-02"),
new Order("ALFKI", 10952, "471.20", "2007-02-03"), new Order("ALFKI", 10952, "471.20", "2007-02-03"),
new Order("ANATR", 10308, "88.80", "2007-01-03"), new Order("ANATR", 10308, "88.80", "2007-01-03"),
......
...@@ -54,7 +54,7 @@ public class Product implements Table { ...@@ -54,7 +54,7 @@ public class Product implements Table {
} }
public static List<Product> getList() { public static List<Product> getList() {
Product[] list = new Product[] { Product[] list = {
create(1, "Chai", "Beverages", 18, 39), create(1, "Chai", "Beverages", 18, 39),
create(2, "Chang", "Beverages", 19.0, 17), create(2, "Chang", "Beverages", 19.0, 17),
create(3, "Aniseed Syrup", "Condiments", 10.0, 13), create(3, "Aniseed Syrup", "Condiments", 10.0, 13),
......
...@@ -19,7 +19,7 @@ import org.h2.test.TestBase; ...@@ -19,7 +19,7 @@ import org.h2.test.TestBase;
*/ */
public class TestNativeSQL extends TestBase { public class TestNativeSQL extends TestBase {
private static final String[] PAIRS = new String[] { private static final String[] PAIRS = {
"CREATE TABLE TEST(ID INT PRIMARY KEY)", "CREATE TABLE TEST(ID INT PRIMARY KEY)",
"CREATE TABLE TEST(ID INT PRIMARY KEY)", "CREATE TABLE TEST(ID INT PRIMARY KEY)",
......
...@@ -57,7 +57,7 @@ public class TestZloty extends TestBase { ...@@ -57,7 +57,7 @@ public class TestZloty extends TestBase {
Connection conn = getConnection("zloty"); Connection conn = getConnection("zloty");
conn.createStatement().execute("CREATE TABLE TEST(ID INT, DATA BINARY)"); conn.createStatement().execute("CREATE TABLE TEST(ID INT, DATA BINARY)");
PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?)"); PreparedStatement prep = conn.prepareStatement("INSERT INTO TEST VALUES(?, ?)");
byte[] shared = new byte[1]; byte[] shared = { 0 };
prep.setInt(1, 0); prep.setInt(1, 0);
prep.setBytes(2, shared); prep.setBytes(2, shared);
prep.execute(); prep.execute();
......
...@@ -106,7 +106,7 @@ public class TestConnectionPool extends TestBase { ...@@ -106,7 +106,7 @@ public class TestConnectionPool extends TestBase {
private void testThreads() throws Exception { private void testThreads() throws Exception {
final int len = getSize(4, 20); final int len = getSize(4, 20);
final JdbcConnectionPool man = getConnectionPool(len - 2); final JdbcConnectionPool man = getConnectionPool(len - 2);
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
/** /**
* This class gets and returns connections from the pool. * This class gets and returns connections from the pool.
......
...@@ -51,8 +51,8 @@ public class TestXA extends TestBase { ...@@ -51,8 +51,8 @@ public class TestXA extends TestBase {
* A simple Xid implementation. * A simple Xid implementation.
*/ */
public static class MyXid implements Xid { public static class MyXid implements Xid {
private byte[] branchQualifier = new byte[1]; private byte[] branchQualifier = { 0 };
private byte[] globalTransactionId = new byte[1]; private byte[] globalTransactionId = { 0 };
public byte[] getBranchQualifier() { public byte[] getBranchQualifier() {
return branchQualifier; return branchQualifier;
} }
......
...@@ -44,9 +44,9 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -44,9 +44,9 @@ public class TestMvccMultiThreaded extends TestBase {
} }
Connection conn = connList[0]; Connection conn = connList[0];
conn.createStatement().execute("create table test(id int primary key, name varchar)"); conn.createStatement().execute("create table test(id int primary key, name varchar)");
final SQLException[] ex = new SQLException[1]; final SQLException[] ex = { null };
Thread[] threads = new Thread[len]; Thread[] threads = new Thread[len];
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
final Connection c = connList[i]; final Connection c = connList[i];
c.setAutoCommit(false); c.setAutoCommit(false);
...@@ -88,7 +88,7 @@ public class TestMvccMultiThreaded extends TestBase { ...@@ -88,7 +88,7 @@ public class TestMvccMultiThreaded extends TestBase {
Connection conn = connList[0]; Connection conn = connList[0];
conn.createStatement().execute("create table test(id int primary key, value int)"); conn.createStatement().execute("create table test(id int primary key, value int)");
conn.createStatement().execute("insert into test values(0, 0)"); conn.createStatement().execute("insert into test values(0, 0)");
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
final int count = 1000; final int count = 1000;
Thread[] threads = new Thread[len]; Thread[] threads = new Thread[len];
......
...@@ -143,7 +143,7 @@ public class Test { ...@@ -143,7 +143,7 @@ public class Test {
} }
private void testDatabases(DataOutputStream out) throws Exception { private void testDatabases(DataOutputStream out) throws Exception {
Test[] dbs = new Test[] { Test[] dbs = {
new Test("org.h2.Driver", "jdbc:h2:test1", "sa", "", true), new Test("org.h2.Driver", "jdbc:h2:test1", "sa", "", true),
new Test("org.h2.Driver", "jdbc:h2:test2", "sa", "", false), new Test("org.h2.Driver", "jdbc:h2:test2", "sa", "", false),
new Test("org.hsqldb.jdbcDriver", "jdbc:hsqldb:test4", "sa", "", false), new Test("org.hsqldb.jdbcDriver", "jdbc:hsqldb:test4", "sa", "", false),
......
...@@ -36,7 +36,7 @@ public class TestRecoverKillLoop extends TestBase { ...@@ -36,7 +36,7 @@ public class TestRecoverKillLoop extends TestBase {
FileSystemDisk.getInstance().deleteRecursive("data/db", false); FileSystemDisk.getInstance().deleteRecursive("data/db", false);
Random random = new Random(1); Random random = new Random(1);
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
String[] procDef = new String[] { String[] procDef = {
"java", "-cp", getClassPath(), "java", "-cp", getClassPath(),
"-Dtest.dir=data/db", "-Dtest.dir=data/db",
TestRecover.class.getName() TestRecover.class.getName()
......
...@@ -54,7 +54,7 @@ public class TestWrite { ...@@ -54,7 +54,7 @@ public class TestWrite {
file.setLength(0); file.setLength(0);
FileDescriptor fd = file.getFD(); FileDescriptor fd = file.getFD();
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
byte[] data = new byte[] { 0 }; byte[] data = { 0 };
file.write(data); file.write(data);
int i = 0; int i = 0;
if (flush) { if (flush) {
......
...@@ -234,7 +234,7 @@ public abstract class TestHalt extends TestBase { ...@@ -234,7 +234,7 @@ public abstract class TestHalt extends TestBase {
// String classPath = "-cp // String classPath = "-cp
// .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar"; // .;D:/data/java/hsqldb.jar;D:/data/java/derby.jar";
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, String[] procDef = { "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "" + operations, "" + flags, "" + testValue}; getClass().getName(), "" + operations, "" + flags, "" + testValue};
traceOperation("start: " + StringUtils.arrayCombine(procDef, ' ')); traceOperation("start: " + StringUtils.arrayCombine(procDef, ' '));
......
...@@ -47,7 +47,7 @@ public class TestKill extends TestBase { ...@@ -47,7 +47,7 @@ public class TestKill extends TestBase {
String user = getUser(); String user = getUser();
String password = getPassword(); String password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { String[] procDef = {
"java", selfDestruct, "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
"org.h2.test.synth.TestKillProcess", url, user, "org.h2.test.synth.TestKillProcess", url, user,
......
...@@ -32,7 +32,7 @@ public class TestKillRestart extends TestBase { ...@@ -32,7 +32,7 @@ public class TestKillRestart extends TestBase {
// "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0", true); // "killRestart;CACHE_SIZE=2048;WRITE_DELAY=0", true);
String user = getUser(), password = getPassword(); String user = getUser(), password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, String[] procDef = { "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "-url", url, "-user", user, getClass().getName(), "-url", url, "-user", user,
"-password", password }; "-password", password };
......
...@@ -45,7 +45,7 @@ public class TestKillRestartMulti extends TestBase { ...@@ -45,7 +45,7 @@ public class TestKillRestartMulti extends TestBase {
user = getUser(); user = getUser();
password = getPassword(); password = getPassword();
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, String[] procDef = { "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "-url", url, "-user", user, getClass().getName(), "-url", url, "-user", user,
"-password", password }; "-password", password };
......
...@@ -23,7 +23,7 @@ public class TestMultiOrder extends TestMultiThread { ...@@ -23,7 +23,7 @@ public class TestMultiOrder extends TestMultiThread {
private static int orderCount; private static int orderCount;
private static int orderLineCount; private static int orderLineCount;
private static final String[] ITEMS = new String[] { "Apples", "Oranges", "Bananas", "Coffee" }; private static final String[] ITEMS = { "Apples", "Oranges", "Bananas", "Coffee" };
private Connection conn; private Connection conn;
private PreparedStatement insertLine; private PreparedStatement insertLine;
......
...@@ -17,7 +17,7 @@ call TO_DATE('1990.02.03') ...@@ -17,7 +17,7 @@ call TO_DATE('1990.02.03')
drop alias if exists TO_CHAR; drop alias if exists TO_CHAR;
create alias TO_CHAR as $$ create alias TO_CHAR as $$
String toChar(BigDecimal x, String pattern) throws Exception { String toChar(BigDecimal x, String pattern) throws Exception {
return new java.text.DecimalFormat(pattern).format(x); return new java.text.DecimalFormat(pattern).format(x);
} }
$$; $$;
call TO_CHAR(123456789.12, '###,###,###,###.##'); call TO_CHAR(123456789.12, '###,###,###,###.##');
......
...@@ -63,8 +63,8 @@ public class TestCompress extends TestBase { ...@@ -63,8 +63,8 @@ public class TestCompress extends TestBase {
private void testMultiThreaded() throws Exception { private void testMultiThreaded() throws Exception {
Thread[] threads = new Thread[3]; Thread[] threads = new Thread[3];
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
for (int i = 0; i < threads.length; i++) { for (int i = 0; i < threads.length; i++) {
Thread t = new Thread() { Thread t = new Thread() {
public void run() { public void run() {
......
...@@ -32,7 +32,7 @@ public class TestExit extends TestBase implements DatabaseEventListener { ...@@ -32,7 +32,7 @@ public class TestExit extends TestBase implements DatabaseEventListener {
} }
deleteDb("exit"); deleteDb("exit");
String selfDestruct = SelfDestructor.getPropertyString(60); String selfDestruct = SelfDestructor.getPropertyString(60);
String[] procDef = new String[] { "java", selfDestruct, String[] procDef = { "java", selfDestruct,
"-cp", getClassPath(), "-cp", getClassPath(),
getClass().getName(), "" + OPEN_WITH_CLOSE_ON_EXIT }; getClass().getName(), "" + OPEN_WITH_CLOSE_ON_EXIT };
Process proc = Runtime.getRuntime().exec(procDef); Process proc = Runtime.getRuntime().exec(procDef);
......
...@@ -99,8 +99,8 @@ public class TestFileLockSerialized extends TestBase { ...@@ -99,8 +99,8 @@ public class TestFileLockSerialized extends TestBase {
conn.close(); conn.close();
final int len = 10; final int len = 10;
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
Thread[] threads = new Thread[len]; Thread[] threads = new Thread[len];
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
Thread t = new Thread(new Runnable() { Thread t = new Thread(new Runnable() {
...@@ -161,7 +161,7 @@ public class TestFileLockSerialized extends TestBase { ...@@ -161,7 +161,7 @@ public class TestFileLockSerialized extends TestBase {
deleteDb("fileLockSerialized"); deleteDb("fileLockSerialized");
String url = "jdbc:h2:" + baseDir + "/fileLockSerialized"; String url = "jdbc:h2:" + baseDir + "/fileLockSerialized";
final String writeUrl = url + ";FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE"; final String writeUrl = url + ";FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE";
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
Connection conn = DriverManager.getConnection(writeUrl, "sa", "sa"); Connection conn = DriverManager.getConnection(writeUrl, "sa", "sa");
conn.createStatement().execute("create table test(id identity) as select x from system_range(1, 100)"); conn.createStatement().execute("create table test(id identity) as select x from system_range(1, 100)");
conn.close(); conn.close();
...@@ -334,9 +334,9 @@ public class TestFileLockSerialized extends TestBase { ...@@ -334,9 +334,9 @@ public class TestFileLockSerialized extends TestBase {
conn.close(); conn.close();
final long endTime = System.currentTimeMillis() + runTime; final long endTime = System.currentTimeMillis() + runTime;
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
final Connection[] connList = new Connection[howManyThreads]; final Connection[] connList = new Connection[howManyThreads];
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
final int[] nextInt = { 0 }; final int[] nextInt = { 0 };
Thread[] threads = new Thread[howManyThreads]; Thread[] threads = new Thread[howManyThreads];
for (int i = 0; i < howManyThreads; i++) { for (int i = 0; i < howManyThreads; i++) {
...@@ -402,9 +402,9 @@ public class TestFileLockSerialized extends TestBase { ...@@ -402,9 +402,9 @@ public class TestFileLockSerialized extends TestBase {
conn.close(); conn.close();
final long endTime = System.currentTimeMillis() + runTime; final long endTime = System.currentTimeMillis() + runTime;
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
final Connection[] connList = new Connection[howManyThreads]; final Connection[] connList = new Connection[howManyThreads];
final boolean[] stop = new boolean[1]; final boolean[] stop = { false };
final int[] lastInt = { 1 }; final int[] lastInt = { 1 };
Thread[] threads = new Thread[howManyThreads]; Thread[] threads = new Thread[howManyThreads];
for (int i = 0; i < howManyThreads; i++) { for (int i = 0; i < howManyThreads; i++) {
...@@ -537,7 +537,7 @@ public class TestFileLockSerialized extends TestBase { ...@@ -537,7 +537,7 @@ public class TestFileLockSerialized extends TestBase {
final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;CACHE_SIZE=" + cacheSizeKb; final String url = "jdbc:h2:" + baseDir + "/fileLockSerialized;FILE_LOCK=SERIALIZED;OPEN_NEW=TRUE;CACHE_SIZE=" + cacheSizeKb;
final boolean[] importFinished = { false }; final boolean[] importFinished = { false };
final Exception[] ex = new Exception[1]; final Exception[] ex = { null };
final Thread importUpdate = new Thread() { final Thread importUpdate = new Thread() {
public void run() { public void run() {
try { try {
......
...@@ -46,7 +46,7 @@ public class TestIntArray extends TestBase { ...@@ -46,7 +46,7 @@ public class TestIntArray extends TestBase {
private void testRandom() { private void testRandom() {
IntArray array = new IntArray(); IntArray array = new IntArray();
int[] test = new int[0]; int[] test = {};
Random random = new Random(1); Random random = new Random(1);
for (int i = 0; i < 10000; i++) { for (int i = 0; i < 10000; i++) {
int idx = test.length == 0 ? 0 : random.nextInt(test.length); int idx = test.length == 0 ? 0 : random.nextInt(test.length);
......
...@@ -32,7 +32,7 @@ public class TestOldVersion extends TestBase { ...@@ -32,7 +32,7 @@ public class TestOldVersion extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
URL[] urls = new URL[] { new URL("file:ext/h2-1.2.127.jar") }; URL[] urls = { new URL("file:ext/h2-1.2.127.jar") };
ClassLoader cl = new URLClassLoader(urls, null); ClassLoader cl = new URLClassLoader(urls, null);
// cl = getClass().getClassLoader(); // cl = getClass().getClassLoader();
Class< ? > driverClass = cl.loadClass("org.h2.Driver"); Class< ? > driverClass = cl.loadClass("org.h2.Driver");
......
...@@ -66,7 +66,7 @@ public class TestScriptReader extends TestBase { ...@@ -66,7 +66,7 @@ public class TestScriptReader extends TestBase {
switch (random.nextInt(10)) { switch (random.nextInt(10)) {
case 0: { case 0: {
int l = random.nextInt(4); int l = random.nextInt(4);
String[] ch = new String[] { "\n", "\r", " ", "*", "a", "0", "$ " }; String[] ch = { "\n", "\r", " ", "*", "a", "0", "$ " };
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
...@@ -75,7 +75,7 @@ public class TestScriptReader extends TestBase { ...@@ -75,7 +75,7 @@ public class TestScriptReader extends TestBase {
case 1: { case 1: {
buff.append('\''); buff.append('\'');
int l = random.nextInt(4); int l = random.nextInt(4);
String[] ch = new String[] { ";", "\n", "\r", "--", "//", "/", "-", "*", "/*", "*/", "\"", "$ " }; String[] ch = { ";", "\n", "\r", "--", "//", "/", "-", "*", "/*", "*/", "\"", "$ " };
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
...@@ -85,7 +85,7 @@ public class TestScriptReader extends TestBase { ...@@ -85,7 +85,7 @@ public class TestScriptReader extends TestBase {
case 2: { case 2: {
buff.append('"'); buff.append('"');
int l = random.nextInt(4); int l = random.nextInt(4);
String[] ch = new String[] { ";", "\n", "\r", "--", "//", "/", "-", "*", "/*", "*/", "\'", "$" }; String[] ch = { ";", "\n", "\r", "--", "//", "/", "-", "*", "/*", "*/", "\'", "$" };
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
...@@ -95,14 +95,14 @@ public class TestScriptReader extends TestBase { ...@@ -95,14 +95,14 @@ public class TestScriptReader extends TestBase {
case 3: { case 3: {
buff.append('-'); buff.append('-');
if (random.nextBoolean()) { if (random.nextBoolean()) {
String[] ch = new String[] { "\n", "\r", "*", "a", " ", "$ " }; String[] ch = { "\n", "\r", "*", "a", " ", "$ " };
int l = 1 + random.nextInt(4); int l = 1 + random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
} else { } else {
buff.append('-'); buff.append('-');
String[] ch = new String[] { ";", "-", "//", "/*", "*/", "a", "$" }; String[] ch = { ";", "-", "//", "/*", "*/", "a", "$" };
int l = random.nextInt(4); int l = random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
...@@ -114,14 +114,14 @@ public class TestScriptReader extends TestBase { ...@@ -114,14 +114,14 @@ public class TestScriptReader extends TestBase {
case 4: { case 4: {
buff.append('/'); buff.append('/');
if (random.nextBoolean()) { if (random.nextBoolean()) {
String[] ch = new String[] { "\n", "\r", "a", " ", "- ", "$ " }; String[] ch = { "\n", "\r", "a", " ", "- ", "$ " };
int l = 1 + random.nextInt(4); int l = 1 + random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
} else { } else {
buff.append('*'); buff.append('*');
String[] ch = new String[] { ";", "-", "//", "/* ", "--", "\n", "\r", "a", "$" }; String[] ch = { ";", "-", "//", "/* ", "--", "\n", "\r", "a", "$" };
int l = random.nextInt(4); int l = random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
...@@ -136,14 +136,14 @@ public class TestScriptReader extends TestBase { ...@@ -136,14 +136,14 @@ public class TestScriptReader extends TestBase {
} }
buff.append("$"); buff.append("$");
if (random.nextBoolean()) { if (random.nextBoolean()) {
String[] ch = new String[] { "\n", "\r", "a", " ", "- ", "/ " }; String[] ch = { "\n", "\r", "a", " ", "- ", "/ " };
int l = 1 + random.nextInt(4); int l = 1 + random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
} }
} else { } else {
buff.append("$"); buff.append("$");
String[] ch = new String[] { ";", "-", "//", "/* ", "--", "\n", "\r", "a", "$ " }; String[] ch = { ";", "-", "//", "/* ", "--", "\n", "\r", "a", "$ " };
int l = random.nextInt(4); int l = random.nextInt(4);
for (int j = 0; j < l; j++) { for (int j = 0; j < l; j++) {
buff.append(ch[random.nextInt(ch.length)]); buff.append(ch[random.nextInt(ch.length)]);
......
...@@ -37,7 +37,7 @@ public class TestStreams extends TestBase { ...@@ -37,7 +37,7 @@ public class TestStreams extends TestBase {
} }
private byte[] getRandomBytes(Random random) { private byte[] getRandomBytes(Random random) {
int[] sizes = new int[] { 0, 1, random.nextInt(1000), random.nextInt(100000), random.nextInt(1000000) }; int[] sizes = { 0, 1, random.nextInt(1000), random.nextInt(100000), random.nextInt(1000000) };
int size = sizes[random.nextInt(sizes.length)]; int size = sizes[random.nextInt(sizes.length)];
byte[] buffer = new byte[size]; byte[] buffer = new byte[size];
if (random.nextInt(5) == 1) { if (random.nextInt(5) == 1) {
...@@ -74,7 +74,7 @@ public class TestStreams extends TestBase { ...@@ -74,7 +74,7 @@ public class TestStreams extends TestBase {
comp.write(buffer); comp.write(buffer);
} else { } else {
for (int j = 0; j < buffer.length;) { for (int j = 0; j < buffer.length;) {
int[] sizes = new int[] { 0, 1, random.nextInt(100), random.nextInt(100000) }; int[] sizes = { 0, 1, random.nextInt(100), random.nextInt(100000) };
int size = sizes[random.nextInt(sizes.length)]; int size = sizes[random.nextInt(sizes.length)];
size = Math.min(size, buffer.length - j); size = Math.min(size, buffer.length - j);
if (size == 1) { if (size == 1) {
...@@ -91,7 +91,7 @@ public class TestStreams extends TestBase { ...@@ -91,7 +91,7 @@ public class TestStreams extends TestBase {
LZFInputStream decompress = new LZFInputStream(in); LZFInputStream decompress = new LZFInputStream(in);
byte[] test = new byte[buffer.length]; byte[] test = new byte[buffer.length];
for (int j = 0; j < buffer.length;) { for (int j = 0; j < buffer.length;) {
int[] sizes = new int[] { 0, 1, random.nextInt(100), random.nextInt(100000) }; int[] sizes = { 0, 1, random.nextInt(100), random.nextInt(100000) };
int size = sizes[random.nextInt(sizes.length)]; int size = sizes[random.nextInt(sizes.length)];
if (size == 1) { if (size == 1) {
int x = decompress.read(); int x = decompress.read();
......
...@@ -21,7 +21,7 @@ public class TestStringCache extends TestBase { ...@@ -21,7 +21,7 @@ public class TestStringCache extends TestBase {
*/ */
volatile boolean stop; volatile boolean stop;
private Random random = new Random(1); private Random random = new Random(1);
private String[] some = new String[] { null, "", "ABC", "this is a medium sized string", "1", "2" }; private String[] some = { null, "", "ABC", "this is a medium sized string", "1", "2" };
private boolean returnNew; private boolean returnNew;
private boolean useIntern; private boolean useIntern;
......
...@@ -98,8 +98,8 @@ public class TestTools extends TestBase { ...@@ -98,8 +98,8 @@ public class TestTools extends TestBase {
rs.addColumn("j", Types.TIMESTAMP, 0, 0); rs.addColumn("j", Types.TIMESTAMP, 0, 0);
Date d = Date.valueOf("2001-02-03"); Date d = Date.valueOf("2001-02-03");
byte[] b = new byte[]{(byte) 0xab}; byte[] b = {(byte) 0xab};
Object[] a = new Object[]{1, 2}; Object[] a = {1, 2};
Time t = Time.valueOf("10:20:30"); Time t = Time.valueOf("10:20:30");
Timestamp ts = Timestamp.valueOf("2002-03-04 10:20:30"); Timestamp ts = Timestamp.valueOf("2002-03-04 10:20:30");
rs.addRow(1, b, true, d, "10.3", Math.PI, "-3", a, t, ts); rs.addRow(1, b, true, d, "10.3", Math.PI, "-3", a, t, ts);
...@@ -606,7 +606,7 @@ public class TestTools extends TestBase { ...@@ -606,7 +606,7 @@ public class TestTools extends TestBase {
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA CLOB) " + stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, DATA CLOB) " +
"AS SELECT X, SPACE(3000) FROM SYSTEM_RANGE(1, 300)"); "AS SELECT X, SPACE(3000) FROM SYSTEM_RANGE(1, 300)");
conn.close(); conn.close();
String[] args = new String[] { "-dir", baseDir, "-db", "utils", "-cipher", "XTEA", "-decrypt", "abc", "-quiet" }; String[] args = { "-dir", baseDir, "-db", "utils", "-cipher", "XTEA", "-decrypt", "abc", "-quiet" };
ChangeFileEncryption.main(args); ChangeFileEncryption.main(args);
args = new String[] { "-dir", baseDir, "-db", "utils", "-cipher", "AES", "-encrypt", "def", "-quiet" }; args = new String[] { "-dir", baseDir, "-db", "utils", "-cipher", "AES", "-encrypt", "def", "-quiet" };
ChangeFileEncryption.main(args); ChangeFileEncryption.main(args);
......
...@@ -33,7 +33,7 @@ public class TestValue extends TestBase { ...@@ -33,7 +33,7 @@ public class TestValue extends TestBase {
} }
private void testDouble(boolean useFloat) { private void testDouble(boolean useFloat) {
double[] d = new double[]{ double[] d = {
Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY,
-1, -1,
0, 0,
......
...@@ -23,9 +23,9 @@ public class CheckTextFiles { ...@@ -23,9 +23,9 @@ public class CheckTextFiles {
private static final String COPYRIGHT = "Copyright 2004-2010 " + "H2 Group."; private static final String COPYRIGHT = "Copyright 2004-2010 " + "H2 Group.";
private static final String LICENSE = "Multiple-Licensed " + "under the H2 License"; private static final String LICENSE = "Multiple-Licensed " + "under the H2 License";
private static final String[] SUFFIX_CHECK = new String[] { "html", "jsp", "js", "css", "bat", "nsi", private static final String[] SUFFIX_CHECK = { "html", "jsp", "js", "css", "bat", "nsi",
"java", "txt", "properties", "sql", "xml", "csv", "Driver", "prefs" }; "java", "txt", "properties", "sql", "xml", "csv", "Driver", "prefs" };
private static final String[] SUFFIX_IGNORE = new String[] { "gif", "png", "odg", "ico", "sxd", private static final String[] SUFFIX_IGNORE = { "gif", "png", "odg", "ico", "sxd",
"layout", "res", "win", "jar", "task", "svg", "MF", "sh", "DS_Store", "prop" }; "layout", "res", "win", "jar", "task", "svg", "MF", "sh", "DS_Store", "prop" };
private boolean failOnError; private boolean failOnError;
...@@ -33,7 +33,7 @@ public class CheckTextFiles { ...@@ -33,7 +33,7 @@ public class CheckTextFiles {
private int spacesPerTab = 4; private int spacesPerTab = 4;
private boolean autoFix = true; private boolean autoFix = true;
private boolean useCRLF; private boolean useCRLF;
private String[] suffixIgnoreLicense = new String[] { "bat", "nsi", "txt", "properties", "xml", "java.sql.Driver", "task", "sh", "prefs" }; private String[] suffixIgnoreLicense = { "bat", "nsi", "txt", "properties", "xml", "java.sql.Driver", "task", "sh", "prefs" };
private boolean hasError; private boolean hasError;
/** /**
......
...@@ -23,7 +23,7 @@ import org.h2.util.StringUtils; ...@@ -23,7 +23,7 @@ import org.h2.util.StringUtils;
public class LinkChecker { public class LinkChecker {
private static final boolean OPEN_EXTERNAL_LINKS = false; private static final boolean OPEN_EXTERNAL_LINKS = false;
private static final String[] IGNORE_MISSING_LINKS_TO = new String[]{ private static final String[] IGNORE_MISSING_LINKS_TO = {
"SysProperties", "ErrorCode" "SysProperties", "ErrorCode"
}; };
......
...@@ -23,9 +23,9 @@ import org.h2.build.BuildBase; ...@@ -23,9 +23,9 @@ import org.h2.build.BuildBase;
*/ */
public class SpellChecker { public class SpellChecker {
private static final String[] SUFFIX = new String[] { "html", "java", "sql", "txt", "xml", "jsp", "css", "bat", private static final String[] SUFFIX = { "html", "java", "sql", "txt", "xml", "jsp", "css", "bat",
"csv", "xml", "js", "Driver", "properties", "task", "MF", "sh", "" }; "csv", "xml", "js", "Driver", "properties", "task", "MF", "sh", "" };
private static final String[] IGNORE = new String[] { "dev", "nsi", "gif", "png", "odg", "ico", "sxd", "zip", private static final String[] IGNORE = { "dev", "nsi", "gif", "png", "odg", "ico", "sxd", "zip",
"bz2", "rc", "layout", "res", "dll", "jar", "svg", "prefs", "prop" }; "bz2", "rc", "layout", "res", "dll", "jar", "svg", "prefs", "prop" };
private static final String DELIMITERS = " \n.();-\"=,*/{}_<>+\r:'@[]&\\!#|?$^%~`\t"; private static final String DELIMITERS = " \n.();-\"=,*/{}_<>+\r:'@[]&\\!#|?$^%~`\t";
private static final String PREFIX_IGNORE = "abc"; private static final String PREFIX_IGNORE = "abc";
......
...@@ -81,7 +81,7 @@ public class XMLChecker { ...@@ -81,7 +81,7 @@ public class XMLChecker {
// String lastElement = null; // String lastElement = null;
// <li>: replace <li>([^\r]*[^<]*) with <li>$1</li> // <li>: replace <li>([^\r]*[^<]*) with <li>$1</li>
// use this for html file, for example if <li> is not closed // use this for html file, for example if <li> is not closed
String[] noClose = new String[] {}; String[] noClose = {};
XMLParser parser = new XMLParser(xml); XMLParser parser = new XMLParser(xml);
Stack<Object[]> stack = new Stack<Object[]>(); Stack<Object[]> stack = new Stack<Object[]>();
boolean rootElement = false; boolean rootElement = false;
......
...@@ -637,4 +637,5 @@ postfix iconified deiconified deactivated activated worker frequent utilities ...@@ -637,4 +637,5 @@ postfix iconified deiconified deactivated activated worker frequent utilities
workers appender recovers balanced serializing breaking austria wildam workers appender recovers balanced serializing breaking austria wildam
census genealogy scapegoat gov compacted migrating dies typtypmod latch await census genealogy scapegoat gov compacted migrating dies typtypmod latch await
counting dtest fallback infix places formal extern destination stdout memmove counting dtest fallback infix places formal extern destination stdout memmove
stdio printf stdio printf jchar sizeof stdlib jbyte jint uint ujlong typedef jdouble stdint
\ No newline at end of file jfloat wchar hotspot jvoid std ujint jlong vars jboolean calloc argc strlen
\ No newline at end of file
...@@ -61,7 +61,7 @@ public class SecureKeyStoreBuilder { ...@@ -61,7 +61,7 @@ public class SecureKeyStoreBuilder {
System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\"" System.out.println(pkFormat + "EncodedKeySpec keySpec = new " + pkFormat + "EncodedKeySpec(getBytes(\""
+ encoded + "\"));"); + encoded + "\"));");
System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);"); System.out.println("PrivateKey privateKey = keyFactory.generatePrivate(keySpec);");
System.out.println("Certificate[] certs = new Certificate[] {"); System.out.println("Certificate[] certs = {");
for (Certificate cert : store.getCertificateChain(alias)) { for (Certificate cert : store.getCertificateChain(alias)) {
System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\")."); System.out.println(" CertificateFactory.getInstance(\""+cert.getType()+"\").");
String enc = Utils.convertBytesToString(cert.getEncoded()); String enc = Utils.convertBytesToString(cert.getEncoded());
......
...@@ -34,7 +34,7 @@ public class FunctionsMySQL { ...@@ -34,7 +34,7 @@ public class FunctionsMySQL {
* See * See
* http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format * http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
*/ */
private static final String[] FORMAT_REPLACE = new String[] { private static final String[] FORMAT_REPLACE = {
"%a", "EEE", "%a", "EEE",
"%b", "MMM", "%b", "MMM",
"%c", "MM", "%c", "MM",
...@@ -68,7 +68,7 @@ public class FunctionsMySQL { ...@@ -68,7 +68,7 @@ public class FunctionsMySQL {
* @param conn the connection * @param conn the connection
*/ */
public static void register(Connection conn) throws SQLException { public static void register(Connection conn) throws SQLException {
String[] init = new String[] { String[] init = {
"UNIX_TIMESTAMP", "unixTimestamp", "UNIX_TIMESTAMP", "unixTimestamp",
"FROM_UNIXTIME", "fromUnixTime", "FROM_UNIXTIME", "fromUnixTime",
"DATE", "date", "DATE", "date",
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论