Re: ThreadLocal with null initial values - avoid create map and entry?

2014-11-18 Thread Tom Hawtin
On 18/11/2014 05:11, Bernd Eckenfels wrote: Unfortunatelly the ThreadLocal#get() will call #setInitialValue() in all cases, and this will in turn call createMap(). setInitialValue() could avoid to call createMap() when value is null. This would reduce the number of created thread specific maps a

Re: State of Serialization

2014-07-21 Thread Tom Hawtin
On 20/07/2014 11:57, Peter Firmstone wrote: Since private methods are only be called by the ObjectOutputStream / ObjectInputStream, during de-serialisation, subclass are not responsible for calling these methods, hence subclass ProtectionDomain's are not present in the Thread's AccessControlCont

Re: please review draft JEP: Convenience Factory Methods for Collections

2014-07-17 Thread Tom Hawtin
On 17/07/2014 22:56, Stuart Marks wrote: On 7/17/14 12:46 AM, Tom Hawtin wrote: I note that with the basic proposal, HashSet.of and indeed NavigableSet.of still work. They just do the wrong thing. I should have made more clear in the JEP that the proposed APIs are static methods on the List

Re: please review draft JEP: Convenience Factory Methods for Collections

2014-07-17 Thread Tom Hawtin
I note that with the basic proposal, HashSet.of and indeed NavigableSet.of still work. They just do the wrong thing. Tom

Re: Creating Thread in AccessController.doPrivileged()

2014-04-28 Thread Tom Hawtin
On 24/04/2014 06:06, Zhong Yu wrote: If a thread is created inside AccessController.doPrivileged(), it seems to inherit AccessControlContext from the calling thread, is that the expected/specified behavior? It should inherit the acc from when it was created. If that context was privileged by t

Re: Reflection.getCallerClass() and @CallerSensitive for a constructor?

2014-03-24 Thread Tom Hawtin
On 24/03/2014 08:41, Wang Weijun wrote: Calling Reflection.getCallerClass() needs the @CallerSensitive annotation, but it cannot be applied to a constructor. Ah, I see your message from 2012-11-26 05:46. > This is very nice but it does not mention Constructor.newInstance(). > In fact, I do s

Re: Unsafe: removing the monitorEnter/monitorExit/tryMonitorEnter methods

2014-03-06 Thread Tom Hawtin
On 04/03/2014 15:32, David M. Lloyd wrote: On 03/03/2014 09:45 PM, David Holmes wrote: We should not introduce anything that allows something that was guaranteed to be safe by the language, to become unsafe. Define 'safe'. Because I don't think it's unsafe, any more than I believe even in

Re: Draft JEP on enhanced volatiles

2014-02-09 Thread Tom Hawtin
I'm very concerned that this adds bulk to an already oversized language to support something which should be incredibly obscure. On 07/02/2014 18:36, Doug Lea wrote: Alternatives We considered instead introducing new forms of "value type" that support volatile operations. However,

Re: CallerSensitive access rights problems

