提交 6aadd150 编写于 作者: V vlivanov

8030079: Lint warnings in java.lang.invoke

8031373: Lint warnings in java.util.stream
Reviewed-by: psandoz, forax
上级 e84c709f
...@@ -612,7 +612,7 @@ import jdk.internal.org.objectweb.asm.Type; ...@@ -612,7 +612,7 @@ import jdk.internal.org.objectweb.asm.Type;
mv.visitVarInsn(ALOAD, 1); mv.visitVarInsn(ALOAD, 1);
mv.visitVarInsn(ALOAD, 2); mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKESPECIAL, BMH, "<init>", makeSignature("", true)); mv.visitMethodInsn(INVOKESPECIAL, BMH, "<init>", makeSignature("", true), false);
for (int i = 0, j = 0; i < types.length(); ++i, ++j) { for (int i = 0, j = 0; i < types.length(); ++i, ++j) {
// i counts the arguments, j counts corresponding argument slots // i counts the arguments, j counts corresponding argument slots
...@@ -663,7 +663,7 @@ import jdk.internal.org.objectweb.asm.Type; ...@@ -663,7 +663,7 @@ import jdk.internal.org.objectweb.asm.Type;
// put fields on the stack // put fields on the stack
emitPushFields(types, className, mv); emitPushFields(types, className, mv);
// finally, invoke the constructor and return // finally, invoke the constructor and return
mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types, false)); mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types, false), false);
mv.visitInsn(ARETURN); mv.visitInsn(ARETURN);
mv.visitMaxs(0, 0); mv.visitMaxs(0, 0);
mv.visitEnd(); mv.visitEnd();
...@@ -679,7 +679,7 @@ import jdk.internal.org.objectweb.asm.Type; ...@@ -679,7 +679,7 @@ import jdk.internal.org.objectweb.asm.Type;
int iconstInsn = ICONST_0 + extensionIndex(t); int iconstInsn = ICONST_0 + extensionIndex(t);
assert(iconstInsn <= ICONST_5); assert(iconstInsn <= ICONST_5);
mv.visitInsn(iconstInsn); mv.visitInsn(iconstInsn);
mv.visitMethodInsn(INVOKEVIRTUAL, SPECIES_DATA, "extendWithIndex", BMHSPECIES_DATA_EWI_SIG); mv.visitMethodInsn(INVOKEVIRTUAL, SPECIES_DATA, "extendWithIndex", BMHSPECIES_DATA_EWI_SIG, false);
mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG); mv.visitFieldInsn(GETFIELD, SPECIES_DATA, "constructor", "[" + MH_SIG);
mv.visitInsn(ICONST_0); mv.visitInsn(ICONST_0);
mv.visitInsn(AALOAD); mv.visitInsn(AALOAD);
...@@ -691,7 +691,7 @@ import jdk.internal.org.objectweb.asm.Type; ...@@ -691,7 +691,7 @@ import jdk.internal.org.objectweb.asm.Type;
// put narg on stack // put narg on stack
mv.visitVarInsn(typeLoadOp(t), 3); mv.visitVarInsn(typeLoadOp(t), 3);
// finally, invoke the constructor and return // finally, invoke the constructor and return
mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types + t, false)); mv.visitMethodInsn(INVOKEVIRTUAL, MH, "invokeBasic", makeSignature(types + t, false), false);
mv.visitInsn(ARETURN); mv.visitInsn(ARETURN);
mv.visitMaxs(0, 0); mv.visitMaxs(0, 0);
mv.visitEnd(); mv.visitEnd();
...@@ -702,7 +702,7 @@ import jdk.internal.org.objectweb.asm.Type; ...@@ -702,7 +702,7 @@ import jdk.internal.org.objectweb.asm.Type;
mv.visitCode(); mv.visitCode();
mv.visitLdcInsn(types); mv.visitLdcInsn(types);
mv.visitLdcInsn(Type.getObjectType(className)); mv.visitLdcInsn(Type.getObjectType(className));
mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG); mv.visitMethodInsn(INVOKESTATIC, SPECIES_DATA, "getForClass", BMHSPECIES_DATA_GFC_SIG, false);
mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG); mv.visitFieldInsn(PUTSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
mv.visitInsn(RETURN); mv.visitInsn(RETURN);
mv.visitMaxs(0, 0); mv.visitMaxs(0, 0);
......
...@@ -193,10 +193,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -193,10 +193,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
CallSite buildCallSite() throws LambdaConversionException { CallSite buildCallSite() throws LambdaConversionException {
final Class<?> innerClass = spinInnerClass(); final Class<?> innerClass = spinInnerClass();
if (invokedType.parameterCount() == 0) { if (invokedType.parameterCount() == 0) {
final Constructor[] ctrs = AccessController.doPrivileged( final Constructor<?>[] ctrs = AccessController.doPrivileged(
new PrivilegedAction<Constructor[]>() { new PrivilegedAction<Constructor<?>[]>() {
@Override @Override
public Constructor[] run() { public Constructor<?>[] run() {
Constructor<?>[] ctrs = innerClass.getDeclaredConstructors(); Constructor<?>[] ctrs = innerClass.getDeclaredConstructors();
if (ctrs.length == 1) { if (ctrs.length == 1) {
// The lambda implementing inner class constructor is private, set // The lambda implementing inner class constructor is private, set
...@@ -338,7 +338,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -338,7 +338,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
m.visitVarInsn(getLoadOpcode(argType), varIndex); m.visitVarInsn(getLoadOpcode(argType), varIndex);
varIndex += getParameterSize(argType); varIndex += getParameterSize(argType);
} }
m.visitMethodInsn(INVOKESPECIAL, lambdaClassName, NAME_CTOR, constructorType.toMethodDescriptorString()); m.visitMethodInsn(INVOKESPECIAL, lambdaClassName, NAME_CTOR, constructorType.toMethodDescriptorString(), false);
m.visitInsn(ARETURN); m.visitInsn(ARETURN);
m.visitMaxs(-1, -1); m.visitMaxs(-1, -1);
m.visitEnd(); m.visitEnd();
...@@ -354,7 +354,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -354,7 +354,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
ctor.visitCode(); ctor.visitCode();
ctor.visitVarInsn(ALOAD, 0); ctor.visitVarInsn(ALOAD, 0);
ctor.visitMethodInsn(INVOKESPECIAL, JAVA_LANG_OBJECT, NAME_CTOR, ctor.visitMethodInsn(INVOKESPECIAL, JAVA_LANG_OBJECT, NAME_CTOR,
METHOD_DESCRIPTOR_VOID); METHOD_DESCRIPTOR_VOID, false);
int parameterCount = invokedType.parameterCount(); int parameterCount = invokedType.parameterCount();
for (int i = 0, lvIndex = 0; i < parameterCount; i++) { for (int i = 0, lvIndex = 0; i < parameterCount; i++) {
ctor.visitVarInsn(ALOAD, 0); ctor.visitVarInsn(ALOAD, 0);
...@@ -402,7 +402,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -402,7 +402,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
mv.visitInsn(AASTORE); mv.visitInsn(AASTORE);
} }
mv.visitMethodInsn(INVOKESPECIAL, NAME_SERIALIZED_LAMBDA, NAME_CTOR, mv.visitMethodInsn(INVOKESPECIAL, NAME_SERIALIZED_LAMBDA, NAME_CTOR,
DESCR_CTOR_SERIALIZED_LAMBDA); DESCR_CTOR_SERIALIZED_LAMBDA, false);
mv.visitInsn(ARETURN); mv.visitInsn(ARETURN);
// Maxs computed by ClassWriter.COMPUTE_MAXS, these arguments ignored // Maxs computed by ClassWriter.COMPUTE_MAXS, these arguments ignored
mv.visitMaxs(-1, -1); mv.visitMaxs(-1, -1);
...@@ -421,7 +421,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -421,7 +421,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
mv.visitInsn(DUP); mv.visitInsn(DUP);
mv.visitLdcInsn("Non-serializable lambda"); mv.visitLdcInsn("Non-serializable lambda");
mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR, mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR,
DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION); DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION, false);
mv.visitInsn(ATHROW); mv.visitInsn(ATHROW);
mv.visitMaxs(-1, -1); mv.visitMaxs(-1, -1);
mv.visitEnd(); mv.visitEnd();
...@@ -434,7 +434,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; ...@@ -434,7 +434,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
mv.visitInsn(DUP); mv.visitInsn(DUP);
mv.visitLdcInsn("Non-serializable lambda"); mv.visitLdcInsn("Non-serializable lambda");
mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR, mv.visitMethodInsn(INVOKESPECIAL, NAME_NOT_SERIALIZABLE_EXCEPTION, NAME_CTOR,
DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION); DESCR_CTOR_NOT_SERIALIZABLE_EXCEPTION, false);
mv.visitInsn(ATHROW); mv.visitInsn(ATHROW);
mv.visitMaxs(-1, -1); mv.visitMaxs(-1, -1);
mv.visitEnd(); mv.visitEnd();
......
...@@ -403,7 +403,7 @@ class InvokerBytecodeGenerator { ...@@ -403,7 +403,7 @@ class InvokerBytecodeGenerator {
String owner = "java/lang/" + wrapper.wrapperType().getSimpleName(); String owner = "java/lang/" + wrapper.wrapperType().getSimpleName();
String name = "valueOf"; String name = "valueOf";
String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";"; String desc = "(" + wrapper.basicTypeChar() + ")L" + owner + ";";
mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc); mv.visitMethodInsn(Opcodes.INVOKESTATIC, owner, name, desc, false);
} }
/** /**
...@@ -417,7 +417,7 @@ class InvokerBytecodeGenerator { ...@@ -417,7 +417,7 @@ class InvokerBytecodeGenerator {
String name = wrapper.primitiveSimpleName() + "Value"; String name = wrapper.primitiveSimpleName() + "Value";
String desc = "()" + wrapper.basicTypeChar(); String desc = "()" + wrapper.basicTypeChar();
mv.visitTypeInsn(Opcodes.CHECKCAST, owner); mv.visitTypeInsn(Opcodes.CHECKCAST, owner);
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, owner, name, desc, false);
} }
/** /**
...@@ -437,7 +437,7 @@ class InvokerBytecodeGenerator { ...@@ -437,7 +437,7 @@ class InvokerBytecodeGenerator {
mv.visitLdcInsn(constantPlaceholder(pclass)); mv.visitLdcInsn(constantPlaceholder(pclass));
mv.visitTypeInsn(Opcodes.CHECKCAST, CLS); mv.visitTypeInsn(Opcodes.CHECKCAST, CLS);
mv.visitInsn(Opcodes.SWAP); mv.visitInsn(Opcodes.SWAP);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "castReference", CLL_SIG); mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "castReference", CLL_SIG, false);
if (pclass.isArray()) if (pclass.isArray())
mv.visitTypeInsn(Opcodes.CHECKCAST, OBJARY); mv.visitTypeInsn(Opcodes.CHECKCAST, OBJARY);
} }
...@@ -575,7 +575,7 @@ class InvokerBytecodeGenerator { ...@@ -575,7 +575,7 @@ class InvokerBytecodeGenerator {
// invocation // invocation
MethodType type = name.function.methodType(); MethodType type = name.function.methodType();
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.basicType().toMethodDescriptorString()); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", type.basicType().toMethodDescriptorString(), false);
} }
static private Class<?>[] STATICALLY_INVOCABLE_PACKAGES = { static private Class<?>[] STATICALLY_INVOCABLE_PACKAGES = {
...@@ -1082,7 +1082,7 @@ class InvokerBytecodeGenerator { ...@@ -1082,7 +1082,7 @@ class InvokerBytecodeGenerator {
emitAloadInsn(0); emitAloadInsn(0);
mv.visitFieldInsn(Opcodes.GETFIELD, MH, "form", "Ljava/lang/invoke/LambdaForm;"); mv.visitFieldInsn(Opcodes.GETFIELD, MH, "form", "Ljava/lang/invoke/LambdaForm;");
mv.visitInsn(Opcodes.SWAP); // swap form and array; avoid local variable mv.visitInsn(Opcodes.SWAP); // swap form and array; avoid local variable
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LF, "interpretWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;"); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, LF, "interpretWithArguments", "([Ljava/lang/Object;)Ljava/lang/Object;", false);
// maybe unbox // maybe unbox
Class<?> rtype = invokerType.returnType(); Class<?> rtype = invokerType.returnType();
...@@ -1145,7 +1145,7 @@ class InvokerBytecodeGenerator { ...@@ -1145,7 +1145,7 @@ class InvokerBytecodeGenerator {
// Invoke // Invoke
String targetDesc = dstType.basicType().toMethodDescriptorString(); String targetDesc = dstType.basicType().toMethodDescriptorString();
mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", targetDesc); mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, MH, "invokeBasic", targetDesc, false);
// Box primitive types // Box primitive types
Class<?> rtype = dstType.returnType(); Class<?> rtype = dstType.returnType();
......
...@@ -158,19 +158,19 @@ class TypeConvertingMethodAdapter extends MethodVisitor { ...@@ -158,19 +158,19 @@ class TypeConvertingMethodAdapter extends MethodVisitor {
visitMethodInsn(Opcodes.INVOKESTATIC, visitMethodInsn(Opcodes.INVOKESTATIC,
wrapperName(w), wrapperName(w),
NAME_BOX_METHOD, NAME_BOX_METHOD,
boxingDescriptor(w)); boxingDescriptor(w), false);
} }
/** /**
* Convert types by unboxing. The source type is known to be a primitive wrapper. * Convert types by unboxing. The source type is known to be a primitive wrapper.
* @param ws A primitive wrapper corresponding to wrapped reference source type * @param sname A primitive wrapper corresponding to wrapped reference source type
* @param wt A primitive wrapper being converted to * @param wt A primitive wrapper being converted to
*/ */
void unbox(String sname, Wrapper wt) { void unbox(String sname, Wrapper wt) {
visitMethodInsn(Opcodes.INVOKEVIRTUAL, visitMethodInsn(Opcodes.INVOKEVIRTUAL,
sname, sname,
unboxMethod(wt), unboxMethod(wt),
unboxingDescriptor(wt)); unboxingDescriptor(wt), false);
} }
private String descriptorToName(String desc) { private String descriptorToName(String desc) {
......
...@@ -32,6 +32,7 @@ import java.util.concurrent.ForkJoinTask; ...@@ -32,6 +32,7 @@ import java.util.concurrent.ForkJoinTask;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.DoubleConsumer; import java.util.function.DoubleConsumer;
import java.util.function.IntConsumer; import java.util.function.IntConsumer;
import java.util.function.IntFunction;
import java.util.function.LongConsumer; import java.util.function.LongConsumer;
/** /**
...@@ -471,9 +472,11 @@ final class ForEachOps { ...@@ -471,9 +472,11 @@ final class ForEachOps {
if (task.getPendingCount() > 0) { if (task.getPendingCount() > 0) {
// Cannot complete just yet so buffer elements into a Node // Cannot complete just yet so buffer elements into a Node
// for use when completion occurs // for use when completion occurs
@SuppressWarnings("unchecked")
IntFunction<T[]> generator = size -> (T[]) new Object[size];
Node.Builder<T> nb = task.helper.makeNodeBuilder( Node.Builder<T> nb = task.helper.makeNodeBuilder(
task.helper.exactOutputSizeIfKnown(rightSplit), task.helper.exactOutputSizeIfKnown(rightSplit),
size -> (T[]) new Object[size]); generator);
task.node = task.helper.wrapAndCopyInto(nb, rightSplit).build(); task.node = task.helper.wrapAndCopyInto(nb, rightSplit).build();
task.spliterator = null; task.spliterator = null;
} }
......
...@@ -63,7 +63,7 @@ final class Nodes { ...@@ -63,7 +63,7 @@ final class Nodes {
// IllegalArgumentException messages // IllegalArgumentException messages
static final String BAD_SIZE = "Stream size exceeds max array size"; static final String BAD_SIZE = "Stream size exceeds max array size";
@SuppressWarnings("raw") @SuppressWarnings("rawtypes")
private static final Node EMPTY_NODE = new EmptyNode.OfRef(); private static final Node EMPTY_NODE = new EmptyNode.OfRef();
private static final Node.OfInt EMPTY_INT_NODE = new EmptyNode.OfInt(); private static final Node.OfInt EMPTY_INT_NODE = new EmptyNode.OfInt();
private static final Node.OfLong EMPTY_LONG_NODE = new EmptyNode.OfLong(); private static final Node.OfLong EMPTY_LONG_NODE = new EmptyNode.OfLong();
...@@ -956,6 +956,7 @@ final class Nodes { ...@@ -956,6 +956,7 @@ final class Nodes {
* Initiate a stack containing, in left-to-right order, the child nodes * Initiate a stack containing, in left-to-right order, the child nodes
* covered by this spliterator * covered by this spliterator
*/ */
@SuppressWarnings("unchecked")
protected final Deque<N> initStack() { protected final Deque<N> initStack() {
// Bias size to the case where leaf nodes are close to this node // Bias size to the case where leaf nodes are close to this node
// 8 is the minimum initial capacity for the ArrayDeque implementation // 8 is the minimum initial capacity for the ArrayDeque implementation
...@@ -969,6 +970,7 @@ final class Nodes { ...@@ -969,6 +970,7 @@ final class Nodes {
* Depth first search, in left-to-right order, of the node tree, using * Depth first search, in left-to-right order, of the node tree, using
* an explicit stack, to find the next non-empty leaf node. * an explicit stack, to find the next non-empty leaf node.
*/ */
@SuppressWarnings("unchecked")
protected final N findNextLeafNode(Deque<N> stack) { protected final N findNextLeafNode(Deque<N> stack) {
N n = null; N n = null;
while ((n = stack.pollFirst()) != null) { while ((n = stack.pollFirst()) != null) {
...@@ -984,6 +986,7 @@ final class Nodes { ...@@ -984,6 +986,7 @@ final class Nodes {
return null; return null;
} }
@SuppressWarnings("unchecked")
protected final boolean initTryAdvance() { protected final boolean initTryAdvance() {
if (curNode == null) if (curNode == null)
return false; return false;
...@@ -1870,6 +1873,7 @@ final class Nodes { ...@@ -1870,6 +1873,7 @@ final class Nodes {
} }
assert task.offset + task.length < MAX_ARRAY_SIZE; assert task.offset + task.length < MAX_ARRAY_SIZE;
@SuppressWarnings("unchecked")
T_SINK sink = (T_SINK) task; T_SINK sink = (T_SINK) task;
task.helper.wrapAndCopyInto(sink, rightSplit); task.helper.wrapAndCopyInto(sink, rightSplit);
task.propagateCompletion(); task.propagateCompletion();
...@@ -2173,6 +2177,7 @@ final class Nodes { ...@@ -2173,6 +2177,7 @@ final class Nodes {
} }
@Override @Override
@SuppressWarnings("unchecked")
protected T_NODE doLeaf() { protected T_NODE doLeaf() {
T_BUILDER builder = builderFactory.apply(helper.exactOutputSizeIfKnown(spliterator)); T_BUILDER builder = builderFactory.apply(helper.exactOutputSizeIfKnown(spliterator));
return (T_NODE) helper.wrapAndCopyInto(builder, spliterator).build(); return (T_NODE) helper.wrapAndCopyInto(builder, spliterator).build();
......
...@@ -29,7 +29,6 @@ import java.util.Arrays; ...@@ -29,7 +29,6 @@ import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.Objects; import java.util.Objects;
import java.util.Spliterator; import java.util.Spliterator;
import java.util.concurrent.ForkJoinTask;
import java.util.function.IntFunction; import java.util.function.IntFunction;
...@@ -113,7 +112,9 @@ final class SortedOps { ...@@ -113,7 +112,9 @@ final class SortedOps {
StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SORTED); StreamOpFlag.IS_ORDERED | StreamOpFlag.IS_SORTED);
this.isNaturalSort = true; this.isNaturalSort = true;
// Will throw CCE when we try to sort if T is not Comparable // Will throw CCE when we try to sort if T is not Comparable
this.comparator = (Comparator<? super T>) Comparator.naturalOrder(); @SuppressWarnings("unchecked")
Comparator<? super T> comp = (Comparator<? super T>) Comparator.naturalOrder();
this.comparator = comp;
} }
/** /**
...@@ -170,7 +171,7 @@ final class SortedOps { ...@@ -170,7 +171,7 @@ final class SortedOps {
} }
@Override @Override
public Sink<Integer> opWrapSink(int flags, Sink sink) { public Sink<Integer> opWrapSink(int flags, Sink<Integer> sink) {
Objects.requireNonNull(sink); Objects.requireNonNull(sink);
if (StreamOpFlag.SORTED.isKnown(flags)) if (StreamOpFlag.SORTED.isKnown(flags))
...@@ -335,6 +336,7 @@ final class SortedOps { ...@@ -335,6 +336,7 @@ final class SortedOps {
} }
@Override @Override
@SuppressWarnings("unchecked")
public void begin(long size) { public void begin(long size) {
if (size >= Nodes.MAX_ARRAY_SIZE) if (size >= Nodes.MAX_ARRAY_SIZE)
throw new IllegalArgumentException(Nodes.BAD_SIZE); throw new IllegalArgumentException(Nodes.BAD_SIZE);
......
...@@ -92,6 +92,7 @@ class SpinedBuffer<E> ...@@ -92,6 +92,7 @@ class SpinedBuffer<E>
* @throws IllegalArgumentException if the specified initial capacity * @throws IllegalArgumentException if the specified initial capacity
* is negative * is negative
*/ */
@SuppressWarnings("unchecked")
SpinedBuffer(int initialCapacity) { SpinedBuffer(int initialCapacity) {
super(initialCapacity); super(initialCapacity);
curChunk = (E[]) new Object[1 << initialChunkPower]; curChunk = (E[]) new Object[1 << initialChunkPower];
...@@ -100,6 +101,7 @@ class SpinedBuffer<E> ...@@ -100,6 +101,7 @@ class SpinedBuffer<E>
/** /**
* Constructs an empty list with an initial capacity of sixteen. * Constructs an empty list with an initial capacity of sixteen.
*/ */
@SuppressWarnings("unchecked")
SpinedBuffer() { SpinedBuffer() {
super(); super();
curChunk = (E[]) new Object[1 << initialChunkPower]; curChunk = (E[]) new Object[1 << initialChunkPower];
...@@ -114,6 +116,7 @@ class SpinedBuffer<E> ...@@ -114,6 +116,7 @@ class SpinedBuffer<E>
: priorElementCount[spineIndex] + spine[spineIndex].length; : priorElementCount[spineIndex] + spine[spineIndex].length;
} }
@SuppressWarnings("unchecked")
private void inflateSpine() { private void inflateSpine() {
if (spine == null) { if (spine == null) {
spine = (E[][]) new Object[MIN_SPINE_SIZE][]; spine = (E[][]) new Object[MIN_SPINE_SIZE][];
...@@ -125,6 +128,7 @@ class SpinedBuffer<E> ...@@ -125,6 +128,7 @@ class SpinedBuffer<E>
/** /**
* Ensure that the buffer has at least capacity to hold the target size * Ensure that the buffer has at least capacity to hold the target size
*/ */
@SuppressWarnings("unchecked")
protected final void ensureCapacity(long targetSize) { protected final void ensureCapacity(long targetSize) {
long capacity = capacity(); long capacity = capacity();
if (targetSize > capacity) { if (targetSize > capacity) {
......
...@@ -516,6 +516,7 @@ class StreamSpliterators { ...@@ -516,6 +516,7 @@ class StreamSpliterators {
} }
@Override @Override
@SuppressWarnings("unchecked")
public T_SPLITR trySplit() { public T_SPLITR trySplit() {
return (T_SPLITR) get().trySplit(); return (T_SPLITR) get().trySplit();
} }
...@@ -643,6 +644,7 @@ class StreamSpliterators { ...@@ -643,6 +644,7 @@ class StreamSpliterators {
// existing and additionally created F/J tasks that perform // existing and additionally created F/J tasks that perform
// redundant work on no elements. // redundant work on no elements.
while (true) { while (true) {
@SuppressWarnings("unchecked")
T_SPLITR leftSplit = (T_SPLITR) s.trySplit(); T_SPLITR leftSplit = (T_SPLITR) s.trySplit();
if (leftSplit == null) if (leftSplit == null)
return null; return null;
...@@ -970,6 +972,7 @@ class StreamSpliterators { ...@@ -970,6 +972,7 @@ class StreamSpliterators {
// Stop splitting when there are no more limit permits // Stop splitting when there are no more limit permits
if (permits.get() == 0) if (permits.get() == 0)
return null; return null;
@SuppressWarnings("unchecked")
T_SPLITR split = (T_SPLITR) s.trySplit(); T_SPLITR split = (T_SPLITR) s.trySplit();
return split == null ? null : makeSpliterator(split); return split == null ? null : makeSpliterator(split);
} }
...@@ -1068,16 +1071,18 @@ class StreamSpliterators { ...@@ -1068,16 +1071,18 @@ class StreamSpliterators {
super(s, skip, limit); super(s, skip, limit);
} }
OfPrimitive(T_SPLITR s, UnorderedSliceSpliterator.OfPrimitive parent) { OfPrimitive(T_SPLITR s, UnorderedSliceSpliterator.OfPrimitive<T, T_CONS, T_BUFF, T_SPLITR> parent) {
super(s, parent); super(s, parent);
} }
@Override @Override
public boolean tryAdvance(T_CONS action) { public boolean tryAdvance(T_CONS action) {
Objects.requireNonNull(action); Objects.requireNonNull(action);
@SuppressWarnings("unchecked")
T_CONS consumer = (T_CONS) this;
while (permitStatus() != PermitStatus.NO_MORE) { while (permitStatus() != PermitStatus.NO_MORE) {
if (!s.tryAdvance((T_CONS) this)) if (!s.tryAdvance(consumer))
return false; return false;
else if (acquirePermits(1) == 1) { else if (acquirePermits(1) == 1) {
acceptConsumed(action); acceptConsumed(action);
...@@ -1316,7 +1321,7 @@ class StreamSpliterators { ...@@ -1316,7 +1321,7 @@ class StreamSpliterators {
* estimate size is 0. * estimate size is 0.
* *
* <p>The {@code forEachRemaining} method if invoked will never terminate. * <p>The {@code forEachRemaining} method if invoked will never terminate.
* The {@coe tryAdvance} method always returns true. * The {@code tryAdvance} method always returns true.
* *
*/ */
static abstract class InfiniteSupplyingSpliterator<T> implements Spliterator<T> { static abstract class InfiniteSupplyingSpliterator<T> implements Spliterator<T> {
......
...@@ -715,6 +715,7 @@ final class Streams { ...@@ -715,6 +715,7 @@ final class Streams {
@Override @Override
public T_SPLITR trySplit() { public T_SPLITR trySplit() {
@SuppressWarnings("unchecked")
T_SPLITR ret = beforeSplit ? aSpliterator : (T_SPLITR) bSpliterator.trySplit(); T_SPLITR ret = beforeSplit ? aSpliterator : (T_SPLITR) bSpliterator.trySplit();
beforeSplit = false; beforeSplit = false;
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册