mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 06:29:37 +00:00
7068616: NIO libraries do not build with javac -Xlint:all,-deprecation -Werror
Reviewed-by: alanb, chegar
This commit is contained in:
parent
281db94b24
commit
d5e142fba4
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2009, 2011, 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
|
||||
@ -28,6 +28,8 @@
|
||||
#
|
||||
|
||||
BUILDDIR = ../../..
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = sctp
|
||||
|
||||
@ -31,7 +31,6 @@ BUILDDIR = ../../../..
|
||||
PACKAGE = com.sun.nio.sctp
|
||||
LIBRARY = sctp
|
||||
PRODUCT = sun
|
||||
#OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
||||
@ -31,7 +31,8 @@ BUILDDIR = ../..
|
||||
PACKAGE = java.nio
|
||||
LIBRARY = nio
|
||||
PRODUCT = java
|
||||
OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint:serial -Werror
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
NIO_SRC = $(SHARE_SRC)/classes/java/nio
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2003, 2011, 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
|
||||
@ -31,7 +31,9 @@ BUILDDIR = ../..
|
||||
PACKAGE = sun.nio
|
||||
PRODUCT = sun
|
||||
|
||||
OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
|
||||
JAVAC_MAX_WARNINGS = false
|
||||
JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2009, 2011, 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
|
||||
@ -26,6 +26,8 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = sun.nio
|
||||
PRODUCT = sun
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
|
||||
SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = cs
|
||||
|
||||
@ -36,7 +36,9 @@ PRODUCT = sun
|
||||
# This re-directs all the class files to a separate location
|
||||
CLASSDESTDIR = $(TEMPDIR)/classes
|
||||
|
||||
OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
|
||||
JAVAC_MAX_WARNINGS = false
|
||||
JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -1080,7 +1080,11 @@ public abstract class $Type$Buffer
|
||||
int h = 1;
|
||||
int p = position();
|
||||
for (int i = limit() - 1; i >= p; i--)
|
||||
#if[int]
|
||||
h = 31 * h + get(i);
|
||||
#else[int]
|
||||
h = 31 * h + (int)get(i);
|
||||
#end[int]
|
||||
return h;
|
||||
}
|
||||
|
||||
|
||||
@ -248,6 +248,7 @@ public abstract class AsynchronousFileChannel
|
||||
return provider.newAsynchronousFileChannel(file, options, executor, attrs);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
|
||||
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
|
||||
|
||||
/**
|
||||
|
||||
@ -287,6 +287,7 @@ public abstract class FileChannel
|
||||
return provider.newFileChannel(path, options, attrs);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" }) // generic array construction
|
||||
private static final FileAttribute<?>[] NO_ATTRIBUTES = new FileAttribute[0];
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -29,7 +29,6 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.security.AccessController;
|
||||
import java.security.AccessControlException;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@ -339,15 +338,15 @@ public abstract class Charset
|
||||
// those whose lookup or instantiation causes a security exception to be
|
||||
// thrown. Should be invoked with full privileges.
|
||||
//
|
||||
private static Iterator providers() {
|
||||
return new Iterator() {
|
||||
private static Iterator<CharsetProvider> providers() {
|
||||
return new Iterator<CharsetProvider>() {
|
||||
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||
ServiceLoader<CharsetProvider> sl =
|
||||
ServiceLoader.load(CharsetProvider.class, cl);
|
||||
Iterator<CharsetProvider> i = sl.iterator();
|
||||
|
||||
Object next = null;
|
||||
CharsetProvider next = null;
|
||||
|
||||
private boolean getNext() {
|
||||
while (next == null) {
|
||||
@ -370,10 +369,10 @@ public abstract class Charset
|
||||
return getNext();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
public CharsetProvider next() {
|
||||
if (!getNext())
|
||||
throw new NoSuchElementException();
|
||||
Object n = next;
|
||||
CharsetProvider n = next;
|
||||
next = null;
|
||||
return n;
|
||||
}
|
||||
@ -386,7 +385,8 @@ public abstract class Charset
|
||||
}
|
||||
|
||||
// Thread-local gate to prevent recursive provider lookups
|
||||
private static ThreadLocal<ThreadLocal> gate = new ThreadLocal<ThreadLocal>();
|
||||
private static ThreadLocal<ThreadLocal<?>> gate =
|
||||
new ThreadLocal<ThreadLocal<?>>();
|
||||
|
||||
private static Charset lookupViaProviders(final String charsetName) {
|
||||
|
||||
@ -410,8 +410,9 @@ public abstract class Charset
|
||||
return AccessController.doPrivileged(
|
||||
new PrivilegedAction<Charset>() {
|
||||
public Charset run() {
|
||||
for (Iterator i = providers(); i.hasNext();) {
|
||||
CharsetProvider cp = (CharsetProvider)i.next();
|
||||
for (Iterator<CharsetProvider> i = providers();
|
||||
i.hasNext();) {
|
||||
CharsetProvider cp = i.next();
|
||||
Charset cs = cp.charsetForName(charsetName);
|
||||
if (cs != null)
|
||||
return cs;
|
||||
@ -588,8 +589,8 @@ public abstract class Charset
|
||||
new TreeMap<String,Charset>(
|
||||
ASCIICaseInsensitiveComparator.CASE_INSENSITIVE_ORDER);
|
||||
put(standardProvider.charsets(), m);
|
||||
for (Iterator i = providers(); i.hasNext();) {
|
||||
CharsetProvider cp = (CharsetProvider)i.next();
|
||||
for (Iterator<CharsetProvider> i = providers(); i.hasNext();) {
|
||||
CharsetProvider cp = i.next();
|
||||
put(cp.charsets(), m);
|
||||
}
|
||||
return Collections.unmodifiableSortedMap(m);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -390,8 +390,10 @@ public class DatagramSocketAdaptor
|
||||
|
||||
protected void receive(DatagramPacket p) throws IOException {}
|
||||
|
||||
@Deprecated
|
||||
protected void setTTL(byte ttl) throws IOException {}
|
||||
|
||||
@Deprecated
|
||||
protected byte getTTL() throws IOException { return 0; }
|
||||
|
||||
protected void setTimeToLive(int ttl) throws IOException {}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -50,29 +50,25 @@ class Reflect { // package-private
|
||||
}});
|
||||
}
|
||||
|
||||
static Constructor lookupConstructor(String className,
|
||||
Class[] paramTypes)
|
||||
static Constructor<?> lookupConstructor(String className,
|
||||
Class<?>[] paramTypes)
|
||||
{
|
||||
try {
|
||||
Class<?> cl = Class.forName(className);
|
||||
Constructor<?> c = cl.getDeclaredConstructor(paramTypes);
|
||||
setAccessible(c);
|
||||
return c;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (NoSuchMethodException x) {
|
||||
} catch (ClassNotFoundException | NoSuchMethodException x) {
|
||||
throw new ReflectionError(x);
|
||||
}
|
||||
}
|
||||
|
||||
static Object invoke(Constructor c, Object[] args) {
|
||||
static Object invoke(Constructor<?> c, Object[] args) {
|
||||
try {
|
||||
return c.newInstance(args);
|
||||
} catch (InstantiationException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (IllegalAccessException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (InvocationTargetException x) {
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException |
|
||||
InvocationTargetException x) {
|
||||
throw new ReflectionError(x);
|
||||
}
|
||||
}
|
||||
@ -86,9 +82,7 @@ class Reflect { // package-private
|
||||
Method m = cl.getDeclaredMethod(methodName, paramTypes);
|
||||
setAccessible(m);
|
||||
return m;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (NoSuchMethodException x) {
|
||||
} catch (ClassNotFoundException | NoSuchMethodException x) {
|
||||
throw new ReflectionError(x);
|
||||
}
|
||||
}
|
||||
@ -96,9 +90,7 @@ class Reflect { // package-private
|
||||
static Object invoke(Method m, Object ob, Object[] args) {
|
||||
try {
|
||||
return m.invoke(ob, args);
|
||||
} catch (IllegalAccessException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (InvocationTargetException x) {
|
||||
} catch (IllegalAccessException | InvocationTargetException x) {
|
||||
throw new ReflectionError(x);
|
||||
}
|
||||
}
|
||||
@ -119,13 +111,11 @@ class Reflect { // package-private
|
||||
|
||||
static Field lookupField(String className, String fieldName) {
|
||||
try {
|
||||
Class cl = Class.forName(className);
|
||||
Class<?> cl = Class.forName(className);
|
||||
Field f = cl.getDeclaredField(fieldName);
|
||||
setAccessible(f);
|
||||
return f;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new ReflectionError(x);
|
||||
} catch (NoSuchFieldException x) {
|
||||
} catch (ClassNotFoundException | NoSuchFieldException x) {
|
||||
throw new ReflectionError(x);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -30,7 +30,6 @@ import java.nio.channels.*;
|
||||
import java.nio.channels.spi.*;
|
||||
import java.net.SocketException;
|
||||
import java.util.*;
|
||||
import sun.misc.*;
|
||||
|
||||
|
||||
/**
|
||||
@ -140,19 +139,16 @@ abstract class SelectorImpl
|
||||
|
||||
void processDeregisterQueue() throws IOException {
|
||||
// Precondition: Synchronized on this, keys, and selectedKeys
|
||||
Set cks = cancelledKeys();
|
||||
Set<SelectionKey> cks = cancelledKeys();
|
||||
synchronized (cks) {
|
||||
if (!cks.isEmpty()) {
|
||||
Iterator i = cks.iterator();
|
||||
Iterator<SelectionKey> i = cks.iterator();
|
||||
while (i.hasNext()) {
|
||||
SelectionKeyImpl ski = (SelectionKeyImpl)i.next();
|
||||
try {
|
||||
implDereg(ski);
|
||||
} catch (SocketException se) {
|
||||
IOException ioe = new IOException(
|
||||
"Error deregistering key");
|
||||
ioe.initCause(se);
|
||||
throw ioe;
|
||||
throw new IOException("Error deregistering key", se);
|
||||
} finally {
|
||||
i.remove();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, 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
|
||||
@ -355,27 +355,24 @@ class Util {
|
||||
return pageSize;
|
||||
}
|
||||
|
||||
private static volatile Constructor directByteBufferConstructor = null;
|
||||
private static volatile Constructor<?> directByteBufferConstructor = null;
|
||||
|
||||
private static void initDBBConstructor() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
try {
|
||||
Class<?> cl = Class.forName("java.nio.DirectByteBuffer");
|
||||
Constructor ctor = cl.getDeclaredConstructor(
|
||||
Constructor<?> ctor = cl.getDeclaredConstructor(
|
||||
new Class[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
ctor.setAccessible(true);
|
||||
directByteBufferConstructor = ctor;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new InternalError();
|
||||
} catch (NoSuchMethodException x) {
|
||||
throw new InternalError();
|
||||
} catch (IllegalArgumentException x) {
|
||||
throw new InternalError();
|
||||
} catch (ClassCastException x) {
|
||||
} catch (ClassNotFoundException |
|
||||
NoSuchMethodException |
|
||||
IllegalArgumentException |
|
||||
ClassCastException x) {
|
||||
throw new InternalError();
|
||||
}
|
||||
return null;
|
||||
@ -395,37 +392,32 @@ class Util {
|
||||
new Long(addr),
|
||||
fd,
|
||||
unmapper });
|
||||
} catch (InstantiationException e) {
|
||||
throw new InternalError();
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new InternalError();
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
return dbb;
|
||||
}
|
||||
|
||||
private static volatile Constructor directByteBufferRConstructor = null;
|
||||
private static volatile Constructor<?> directByteBufferRConstructor = null;
|
||||
|
||||
private static void initDBBRConstructor() {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
try {
|
||||
Class<?> cl = Class.forName("java.nio.DirectByteBufferR");
|
||||
Constructor ctor = cl.getDeclaredConstructor(
|
||||
Constructor<?> ctor = cl.getDeclaredConstructor(
|
||||
new Class[] { int.class,
|
||||
long.class,
|
||||
FileDescriptor.class,
|
||||
Runnable.class });
|
||||
ctor.setAccessible(true);
|
||||
directByteBufferRConstructor = ctor;
|
||||
} catch (ClassNotFoundException x) {
|
||||
throw new InternalError();
|
||||
} catch (NoSuchMethodException x) {
|
||||
throw new InternalError();
|
||||
} catch (IllegalArgumentException x) {
|
||||
throw new InternalError();
|
||||
} catch (ClassCastException x) {
|
||||
} catch (ClassNotFoundException |
|
||||
NoSuchMethodException |
|
||||
IllegalArgumentException |
|
||||
ClassCastException x) {
|
||||
throw new InternalError();
|
||||
}
|
||||
return null;
|
||||
@ -445,11 +437,9 @@ class Util {
|
||||
new Long(addr),
|
||||
fd,
|
||||
unmapper });
|
||||
} catch (InstantiationException e) {
|
||||
throw new InternalError();
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new InternalError();
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (InstantiationException |
|
||||
IllegalAccessException |
|
||||
InvocationTargetException e) {
|
||||
throw new InternalError();
|
||||
}
|
||||
return dbb;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2004, 2011, 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
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.spi.CharsetProvider;
|
||||
import java.util.Iterator;
|
||||
@ -116,17 +115,15 @@ public class FastCharsetProvider
|
||||
|
||||
// Instantiate the charset and cache it
|
||||
try {
|
||||
Class c = Class.forName(packagePrefix + "." + cln,
|
||||
Class<?> c = Class.forName(packagePrefix + "." + cln,
|
||||
true,
|
||||
this.getClass().getClassLoader());
|
||||
cs = (Charset)c.newInstance();
|
||||
cache.put(csn, cs);
|
||||
return cs;
|
||||
} catch (ClassNotFoundException x) {
|
||||
return null;
|
||||
} catch (IllegalAccessException x) {
|
||||
return null;
|
||||
} catch (InstantiationException x) {
|
||||
} catch (ClassNotFoundException |
|
||||
IllegalAccessException |
|
||||
InstantiationException x) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -112,6 +112,7 @@ public class StreamDecoder extends Reader
|
||||
return read0();
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
private int read0() throws IOException {
|
||||
synchronized (lock) {
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, 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
|
||||
@ -26,7 +26,6 @@
|
||||
|
||||
package sun.nio.cs;
|
||||
|
||||
import java.nio.*;
|
||||
import java.nio.charset.*;
|
||||
|
||||
|
||||
@ -41,7 +40,7 @@ public class ThreadLocalCoders {
|
||||
private static abstract class Cache {
|
||||
|
||||
// Thread-local reference to array of cached objects, in LRU order
|
||||
private ThreadLocal cache = new ThreadLocal();
|
||||
private ThreadLocal<Object[]> cache = new ThreadLocal<>();
|
||||
private final int size;
|
||||
|
||||
Cache(int size) {
|
||||
@ -60,7 +59,7 @@ public class ThreadLocalCoders {
|
||||
abstract boolean hasName(Object ob, Object name);
|
||||
|
||||
Object forName(Object name) {
|
||||
Object[] oa = (Object[])cache.get();
|
||||
Object[] oa = cache.get();
|
||||
if (oa == null) {
|
||||
oa = new Object[size];
|
||||
cache.set(oa);
|
||||
|
||||
@ -62,6 +62,7 @@ class Util {
|
||||
/**
|
||||
* Returns a Set containing the given elements.
|
||||
*/
|
||||
@SafeVarargs
|
||||
static <E> Set<E> newSet(E... elements) {
|
||||
HashSet<E> set = new HashSet<>();
|
||||
for (E e: elements) {
|
||||
@ -74,6 +75,7 @@ class Util {
|
||||
* Returns a Set containing all the elements of the given Set plus
|
||||
* the given elements.
|
||||
*/
|
||||
@SafeVarargs
|
||||
static <E> Set<E> newSet(Set<E> other, E... elements) {
|
||||
HashSet<E> set = new HashSet<>(other);
|
||||
for (E e: elements) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, 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
|
||||
@ -53,8 +53,6 @@ import com.sun.nio.sctp.MessageInfo;
|
||||
import com.sun.nio.sctp.NotificationHandler;
|
||||
import com.sun.nio.sctp.SctpChannel;
|
||||
import com.sun.nio.sctp.SctpSocketOption;
|
||||
import sun.nio.ch.PollArrayWrapper;
|
||||
import sun.nio.ch.SelChImpl;
|
||||
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
|
||||
import static sun.nio.ch.SctpResultContainer.SEND_FAILED;
|
||||
import static sun.nio.ch.SctpResultContainer.ASSOCIATION_CHANGED;
|
||||
@ -118,7 +116,7 @@ public class SctpChannelImpl extends SctpChannel
|
||||
|
||||
private Association association;
|
||||
|
||||
private Set<SocketAddress> remoteAddresses = Collections.EMPTY_SET;
|
||||
private Set<SocketAddress> remoteAddresses = Collections.emptySet();
|
||||
|
||||
/* -- End of fields protected by stateLock -- */
|
||||
|
||||
@ -853,7 +851,7 @@ public class SctpChannelImpl extends SctpChannel
|
||||
return n;
|
||||
}
|
||||
|
||||
private InternalNotificationHandler<?> internalNotificationHandler =
|
||||
private InternalNotificationHandler internalNotificationHandler =
|
||||
new InternalNotificationHandler();
|
||||
|
||||
private void handleNotificationInternal(SctpResultContainer resultContainer)
|
||||
@ -862,12 +860,12 @@ public class SctpChannelImpl extends SctpChannel
|
||||
internalNotificationHandler, null);
|
||||
}
|
||||
|
||||
private class InternalNotificationHandler<T>
|
||||
extends AbstractNotificationHandler<T>
|
||||
private class InternalNotificationHandler
|
||||
extends AbstractNotificationHandler<Object>
|
||||
{
|
||||
@Override
|
||||
public HandlerResult handleNotification(
|
||||
AssociationChangeNotification not, T unused) {
|
||||
AssociationChangeNotification not, Object unused) {
|
||||
if (not.event().equals(
|
||||
AssociationChangeNotification.AssocChangeEvent.COMM_UP) &&
|
||||
association == null) {
|
||||
@ -893,8 +891,8 @@ public class SctpChannelImpl extends SctpChannel
|
||||
}
|
||||
|
||||
/* AbstractNotificationHandler */
|
||||
AbstractNotificationHandler absHandler =
|
||||
(AbstractNotificationHandler)handler;
|
||||
AbstractNotificationHandler<T> absHandler =
|
||||
(AbstractNotificationHandler<T>)handler;
|
||||
switch(resultContainer.type()) {
|
||||
case ASSOCIATION_CHANGED :
|
||||
return absHandler.handleNotification(
|
||||
@ -1053,7 +1051,7 @@ public class SctpChannelImpl extends SctpChannel
|
||||
if (!isOpen())
|
||||
throw new ClosedChannelException();
|
||||
if (!isBound())
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
|
||||
return SctpNet.getLocalAddresses(fdVal);
|
||||
}
|
||||
@ -1066,7 +1064,7 @@ public class SctpChannelImpl extends SctpChannel
|
||||
if (!isOpen())
|
||||
throw new ClosedChannelException();
|
||||
if (!isConnected() || isShutdown)
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
|
||||
try {
|
||||
return SctpNet.getRemoteAddresses(fdVal, 0/*unused*/);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, 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
|
||||
@ -586,12 +586,12 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
|
||||
internalNotificationHandler, null);
|
||||
}
|
||||
|
||||
private class InternalNotificationHandler<T>
|
||||
extends AbstractNotificationHandler<T>
|
||||
private class InternalNotificationHandler
|
||||
extends AbstractNotificationHandler<Object>
|
||||
{
|
||||
@Override
|
||||
public HandlerResult handleNotification(
|
||||
AssociationChangeNotification not, T unused) {
|
||||
AssociationChangeNotification not, Object unused) {
|
||||
SctpAssocChange sac = (SctpAssocChange) not;
|
||||
|
||||
/* Update map to reflect change in association */
|
||||
@ -622,8 +622,8 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
|
||||
if (!(handler instanceof AbstractNotificationHandler)) {
|
||||
result = handler.handleNotification(notification, attachment);
|
||||
} else { /* AbstractNotificationHandler */
|
||||
AbstractNotificationHandler absHandler =
|
||||
(AbstractNotificationHandler)handler;
|
||||
AbstractNotificationHandler<T> absHandler =
|
||||
(AbstractNotificationHandler<T>)handler;
|
||||
switch(resultContainer.type()) {
|
||||
case ASSOCIATION_CHANGED :
|
||||
result = absHandler.handleNotification(
|
||||
@ -912,7 +912,7 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
|
||||
if (!isOpen())
|
||||
throw new ClosedChannelException();
|
||||
if (!isBound())
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
|
||||
return SctpNet.getLocalAddresses(fdVal);
|
||||
}
|
||||
@ -931,7 +931,7 @@ public class SctpMultiChannelImpl extends SctpMultiChannel
|
||||
} catch (SocketException se) {
|
||||
/* a valid association should always have remote addresses */
|
||||
Set<SocketAddress> addrs = associationMap.get(association);
|
||||
return addrs != null ? addrs : Collections.EMPTY_SET;
|
||||
return addrs != null ? addrs : Collections.<SocketAddress>emptySet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, 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
|
||||
@ -118,18 +118,14 @@ public class SctpNet {
|
||||
return set;
|
||||
}
|
||||
|
||||
static void setSocketOption(int fd,
|
||||
SctpSocketOption name,
|
||||
Object value,
|
||||
int assocId)
|
||||
static <T> void setSocketOption(int fd,
|
||||
SctpSocketOption<T> name,
|
||||
T value,
|
||||
int assocId)
|
||||
throws IOException {
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("Invalid option value");
|
||||
|
||||
Class<?> type = name.type();
|
||||
if (!type.isInstance(value))
|
||||
throw new IllegalArgumentException("Invalid option value");
|
||||
|
||||
if (name.equals(SCTP_INIT_MAXSTREAMS)) {
|
||||
InitMaxStreams maxStreamValue = (InitMaxStreams)value;
|
||||
SctpNet.setInitMsgOption0(fd,
|
||||
@ -169,7 +165,7 @@ public class SctpNet {
|
||||
}
|
||||
}
|
||||
|
||||
static Object getSocketOption(int fd, SctpSocketOption name, int assocId)
|
||||
static Object getSocketOption(int fd, SctpSocketOption<?> name, int assocId)
|
||||
throws IOException {
|
||||
if (name.equals(SCTP_SET_PEER_PRIMARY_ADDR)) {
|
||||
throw new IllegalArgumentException(
|
||||
@ -194,7 +190,7 @@ public class SctpNet {
|
||||
}
|
||||
}
|
||||
|
||||
static void setIntOption(int fd, SctpSocketOption name, Object value)
|
||||
static void setIntOption(int fd, SctpSocketOption<?> name, Object value)
|
||||
throws IOException {
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("Invalid option value");
|
||||
@ -234,7 +230,7 @@ public class SctpNet {
|
||||
setIntOption0(fd, ((SctpStdSocketOption)name).constValue(), arg);
|
||||
}
|
||||
|
||||
static Object getIntOption(int fd, SctpSocketOption name)
|
||||
static Object getIntOption(int fd, SctpSocketOption<?> name)
|
||||
throws IOException {
|
||||
Class<?> type = name.type();
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2011, 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
|
||||
@ -367,6 +367,7 @@ public class SctpServerChannelImpl extends SctpServerChannel
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getOption(SctpSocketOption<T> name) throws IOException {
|
||||
if (name == null)
|
||||
throw new NullPointerException();
|
||||
@ -403,7 +404,7 @@ public class SctpServerChannelImpl extends SctpServerChannel
|
||||
if (!isOpen())
|
||||
throw new ClosedChannelException();
|
||||
if (!isBound())
|
||||
return Collections.EMPTY_SET;
|
||||
return Collections.emptySet();
|
||||
|
||||
return SctpNet.getLocalAddresses(fdVal);
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ class PendingIoCache {
|
||||
private boolean closePending;
|
||||
|
||||
// maps OVERLAPPED to PendingFuture
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final Map<Long,PendingFuture> pendingIoMap =
|
||||
new HashMap<Long,PendingFuture>();
|
||||
|
||||
|
||||
@ -314,7 +314,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
// create Future and task that will be invoked to acquire lock
|
||||
PendingFuture<FileLock,A> result =
|
||||
new PendingFuture<FileLock,A>(this, handler, attachment);
|
||||
LockTask lockTask = new LockTask<A>(position, fli, result);
|
||||
LockTask<A> lockTask = new LockTask<A>(position, fli, result);
|
||||
result.setContext(lockTask);
|
||||
|
||||
// initiate I/O
|
||||
@ -552,7 +552,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
// create Future and task that initiates read
|
||||
PendingFuture<Integer,A> result =
|
||||
new PendingFuture<Integer,A>(this, handler, attachment);
|
||||
ReadTask readTask = new ReadTask<A>(dst, pos, rem, position, result);
|
||||
ReadTask<A> readTask = new ReadTask<A>(dst, pos, rem, position, result);
|
||||
result.setContext(readTask);
|
||||
|
||||
// initiate I/O
|
||||
@ -726,7 +726,7 @@ public class WindowsAsynchronousFileChannelImpl
|
||||
// create Future and task to initiate write
|
||||
PendingFuture<Integer,A> result =
|
||||
new PendingFuture<Integer,A>(this, handler, attachment);
|
||||
WriteTask writeTask = new WriteTask<A>(src, pos, rem, position, result);
|
||||
WriteTask<A> writeTask = new WriteTask<A>(src, pos, rem, position, result);
|
||||
result.setContext(writeTask);
|
||||
|
||||
// initiate I/O
|
||||
|
||||
@ -351,7 +351,7 @@ class WindowsAsynchronousSocketChannelImpl
|
||||
// setup task
|
||||
PendingFuture<Void,A> result =
|
||||
new PendingFuture<Void,A>(this, handler, attachment);
|
||||
ConnectTask task = new ConnectTask<A>(isa, result);
|
||||
ConnectTask<A> task = new ConnectTask<A>(isa, result);
|
||||
result.setContext(task);
|
||||
|
||||
// initiate I/O
|
||||
@ -615,7 +615,8 @@ class WindowsAsynchronousSocketChannelImpl
|
||||
bufs = new ByteBuffer[1];
|
||||
bufs[0] = dst;
|
||||
}
|
||||
final ReadTask readTask = new ReadTask<V,A>(bufs, isScatteringRead, result);
|
||||
final ReadTask<V,A> readTask =
|
||||
new ReadTask<V,A>(bufs, isScatteringRead, result);
|
||||
result.setContext(readTask);
|
||||
|
||||
// schedule timeout
|
||||
@ -872,7 +873,8 @@ class WindowsAsynchronousSocketChannelImpl
|
||||
bufs = new ByteBuffer[1];
|
||||
bufs[0] = src;
|
||||
}
|
||||
final WriteTask writeTask = new WriteTask<V,A>(bufs, gatheringWrite, result);
|
||||
final WriteTask<V,A> writeTask =
|
||||
new WriteTask<V,A>(bufs, gatheringWrite, result);
|
||||
result.setContext(writeTask);
|
||||
|
||||
// schedule timeout
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user