2013-11-18 Thread Tom Hawtin
On 18/11/2013 14:59, Jochen Theodorou wrote: java.lang.Class has multiple methods annotated with CallerSensitive (see http://hg.openjdk.java.net/jdk8/jdk8-gate/jdk/file/tip/src/share/classes/java/lang/Class.java). Now if we in Groovy here want to build our runtime structure for this class, an

Re: shared "value" in java.lang.StringBuilder

2013-11-11 Thread Tom Hawtin
On 06/11/2013 21:54, Robert Stupp wrote: > Wouldn't it worth to try whether passing the > (Abstract)StringBuilder's value+count values to String results in > less temporary object creations and therefore reduce pressure on new > generation (and reduce GC effort)? My idea is to add a field 'shared

Re: Slow readng tzdb.dat

2013-10-09 Thread Tom Hawtin
On 09/10/2013 19:00, Dr Heinz M. Kabutz wrote: That way, the resources are closed in the reverse order in which they are opened and an exception in the middle of the creation chain does not prevent the earlier resources from being closed. But there is only one resource. File tzdb = new File

Re: [concurrency-interest] FutureTask.cancel(true) should run thread.interrupt within doPrivileged

2013-10-02 Thread Tom Hawtin
On 02/10/2013 18:02, Doug Lea wrote: On 10/02/2013 12:29 PM, Martin Buchholz wrote: FutureTask.cancel(true) invokes thread.interrupt on the thread (if any) currently running the task. This should succeed even if modifyThread permission is denied by the security manager. We haven't interpreted

Re: [PATCH] 4851444: Exposing sun.reflect.Reflection#getCallerClass as a public API in Java 8

2013-09-02 Thread Tom Hawtin
On 02/09/2013 09:33, Alan Bateman wrote: From a quick scan then it appears that you've decided to ignore the security concerns so I don't think anyone can (or should) sponsor this patch until there is further discussion on the API and the security implications. I've barely looked through the

Re: RFR: 7057785 : (xs) Add note to hashCode() that support for self referential is optional

2013-08-29 Thread Tom Hawtin
On 29/08/2013 00:23, Mike Duigou wrote: I am unsure what solution was used in Common Lisp (I think I knew once). The most likely solution for Java Collections would be to use a ThreadLocal which potentially recursive methods could check/set on entry and avoid recursing. Explicitly concurrent

Re: RFR: 8022446: Fix serial warnings in java.util.stream

2013-08-06 Thread Tom Hawtin
Jen wrote: On 08/06/2013 03:01 PM, Tom Hawtin wrote: Are you happy with the API docs in docs/api/serialized-form.html? Those are all internal classes, thus is not showing up on that page at all. I assume this is the concern? Cheers, Henry

Re: RFR: 8022446: Fix serial warnings in java.util.stream

2013-08-06 Thread Tom Hawtin
Are you happy with the API docs in docs/api/serialized-form.html? Tom On 06/08/2013 14:28, Henry Jen wrote: Hi, Please review a webrev[1] clean up on serial warning, as we don't intend to serialize those tasks, we simply suppress those warnings. It would be nice if there is a way to undo seri

Re: Prevent privilege escalation through AccessController.doPrivileged()

2013-07-04 Thread Tom Hawtin
On 04/07/2013 15:44, Florian Weimer wrote: Is there a way to prevent future calls to AccessController.doPrivileged() from the same thread from actually increasing privilege? No. If the code has the relevant permissions it can call doPrivileged together with the 1.0/1.1 legacy and new caller-se

Re: Inefficient use StringBuffer or StringBuilder[Optimization|clean-up] {Package: con.sun. * java.lang*}

2013-06-07 Thread Tom Hawtin
On 07/06/2013 14:54, Andrew Haley wrote: On 06/07/2013 02:18 PM, Otávio Gonçalves de Santana wrote: sb.append("xxx: [" + getXXX() + "]\n"); for this: sb.append("xxx: [").append(getXXX()).append("]\n"); Hmm. I wonder that a JIT can't do this automatically. Perhaps it already d

Re: JEP 180: Handle Frequent HashMap Collisions with Balanced Trees

2013-04-15 Thread Tom Hawtin
On 05/04/2013 19:08, mark.reinh...@oracle.com wrote: Posted: http://openjdk.java.net/jeps/180 If you're using WeakHashMap with types that (may) override equals/hashCode you have bigger problems. You almost certainly want "identity" semantics (violating the java.util.Map contract) and quite p

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

2013-01-15 Thread Tom Hawtin
On 15/01/2013 16:33, Chris Hegarty wrote: Updated webrev: http://cr.openjdk.java.net/~chegar/8005926/webrev.01/webrev/ Any chance of using SharedSecrets instead of UNSAFE? You know, with Unsafe being like unsafe and everything. Tom

Re: RFR: (jaxp) 8003261 : static field is public but not final

2012-12-18 Thread Tom Hawtin
Not that it's particularly important, but it's /possible/ clients are relying on the non-compile time constant nature of this field causing it not to be inlined into client class files, rather than the ability to switch the version string. So it may be a good idea to add the final, but make it

Re: review request 7172551

2012-06-11 Thread Tom Hawtin
On 07/06/2012 21:39, Joe Darcy wrote: I'd like to see some "()" on this line! 470 ClassLoader cl = cc != null ? cc.getClassLoader() : null; It's `a==b ? c : d` is such an incredibly common idiom in Java, and generally unambiguous, that parentheses are unhelpful noise. Emphasising precedenc

Re: Codereview request for 4153167: separate between ANSI and OEM code pages on Windows

2012-02-17 Thread Tom Hawtin
On 16/02/2012 20:18, Xueming Shen wrote: Thanks Alan, webrev has been updated accordingly. http://cr.openjdk.java.net/~sherman/4153167/webrev Although it's in some sense safe in this case, you might get a grumble about introducing a new

Re: Please review: 7143711 : Feature added by 7053556 should not override what's set by the constructor in secure mode

2012-02-13 Thread Tom Hawtin
Looks good to me. Tom On 08/02/2012 22:13, Joe Wang wrote: Hi, The 7053556 patch added a (Oracle) implementation-only feature to allow users to skip the plugability layer. In the same patch, there was also a change that in secure mode, dependent components should be loaded in a hardwired mode.

Re: FilterOutputStream.close() throws exception from flush()

2012-02-10 Thread Tom Hawtin
On 10/02/2012 13:16, Alex Lam S.L. wrote: To recover the previous behaviour, I think the following might just work: try (OutputStream ostream = out) { flush(); } catch (IOException ignored) { } Remember try-with-resource-catch works the inside-out from try-catch-finally! You are discardin

Re: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods

2012-01-30 Thread Tom Hawtin
On 30/01/2012 13:16, Ulf Zibis wrote: Isn't cloning faster than normal instantiation? I can imagine, that behind the scenes cloning mainly only needs to duplicate the binary footprint of an object. I don't see a good reason why it should be (equally, I've not tried benchmarking). For the imm

Re: JDK 8 code review request for 7140820 Add covariant overrides to Collections clone methods

2012-01-30 Thread Tom Hawtin
On 30/01/2012 03:58, Joe Darcy wrote: Object clone() method inherited from java.lang.Object with a covariant override such as MyType clone() This is, of course, going to break any existing overrides (that aren't making use of covariant return types). This will be why the changes weren't ma

Re: 7116722: Miscellaneous warnings sun.misc ( and related classes )

2011-11-30 Thread Tom Hawtin
On 30/11/2011 17:04, Joe Darcy wrote: public JarIndex() { - indexMap = new HashMap(); - jarMap = new HashMap(); + indexMap = new HashMap>(); + jarMap = new HashMap>(); jarMap = new HashMap>(); or similar might be better. Looks a bit O(n^2). But that's a different sort of style. Tom

Re: Who is on Dedoxx?

2011-11-07 Thread Tom Hawtin
On 07/11/11 11:40, Ulf Zibis wrote: I want to know, if there are any members of the list participating on the Devoxx Conference next week. I shall be attending. For the third year running I shall be on holiday and not representing my employer. Tom

core-libs-dev@openjdk.java.net

2011-11-04 Thread Tom Hawtin
On 04/11/11 09:58, Heiko Wagner wrote: This is caused by the fact that the ResourceBundle class tries to determine the actual ClassLoader using the getLoader() method, via accessing the hardcoded stack offset 2, which works when the getBundle() method is callen from Java, but in my case I invoke

Re: Objects.nonNull()

2011-01-14 Thread Tom Hawtin
On 14/01/2011 11:30, Stephen Colebourne wrote: These are prior art that users are familiar with, just as much as the JDK. There is actually prior art in JSRs. JSR 305: Annotations for Software Defect Detection Used @Nonnull. In normal circumstances, we would expect this annotation and the

Re: Objects.nonNull()

2011-01-13 Thread Tom Hawtin
On 13/01/2011 22:11, Brian Goetz wrote: I disagree with Tom here. We have *already* made the billion dollar mistake, and we can't eliminate that headache (but we can provide easier access to aspirin.) Java developers are *constantly* writing methods like the suggested carpet-sweeping nonNull() t

Re: Objects.nonNull()

2011-01-13 Thread Tom Hawtin
On 13/01/2011 20:06, Brian Goetz wrote: Most of the other methods in this class are of the form "do the right thing if the object is null (or an array)", but this one is "throw an exception if the object is null." The intent is clear -- it is for simplifying fail-fast behavior by checking for nu

Re: Source snapshot release - country-specific restriction? [2]

2010-12-12 Thread Tom Hawtin
On 12/12/2010 19:30, Dalibor Topic wrote: On 12/12/10 3:57 PM, assembling signals wrote: Since JDK b121 I can't download JDK sources from here [ http://download.java.net/jdk7/ ], because my country (Germany) is not in some green list for it. I assume this is related to the retirement of the

Re: StringBuffer.build() - a way to create strings without unnecessary allocations

2010-12-08 Thread Tom Hawtin
On 08/12/2010 23:03, Jaroslav Tulach wrote: I've been investigating the memory allocations during NetBeans start. I've noticed that we are allocating about 60MB of char[] mostly due to parsing of various configuration files. Suprisingly at least half of these 60MB is garbage collected quickly. T

Re: A small ClassLoader change proposal

2010-09-16 Thread tom . hawtin
On 16/09/2010 13:56, Jevgeni Kabanov wrote: I'd like to contribute two new classes to the JDK7 and add a new package-visible field to the ClassLoader. These classes would be meant for the framework and server developers to allow for greater control over the references between classes in differen

Re: Threads should not be Cloneable

2010-08-13 Thread tom . hawtin
On 13/08/2010 14:58, Chris Hegarty wrote: protected final Object clone() throws CloneNotSupportedException { throw new CloneNotSupportedException(); The final can (and should, IMO) be removed. Tom

Re: HashMap bug for large map sizes

2010-07-13 Thread tom . hawtin
On 13/07/2010 18:13, Kasper Nielsen wrote: s.writeInt(Integer.MAX_VALUE); for (int i=0;i Adding a field to the serial form would probably be better. Tom

Re: java.util.Pair

2010-04-02 Thread tom . hawtin
On 30/03/2010 09:08, Weijun Wang wrote: > I know such a simple thing can be made very complex and everyone might > want to add a new method into it. How about we just make it most > primitive? Simply an immutable and Serializable class, two final > fields, one constructor, two getters (?), and no

Re: Serialization problem

2010-01-31 Thread Tom Hawtin
Stephen Colebourne wrote: Workarounds include lazily creating the caches in transient fields, bloating the serialzed data, using reflection or creating a dummy inner class to act as the serialized form. All are rubbish solutions. IMO, a "serial proxy" is a good rubbish solution. Nested classe

Re: jdk6: LazyInitialization in java.io.File

2010-01-18 Thread Tom Hawtin
Nico R. wrote: In java.io.File.createTempFile(String,String,File) (see http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/ea5036d799e5/src/share/classes/java/io/File.java>), line 1797 says: String tmpDir = LazyInitialization.temporaryDirectory(); LazyInitialization, line 1683, has stat

Re: final transient fields serialization

2009-12-03 Thread Tom Hawtin
- errors by unchecked exception FieldRead.read - Dynamic check that called from readObject on this instance (can cheat). - Dynamic check for no reassignment. - Dynamic check after readObject call for definite assignment. - Could also add static checks as well. ) Tom Hawtin

Re: What methods should go into a java.util.Objects class in JDK 7?

2009-10-12 Thread Tom Hawtin
cause a security issue. It might be an issue for other languages on the JVM. In practice, it doesn't matter very much; I'll consider final-izing j.u.Objects on the next round of edits. Oh don't put a finalizer on it. ;) Tom Hawtin

Re: System.identityHashCode performance

2009-09-22 Thread Tom Hawtin
e of years... http://bugs.sun.com/view_bug.do?bug_id=6378256 Tom Hawtin

Re: java.util.LinkedList clear() improvement

2009-08-27 Thread Tom Hawtin
Guy Korland wrote: It seems like linkedList.clear() can be easily fixed to O(1) instead of O(n). The code is like that on purpose(!). It was done to help GC, in mustang IIRC. There really isn't a problem with clear() being O(n) - it's going to take at least O(n) to populate it, and in realit

Re: Fastpath for new String(bytes..) and String#getBytes(..) for ASCII + ISO-8859-1

2009-06-17 Thread Tom Hawtin
Xueming Shen wrote: I would be very hesitated to add methods with specific encoding names, even these encodings are VERY important, such as ASCII and ISO8859. Hack a fast path in the implementation to boost the performance for some important encodings is something we want to do, but add specifi

Re: Adding a fixate method to StringBuilder and StringBuffer.

2009-04-15 Thread Tom Hawtin
immutable char[] wrapper class. Tom Hawtin

Re: OpenJDK Forum: Core Libraries Round Table

2009-04-09 Thread Tom Hawtin
Dalibor Topic wrote: Tom Hawtin wrote: Dalibor Topic wrote: A recording of the call is available on http://mediacast.sun.com/users/robilad/media/openjdk6-core-libs.ogg Any chance of getting that in a mainstream format? Windows doesn't understand it. Rhythmbox under VirtualBox freezes.

Re: OpenJDK Forum: Core Libraries Round Table

2009-04-09 Thread Tom Hawtin
I think it needs a better story than that. +1 :) Personally, I think there was already a compromise by going with Ogg Vorbis over Speex ;) At least I've heard of Ogg Vorbis. Really it ought to be in FXM so JavaFX can play it. Tom Hawtin

Re: OpenJDK Forum: Core Libraries Round Table

2009-04-09 Thread Tom Hawtin
Dalibor Topic wrote: A recording of the call is available on http://mediacast.sun.com/users/robilad/media/openjdk6-core-libs.ogg Any chance of getting that in a mainstream format? Windows doesn't understand it. Rhythmbox under VirtualBox freezes. Tom Hawtin

Re: java.lang.Thread.contextClassLoader : what if it were a weak reference ?

2009-03-23 Thread Tom Hawtin
y become a weak reference?). Really there needs to be more care taken when creating threads to make sure the context class loader (and indeed InheritableThreadLocals) are inherited only when appropriate. Tom Hawtin

Re: How to get FileChannel from resource

2009-03-02 Thread Tom Hawtin
return a JarFile. Tom Hawtin

Re: How to get list of classes from a package

2009-02-16 Thread Tom Hawtin
he same package name will not have Java access to default/protected members/classes/interface/constructors from different class loaders. But yes, a list of classes is not necessarily complete. Also, IIRC, Proxy dynamically inserts classes into packages as well. Tom Hawtin

Re: [PATCH 1/1] RFC: Add a couple more trivial set methods to java.util.Collections

2008-12-04 Thread Tom Hawtin
David M. Lloyd wrote: BTW, I'm sceptical about the claims within the javadoc for singleton() that the resultant set is serializable, as the field containing the element is final. final is fine with serialisation. You can even provide a readObject and set it with ObjectInputStream.readObject