Re: RFR: 8223260: NamingManager should cache InitialContextFactory

2020-02-05 Thread Peter Levart
o - I'm hoping to port this to JDK 11u also so I might spin the specification changes into a different bug ID. regards, Sean. On 03/02/2020 09:05, Peter Levart wrote: Hi Seán, On 2/1/20 12:22 AM, Seán Coffey wrote: The following is also possible:     // 1st try finding a Ser

Re: RFR: 8223260: NamingManager should cache InitialContextFactory

2020-02-03 Thread Peter Levart
Hi Seán, On 2/1/20 12:22 AM, Seán Coffey wrote: The following is also possible:     // 1st try finding a ServiceLoader.Provider with type() of correct name     factory = loader     .stream()     .filter(p -> p.type().getName().equals(className))    

Re: RFR: 8223260: NamingManager should cache InitialContextFactory

2020-01-31 Thread Peter Levart
d approach * insert use of sleep which testing GC. http://cr.openjdk.java.net/~coffeys/webrev.8223260.v2/webrev/ regards, Sean. On 30/01/2020 07:59, Peter Levart wrote: Hi Seán, WeakHashMap is not safe to be called concurrently. Even get() method, although it may seem read-only, can modify interna

Re: RFR: 8223260: NamingManager should cache InitialContextFactory

2020-01-30 Thread Peter Levart
On 1/30/20 8:59 AM, Peter Levart wrote: So if you know that the (implementation class of) InitialContextFactory instance is always resolvable (by class name) from the ClassLoader you are using for the caching key (the TCCL), then this utility might be just right for your purpose. Thinking

Re: RFR: 8223260: NamingManager should cache InitialContextFactory

2020-01-30 Thread Peter Levart
Hi Seán, WeakHashMap is not safe to be called concurrently. Even get() method, although it may seem read-only, can modify internal state (expunging stale Weak entries), so holding a READ lock while accessing WeakHashMap it is wrong. getInitialContext() static method is called with an env Has

Re: [PING] RFR: 8231111: Cgroups v2: Rework Metrics in java.base so as to recognize unified hierarchy

