Re: Very fast List/Deque to java.util?

2022-06-11 Thread Rob Spoor
I'd like to point out that rodde has also asked this project to be included in Apache Commons Collections: https://lists.apache.org/thread/klwtkbz96rp9zfr1077sc9r8tjtthfl4 On 11/06/2022 15:53, - wrote: Hello, What do you think? First, for your benchmarks, I recommend you write them with

Re: RFR: 8287442: Reduce list to array conversions in java.lang.invoke.MethodHandles

2022-05-27 Thread Rob Spoor
On Fri, 27 May 2022 14:18:19 GMT, Claes Redestad wrote: > In preparation of #8855 this PR refactors the conversions from `List` to > array and array to `List`, reducing the number of conversions when calling > `MethodHandles.dropArguments` in particular. This remove about ~5% of > allocations

Re: Type narrowing security leak

2021-12-30 Thread Rob Spoor
value: 1100_1000. On 30/12/2021 13:13, Fabrice Tiercelin wrote: Hi, Le mercredi 29 décembre 2021, 11:35:12 UTC+1, Rob Spoor a écrit : An example is reading input streams byte-by-byte: the result is an int between 0 and > 255 (inclusive), or -1 for EOF. If the result is not -1, the res

Re: Type narrowing security leak

2021-12-29 Thread Rob Spoor
This isn't a security leak in Java (because that would mean it would be a security leak in any language that supports narrowing). This is a security leak in the application that does the narrowing. Developers should be aware that narrowing can change values. And furthermore, I don't think

Re: Adding an @Immutable annotation to Java

2021-11-26 Thread Rob Spoor
If this is really something that's desired, then why use an annotation when there's a keyword already available: const. However, there's a reason that's never been actually used in Java, and that's because it's so hard to get right. On 26/11/2021 00:11, Alan Snyder wrote: I like the idea of

Feature request: custom default annotation attributes

2021-11-21 Thread Rob Spoor
Hi all, I've been writing a few annotations lately that have one required attribute and some optional ones. That leaves me with three options: 1) Use value() for the required attribute. That becomes ugly when the optional attributes are given though. 2) Make developers write the attribute

Re: TreeMap in JDK15 deviates from spec

2021-01-11 Thread Rob Spoor
This is a regression, because Java 11 shows "default" twice for the TreeMap, whereas Java 15 shows "null" twice. On 11/01/2021 19:05, Phil Smith wrote: Hello, I submitted bug report 9068554 recently, but I consider this a pretty big issue and I'd like for this not to get lost in triage. With

Re: [BUG] InputStream.readNBytes doesn't correctly check for EOF

2020-12-21 Thread Rob Spoor
On 20/12/2020 19:15, Philippe Marschall wrote: On 20.12.20 18:47, Rob Spoor wrote: ... That "> 0" is incorrect here; it's allowed to return 0 before EOF I don't think the method is allowed to return 0 before EOF. To quote from the method Javadoc. > This method blocks

[BUG] InputStream.readNBytes doesn't correctly check for EOF

2020-12-20 Thread Rob Spoor
According to the documentation of InputStream.readNBytes: Reads up to a specified number of bytes from the input stream. This method blocks until the requested number of bytes have been read, end of stream is detected, or an exception is thrown. This method does not close the input

Feature Request: CharSequence.getChars

2020-11-13 Thread Rob Spoor
Hi all, In Java 9, compact strings were added. Ever since, I've been trying to use getChars instead of charAt for Strings. However, I prefer to also do the same for StringBuilder and StringBuffer. This can lead to some special cases. For instance, in Apache Commons I/O:

Re: Asking to contribute(?)

2020-11-13 Thread Rob Spoor
know what the community thinks about it. Regards, Justin Dekeyser On Wednesday, November 4, 2020, Rob Spoor wrote: On 04/11/2020 14:18, Justin Dekeyser wrote: Hello everyone, I have been following this mailing list for several months, and earlier today my attention was draw

Re: Asking to contribute(?)

2020-11-04 Thread Rob Spoor
On 04/11/2020 14:18, Justin Dekeyser wrote: Hello everyone, I have been following this mailing list for several months, and earlier today my attention was drawn to https://bugs.openjdk.java.net/browse/JDK-8140283. Actually I've been dreaming of such a feature for a long time now. I would

Re: [BUG] Java 15: DecimalFormatSymbols overrides equals but not hashCode

2020-09-15 Thread Rob Spoor
On 15/09/2020 22:02, Pavel Rappo wrote: On 15 Sep 2020, at 20:50, Brian Burkhalter wrote: On Sep 15, 2020, at 12:38 PM, Kevin Rushforth wrote: I see this in DecimalFormatSymbols: /** * Override hashCode. */ private volatile int hashCode; @Override public

Re: [BUG] Java 15: DecimalFormatSymbols overrides equals but not hashCode

2020-09-15 Thread Rob Spoor
/java.base/java/text/DecimalFormatSymbols.html On Sep 15, 2020, at 12:14 PM, Rob Spoor wrote: In Java 14 and before, DecimalFormatSymbols had overrides for both equals and hashCode. In Java 15, the override for hashCode has disappeared, and it now inherits hashCode from java.lang.Object

[BUG] Java 15: DecimalFormatSymbols overrides equals but not hashCode

2020-09-15 Thread Rob Spoor
In Java 14 and before, DecimalFormatSymbols had overrides for both equals and hashCode. In Java 15, the override for hashCode has disappeared, and it now inherits hashCode from java.lang.Object. That means it now violates the contract for equals + hashCode: two equal DecimalFormatSymbols

