Re: Creating Thread in AccessController.doPrivileged()

2014-04-23 Thread Zhong Yu
On Thu, Apr 24, 2014 at 12:06 AM, Zhong Yu wrote: > If a thread is created inside AccessController.doPrivileged(), it > seems to inherit AccessControlContext from the calling thread, sorry, I was mistaken; there is no such inheritance, the new thread is indeed privileged. > is t

Creating Thread in AccessController.doPrivileged()

2014-04-23 Thread Zhong Yu
aders through Thread.inheritedAccessControlContext. I try to avoid that and make sure that only the immediate caller class loader is referenced; my concern is rather garbage collection than permissions. Is there anyway to achieve that? Thanks, Zhong Yu

Re: Covariant overrides on the Buffer Hierachy

2014-04-21 Thread Zhong Yu
new HashMap<>().{ put(n1,v1); put(n2,v2); } new Button().{ color(red); text("hello"); onClick(event->color(blue)); } Zhong Yu

Re: RFR: 8023528: Rename Comparator combinators to disambiguate overloading methods

2013-08-23 Thread Zhong Yu
lambda parameter types. This restricted case happens to be the most common case where overload is needed, e.g. Stream.map(), Comparator.comparing(). It is heartbreaking to hear the decision of banning all overloads because of some bad corner cases that won't likely happen in real code. Zhong Yu

Re: FunctionalInterface as a rule in the matching interfaces ?

2013-08-01 Thread Zhong Yu
Some of these don't feel like "functions", e.g. Formattable, it's unlikely that anyone would use lambda expression to instantiate them. What is the general guideline to apply @FunctionalInterface? For example, why should AutoCloseable be marked as @FI? Zhong Yu On Thu, Au

Re: Invalid "self-closing element not allowed" JavaDoc error

2013-07-26 Thread Zhong Yu
rgon. There are exactly 10 such elements in html 4 area base br col hr img input link meta param I agree with Nick that a mere warning is appropriate for these elements. Zhong Yu On Fri, Jul 26, 2013 at 10:46 AM, Nick Williams wrote: > > On Jul 26, 2013, at 10:27 AM, Stephen Cole

Re: RFR: 8015317: Optional.filter, map, and flatMap

2013-07-15 Thread Zhong Yu
parameter that >> fails… >> >> >> On 15 July 2013 12:52, Zhong Yu wrote: >>> >>> Another example of possible missing a wildcard >>> >>> >>> http://gee.cs.oswego.edu/dl/jsr166/dist/docs/java/util/concurrent/CompletionStage.html#thenCo

Re: RFR: 8015317: Optional.filter, map, and flatMap

2013-07-14 Thread Zhong Yu
and we need a tool to find these mistakes. Zhong Yu On Sun, Jul 14, 2013 at 8:04 AM, Jed Wesley-Smith wrote: > (accidentally didn't post to the list) > >> You probably know that the example provided is not completed ported to > work with our Optional implementation, > >

Re: RFR: 8015317: Optional.filter, map, and flatMap

2013-07-14 Thread Zhong Yu
X> is not a subtype of X>. We have to go wildcard all the way - X>. The subtyping rules don't care about final-ness of types. For example, X is a distinct type from X, even though String has only one subtype (itself). Zhong Yu On Sun, Jul 14, 2013 at 8:04 AM, Jed Wesle

Re: RFR: 8017513: Support for closeable streams

2013-07-12 Thread Zhong Yu
th If the only information we have is that the object is a MHCR, we must close it. If we have other information, e.g. it's a Stream is from an ArrayList, then we may omit the close() call. The annotation @HoldsResource is meant to add extra information; particularly, *lack* of the annotation is meant

Re: RFR: 8017513: Support for closeable streams

2013-07-12 Thread Zhong Yu
On Fri, Jul 12, 2013 at 4:30 AM, Peter Levart wrote: > On 07/12/2013 01:14 AM, Zhong Yu wrote: > > On Thu, Jul 11, 2013 at 4:08 PM, Peter Levart > wrote: > > Hi Paul, > > I think the MayHoldCloseableResource extends AutoClosable is correct and > AutoClosable exten

Re: RFR: 8017513: Support for closeable streams

2013-07-11 Thread Zhong Yu
contract and which uses the lookup of @HoldsResource at runtime to decide How do you lookup an annotation on an _instance_ at runtime? And why do we even care? Just call close() regardless. And we can revert the parent/child relation, because the "otherwise specified" clause is a panacea.

Re: RFR: 8017513: Support for closeable streams

2013-07-10 Thread Zhong Yu
@HoldsResource interface D extends B What does it mean? If it mean that D definitely holds resource, is @HoldResource still necessary on methods that return D? Zhong Yu On Wed, Jul 10, 2013 at 4:30 PM, Henry Jen wrote: > Hi, > > Please review webrev at > http://cr.openjdk.java.n

Re: Use of super in type parameters

2013-04-17 Thread Zhong Yu
of the method, the type system couldn't help to catch the mistake today, but it's a bug regardless. Zhong Yu > CompletableFuture. Which is pretty bad for a feature that is designed > specifically to provide compile time safety. It would be nice to at least > have an acknowledg

Re: Use of super in type parameters

2013-04-15 Thread Zhong Yu
signature Stream Optional reduce(BinaryOperator accumulator) So I don't think there's a lack of use cases for lower bound. (But I have no idea how difficult it is to support it) Zhong Yu On Mon, Apr 15, 2013 at 2:37 PM, Martin Buchholz wrote: > CompletableFuture currently

Re: Throwable.addSuppressed error conditions -- use the exception as the cause?

2013-04-11 Thread Zhong Yu
On Tue, Apr 9, 2013 at 11:54 AM, Steven Schlansker wrote: > > On Apr 9, 2013, at 9:30 AM, Zhong Yu wrote: > >> >> >> >> On Mon, Apr 8, 2013 at 6:54 PM, Steven Schlansker >> wrote: >> Today I encountered "java.lang.IllegalArgumentE

Re: Code review request for 8012044: Give more information about self-suppression from Throwable.addSuppressed

2013-04-11 Thread Zhong Yu
It doesn't feel very right to say the exception is the "cause" of the IAE. If the user code reuses an exception instance "x", as reported by OP, there is a possibility that the IAE is later added as a suppressed exception to "x", forming a loop x->IAE->x.

Re: Throwable.addSuppressed error conditions -- use the exception as the cause?

2013-04-09 Thread Zhong Yu
ssion=writableStackTrace=true. Interestingly, even for an immutable exception, `e.addSuppressed(e)` isn't allowed. I think that it should be allowed. Zhong Yu

Re: RFR : JDK-8001642 : Add Optional, OptionalDouble, OptionalInt, OptionalLong

2013-03-06 Thread Zhong Yu
); stream.ifEmpty(-1).min(); Zhong Yu On Wed, Mar 6, 2013 at 3:47 AM, Remi Forax wrote: > Ok, let be nuclear on this, > There is no good reason to introduce Optional in java.util. > > It doen't work like Google's Guava Optional despite having the same > name, it doesn't work like S

