8243156: Fix deprecation and unchecked warnings in microbenchmark
Reviewed-by: erikj, redestad
This commit is contained in:
parent
71b06ed298
commit
48569d9da0
@ -77,7 +77,7 @@ $(eval $(call SetupJavaCompilation, BUILD_INDIFY, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := $(TOPDIR)/test/jdk/java/lang/invoke, \
|
||||
INCLUDE_FILES := indify/Indify.java, \
|
||||
DISABLED_WARNINGS := rawtypes unchecked serial deprecation, \
|
||||
DISABLED_WARNINGS := rawtypes serial, \
|
||||
BIN := $(MICROBENCHMARK_TOOLS_CLASSES), \
|
||||
))
|
||||
|
||||
@ -99,7 +99,7 @@ $(eval $(call SetupJavaCompiler, MICROBENCHMARK_JAVA_COMPILER, \
|
||||
$(eval $(call SetupJavaCompilation, BUILD_JDK_MICROBENCHMARK, \
|
||||
SETUP := MICROBENCHMARK_JAVA_COMPILER, \
|
||||
ADD_JAVAC_FLAGS := -cp $(MICROBENCHMARK_CLASSPATH), \
|
||||
DISABLED_WARNINGS := processing rawtypes cast serial deprecation, \
|
||||
DISABLED_WARNINGS := processing rawtypes cast serial, \
|
||||
SRC := $(MICROBENCHMARK_SRC), \
|
||||
BIN := $(MICROBENCHMARK_CLASSES), \
|
||||
))
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -702,7 +702,9 @@ public class Indify {
|
||||
args = jvm.args(3); // array, index, value
|
||||
if (args.get(0) instanceof List &&
|
||||
args.get(1) instanceof Integer) {
|
||||
((List<Object>)args.get(0)).set( (Integer)args.get(1), args.get(2) );
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> arg0 = (List<Object>)args.get(0);
|
||||
arg0.set( (Integer)args.get(1), args.get(2) );
|
||||
}
|
||||
args.clear();
|
||||
break;
|
||||
@ -869,7 +871,7 @@ public class Indify {
|
||||
if (patternMark != 'I') break decode;
|
||||
if ("invokeWithArguments".equals(intrinsic))
|
||||
flattenVarargs(args);
|
||||
bsmArgs = new ArrayList(args);
|
||||
bsmArgs = new ArrayList<>(args);
|
||||
args.clear(); args.add("invokeGeneric");
|
||||
continue;
|
||||
case "Integer.valueOf":
|
||||
@ -970,8 +972,10 @@ public class Indify {
|
||||
|
||||
private void flattenVarargs(List<Object> args) {
|
||||
int size = args.size();
|
||||
if (size > 0 && args.get(size-1) instanceof List)
|
||||
args.addAll((List<Object>) args.remove(size-1));
|
||||
if (size > 0 && args.get(size - 1) instanceof List) {
|
||||
List<?> removedArg = (List<?>) args.remove(size - 1);
|
||||
args.addAll(removedArg);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isConstant(Object x, int tag) {
|
||||
@ -1032,6 +1036,7 @@ public class Indify {
|
||||
extraArgs.addAll(args.subList(argi, args.size() - 1));
|
||||
Object lastArg = args.get(args.size() - 1);
|
||||
if (lastArg instanceof List) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> lastArgs = (List<Object>) lastArg;
|
||||
removeEmptyJVMSlots(lastArgs);
|
||||
extraArgs.addAll(lastArgs);
|
||||
@ -1098,7 +1103,9 @@ public class Indify {
|
||||
} catch (IOException ex) { throw new InternalError(); }
|
||||
bsms.item = specs;
|
||||
}
|
||||
return (List<Object[]>) bsms.item;
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object[]> specs = (List<Object[]>) bsms.item;
|
||||
return specs;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1168,7 +1175,7 @@ public class Indify {
|
||||
data = in.readUTF();
|
||||
} else if (Chunk.class.isAssignableFrom(dataClass)) {
|
||||
T obj;
|
||||
try { obj = dataClass.newInstance(); }
|
||||
try { obj = dataClass.getDeclaredConstructor().newInstance(); }
|
||||
catch (Exception ex) { throw new RuntimeException(ex); }
|
||||
((Chunk)obj).readFrom(in);
|
||||
data = obj;
|
||||
@ -1317,7 +1324,7 @@ public class Indify {
|
||||
readConstant(in);
|
||||
}
|
||||
}
|
||||
public <T> Constant<T> addConstant(byte tag, T item) {
|
||||
public <T> Constant addConstant(byte tag, T item) {
|
||||
Constant<T> con = new Constant<>(size(), tag, item);
|
||||
int idx = indexOf(con);
|
||||
if (idx >= 0) return get(idx);
|
||||
@ -1339,7 +1346,7 @@ public class Indify {
|
||||
arg = in.readInt(); break;
|
||||
case CONSTANT_Long:
|
||||
case CONSTANT_Double:
|
||||
add(new Constant(index, tag, in.readLong()));
|
||||
add(new Constant<>(index, tag, in.readLong()));
|
||||
add(null);
|
||||
return;
|
||||
case CONSTANT_Class:
|
||||
@ -1362,7 +1369,7 @@ public class Indify {
|
||||
default:
|
||||
throw new InternalError("bad CP tag "+tag);
|
||||
}
|
||||
add(new Constant(index, tag, arg));
|
||||
add(new Constant<>(index, tag, arg));
|
||||
}
|
||||
|
||||
// Access:
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,6 +60,7 @@ public class NewInstance {
|
||||
* Performs Class.newInstance on the same class over and over again. That it is the same class is not provable at
|
||||
* compile time. The class is protected.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeSameProtected(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
for (Class<?> cl : sameProtectedClasses) {
|
||||
@ -71,6 +72,7 @@ public class NewInstance {
|
||||
* Performs Class.newInstance on three different classes, just allocating one instance of one class at a time. The
|
||||
* classes are all protected.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeDifferentProtected(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
for (Class<?> cl : differentProtectedClasses) {
|
||||
@ -82,6 +84,7 @@ public class NewInstance {
|
||||
* Performs Class.newInstance on the same class over and over again. That it is the same class is not provable at
|
||||
* compile time. The class is public.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeSamePublic(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
for (Class<?> cl : samePublicClasses) {
|
||||
@ -93,6 +96,7 @@ public class NewInstance {
|
||||
* Performs Class.newInstance on three different classes, just allocating one instance of one class at a time. The
|
||||
* classes are all public.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeDifferentPublic(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
for (Class<?> cl : differentPublicClasses) {
|
||||
@ -104,6 +108,7 @@ public class NewInstance {
|
||||
* Performs Class.newInstance on three different classes, just allocating one instance of one class at a time. The
|
||||
* classes are all public.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeDifferentPublicConstant(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
bh.consume(Apub.class.newInstance());
|
||||
@ -111,6 +116,7 @@ public class NewInstance {
|
||||
bh.consume(Cpub.class.newInstance());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Benchmark
|
||||
public void threeDifferentPublicFinal(Blackhole bh) throws IllegalAccessException, InstantiationException {
|
||||
for (Class<?> cl : differentPublicClassesConstant) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -59,9 +59,9 @@ public class MethodInvoke {
|
||||
args_6ref = new Object[]{ new Object(), new Object(),
|
||||
new Object(), new Object(), new Object(), new Object()};
|
||||
args_6prim = new Object[]{
|
||||
new Integer(1), new Long(5L),
|
||||
new Double(5.6d), new Float(23.11f),
|
||||
Boolean.TRUE, new Character('d')
|
||||
1, 5L,
|
||||
5.6d, 23.11f,
|
||||
Boolean.TRUE, 'd'
|
||||
};
|
||||
|
||||
staticMeth_0 = getMethodWithName("staticMethodWithoutParams");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -73,11 +73,13 @@ public class ProxyBench {
|
||||
PkgPrivate1.class, PkgPrivate2.class};
|
||||
|
||||
@Benchmark
|
||||
@SuppressWarnings("deprecation")
|
||||
public Class<?> getProxyClass1i() {
|
||||
return Proxy.getProxyClass(loader1, interfaces1);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@SuppressWarnings("deprecation")
|
||||
public Class<?> getProxyClass4i() {
|
||||
return Proxy.getProxyClass(loader4, interfaces4);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -33,6 +33,7 @@ import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -142,7 +143,7 @@ public class BigDecimals {
|
||||
@OperationsPerInvocation(TEST_SIZE)
|
||||
public void testSetScale(Blackhole bh) {
|
||||
for (BigDecimal s : bigDecimals) {
|
||||
bh.consume(s.setScale(2, BigDecimal.ROUND_HALF_UP));
|
||||
bh.consume(s.setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,7 +153,7 @@ public class BigDecimals {
|
||||
public void testSetScaleVarious(Blackhole bh) {
|
||||
for (int scale = 0; scale < 50; scale++) {
|
||||
for (BigDecimal s : bigDecimals) {
|
||||
bh.consume(s.setScale(scale, BigDecimal.ROUND_HALF_UP));
|
||||
bh.consume(s.setScale(scale, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -62,7 +62,7 @@ public class Maps {
|
||||
total = 0;
|
||||
key = new Integer[nkeys];
|
||||
for (int i = 0; i < key.length; ++i) {
|
||||
key[i] = new Integer(rng.next());
|
||||
key[i] = rng.next();
|
||||
}
|
||||
position = key.length / 2;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,7 +35,7 @@ public class IntegerDuplicateProblem {
|
||||
Random rand = new Random(0x30052012);
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = new Integer(rand.nextInt());
|
||||
data[i] = rand.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,7 +35,7 @@ public class IntegerMaxProblem {
|
||||
Random rand = new Random(0x30052012);
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = new Integer(rand.nextInt());
|
||||
data[i] = rand.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -35,7 +35,7 @@ public class IntegerSumProblem {
|
||||
Random rand = new Random(0x30052012);
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = new Integer(rand.nextInt());
|
||||
data[i] = rand.nextInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user