Re: Feature Request

2020-07-21 Thread Rob Spoor
If you need something right now, you can try https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/StringSubstitutor.html. On 21/07/2020 09:29, Jessica wrote: Hi, I would like to strongly request Java have the ability to do string interpolation. It is

Re: [PATCH] 8245694 : java.util.Properties.entrySet() does not override java.lang.Object methods

2020-05-30 Thread Rob Spoor
There's still a little regression there since Java 8, if you add the keySet(), values() or entrySet() to the Properties object as either key or value; in Java 8 this would cause "(this Collection)" to be included, while even with this fix that would cause a StackOverflowError. However, given

Re: [BUG] java.util.Properties.entrySet() does not override java.lang.Object methods since Java 9

2020-05-23 Thread Rob Spoor
On 23/05/2020 21:13, Rob Spoor wrote: Hi, I was working on upgrading a library of mine from Java 8 to 11, and I noticed my unit tests started failing. Some investigation showed that in Java 9, java.util.Properties was rewritten to no longer rely on the fact that it extends Hashtable. One

[BUG] java.util.Properties.entrySet() does not override java.lang.Object methods since Java 9

2020-05-23 Thread Rob Spoor
Hi, I was working on upgrading a library of mine from Java 8 to 11, and I noticed my unit tests started failing. Some investigation showed that in Java 9, java.util.Properties was rewritten to no longer rely on the fact that it extends Hashtable. One of the changes was to use a private

Re: Question about String.toUpperCase behaviour

2019-10-29 Thread Rob Spoor
On 28/10/2019 21:34, Florian Weimer wrote: * Сергей Цыпанов: Hello, current implementation of e.g. String.toUpperCase() returns the object it was called on in case all code points are in upper case. E.g. this test @Test public void upperCase() { String str = "AZ";//

RFE: annotation for resource wrapper methods

2019-08-10 Thread Rob Spoor
Hi, When you wrap a resource (InputStream, etc) using a class constructor (e.g. new BufferedInputStream(...)), compilers usually don't complain. If you do the exact same thing using a utility method, compilers aren't that smart anymore. For instance, the following produces a warning that the

[BUG] Inet6Address.isIPv4CompatibleAddress uses wrong prefix

2019-06-24 Thread Rob Spoor
I found a bug in Inet6Adress.isIPv4CompatibleAddress(). While parsing correctly uses the ::: format, isIPv4CompatibleAddress() checks for :: instead. An example: Inet6Address address = (Inet6Address) InetAddress.getByName("::192.168.1.13"); System.out.printf("%s: %b%n", address,

Re: java.util.regex.Matcher and StringBuilder/StringBuffer APIs

2019-06-21 Thread Rob Spoor
Maybe because Appendable comes with IOExceptions? On 21/06/2019 17:06, Robert Marcano wrote: Greetings. Is there a reason the newest APIs added to Matcher (performance maybe?) with StringBuilder arguments weren't added as Appendable instead? For example:   public StringBuilder

Re: Proposal to enhance Stream.collect

2019-02-24 Thread Rob Spoor
If you already know the size and are not going to parallelize your stream, you can simply use Collectors.toCollection: Stream.of(1,2,3) .map(i -> i+1) .collect(Collectors.toCollection(() -> new ArrayList<>(3))); It could perhaps be a bit easier if Collectors.toList would be

Re: RFE: add missing methods to Optional, OptionalInt, OptionalLong and OptionalDouble

2019-02-20 Thread Rob Spoor
dditional API surface area here is negative.  But, we can surely have a discussion on this. On 2/16/2019 7:52 AM, Rob Spoor wrote: I noticed that, while Stream and its primitive equivalents have multiple map and flapMap methods, Optional and its primitive equivalents were missing those. Sin

RFE: add missing methods to Optional, OptionalInt, OptionalLong and OptionalDouble

2019-02-16 Thread Rob Spoor
I noticed that, while Stream and its primitive equivalents have multiple map and flapMap methods, Optional and its primitive equivalents were missing those. Since these can still be very useful, I wrote a patch to add the following methods: * Optional: mapToInt, mapToLong, mapToDouble,

Re: 8212620: Provide a mechansim to allow a class/method to request filtering from the stack trace

2019-01-11 Thread Rob Spoor
On 10/01/2019 22:59, Mandy Chung wrote: On 1/10/19 11:30 AM, Rob Spoor wrote: I had an idea that can possibly help solve three issues: * 8212620 Provide a mechansim to allow a class/method to request filtering from the stack trace This RFE is not just about stack trace format and a generic

8212620: Provide a mechansim to allow a class/method to request filtering from the stack trace

2019-01-10 Thread Rob Spoor
I had an idea that can possibly help solve three issues: * 8212620 Provide a mechansim to allow a class/method to request filtering from the stack trace * 8211152 Improve unclear and incomplete Exception stack trace * 6507809 "Caused by" notation for stack traces unnecessarily hard to read

Feature suggestion: Add support to Base64.Encoder and Base64.Decoder to wrap Writer / Reader

2019-01-08 Thread Rob Spoor
Java 8 added Base64 with its nested classes Encoder and Decoder. These both have methods to wrap an OutputStream / InputStream respectively. However, base64 is text; the alphabets exist out of ASCII characters only. This is (somewhat) acknowledged by the presence of the encodeToString(byte[])