Re: API question for point lambdafication

2013-02-19 Thread Zhong Yu
der and StringBuffer, the method will copy the chars in range. Therefore you may as well do the copy yourself to make Strings. Currently String does not have a constructor like public String(CharSequence source, int offset, int count) maybe it should be added? Zhong Yu > This provides a st

Re: FYC : JDK-7197183 : Improve copying behaviour of String.subSequence()

2013-02-19 Thread Zhong Yu
e got a problem with the change of String impl, we can refer him to wrap the string in a Strand, and operate on the strand instead. Zhong Yu On Mon, Feb 18, 2013 at 11:27 PM, Mike Duigou wrote: > Hello all; > > JDK 7u6 included a significant change to java.lang.String. The change was

Re: Early review on NIO Stream APIs

2013-02-07 Thread Zhong Yu
ilter with walk, which return a Stream. I see. It's a pity that we don't have an abstraction for Path+Attributes, since often applications need both. > Hope that helps. > > Cheers, > Henry > > On Feb 7, 2013, at 6:53 PM, Zhong Yu wrote: > >> The find() method

Re: Early review on NIO Stream APIs

2013-02-07 Thread Zhong Yu
Path-based APIs - path alone often isn't enough and app has to look up attributes in a separate step. Zhong Yu On Thu, Feb 7, 2013 at 6:15 PM, Henry Jen wrote: > Hi, > > While lambda still finalizing the final API for Stream, there are a > couple of streamifaction APIs in nio

Re: RFR (S): CR 8005926: (thread) Merge ThreadLocalRandom state into java.lang.Thread

2013-01-15 Thread Zhong Yu
>From user's point of view, there is nothing thread local about it - it is more like one global random generator, which is unseedable and unrepeatable. So why not call it a different name, like concurrent random? On Mon, Jan 14, 2013 at 4:17 PM, Alan Bateman wrote: > On 14/01/2013 18:20, Chris He

Re: review request 8006139, add missing methods to javax.sql.rowset.serial.SQLInput/OutputImpl

2013-01-13 Thread Zhong Yu
lastValueWasNull = attrib == null; xxx return attrib; xxx } if the wrong attribute type is requested, line 001 does not throw, so line 002 is also executed, which is probably a bug. If line 001 throws, we won't have this bug. Zhong Yu On Sun, Jan 13, 2013 at 9:11 AM, Remi Forax

Re: Scaling problem of HashMap (introduced with alternative hashing)

2012-12-27 Thread Zhong Yu
on commodity hardware, but OP got 64 cores. Zhong Yu > Mike > > On Dec 27 2012, at 11:38 , Aleksey Shipilev wrote: > >> Looks very like dumb inlined java.util.Random? >> Is there a security threat to use ThreadLocalRandom instead there? >> >> -Aleksey. >> &g

Re: RFR: JDK-8005263: Logging APIs takes Supplier for message