2019-12-23 Thread Peter Levart
Hi, On 12/2/19 6:13 PM, Bob Vandette wrote: 2) How should we deal with "not supported" for booleans/arrays, etc.? Would it make sense to return record objects from the Metrics API so that this could be dealt with? E.g. Metrics m = ... MetricResult result = m.getCpuSetCpus(); switch(result.getTy

Re: RFR JDK-8234049: Implementation of Memory Access API (Incubator)

2019-12-09 Thread Peter Levart
Hi Maurizio, Nice work! I see the API prefixes each independent access to memory with a call to the following MemorySegmentImpl method:  157 @Override  158 public final void checkValidState() {  159 if (owner != Thread.currentThread()) {  160 throw new IllegalState

Re: RFR JDK-8233527: Update Lookup::hasPrivateAccess and Lookup::defineClass spec w.r.t. full power lookup

2019-11-15 Thread Peter Levart
Hi Mandy, http://cr.openjdk.java.net/~mchung/jdk14/8233527/webrev.03/ In Lookup's findBoundCallerClass and checkSecurityManager the javadoc is still talking about private access only although the checks are now made against full privilege access. Some possible nano optimization / simpli

Re: RFR of JDK-8232446: logging enhancement for rmi when socket closed

2019-11-06 Thread Peter Levart
Hi Hamlin, in TCPTransport.decrementExportCount():  283 try {  284 if (tcpLog.isLoggable(Log.BRIEF)) {  285 tcpLog.log(Log.BRIEF, "close server socket on " + ss);  286 }  287 ss.close();  288 } catch (I

Re: RFR: JDK-8229871: Improve performance of Method.copy() and leafCopy()

2019-10-23 Thread Peter Levart
= 2331 ms (+106%) webrev.04: Elapsed time = 3746 ms (+ 28%) I'll measure larger benchmark and try to think if we can reduce the overhead of memory barrier. Regards, Ogata Peter Levart wrote on 2019/10/09 16:44:13: From: Peter Levart To: Kazunori Ogata , core-libs-dev@openjdk.java.net

Re: RFR: JDK-8229871: Improve performance of Method.copy() and leafCopy()

2019-10-09 Thread Peter Levart
On 10/8/19 8:37 PM, Claes Redestad wrote: On 2019-10-08 18:57, Kazunori Ogata wrote: Hi Claes, Thank you for your review and comment. I was also wondering why only these two fields aren't initialized in the constructor.  Shall I also make the change you mentioned? I think it might be be

Re: RFR: JDK-8229871: Improve performance of Method.copy() and leafCopy()

2019-10-09 Thread Peter Levart
Hi Ogata, May I just add that volatile field ensured that MethodAccessor object was correctly published. DelegatingMethodAccessortImpl is not safe to be published via data race because it contains plain `delegate` field initialized in the constructor. In addition, the object that is first ass

Re: JDK 14 RF(pre)R: add section on "conditionally serializable" collections

2019-10-05 Thread Peter Levart
Hi Stuart, I also prefer your wording. There's just a nit... On 10/5/19 1:46 AM, Stuart Marks wrote: On 10/3/19 8:32 AM, Joe Darcy wrote: In response to the recent and on-going review of serializable types in the base module and elsewhere, I thought it would be helpful if the collections sp

Re: JDK 14 RF(pre)R: add section on "conditionally serializable" collections

2019-10-04 Thread Peter Levart
Oh god, a typo in a typo comment... I better go to sleep now ;-) On 10/4/19 11:14 PM, Peter Levart wrote: + * serialized. Otherwise, is one or more objects in a collection are s/is/in/ s/is/if/ Peter

Re: JDK 14 RF(pre)R: add section on "conditionally serializable" collections

2019-10-04 Thread Peter Levart
Hi Joe, On 10/3/19 5:32 PM, Joe Darcy wrote: Hello, In response to the recent and on-going review of serializable types in the base module and elsewhere, I thought it would be helpful if the collections specs discussed how collections were serialiazable. In particular, the proposed terminolo

Re: RFR (S) 8230407 : SocketPermission and FilePermission action list allows leading comma

2019-10-02 Thread Peter Levart
Hi Ivan, On 10/1/19 10:26 PM, Ivan Gerasimov wrote: Hello! The constructors of SocketPermission and FilePermission expect a String argument with comma-separated list of actions. If the list is malformed, then the constructors throw IllegalArgumentException. It turns out that the current i

Re: RandomAccess Interface and List Heirarchy

2019-09-28 Thread Peter Levart
On 9/25/19 12:15 PM, Remi Forax wrote: that said, i believe we should deprecate LinkedList (and any other List implementation that doesn't implement RandomAccess) because there are too much code out there that suppose that list.get() is O(1). Hi Remi, Deprecating LinkedList as a whole is may

Re: RFR 8231314: java.time serialization warning cleanup

2019-09-23 Thread Peter Levart
Once more, for the list (sorry)... Hi, On 9/21/19 12:31 PM, Chris Hegarty wrote: Roger, On 20 Sep 2019, at 19:51, Roger Riggs wrote: Please review code cleanup that will remove the need to suppress soon to be introduced warnings [1] about static typing of serialization related fields. A f

Re: JDK 14 RFR of JDK-8231202: Suppress warnings on non-serializable non-transient instance fields in serializable classes

2019-09-23 Thread Peter Levart
Hi Joe, I've been thinking of this example:   83 final class Ser implements Externalizable {   84 ...   99 /** The object being serialized. */  100 @SuppressWarnings("serial") // Not statically typed as Serializable  101 private Object object; Externalizable does extend Serializa

Re: RFR: 8230662: Remove dead code from MethodTypeForm

2019-09-09 Thread Peter Levart
Hi Claes, Your changes look good. But I spotted a pre-existing and unusual use of @Stable annotation in java.lang.invoke.MethodTypeForm class:     // Cached adapter information:     @Stable final SoftReference[] methodHandles;     // Cached lambda form information, for basic types only:     f

Re: Reply: what to do next to fix JDK-8230557. thanks

2019-09-05 Thread Peter Levart
patibility problem, it's really a bug. User can't understand why the size method return a negative number.   Best, lamber-ken --  -- ??: "Peter Levart"??: ""<2217232...@qq.com&

Re: Reply: what to do next to fix JDK-8230557. thanks

2019-09-05 Thread Peter Levart
javadoc of the method described this corner case, he/she would understand? Regards, Peter Best, lamber-ken --?0?2?0?2-- *??????:*?0?2"Peter Levart"; *:*?0?22019??9??5??(??) 3:51 *??:*?0?2""<2217232...@qq.c

Re: 回复: 回复: what to do next to fix JDK-8230557. thanks

2019-09-05 Thread Peter Levart
Hi 未来阳光, As David has pointed out, your proposed fix would break binary and source compatibility of BitSet.size() method, so it is not acceptable. BitSet API allows addressing individual bits using non-negative 'int' typed indexes (analogous to indexes of Java arrays). The range of indexes i

Re: RFR JDK-8193325: StackFrameInfo::getByteCodeIndex returns wrong value if bci > 32767

2019-08-13 Thread Peter Levart
On 8/13/19 3:57 PM, Aleksey Shipilev wrote: On 8/13/19 3:33 AM, Mandy Chung wrote: On 8/12/19 5:13 PM, Frederic Parain wrote: 96 // VM adds 1 to the code index to StackFrameInfo::bci field such that 97 // zero (and negative values) indicates invalid BCI. So substract 1. http://cr.openjdk.jav

Re: RFR JDK-8193325: StackFrameInfo::getByteCodeIndex returns wrong value if bci > 32767

2019-08-13 Thread Peter Levart
Hi Mandy, Just a question... On 8/12/19 10:24 PM, Mandy Chung wrote: Having a second thought, I'm keeping @Stable bci field while zero indicates an invalid BCI that makes it obvious that this field will be updated.  VM will set StackFrameInfo::bci to value+1. http://cr.openjdk.java.net/~mchu

Re: Review Request: JDK-8209005: Lookup.unreflectSpecial fails for default methods when Lookup.findSpecial works

2019-07-31 Thread Peter Levart
On 7/31/19 9:59 AM, Peter Levart wrote: Hi, I think Daniel is talking about the "dispatch" semantics of unreflectSpecial here, right Daniel? The findSpecial / unreflectSpecial is a MethodHandle equivalent for bytecode instruction invokespecial (sans actual invoking). invoke

Re: Review Request: JDK-8209005: Lookup.unreflectSpecial fails for default methods when Lookup.findSpecial works

2019-07-31 Thread Peter Levart
Hi, I think Daniel is talking about the "dispatch" semantics of unreflectSpecial here, right Daniel? The findSpecial / unreflectSpecial is a MethodHandle equivalent for bytecode instruction invokespecial (sans actual invoking). invokespecial is typically used for implementing the super.metho

Re: 8193072: File.delete() should remove its path from DeleteOnExitHook.files

2019-07-26 Thread Peter Levart
Hi Brian, On 7/26/19 12:42 AM, Brian Burkhalter wrote: On Jul 11, 2019, at 12:52 AM, Peter Levart <mailto:peter.lev...@gmail.com>> wrote: On 7/11/19 9:47 AM, Peter Levart wrote: http://cr.openjdk.java.net/~plevart/jdk-dev/8193072_File.undoDeleteOnExit/webrev.02/ Another

Re: RFR: 8227587: Add internal privileged System.loadLibrary

2019-07-17 Thread Peter Levart
Hi Claes, Am I reading correct that package-private ClassLoader.loadLibrary(Class fromClass, String name, boolean isAbsolute) wouldn't need to consult SecurityManager wasn't it for accessing system properties in private ClassLoader.initializePath(String propName). So perhaps if the two calls

Re: RFR [14] JDK-8225763 Inflater and Deflater should implement AutoCloseable

2019-07-13 Thread Peter Levart
Hi Jaikiran, On 7/12/19 9:07 AM, Jaikiran Pai wrote: The new updated webrev is at http://cr.openjdk.java.net/~jpai/webrev/8225763/4/webrev/ I don't know if there are any custom subclasses of Inflater/Deflater around and what they do, but hypothetically consider a subclass of Deflater simila

Re: 8193072: File.delete() should remove its path from DeleteOnExitHook.files

2019-07-11 Thread Peter Levart
On 7/11/19 9:47 AM, Peter Levart wrote: http://cr.openjdk.java.net/~plevart/jdk-dev/8193072_File.undoDeleteOnExit/webrev.02/ Another thing to consider (done in above webrev.02) is what to do with unbalanced cancelDeleteOnExit(). I think it is better to throw exception than to

Re: 8193072: File.delete() should remove its path from DeleteOnExitHook.files

2019-07-11 Thread Peter Levart
Hi, On 7/11/19 3:51 AM, Ivan Gerasimov wrote: On 7/10/19 5:17 PM, Brian Burkhalter wrote: I incorporated Peter’s version, adding the security check in cancelDeleteOnExit(), tweaking its verbiage along with that of deleteOnExit(), and modified the test DeleteOnExit to verify the new method. T

Re: EnumSet.class serialization broken - twice - JDK-8227368

2019-07-10 Thread Peter Levart
On 7/10/19 6:03 PM, Joe Darcy wrote: Hello, I'd advise against including at least part of the comment     // declare serialization compatibility with JDK 8 (see JDK-8227368) We generally don't include bug numbers in the text of the code and rely mapping from the SCM to the bug database to pro

Re: 8193072: File.delete() should remove its path from DeleteOnExitHook.files

2019-07-10 Thread Peter Levart
Hi, On 7/9/19 8:08 PM, Brian Burkhalter wrote: On Jul 9, 2019, at 8:31 AM, Brian Burkhalter wrote: Since deleteOnExit() is an deliberate act, perhaps there should be a corresponding withdrawDeleteOnExit() that reverses it so that it is intentional and not a side-effect of other File method

Re: EnumSet.class serialization broken - twice - JDK-8227368

2019-07-10 Thread Peter Levart
Hi Stuart, On 7/10/19 4:32 AM, Stuart Marks wrote: 1. New changeset with constant version of EnumSet.serialVersionUID. This is already in the webrev.01 changeset. webrev.02 is an attempt to sneak the change without being visible in the serialized-form.html. Ah. I skipped webrev.01 because I

Re: EnumSet.class serialization broken - twice - JDK-8227368

2019-07-09 Thread Peter Levart
On 7/9/19 1:57 AM, Stuart Marks wrote: 2. Create draft CSR. Created: https://bugs.openjdk.java.net/browse/JDK-8227432 Regards, Peter

Re: EnumSet.class serialization broken - twice - JDK-8227368

2019-07-09 Thread Peter Levart
ngeset. webrev.02 is an attempt to sneak the change without being visible in the serialized-form.html. 2. Create draft CSR. I'll try that right away. Regards, Peter Thanks, s'marks [1] http://openjdk.java.net/jeps/3 [2] http://openjdk.java.net/projects/jdk/13/ On 7/7/

Re: EnumSet.class serialization broken - twice

2019-07-07 Thread Peter Levart
On 7/7/19 4:31 PM, Peter Levart wrote: On 6/29/19 2:00 AM, Stuart Marks wrote: Daniel Fuchs pointed me to a weird thing they had to do with the serialVersionUID in one of the JMX classes: https://hg.openjdk.java.net/jdk/jdk/file/c59f36ed7b52/src/java.management/share/classes/javax/management

Re: EnumSet.class serialization broken - twice

2019-07-07 Thread Peter Levart
, it would seem sensible to file a bug and start on a fix for the current release(s). Would you be able to do that? Again, thanks for finding this. s'marks On 6/18/19 7:32 AM, Peter Levart wrote: On 6/18/19 4:00 PM, Martin Buchholz wrote: Java Historian says: I was a reviewer for

Re: Review Request: JDK-8173978: Lookup.in should allow teleporting from a lookup class in a named module without dropping all access

2019-07-05 Thread Peter Levart
8:24 AM, Peter Levart wrote: Hi Mandy, On 7/2/19 7:20 PM, Mandy Chung wrote: Webrev updated: http://cr.openjdk.java.net/~mchung/jdk14/8173978/webrev.01/ I just skimmed across code and I think there's a little optimization possible in VerifyAccess:  : ...instead of seting prevLookupModu

Re: Review Request: JDK-8173978: Lookup.in should allow teleporting from a lookup class in a named module without dropping all access

2019-07-05 Thread Peter Levart
Hi Mandy, On 7/2/19 7:20 PM, Mandy Chung wrote: Webrev updated: http://cr.openjdk.java.net/~mchung/jdk14/8173978/webrev.01/ I just skimmed across code and I think there's a little optimization possible in VerifyAccess:  224 // cross-module access  225 // 1. refc is i

Re: [PATCH] Use StringJoiner where appropriate in java.base

2019-06-21 Thread Peter Levart
On 6/21/19 9:41 AM, Andrew Haley wrote: On 6/20/19 9:31 PM, Peter Levart wrote: I would also add overflow checks when computing the length of resulting byte[]. First I would pre-check the length of passed in int[] array (it must be less than Integer.MAX_VALUE / 3), then checking for

Re: [PATCH] Use StringJoiner where appropriate in java.base

2019-06-20 Thread Peter Levart
On 6/20/19 2:39 PM, Kasper Nielsen wrote: If you allowed a two-time pass of the primitive array you could actually create a version that only allocated the actual String and backing array. I tried implementing it https://gist.github.com/kaspernielsen/62e4eedffdb395228777925551a45e7f And got a

Re: [PATCH] Use StringJoiner where appropriate in java.base

2019-06-20 Thread Peter Levart
Hi, On 6/20/19 10:50 AM, Kasper Nielsen wrote: Hi, On Wed, 19 Jun 2019 at 14:12, Сергей Цыпанов wrote: Hello, in JDK code base we have many places (mainly in j.u.Arrays) where we convert array to String using verbose constructions with StringBuilder. As far as we have got StringJoiner for

Re: EnumSet.class serialization broken - twice

2019-06-18 Thread Peter Levart
quirement simply be relaxed with no ill consequences? Regards, Peter On Tue, Jun 18, 2019 at 5:32 AM Peter Levart <mailto:peter.lev...@gmail.com>> wrote: Hi, I recently stumbled on an exception thrown when deserializing stream produced on JDK 8 and read with JDK 11. I

EnumSet.class serialization broken - twice

2019-06-18 Thread Peter Levart
Hi, I recently stumbled on an exception thrown when deserializing stream produced on JDK 8 and read with JDK 11. I narrowed the problem down to serialization/deserialization of a public EnumSet.class object. There were several changes made to EnumSet in the Mercurial history of jdk repo, but

Re: RFR 8220238 : Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement

2019-06-02 Thread Peter Levart
On 5/31/19 7:24 PM, Roger Riggs wrote: Hi Martin, True, calling System.gc() and then checking for its hoped-for/expected side-effects is the norm. But its robustness depends on a combination of gc implementation behavior and the particular side-effect expected: allocation, reference processi

Re: RFR 8220238 : Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement

2019-05-30 Thread Peter Levart
Yes Roger, this sounds better to me. Maybe even easier: "There is no guarantee that this effort will recycle any particular number of unused objects, reclaim any particular amount of space, or complete before the method returns (or ever)." So, hypothetically, the effort triggered by System.g

Re: RFR 8220238 : Enhancing j.l.Runtime/System::gc specification with an explicit 'no guarantee' statement

2019-05-29 Thread Peter Levart
Hi, On 5/29/19 9:25 PM, Roger Riggs wrote: Any other comments on: "* Runs the garbage collector in the Java Virtual Machine. * * Calling this method suggests that the Java Virtual Machine * expend effort toward recycling unused objects in order to * make the memory they currently occupy availab

Re: RFR (M): JDK-6394757: rev1: AbstractSet.removeAll semantics are surprisingly dependent on relative sizes

2019-05-27 Thread Peter Levart
On 5/26/19 6:25 PM, Martin Buchholz wrote: On Mon, May 13, 2019 at 5:29 PM Stuart Marks wrote: - addition of FIXME comment and reference to javadoc bug report, where doc comment from interface cannot be inherited This is yet another symptom of Java's fundamental design mistake of being

Re: RFR - JDK-8223775 String::stripIndent (Preview)

2019-05-23 Thread Peter Levart
Hi, Excuse me for asking, but I can't find any text describing motivation for introduction of this method in JEP-355 other than "Developers will have access to this algorithm via String::stripIndent instance method"... If I understand the JEP correctly, this is an algorithm that is applied t

Re: RFR 8223593 : Refactor code for reallocating storage

2019-05-20 Thread Peter Levart
On 5/20/19 11:11 AM, Ivan Gerasimov wrote: Hi Peter! On 5/19/19 11:17 PM, Peter Levart wrote: Hi Ivan, Roger, What about "calcNewLength" ? The word "new" gives enough hint as to what the method does - it calculates the length of new array to be allocated instead o

Re: RFR 8223593 : Refactor code for reallocating storage

2019-05-19 Thread Peter Levart
Hi Ivan, Roger, What about "calcNewLength" ? The word "new" gives enough hint as to what the method does - it calculates the length of new array to be allocated instead of old one. Regards, Peter On 5/17/19 8:45 PM, Ivan Gerasimov wrote: Hi Roger! I think that not only the name, but also t

Re: RFR (M): JDK-6394757: rev1: AbstractSet.removeAll semantics are surprisingly dependent on relative sizes

2019-05-16 Thread Peter Levart
Hi Alan, I can sympathize with the performance loss aspect of this patch, but I nevertheless think it is a move in the right direction. You must admit that the performance optimization of AbstractSet.removeAll was a rather shaky one (dependent on the relative sizes of the two collections) and

Re: RFR 8223593 : Refactor code for reallocating storage

2019-05-10 Thread Peter Levart
Hi Ivan, On 5/9/19 8:07 PM, Ivan Gerasimov wrote: 3. I know that this is not new and has been copied from the old code. However, I'm not sure I understand the meaning of "unless necessary" here: /**   * The maximum size of array to allocate (unless necessary). It means that if the min

Re: RFR 8222955 : Optimize String.replace(CharSequence, CharSequence) for Latin1 encoded strings

2019-04-30 Thread Peter Levart
On 4/30/19 6:43 AM, Ivan Gerasimov wrote: I used StringConcatHelper.newArray() to avoid bringing Unsafe into StringLatin1. In the StringLatin1.replace(), the newly allocated array is guaranteed to be filled up, and the filling code should never throw, so I believe using uninitialized arrays

Re: RFR: 8222852: Reduce String concat combinator tree shapes by folding constants into prependers

2019-04-28 Thread Peter Levart
Hi Claes, On 4/28/19 8:24 PM, Peter Levart wrote: Hi Claes, If you had just one prepend method shape:   static long prepend(long indexCoder, byte[] buf, String prefix, long value, String suffix) {   if (suffix != null) indexCoder = prepend(indexCoder, buf, suffix

Re: RFR: 8222852: Reduce String concat combinator tree shapes by folding constants into prependers

2019-04-28 Thread Peter Levart
/Claes On 2019-04-26 15:55, Claes Redestad wrote: Hi Peter, thanks for looking at this! On 2019-04-26 11:08, Peter Levart wrote: Hi Claes, I wonder if it is even possible to create a test that would do something like the following: String s = ... String s2 = s + "const1&qu

Re: RFR: 8222852: Reduce String concat combinator tree shapes by folding constants into prependers

2019-04-26 Thread Peter Levart
On 4/26/19 11:08 AM, Peter Levart wrote: I wonder if it is even possible to create a test that would do something like the following:     String s = ...     String s2 = s + "const1" + "const2" + s; ...since javac concatenates consecutive constants into a singl

Re: RFR: 8222852: Reduce String concat combinator tree shapes by folding constants into prependers

2019-04-26 Thread Peter Levart
Hi Claes, I wonder if it is even possible to create a test that would do something like the following:     String s = ...     String s2 = s + "const1" + "const2" + s; ...since javac concatenates consecutive constants into a single constant. So this actually becomes:     String

Re: ZipFileSystem performance regression

2019-04-17 Thread Peter Levart
Just a thought... Would it be feasible to create a brand new "Generic Caching Filesystem" implementation that would delegate to another filesystem for persistent storage (be it ZipFilesystem or any other) and implement interesting caching strategies (lazy flushing, concurrent flushing, etc...)

Re: RFR: 8221836: Avoid recalculating String.hash when zero

2019-04-09 Thread Peter Levart
On 4/9/19 10:42 AM, Claes Redestad wrote: Hi Andrew, On 2019-04-09 10:20, Andrew Dinn wrote: If the patch is to go in -- and I concede there is an acceptable argument for that -- then it needs commenting to help avoid this happening. open.02 already adds what I believed to be sufficient c

Re: RFR: 8221836: Avoid recalculating String.hash when zero

2019-04-09 Thread Peter Levart
Hi Aleksey, On 4/9/19 10:11 AM, Aleksey Shipilev wrote: 2. No risk of hashcode recomputation for the 2^-32 case. This might seem laughable, until you remember that it's exactly those cases that DOS attackers like to create. Alt-hashing covers this obscure case in the course of mitigating much

Re: RFR: 8221836: Avoid recalculating String.hash when zero

2019-04-08 Thread Peter Levart
On 4/8/19 1:40 PM, Aleksey Shipilev wrote: On 4/8/19 1:28 PM, Peter Levart wrote: The reasoning is very similar as with just one field. With one field (hash) the thread sees either the default value (0) or a non-zero value calculated either by this thread sometime before or by a concurrent

Re: RFR: 8221836: Avoid recalculating String.hash when zero

2019-04-08 Thread Peter Levart
On 4/8/19 12:28 PM, Aleksey Shipilev wrote: However, you also said in your opening criticism "I had hard time convincing myself that code is concurrency-safe" I think that is a more telling complaint. Can you elaborate on why you found it hard to convince yourself of this? (I know what I

Re: RFR: 8221836: Avoid recalculating String.hash when zero

2019-04-08 Thread Peter Levart
: by adding a bit to String that is true iff String.hash has been calculated as being 0, we can get rid of the corner case where such hash codes are recalculated on every call. Peter Levart came up with a elegant scheme for ensuring that we can keep using non-volatile stores without explicit fe

Re: RFR: 8221477: Inject os/cpu-specific constants into Unsafe from JVM

2019-04-05 Thread Peter Levart
On 4/5/19 10:48 AM, Andrew Dinn wrote: Hi Peter, Regarding the static initializer ... there is an explanatory implNote explaining the rationale for the static block in the class javadoc at the top of the file. I agree this could be improved by explaining that the block is executed and then it

Re: RFR: 8221477: Inject os/cpu-specific constants into Unsafe from JVM

2019-04-05 Thread Peter Levart
Hi Andrew, For a casual reader (like me) the comments in the UnsafeConstants for each field:   69  * @implNote   70  * The actual value for this field is injected by the JVM. ...make one wonder what is actually going on regarding the static initializer at the end of the class. Is it

Re: RFR: 8221924: get(null) on single-entry unmodifiable Map returns null instead of throwing NPE

2019-04-05 Thread Peter Levart
Map1.get() should be much faster with this patch too, right? Peter On 4/4/19 11:11 PM, Stuart Marks wrote: Hi all, An unmodifiable map with one entry doesn't throw NPE from get(null). Instead, it returns null. This makes it quite an outlier: Map.of().get(null) ==> NPE Map.of().containsKey(n

Re: RFR: 8221723: Avoid storing zero to String.hash

2019-04-02 Thread Peter Levart
Hi Claes, I also think that the variant shown below should be compatible with existing VM code that "injects" hash value. No changes necessary, right? Peter On 4/2/19 12:53 PM, Peter Levart wrote: Hi Claes, On 4/2/19 10:29 AM, Claes Redestad wrote: Hi Peter, On 2019-04-01 23

Re: RFR: 8221723: Avoid storing zero to String.hash

2019-04-02 Thread Peter Levart
Hi Claes, On 4/2/19 10:29 AM, Claes Redestad wrote: Hi Peter, On 2019-04-01 23:54, Peter Levart wrote: In addition, this might not be easy from another point of view. You all know that there's no synchronization performed when caching the hash value. This works, because 32 bits are a

Re: RFR: 8221723: Avoid storing zero to String.hash

2019-04-01 Thread Peter Levart
On 4/1/19 10:44 PM, Claes Redestad wrote: We actually looked at this idea earlier today, and squeezing a "not- computed" value into String might be "free" since there seems to be a padding gap on all VM varieties (at least according to JOL estimates[1]) That'd be a larger endeavor, though, sin

Re: RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.

2019-03-29 Thread Peter Levart
On 3/29/19 4:36 PM, Peter Levart wrote: On 3/29/19 8:49 AM, Lindenmaier, Goetz wrote: So I want to withdraw my claim that NPEs are thrown frequently. Probably I was biased by my compiler construction background, remembering NPE checks are all over the place in the code. But I think I can

Re: RFR(L): 8218628: Add detailed message to NullPointerException describing what is null.

2019-03-29 Thread Peter Levart
On 3/29/19 8:49 AM, Lindenmaier, Goetz wrote: So I want to withdraw my claim that NPEs are thrown frequently. Probably I was biased by my compiler construction background, remembering NPE checks are all over the place in the code. But I think I can still keep the claim that the message is pri

Re: Review Request: 8221530: Caller sensitive methods not handling caller = null when invoked by JNI code with no java frames on stack

2019-03-28 Thread Peter Levart
On 3/28/19 4:46 PM, Peter Levart wrote: Reflection.verifyMemberAccess() is called not only from AccessibleObject.slowVerifyAccess() but from elsewhere too. For example, from ReflectUtil.ensureMemberAccess which is used in @CS AtomicXxxFieldUpdater(s), or from @CS

Re: Review Request: 8221530: Caller sensitive methods not handling caller = null when invoked by JNI code with no java frames on stack

2019-03-28 Thread Peter Levart
On 3/28/19 4:08 PM, Alan Bateman wrote: On 28/03/2019 14:48, Peter Levart wrote: : In addition, if access from null caller is granted and it is performed to a member in a "concealed" package, there's no warning displayed The proposed check is that the package is exported

Re: Review Request: 8221530: Caller sensitive methods not handling caller = null when invoked by JNI code with no java frames on stack

2019-03-28 Thread Peter Levart
On 3/28/19 3:48 PM, Peter Levart wrote: In addition, if access from null caller is granted and it is performed to a member in a "concealed" package, there's no warning displayed (the further logic in the AccessibleObject is skipped). What would it look like if Accessible

Re: Review Request: 8221530: Caller sensitive methods not handling caller = null when invoked by JNI code with no java frames on stack

2019-03-28 Thread Peter Levart
Hi, On 3/28/19 9:40 AM, Alan Bateman wrote: On 27/03/2019 23:17, Mandy Chung wrote: : The proposed fix is to perform proper access check.  When there is no caller frame, it only allows to access to public members of a public type in an unconditional exported API package. The approach seems

Re: RFR: 8221473: Configuration::reads can use Set.copyOf

2019-03-27 Thread Peter Levart
Hi, On 3/26/19 7:44 PM, Daniel Fuchs wrote: Hi Peter, On 26/03/2019 18:01, Peter Levart wrote: Would such method addition be worth it? Here is the impl of Set.copyOf:     static Set copyOf(Collection coll) {     if (coll instanceof ImmutableCollections.AbstractImmutableSet

Re: RFR: 8221473: Configuration::reads can use Set.copyOf

2019-03-26 Thread Peter Levart
Hi, This change is OK, but I was thinking that in general, for cases like this one, it would be better to check that the Set obtained from the 'graph' Map is already immutable and throw an exception if that is not the case. Like Objects.requireNonNull method, there could be a similar static m

Re: ClassCastException: cannot assign SerializedLambda to field with ClassLoader

2019-03-26 Thread Peter Levart
Hi, I think that Seth's case is a general problem with serialization of circular graph(s) with classes containing readResolve() method(s). The issue is being described here in full: https://bugs.openjdk.java.net/browse/JDK-6785441 In short: readResolve() method is specified to be invoked aft

Re: ClassCastException: cannot assign SerializedLambda to field with ClassLoader

2019-03-26 Thread Peter Levart
eckObjFieldValueTypes(ObjectStreamClass.java:1407)     at java.base/java.io.ObjectInputStream.defaultCheckFieldValues(ObjectInputStream.java:2371)     at java.base/java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:2278)     ... which suggests that my claims are correct... Peter On 3/26/

Re: ClassCastException: cannot assign SerializedLambda to field with ClassLoader

2019-03-26 Thread Peter Levart
Hi Seth, I think you stumbled on a "defect" of Java Serialization mechanism. Namely, the inability for it to correctly deserialize object graphs containing a cycle when an object in such cycle uses the "readResolve()" special method to replace the deserialized object with a replacement object

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-21 Thread Peter Levart
On 3/21/19 2:17 PM, fo...@univ-mlv.fr wrote: for some reason i was convinced that IntStream.iterator() was returning a PrimitiveIterator.OfInt and not an Iterator, so yes, it will work but i don't understand why it's not BaseStream instead of Stream that inherits from Iterable. I think it'

Re: [PATCH] Some improvements for java.lang.Class

2019-03-20 Thread Peter Levart
Hi Sergei, I don't know if you are aware that the new invokedynamic based translation of string concatenation expressions introduced in JDK 9 (http://openjdk.java.net/jeps/280) only applies to code outside java.base module. java.base module is still compiled with old-style StringBuilder based

Re: I don't understand why we need IterableOnce ? Was: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-18 Thread Peter Levart
On 3/15/19 10:07 AM, Ivan Gerasimov wrote: On 3/15/19 1:51 AM, Peter Levart wrote: On 3/15/19 9:38 AM, Ivan Gerasimov wrote: Hi Peter! On 3/15/19 1:24 AM, Peter Levart wrote: On 3/15/19 9:03 AM, fo...@univ-mlv.fr wrote:   * @since 13   */ interface Once {} What do

Re: RFR: 8214712: Archive Attributes$Name.KNOWN_NAMES

2019-03-15 Thread Peter Levart
what you'd typically get if you signed a JAR file today. /Claes On 2019-03-15 17:07, Peter Levart wrote: Hi Claes, If you have observed memory churn allocating Name objects when reading jar files, then perhaps we could do something to the logic of Attributes class so that lazily alloca

Re: RFR: 8214712: Archive Attributes$Name.KNOWN_NAMES

2019-03-15 Thread Peter Levart
Hi Claes, If you have observed memory churn allocating Name objects when reading jar files, then perhaps we could do something to the logic of Attributes class so that lazily allocated Name(s) would get interned too? As a separate change of course. This looks good as is. Regards, Peter On 3

Re: I don't understand why we need IterableOnce ? Was: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-15 Thread Peter Levart
On 3/15/19 9:38 AM, Ivan Gerasimov wrote: Hi Peter! On 3/15/19 1:24 AM, Peter Levart wrote: On 3/15/19 9:03 AM, fo...@univ-mlv.fr wrote:   * @since 13   */ interface Once {} What do you think of that? It's not clear to me if an annotation, available at runtime, is n

Re: I don't understand why we need IterableOnce ? Was: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-15 Thread Peter Levart
On 3/15/19 9:24 AM, Peter Levart wrote: On 3/15/19 9:03 AM, fo...@univ-mlv.fr wrote: * @since 13 */     interface Once {} What do you think of that? It's not clear to me if an annotation, available at runtime, is not a better fit. Anyway, i'm not sure not sure i

Re: I don't understand why we need IterableOnce ? Was: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-15 Thread Peter Levart
On 3/15/19 9:03 AM, fo...@univ-mlv.fr wrote: * @since 13 */     interface Once {} What do you think of that? It's not clear to me if an annotation, available at runtime, is not a better fit. Anyway, i'm not sure not sure introducing such interface/annotation worth its mainten

Re: I don't understand why we need IterableOnce ? Was: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-15 Thread Peter Levart
Hi, On 3/14/19 9:51 PM, Remi Forax wrote: yes, i think i prefer this solution, one Iterable to rule them all. First, it's not in the spirit of the Collection API to multiply the interfaces, by example, we have only one kind of Iterator and not an Iterator and a ReadOnlyIterator even if a lot

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-15 Thread Peter Levart
On 3/15/19 12:16 AM, Stephen Colebourne wrote: On Thu, 14 Mar 2019 at 19:45, Brian Goetz wrote: Why not make `Iterator` implement `IterableOnce`? The default method would obviously just return `this`. Such a default would not conform to the contract, as IO requires that subsequent calls th

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-14 Thread Peter Levart
Now that Brian put it so nicely, I'm convinced and I'd like to draw back and support this proposal as is... On 3/14/19 3:50 PM, Stephen Colebourne wrote: On Thu, 14 Mar 2019 at 14:21, Brian Goetz wrote: There's a reason it took as long as it did for Stuart to come up with this proposal; all t

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-14 Thread Peter Levart
Hi Stuart, The Alternatives section of the proposal is very thorough and it mentions the following alternative: "     An alternative adapter is to add a default method to Stream:     default Iterable asIterable() { return this::iterator; }     for (T t : asIterable(stream)) {         ...    

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-12 Thread Peter Levart
ent of "have you thought about extensively>".) On 3/6/2019 10:50 AM, Peter Levart wrote: In this respect Iterable should be a subtype of IterableOnce and foreach loop should be retrofitted to work with IterableOnce.

Re: Proposal: JDK-8148917 Enhanced-For Statement Should Allow Streams

2019-03-12 Thread Peter Levart
Hi John, On 3/12/19 12:07 AM, John Rose wrote: public static void main(String[] args) { for(int i : range(0, 100)) { System.out.println(i); } } It correctly compiles and prints numbers from 0 to 99. As IntStream extends BaseStream and BaseStream> defines Iterator iterator(), it would be

Re: JDK 13 RFR of JDK-8220346: Refactor java.lang.Throwable to use Objects.requireNonNull

2019-03-12 Thread Peter Levart
Hi, On 3/11/19 5:29 PM, Joe Darcy wrote: Hello, Always surprising how much discussion an (apparently) simple refactoring can generate! Thanks to Tagir for spotting this issue. For completeness, the two-argument forms of requireNonNull which takes a Supplier is not applicable to preserve th

java.lang.CharSequence#compare - lexicographical ordering of custom Comparable CharSequence(s)

2019-03-11 Thread Peter Levart
Hello, I stumbled on the specification of a static utility method CharSequence#compare introduced in Java 11 which says: * Compares two {@code CharSequence} instances lexicographically. Returns a * negative value, zero, or a positive value if the first sequence is lexicographically

Re: JDK 13 RFR of JDK-8220346: Refactor java.lang.Throwable to use Objects.requireNonNull

2019-03-11 Thread Peter Levart
On 3/10/19 9:19 PM, Martin Buchholz wrote: We should stop discussing this here, but ... ... I think that we really should, but ... On Sun, Mar 10, 2019 at 1:51 AM Peter Levart <mailto:peter.lev...@gmail.com>> wrote: In this particular case, this is not true. A lambda that

<    1   2   3   4   5   6   7   8   9   10   >