2012-12-21 Thread Zhong Yu
Question: why not delay the evaluation of the message even further, until LogRecord.getMessage() is invoked? Since a logger might be enabled for the level, but the handler is not, so the message is not really logged. Or is that considered uncommon? On Fri, Dec 21, 2012 at 12:28 AM, Henry Jen wrot

Re: Review request:Updated JDK-8004728 Implement core reflection API for parameter reflection

2012-12-19 Thread Zhong Yu
en wondering : why do JDK methods return arrays, instead of something like List? To avoid dependencies among JDK packages? Then how about an interface java.lang.Sequence? It would be very useful for user applications as well. Zhong Yu

Re: java.nio.*Buffer read/write atomicity

2012-12-19 Thread Zhong Yu
Users are unlikely to expect multi-byte atomicity on a ByteBuffer. However they are more likely to expect int-width atomicity on an IntBuffer view of a ByteBuffer; such atomicity is unfortunately not guaranteed either. Zhong Yu On Wed, Dec 19, 2012 at 11:48 AM, Aleksey Shipilev wrote: >

Re: Proposal: Fully Concurrent ClassLoading

2012-12-16 Thread Zhong Yu
On Sat, Dec 15, 2012 at 3:24 AM, David Holmes wrote: > On 15/12/2012 12:58 AM, Zhong Yu wrote: >> >> On Wed, Dec 12, 2012 at 5:48 PM, David Holmes >> wrote: >>> >>> On 13/12/2012 1:51 AM, Zhong Yu wrote: >>>> >>>> >>>> I

Re: Proposal: Fully Concurrent ClassLoading

2012-12-14 Thread Zhong Yu
On Wed, Dec 12, 2012 at 5:48 PM, David Holmes wrote: > On 13/12/2012 1:51 AM, Zhong Yu wrote: >> >> If a class loader is declared fully concurrent, yet >> getClassLoadingLock() is invoked, what's the harm of returning a >> dedicated lock anyway, exactly like wha

Re: RFR: 8005051: default methods for Iterator

2012-12-14 Thread Zhong Yu
On Fri, Dec 14, 2012 at 4:54 AM, Remi Forax wrote: > Hi Akhil, > > On 12/14/2012 02:24 AM, Akhil Arora wrote: >> >> As part of the library lambdafication, this patch adds a forEach default >> method to Iterator, and converts remove() into a default method so that >> implementations of Iterator no

Re: Proposal: Fully Concurrent ClassLoading

2012-12-12 Thread Zhong Yu
On Wed, Dec 12, 2012 at 10:05 AM, Peter Levart wrote: > On 12/12/2012 04:51 PM, Zhong Yu wrote: >> >> If a class loader is declared fully concurrent, yet >> getClassLoadingLock() is invoked, what's the harm of returning a >> dedicated lock anyway, exactly like what

Re: Proposal: Fully Concurrent ClassLoading

2012-12-12 Thread Zhong Yu
If a class loader is declared fully concurrent, yet getClassLoadingLock() is invoked, what's the harm of returning a dedicated lock anyway, exactly like what's done before? On Tue, Dec 11, 2012 at 7:40 PM, David Holmes wrote: > On 11/12/2012 9:58 PM, Peter Levart wrote: >> >> On 12/11/2012 12:27

Re: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String

2012-11-23 Thread Zhong Yu
I just realized that I also use String.trim() a lot, and have always assumed it's very cheap; that's no longer the case. JDK itself contains many usages of trim(); even a lot of str.substring().trim() Just saying. On Wed, Nov 14, 2012 at 9:14 AM, Zhong Yu wrote:

Re: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String

2012-11-14 Thread Zhong Yu
that's the worst blow in my book. There's no problem if substring() does copying from day one, but 17 years have passed. Zhong Yu On Wed, Nov 14, 2012 at 6:58 PM, Vitaly Davidovich wrote: > Personally, I feel like the concern is a bit overstated: > > 1) the n in O(n) is likely actu

Re: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String

2012-11-14 Thread Zhong Yu
f strings are no longer certain, what else can we believe in? Is there any chance in hell to roll it back? Maybe add a new method for the new behavior? Zhong Yu

Re: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String

2012-11-14 Thread Zhong Yu
at 9:14 AM, Zhong Yu wrote: > Changing String.substring() from O(1) to O(n) is a big deal; we may > say it breaks compatibility. > > Any code that intends to work across JDK versions before and after 7u6 > cannot use the method, since its behavior is so different in different >

Re: hg: jdk8/tl/jdk: 6924259: Remove offset and count fields from java.lang.String

2012-11-14 Thread Zhong Yu
another type if it's part of a method signature. With all these problems, please reconsider this change and see if you should roll it back. Thanks. Zhong Yu

java.util.zip.Deflater: needsInput() returns true after finish()

2012-03-21 Thread Zhong Yu
c boolean needsInput() { synchronized (zsRef) { return !finish && len <= 0; } } (I don't understand the `synchronized (zsRef)` part; this class should only be used serially anyway. But if other methods require synchronization, this method requires it too) Regards, Zhong Yu

Return type of Object.getClass()

2011-06-30 Thread Zhong Yu
n for erasure here? Thanks. Zhong Yu