Re: RFR: 8244146: javac changes for JEP 306

2021-05-04 Thread Srikanth Adayapalam
On Sat, 1 May 2021 23:00:05 GMT, Joe Darcy  wrote:

> 8244146: javac changes for JEP 306

src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties
 line 1769:

> 1767: compiler.warn.strictfp=\
> 1768: as of release 17, all floating-point expressions are evaluated 
> strictly and ''strictfp'' is not required
> 1769: 

Nitpick: Three other uses of floating point in the same file use the 
non-hyphenated form.

-

PR: https://git.openjdk.java.net/jdk/pull/3831


Re: RFR: 8244146: javac changes for JEP 306

2021-05-04 Thread Srikanth Adayapalam
On Sat, 1 May 2021 23:00:05 GMT, Joe Darcy  wrote:

> 8244146: javac changes for JEP 306

src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java line 
1704:

> 1702: if (Feature.REDUNDANT_STRICTFP.allowedInSource(source))
> 1703: result = result & ~STRICTFP;
> 1704: 

Nitpick: Doing in Rome as ... would mean this is better written as 

result &= ~STRICTFP;

to be in harmony with the code in the vicinity

Also I am OK with the feature-allowed-in-source-check, but wonder if it is an 
overkill for smaller focussed changes like this one. I will say I don't know 
what is the standard operating procedure. See that elsewhere in Lint.java you 
are doing 

if (source.compareTo(Source.JDK17) >= 0) {
values.add(LintCategory.STRICTFP);
}

-

PR: https://git.openjdk.java.net/jdk/pull/3831


Re: [External] : Re: ReversibleCollection proposal

2021-05-04 Thread Stuart Marks




On 5/1/21 5:57 AM, fo...@univ-mlv.fr wrote:

I suppose the performance issue comes from the fact that traversing a 
LinkedHahSet is slow because it's a linked list ?

You can replace a LinkedHashSet by a List + Set, the List keeps the values in 
order, the Set avoids duplicates.

Using a Stream, it becomes
   Stream.of(getItemsFromSomeplace(), getItemsFromAnotherPlace(), 
getItemsFromSomeplaceElse())
.flatMap(List::stream)
.distinct()  // use a Set internally
.collect(toList());


The problem with any example is that simplifying assumptions are necessary for 
showing the example, but those assumptions enable it to be easily picked apart. Of 
course, the example isn't just a particular example; it is a *template* for a whole 
space of possible examples. Consider the possibility that the items processing 
client needs to do some intermediate processing on the first group of items before 
adding the other groups. This might not be possible to do using streams. Use your 
imagination.



I think there are maybe some scenarios where ReversibleCollection can be 
useful, but they are rare, to the point where when there is a good scenario for 
it people will not recognize it because ReversibleCollection will not be part 
of their muscle memory.


I'm certain that uses of RC/RS will be rare in the beginning, because they will be 
new, and people won't be familar with them. And then there will the people who say 
"I can't use them because I'm stuck on JDK 11 / 8 / 7 / 6 " It was the same 
thing with lambdas and streams in Java 8, with List.of() etc in Java 9, records in 
Java 16, etc. This wan't an argument not to add them, and it isn't an argument not 
to add RC/RS.


There is a real value to add methods like descendingSet/descendingList()/getFirst/getLast on existing collections, but we don't need a new interface (or two) for that. 


It depends on what you mean by "need". Sure, we could get away without this; after 
all, we've survived the past twenty years without it, so we could probably survive 
the next twenty years as well.


It would indeed be useful to add various methods to List, Deque, SortedSet, and 
LinkedHashSet to provide a full set of methods on all of them. And it would also be 
nice to have those methods be similar to one another. An interface helps with that, 
but I agree, that's not really the reason to have an interface though.


The reversed-view concept could also be added individually to the different places. 
A reverse-ordered List is a List, a reverse-ordered Deque is a Deque, a 
reverse-ordered SortedSet is a SortedSet, and a reverse-ordered LinkedHashSet is a 
... ? And what is the type of the keySet of a LinkedHashMap, that enables one to 
(say) get the last element?


After working with a system like this for a while, it begins to emerge that there is 
an abstraction missing from the collections framework, something like an "ordered 
collection". People have been missing this for quite a long time. The most recent 
example (which this proposal builds on) is Tagir's proposal from a year ago. And 
it's been asked about several times before that. ReversibleCollection fills in that 
missing abstraction.


s'marks


Integrated: 8266179: [macos] jpackage should specify architecture for produced pkg files

2021-05-04 Thread Alexander Matveev
On Fri, 30 Apr 2021 04:22:37 GMT, Alexander Matveev  
wrote:

> jpackage should specify architecture for produced PKG files via 
> hostArchitectures="x86_x64 or arm64". aarch64 installer will be installable 
> on x64 without specifying hostArchitectures which is not correct and if 
> install on arm Mac it will request Rosetta 2. With proposed fix by setting 
> hostArchitectures="x86_x64" if installer contains x64 binaries, it will be 
> installable on x64 Mac and will require Rosetta 2 on arm Mac. 
> hostArchitectures will be set to arm64 if installer contain aarch64 binaries 
> and will gave error when run on x64 Mac and will be installable on arm Mac 
> without triggering installation of Rosetta 2.

This pull request has now been integrated.

Changeset: 2c53654b
Author:Alexander Matveev 
URL:   
https://git.openjdk.java.net/jdk/commit/2c53654bf1140c7cd243598ebdbff9ca4b9c54ba
Stats: 101 lines in 3 files changed: 100 ins; 0 del; 1 mod

8266179: [macos] jpackage should specify architecture for produced pkg files

Reviewed-by: herrick, kcr, asemenyuk

-

PR: https://git.openjdk.java.net/jdk/pull/3807


Re: [External] : Re: ReversibleCollection proposal

2021-05-04 Thread Stuart Marks
The line of discussion here was introduced by Remi, who was making an argument of 
the form "introducing a type cannot solve this particular problem, therefore, 
introducing a new type is not useful at all." I was providing an example of where 
the new type is useful as a method parameter. That's all.



Have you considered the alternative of a collection providing a Reversed view 
of itself, in the same sense that unmodifiable collections are views of an 
underlying collection?


The proposal does define ReversibleCollection::reversed as providing a reversed 
view, through which modifications to the underlying collection are visible, and to 
which modifications are written through to the underlying collection. Or are you 
talking about something different?


s'marks

On 4/30/21 4:15 PM, Alan Snyder wrote:

It sounds like the items processing maintainer would be looking for 
OrderedCollection and might or might not find ReversibleCollection. :-)

I suspect you would agree that OrderedCollection by itself is too weak to 
justify being a type. It’s basically Iterable with the extra bit that the 
iteration order is not an implementation artifact.

In this example, using the type system to detect a bug like the old bug seems 
like overkill. Even if the parameter were Ordered, it still might not be the 
*right* order. The maintainer of the client code needs to understand that.

Suppose the items processor wants to require that the parameter collection not 
contain duplicates. Would you suggest adding a type for that? Clearly Set would 
be just as unnecessarily restrictive as List was for ordering. Absurdity 
approaches…

The issue of Reversible remains, above and beyond Ordered. Have you considered 
the alternative of a collection providing a Reversed view of itself, in the 
same sense that unmodifiable collections are views of an underlying collection?

   Alan




On Apr 30, 2021, at 3:42 PM, Stuart Marks  wrote:

Consider the case of a large application or other system, one that's large 
enough to have lots of internal APIs, but that is built as a single unit, so 
release-to-release compatibility isn't an issue. Suppose there is some method

processItemsInOrder(List items)

that has to process items in the order in which they occur, because processing 
of later items might depend the processing of earlier ones. The maintainer of 
this API chose to accept a List as a parameter, because it's a common interface 
and it's clearly an ordered collection.

Now consider a client that gets items from different places, keeping them in 
order, but removing duplicates. It might do something like this:

var items = new LinkedHashSet();
items.addAll(getItemsFromSomeplace());
items.addAll(getItemsFromAnotherPlace());
items.addAll(getItemsFromSomeplaceElse());
processItemsInOrder(new ArrayList<>(items));

It turns out the copying of the items into an ArrayList is a performance 
bottleneck, so the maintainer of the client code asks the maintainer of the 
items processing code to change the API to accept Collection instead.

The items processing maintainer demurs, recalling that the API *did* accept 
Collection in the past, and a bug where somebody accidentally passed a HashSet 
resulted in a customer escalation because of item processing irregularities. In 
the aftermath of that escalation, the API was changed to List. The client 
maintainer reluctantly pursues alternatives for generating a deduplicated List.

But wait! Those Java guys added a ReversibleCollection interface in Java N. It 
has the desired property of being ordered, and conveniently it's a supertype of 
both List and LinkedHashSet. The items processing maintainer adjusts the API to 
consume ReversibleCollection, and the client maintainer removes the temporary 
ArrayList, and everybody is happy.

s'marks





Re: RFR: 8244146: javac changes for JEP 306

2021-05-04 Thread Joe Darcy
On Sat, 1 May 2021 23:00:05 GMT, Joe Darcy  wrote:

> 8244146: javac changes for JEP 306

For core-libs, under JEP 306 strictfp would be a no-op under 17. Therefore, the 
few uses of the strictfp modifier in the base module can be removed.

-

PR: https://git.openjdk.java.net/jdk/pull/3831


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 20:45:43 GMT, Lance Andersen  wrote:

> Hi all,
> 
> This fix addresses a change in TestNG behavior for the Before/AfterGroups 
> annotations that was introduced  via  
> https://github.com/cbeust/testng/pull/2167.   The tests have been verified 
> against the latest TestNG release and continue to run with the current TestNG 
> release used by jtreg

Marked as reviewed by bpb (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 22:49:22 GMT, Lance Andersen  wrote:

>> Ah. I was just thinking of consistency with other tests. Up to you.
>
> I think your milage will vary depending on the author and the IDE being used. 
>  My primary concern was to address the issue for the failing test and 
> Intellij arranged the imports as they are above.  I guess I am less concerned 
> about the imports as I think in some cases it comes to personal preference.
> 
> So I would prefer to leave as is if you are OK :-)

I think that's fine.

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Lance Andersen
On Tue, 4 May 2021 22:44:18 GMT, Brian Burkhalter  wrote:

>> That's IntelliJ magic.  I can update if you prefer and can let IntelliJ 
>> optimize all of the imports
>
> Ah. I was just thinking of consistency with other tests. Up to you.

I think your milage will vary depending on the author and the IDE being used.  
My primary concern was to address the issue for the failing test and Intellij 
arranged the imports as they are above.  I guess I am less concerned about the 
imports as I think in some cases it comes to personal preference.

So I would prefer to leave as is if you are OK :-)

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 22:42:57 GMT, Lance Andersen  wrote:

>> test/jdk/java/io/InputStream/NullInputStream.java line 33:
>> 
>>> 31: import java.io.InputStream;
>>> 32: 
>>> 33: import static org.testng.Assert.*;
>> 
>> Would it not be more standard to put the new imports just after this import? 
>> Same comment applies in the other files.
>
> That's IntelliJ magic.  I can update if you prefer and can let IntelliJ 
> optimize all of the imports

Ah. I was just thinking of consistency with other tests. Up to you.

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Lance Andersen
On Tue, 4 May 2021 22:36:29 GMT, Brian Burkhalter  wrote:

>> Hi all,
>> 
>> This fix addresses a change in TestNG behavior for the Before/AfterGroups 
>> annotations that was introduced  via  
>> https://github.com/cbeust/testng/pull/2167.   The tests have been verified 
>> against the latest TestNG release and continue to run with the current 
>> TestNG release used by jtreg
>
> test/jdk/java/io/InputStream/NullInputStream.java line 33:
> 
>> 31: import java.io.InputStream;
>> 32: 
>> 33: import static org.testng.Assert.*;
> 
> Would it not be more standard to put the new imports just after this import? 
> Same comment applies in the other files.

That's IntelliJ magic.  I can update if you prefer and can let IntelliJ 
optimize all of the imports

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 20:45:43 GMT, Lance Andersen  wrote:

> Hi all,
> 
> This fix addresses a change in TestNG behavior for the Before/AfterGroups 
> annotations that was introduced  via  
> https://github.com/cbeust/testng/pull/2167.   The tests have been verified 
> against the latest TestNG release and continue to run with the current TestNG 
> release used by jtreg

test/jdk/java/io/InputStream/NullInputStream.java line 33:

> 31: import java.io.InputStream;
> 32: 
> 33: import static org.testng.Assert.*;

Would it not be more standard to put the new imports just after this import? 
Same comment applies in the other files.

-

PR: https://git.openjdk.java.net/jdk/pull/3866


Re: RFR: 8265448: (zipfs): Reduce read contention in ZipFileSystem [v2]

2021-05-04 Thread Jason Zaugg
> If the given Path represents a file, use the overload of read defined
> in FileChannel that accepts an explicit position and avoid serializing
> reads.
> 
> Note: The underlying NIO implementation is not required to implement
> FileChannel.read(ByteBuffer, long) concurrently; Windows still appears
> to lock, as it returns true for NativeDispatcher.needsPositionLock.
> 
> 
> On MacOS X, the enclosed benchmark improves from:
> 
> 
> BenchmarkMode  Cnt   Score   Error  Units
> ZipFileSystemBenchmark.read  avgt   10  75.311 ? 3.301  ms/op
> 
> 
> To:
> 
> 
> BenchmarkMode  Cnt   Score   Error  Units
> ZipFileSystemBenchmark.read  avgt   10  12.520 ? 0.875  ms/op

Jason Zaugg has updated the pull request incrementally with one additional 
commit since the last revision:

  Use pattern matching instanceof

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3853/files
  - new: https://git.openjdk.java.net/jdk/pull/3853/files/b7b6f9a8..0859d2d6

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3853=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3853=00-01

  Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3853.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3853/head:pull/3853

PR: https://git.openjdk.java.net/jdk/pull/3853


Re: RFR: 8265783: Create a separate library for x86 Intel SVML assembly intrinsics [v2]

2021-05-04 Thread Sandhya Viswanathan
On Wed, 28 Apr 2021 21:11:26 GMT, Sandhya Viswanathan 
 wrote:

>> This PR contains Short Vector Math Library support related changes for 
>> [JEP-414 Vector API (Second Incubator)](https://openjdk.java.net/jeps/414), 
>> in preparation for when targeted.
>> 
>> Intel Short Vector Math Library (SVML) based intrinsics in native x86 
>> assembly provide optimized implementation for Vector API transcendental and 
>> trigonometric methods.
>> These methods are built into a separate library instead of being part of 
>> libjvm.so or jvm.dll.
>> 
>> The following changes are made:
>>The source for these methods is placed in the jdk.incubator.vector module 
>> under src/jdk.incubator.vector/linux/native/libsvml and 
>> src/jdk.incubator.vector/windows/native/libsvml.
>>The assembly source files are named as “*.S” and include files are named 
>> as “*.S.inc”.
>>The corresponding build script is placed at 
>> make/modules/jdk.incubator.vector/Lib.gmk.
>>Changes are made to build system to support dependency tracking for 
>> assembly files with includes.
>>The built native libraries (libsvml.so/svml.dll) are placed in bin 
>> directory of JDK on Windows and lib directory of JDK on Linux.
>>The C2 JIT uses the dll_load and dll_lookup to get the addresses of 
>> optimized methods from this library.
>> 
>> Build system changes and module library build scripts are contributed by 
>> Magnus (magnus.ihse.bur...@oracle.com).
>> 
>> Looking forward to your review and feedback.
>> 
>> Performance:
>> Micro benchmark Base Optimized Unit Gain(Optimized/Base)
>> Double128Vector.ACOS 45.91 87.34 ops/ms 1.90
>> Double128Vector.ASIN 45.06 92.36 ops/ms 2.05
>> Double128Vector.ATAN 19.92 118.36 ops/ms 5.94
>> Double128Vector.ATAN2 15.24 88.17 ops/ms 5.79
>> Double128Vector.CBRT 45.77 208.36 ops/ms 4.55
>> Double128Vector.COS 49.94 245.89 ops/ms 4.92
>> Double128Vector.COSH 26.91 126.00 ops/ms 4.68
>> Double128Vector.EXP 71.64 379.65 ops/ms 5.30
>> Double128Vector.EXPM1 35.95 150.37 ops/ms 4.18
>> Double128Vector.HYPOT 50.67 174.10 ops/ms 3.44
>> Double128Vector.LOG 61.95 279.84 ops/ms 4.52
>> Double128Vector.LOG10 59.34 239.05 ops/ms 4.03
>> Double128Vector.LOG1P 18.56 200.32 ops/ms 10.79
>> Double128Vector.SIN 49.36 240.79 ops/ms 4.88
>> Double128Vector.SINH 26.59 103.75 ops/ms 3.90
>> Double128Vector.TAN 41.05 152.39 ops/ms 3.71
>> Double128Vector.TANH 45.29 169.53 ops/ms 3.74
>> Double256Vector.ACOS 54.21 106.39 ops/ms 1.96
>> Double256Vector.ASIN 53.60 107.99 ops/ms 2.01
>> Double256Vector.ATAN 21.53 189.11 ops/ms 8.78
>> Double256Vector.ATAN2 16.67 140.76 ops/ms 8.44
>> Double256Vector.CBRT 56.45 397.13 ops/ms 7.04
>> Double256Vector.COS 58.26 389.77 ops/ms 6.69
>> Double256Vector.COSH 29.44 151.11 ops/ms 5.13
>> Double256Vector.EXP 86.67 564.68 ops/ms 6.52
>> Double256Vector.EXPM1 41.96 201.28 ops/ms 4.80
>> Double256Vector.HYPOT 66.18 305.74 ops/ms 4.62
>> Double256Vector.LOG 71.52 394.90 ops/ms 5.52
>> Double256Vector.LOG10 65.43 362.32 ops/ms 5.54
>> Double256Vector.LOG1P 19.99 300.88 ops/ms 15.05
>> Double256Vector.SIN 57.06 380.98 ops/ms 6.68
>> Double256Vector.SINH 29.40 117.37 ops/ms 3.99
>> Double256Vector.TAN 44.90 279.90 ops/ms 6.23
>> Double256Vector.TANH 54.08 274.71 ops/ms 5.08
>> Double512Vector.ACOS 55.65 687.54 ops/ms 12.35
>> Double512Vector.ASIN 57.31 777.72 ops/ms 13.57
>> Double512Vector.ATAN 21.42 729.21 ops/ms 34.04
>> Double512Vector.ATAN2 16.37 414.33 ops/ms 25.32
>> Double512Vector.CBRT 56.78 834.38 ops/ms 14.69
>> Double512Vector.COS 59.88 837.04 ops/ms 13.98
>> Double512Vector.COSH 30.34 172.76 ops/ms 5.70
>> Double512Vector.EXP 99.66 1608.12 ops/ms 16.14
>> Double512Vector.EXPM1 43.39 318.61 ops/ms 7.34
>> Double512Vector.HYPOT 73.87 1502.72 ops/ms 20.34
>> Double512Vector.LOG 74.84 996.00 ops/ms 13.31
>> Double512Vector.LOG10 71.12 1046.52 ops/ms 14.72
>> Double512Vector.LOG1P 19.75 776.87 ops/ms 39.34
>> Double512Vector.POW 37.42 384.13 ops/ms 10.26
>> Double512Vector.SIN 59.74 728.45 ops/ms 12.19
>> Double512Vector.SINH 29.47 143.38 ops/ms 4.87
>> Double512Vector.TAN 46.20 587.21 ops/ms 12.71
>> Double512Vector.TANH 57.36 495.42 ops/ms 8.64
>> Double64Vector.ACOS 24.04 73.67 ops/ms 3.06
>> Double64Vector.ASIN 23.78 75.11 ops/ms 3.16
>> Double64Vector.ATAN 14.14 62.81 ops/ms 4.44
>> Double64Vector.ATAN2 10.38 44.43 ops/ms 4.28
>> Double64Vector.CBRT 16.47 107.50 ops/ms 6.53
>> Double64Vector.COS 23.42 152.01 ops/ms 6.49
>> Double64Vector.COSH 17.34 113.34 ops/ms 6.54
>> Double64Vector.EXP 27.08 203.53 ops/ms 7.52
>> Double64Vector.EXPM1 18.77 96.73 ops/ms 5.15
>> Double64Vector.HYPOT 18.54 103.62 ops/ms 5.59
>> Double64Vector.LOG 26.75 142.63 ops/ms 5.33
>> Double64Vector.LOG10 25.85 139.71 ops/ms 5.40
>> Double64Vector.LOG1P 13.26 97.94 ops/ms 7.38
>> Double64Vector.SIN 23.28 146.91 ops/ms 6.31
>> Double64Vector.SINH 17.62 88.59 ops/ms 5.03
>> Double64Vector.TAN 21.00 86.43 ops/ms 4.12
>> Double64Vector.TANH 23.75 111.35 ops/ms 4.69
>> Float128Vector.ACOS 57.52 110.65 

RFR: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG

2021-05-04 Thread Lance Andersen
Hi all,

This fix addresses a change in TestNG behavior for the Before/AfterGroups 
annotations that was introduced  via  
https://github.com/cbeust/testng/pull/2167.   The tests have been verified 
against the latest TestNG release and continue to run with the current TestNG 
release used by jtreg

-

Commit messages:
 - remove trailing space
 - Updates for TestNG 7.4

Changes: https://git.openjdk.java.net/jdk/pull/3866/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3866=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8266460
  Stats: 122 lines in 4 files changed: 12 ins; 24 del; 86 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3866.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3866/head:pull/3866

PR: https://git.openjdk.java.net/jdk/pull/3866


Integrated: JDK-8266527 RandomTestCoverage.java failing due to API removal

2021-05-04 Thread Jim Laskey
On Tue, 4 May 2021 21:09:59 GMT, Jim Laskey  wrote:

> RandomTestCoverage.java was overlooked when doing local test. Apologies.

This pull request has now been integrated.

Changeset: f00b70e2
Author:Jim Laskey 
URL:   
https://git.openjdk.java.net/jdk/commit/f00b70e2caaa9c2bb49bb9eae49a29ffbbf87af8
Stats: 15 lines in 1 file changed: 5 ins; 0 del; 10 mod

8266527: RandomTestCoverage.java failing due to API removal

Reviewed-by: rriggs

-

PR: https://git.openjdk.java.net/jdk/pull/3867


Re: RFR: JDK-8266527 RandomTestCoverage.java failing due to API removal

2021-05-04 Thread Roger Riggs
On Tue, 4 May 2021 21:09:59 GMT, Jim Laskey  wrote:

> RandomTestCoverage.java was overlooked when doing local test. Apologies.

Good to clean those out.

-

Marked as reviewed by rriggs (Reviewer).

PR: https://git.openjdk.java.net/jdk/pull/3867


RFR: JDK-8266527 RandomTestCoverage.java failing due to API removal

2021-05-04 Thread Jim Laskey
RandomTestCoverage.java was overlooked when doing local test. Apologies.

-

Commit messages:
 - Adjust testing for API removal

Changes: https://git.openjdk.java.net/jdk/pull/3867/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3867=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8266527
  Stats: 15 lines in 1 file changed: 5 ins; 0 del; 10 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3867.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3867/head:pull/3867

PR: https://git.openjdk.java.net/jdk/pull/3867


Re: RFR: 8264777: Overload optimized FileInputStream::readAllBytes [v2]

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 19:01:45 GMT, Brian Burkhalter  wrote:

>> Only regular files this far. Are there any particular special files which 
>> would be of interest?
>
> On `/proc/cpuinfo` for example, `fstat()` succeeds but `st_size` in `struct 
> stat` is zero. The correct position is however returned by `lseek()`. 
> Apparently this proposal needs to be reworked to expect size zero when the 
> size is in fact non-zero.

Updated to handle `length() == 0` case. Not sure however whether for this case 
it might not be better just to fall back to `super.readXBytes()` instead.

-

PR: https://git.openjdk.java.net/jdk/pull/3845


Re: RFR: 8264777: Overload optimized FileInputStream::readAllBytes [v2]

2021-05-04 Thread Brian Burkhalter
> Please consider this request to override the `java.io.InputStream` methods 
> `readAllBytes()` and `readNBytes(int)` in `FileInputStream` with more 
> performant implementations. The method overrides attempt to read all 
> requested bytes into a single array of the required size rather than 
> composing the result from a sequence of smaller arrays. An example of the 
> performance improvements is as follows.
> 
> **readAllBytes**
> Before
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   2412.031 
> ±   7.309  ops/s
> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20212.181 
> ±   0.369  ops/s
> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 19.860 
> ±   0.048  ops/s
> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.298 
> ±   0.183  ops/s
> 
> After
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   8218.473 
> ±  43.425  ops/s
> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20302.781 
> ±   1.273  ops/s
> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 22.461 
> ±   0.084  ops/s
> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.502 
> ±   0.003  ops/s
> 
> 
> **readNBytes**
> 
> `N = file_size / 2`
> 
> Before
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20   5585.500 
> ± 153.353  ops/s
> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20436.164 
> ±   1.104  ops/s
> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 40.167 
> ±   0.141  ops/s
> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  3.291 
> ±   0.211  ops/s
> 
> 
> After
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20  15463.210 
> ±  66.045  ops/s
> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20561.752 
> ±   0.951  ops/s
> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 45.043 
> ±   0.102  ops/s
> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  4.629 
> ±   0.035  ops/s

Brian Burkhalter has updated the pull request incrementally with one additional 
commit since the last revision:

  8264777: Handle cases where length() returns zero

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3845/files
  - new: https://git.openjdk.java.net/jdk/pull/3845/files/8b568686..98a03a55

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3845=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3845=00-01

  Stats: 25 lines in 1 file changed: 16 ins; 2 del; 7 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3845.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3845/head:pull/3845

PR: https://git.openjdk.java.net/jdk/pull/3845


Integrated: JDK-8266227: Fix help text for --mac-signing-keychain

2021-05-04 Thread Andy Herrick
On Fri, 30 Apr 2021 15:25:13 GMT, Andy Herrick  wrote:

> JDK-8266227: Fix help text for --mac-signing-keychain

This pull request has now been integrated.

Changeset: c53dee74
Author:Andy Herrick 
URL:   
https://git.openjdk.java.net/jdk/commit/c53dee7480858811c32ac718f5a27a00e3483a38
Stats: 89 lines in 3 files changed: 27 ins; 5 del; 57 mod

8266227: Fix help text for --mac-signing-keychain

Reviewed-by: almatvee, asemenyuk

-

PR: https://git.openjdk.java.net/jdk/pull/3819


Re: Fast and cheap (Double|Float)::toString Java algorithm

2021-05-04 Thread Raffaello Giulietti

Hi Suminda,

as I explained back in February, I already experimented blending 
Schubfach with a variant of Grisu back in 2018. Contrary to my 
expectations, I observed noticeable performance drops wrt pure 
Schubfach. I didn't explore any further, but I think that the more 
complex control logic required by the blend makes it harder for a JIT 
compiler to optimize.


Thus, I prefer to wait until my own contribution has been reviewed and 
integrated (if at all) before adding complexity that might not be 
beneficial in Java.


(Junekey measured that a blend *is* beneficial in C++, though. But it's 
somehow hard to compare a static AOT compilation, as done in C++, and a 
JIT compilation, as done on the JVM.)



Greetings
Raffaello



On 2021-05-04 18:14, Suminda Sirinath Salpitikorala Dharmasena wrote:

Hello,

I hope everything is well with you.

Due to other commitments this work has stalled.

I was planning to implement:
- fast to string conversion
- fast string parsing
- fast formatting
- fast search
- fast sort
- fast templating
- fast buffers

The code I have done so far is here: https://github.com/sirinath/moby 



Wondering if someone can take this forward until I have more time in my 
hand.


Suminda

On Sat, 6 Feb 2021 at 09:50, Suminda Sirinath Salpitikorala Dharmasena 
mailto:sirinath19...@gmail.com>> wrote:


Hello,

I am working on a port of DragonBox to Java. If there is interest in
contributing this is most welcome.

Suminda

On Fri, 5 Feb 2021 at 21:51, Raffaello Giulietti
mailto:raffaello.giulie...@gmail.com>> wrote:

Hello,

as a reminder, a Java implementation of Schubfach [1] intended to
replace the current slow and expensive OpenJDK
(Double|Float)::toString
algorithm has been discussed, presented and contributed to this
mailing
list in several posts. The last implementation is available in
pre-Skara
webrev form, as referenced in [2]. On my laptop hardware, the
speedup
factor is 17.7x wrt OpenJDK.



Recently, Alexander Bolz translated Schubfach to C++ for the
purpose of
comparing the performance of several bin2dec floating-point numbers
algorithms [3].

In the meantime, Junekey Jeon implemented and perfected his own
Dragonbox in C++, a new algorithm based on Schubfach [4]. From
[5]: "In
addition to the core idea of Schubfach, Dragonbox utilizes some
Grisu-like ideas to minimize the number of expensive 128-bit ×
64-bit
multiplications, at the cost of having more branches and
divisions-by-constants."

In the C++ ecosystem, Schubfach has been the fastest known
algorithm
before being gently pushed aside by Dragonbox, as can be seen in
the
graphs in [3].



While developing Schubfach back in 2018, I experimented myself with
blending core Schubfach with my own earlier algorithm similar to
Grisu.
However, probably due to uncontrollable JIT compilation behavior, I
could not observe any benefit. On the contrary, I measured
performance
drops probably because of the added complexity, which is public
enemy
nr. 1 for JIT compilers. Therefore, I opted for the simpler current
design that seemed more suitable for (the then 2018 version of) C2.



I hope this can somehow revive this community's interest and
confidence
toward Schubfach to definitely supplant the current expensive
(Double|Float)::toString algorithm.


Greetings
Raffaello



[1]
https://drive.google.com/open?id=1luHhyQF9zKlM8yJ1nebU0OgVYhfC6CBN

[2]

https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-March/065297.html


[3] https://github.com/abolz/Drachennest

[4] https://github.com/jk-jeon/dragonbox

[5]

https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf





Re: RFR: 8264777: Overload optimized FileInputStream::readAllBytes

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 17:46:15 GMT, Brian Burkhalter  wrote:

>> src/java.base/share/classes/java/io/FileInputStream.java line 342:
>> 
>>> 340: 
>>> 341: private native long length() throws IOException;
>>> 342: private native long position() throws IOException;
>> 
>> Can you confirm that you've tested with special files? It's very likely that 
>> there will be cases where lseek will fail.
>
> Only regular files this far. Are there any particular special files which 
> would be of interest?

On `/proc/cpuinfo` for example, `fstat()` succeeds but `st_size` in `struct 
stat` is zero. The correct position is however returned by `lseek()`. 
Apparently this proposal needs to be reworked to expect size zero when the size 
is in fact non-zero.

-

PR: https://git.openjdk.java.net/jdk/pull/3845


Re: RFR: 8264777: Overload optimized FileInputStream::readAllBytes

2021-05-04 Thread Brian Burkhalter
On Tue, 4 May 2021 14:07:18 GMT, Alan Bateman  wrote:

>> Please consider this request to override the `java.io.InputStream` methods 
>> `readAllBytes()` and `readNBytes(int)` in `FileInputStream` with more 
>> performant implementations. The method overrides attempt to read all 
>> requested bytes into a single array of the required size rather than 
>> composing the result from a sequence of smaller arrays. An example of the 
>> performance improvements is as follows.
>> 
>> **readAllBytes**
>> Before
>> 
>> Benchmark(length)   Mode  Cnt  Score 
>> Error  Units
>> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   2412.031 
>> ±   7.309  ops/s
>> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20212.181 
>> ±   0.369  ops/s
>> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 19.860 
>> ±   0.048  ops/s
>> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.298 
>> ±   0.183  ops/s
>> 
>> After
>> 
>> Benchmark(length)   Mode  Cnt  Score 
>> Error  Units
>> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   8218.473 
>> ±  43.425  ops/s
>> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20302.781 
>> ±   1.273  ops/s
>> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 22.461 
>> ±   0.084  ops/s
>> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.502 
>> ±   0.003  ops/s
>> 
>> 
>> **readNBytes**
>> 
>> `N = file_size / 2`
>> 
>> Before
>> 
>> Benchmark(length)   Mode  Cnt  Score 
>> Error  Units
>> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20   5585.500 
>> ± 153.353  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20436.164 
>> ±   1.104  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 40.167 
>> ±   0.141  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  3.291 
>> ±   0.211  ops/s
>> 
>> 
>> After
>> 
>> Benchmark(length)   Mode  Cnt  Score 
>> Error  Units
>> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20  15463.210 
>> ±  66.045  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20561.752 
>> ±   0.951  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 45.043 
>> ±   0.102  ops/s
>> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  4.629 
>> ±   0.035  ops/s
>
> src/java.base/share/classes/java/io/FileInputStream.java line 342:
> 
>> 340: 
>> 341: private native long length() throws IOException;
>> 342: private native long position() throws IOException;
> 
> Can you confirm that you've tested with special files? It's very likely that 
> there will be cases where lseek will fail.

Only regular files this far. Are there any particular special files which would 
be of interest?

-

PR: https://git.openjdk.java.net/jdk/pull/3845


Integrated: 8265989: System property for the native character encoding name

2021-05-04 Thread Naoto Sato
On Wed, 28 Apr 2021 22:24:31 GMT, Naoto Sato  wrote:

> After some internal discussion, we thought it was good to expose the native 
> environment's default character encoding, which Charset.defaultCharset() is 
> currently based on. This way applications will have a better migration path 
> after the [JEP 400](https://openjdk.java.net/jeps/400) is implemented, in 
> which Charset.defaultCharset() will return UTF-8, but the value of this new 
> system property will remain intact. A 
> [CSR](https://bugs.openjdk.java.net/browse/JDK-8266075) has been filed with 
> more detailed information.

This pull request has now been integrated.

Changeset: 4e96b310
Author:Naoto Sato 
URL:   
https://git.openjdk.java.net/jdk/commit/4e96b310425de541675b28493fdbe195780623c3
Stats: 32 lines in 4 files changed: 23 ins; 3 del; 6 mod

8265989: System property for the native character encoding name

Reviewed-by: iris, joehw, rriggs

-

PR: https://git.openjdk.java.net/jdk/pull/3777


Re: RFR: 8266317: Vector API enhancements

2021-05-04 Thread Paul Sandoz
On Thu, 29 Apr 2021 21:13:38 GMT, Paul Sandoz  wrote:

> This PR contains API and implementation changes for [JEP-414 Vector API 
> (Second Incubator)](https://openjdk.java.net/jeps/414), in preparation for 
> when targeted.
> 
> Enhancements are made to the API for the support of operations on characters, 
> such as for UTF-8 character decoding. Specifically, methods for 
> loading/storing a `short` vector from/to a `char[]` array, and new vector 
> comparison operators for unsigned comparisons with integral vectors. The x64 
> implementation is enhanced to supported unsigned comparisons.
> 
> Enhancements are made to the API for loading/storing a `byte` vector from/to 
> a `boolean[]` array.
> 
> The testing of loads/stores can be expanded for scatter/gather, but before 
> doing that i think some refactoring of the tests is required to reposition 
> tests in the right classes. I would like to do that work after integration of 
> the PR.

All tests pass for tier1,tier2,tier3 for build profiles linux-x64, 
linux-aarch64, macosx-x64, and windows-x64.

-

PR: https://git.openjdk.java.net/jdk/pull/3803


RFR: 8266317: Vector API enhancements

2021-05-04 Thread Paul Sandoz
This PR contains API and implementation changes for [JEP-414 Vector API (Second 
Incubator)](https://openjdk.java.net/jeps/414), in preparation for when 
targeted.

Enhancements are made to the API for the support of operations on characters, 
such as for UTF-8 character decoding. Specifically, methods for loading/storing 
a `short` vector from/to a `char[]` array, and new vector comparison operators 
for unsigned comparisons with integral vectors. The x64 implementation is 
enhanced to supported unsigned comparisons.

Enhancements are made to the API for loading/storing a `byte` vector from/to a 
`boolean[]` array.

The testing of loads/stores can be expanded for scatter/gather, but before 
doing that i think some refactoring of the tests is required to reposition 
tests in the right classes. I would like to do that work after integration of 
the PR.

-

Commit messages:
 - Minor clarifications to the specification.
 - 8266317: Vector API enhancements

Changes: https://git.openjdk.java.net/jdk/pull/3803/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3803=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8266317
  Stats: 10002 lines in 121 files changed: 9070 ins; 190 del; 742 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3803.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3803/head:pull/3803

PR: https://git.openjdk.java.net/jdk/pull/3803


Re: Fast and cheap (Double|Float)::toString Java algorithm

2021-05-04 Thread Suminda Sirinath Salpitikorala Dharmasena
Hello,

I hope everything is well with you.

Due to other commitments this work has stalled.

I was planning to implement:
- fast to string conversion
- fast string parsing
- fast formatting
- fast search
- fast sort
- fast templating
- fast buffers

The code I have done so far is here: https://github.com/sirinath/moby

Wondering if someone can take this forward until I have more time in my
hand.

Suminda

On Sat, 6 Feb 2021 at 09:50, Suminda Sirinath Salpitikorala Dharmasena <
sirinath19...@gmail.com> wrote:

> Hello,
>
> I am working on a port of DragonBox to Java. If there is interest in
> contributing this is most welcome.
>
> Suminda
>
> On Fri, 5 Feb 2021 at 21:51, Raffaello Giulietti <
> raffaello.giulie...@gmail.com> wrote:
>
>> Hello,
>>
>> as a reminder, a Java implementation of Schubfach [1] intended to
>> replace the current slow and expensive OpenJDK (Double|Float)::toString
>> algorithm has been discussed, presented and contributed to this mailing
>> list in several posts. The last implementation is available in pre-Skara
>> webrev form, as referenced in [2]. On my laptop hardware, the speedup
>> factor is 17.7x wrt OpenJDK.
>>
>>
>>
>> Recently, Alexander Bolz translated Schubfach to C++ for the purpose of
>> comparing the performance of several bin2dec floating-point numbers
>> algorithms [3].
>>
>> In the meantime, Junekey Jeon implemented and perfected his own
>> Dragonbox in C++, a new algorithm based on Schubfach [4]. From [5]: "In
>> addition to the core idea of Schubfach, Dragonbox utilizes some
>> Grisu-like ideas to minimize the number of expensive 128-bit × 64-bit
>> multiplications, at the cost of having more branches and
>> divisions-by-constants."
>>
>> In the C++ ecosystem, Schubfach has been the fastest known algorithm
>> before being gently pushed aside by Dragonbox, as can be seen in the
>> graphs in [3].
>>
>>
>>
>> While developing Schubfach back in 2018, I experimented myself with
>> blending core Schubfach with my own earlier algorithm similar to Grisu.
>> However, probably due to uncontrollable JIT compilation behavior, I
>> could not observe any benefit. On the contrary, I measured performance
>> drops probably because of the added complexity, which is public enemy
>> nr. 1 for JIT compilers. Therefore, I opted for the simpler current
>> design that seemed more suitable for (the then 2018 version of) C2.
>>
>>
>>
>> I hope this can somehow revive this community's interest and confidence
>> toward Schubfach to definitely supplant the current expensive
>> (Double|Float)::toString algorithm.
>>
>>
>> Greetings
>> Raffaello
>>
>> 
>>
>> [1] https://drive.google.com/open?id=1luHhyQF9zKlM8yJ1nebU0OgVYhfC6CBN
>> [2]
>>
>> https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-March/065297.html
>> [3] https://github.com/abolz/Drachennest
>> [4] https://github.com/jk-jeon/dragonbox
>> [5]
>> https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf
>>
>


Re: RFR: JDK-8266227: Fix help text for --mac-signing-keychain

2021-05-04 Thread Alexey Semenyuk
On Fri, 30 Apr 2021 15:25:13 GMT, Andy Herrick  wrote:

> JDK-8266227: Fix help text for --mac-signing-keychain

Marked as reviewed by asemenyuk (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/3819


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v11]

2021-05-04 Thread Maurizio Cimadamore
> This PR contains the API and implementation changes for JEP-412 [1]. A more 
> detailed description of such changes, to avoid repetitions during the review 
> process, is included as a separate comment.
> 
> [1] - https://openjdk.java.net/jeps/412

Maurizio Cimadamore has updated the pull request incrementally with one 
additional commit since the last revision:

  Fix message string in Reflection::ensureNativeAccess

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3699/files
  - new: https://git.openjdk.java.net/jdk/pull/3699/files/2a31da40..72eb9bbc

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3699=10
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3699=09-10

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3699.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3699/head:pull/3699

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v7]

2021-05-04 Thread Alan Bateman
On Tue, 4 May 2021 12:01:44 GMT, Maurizio Cimadamore  
wrote:

>> src/java.base/share/classes/jdk/internal/module/IllegalNativeAccessChecker.java
>>  line 34:
>> 
>>> 32: import java.util.Set;
>>> 33: 
>>> 34: public final class IllegalNativeAccessChecker {
>> 
>> Are you sure about the name of the this class? It doesn't do any checking 
>> and it's not concerned with "illegal native access" either, instead it just 
>> provides access to the names of modules that have been granted native access.
>
> I've decided to drop this class and move the logic in ModuleBootstrap. To 
> handle unnamed modules, I had to piggy back on the special static ALL_UNNAMED 
> module and set the flag there when decoding the command line option. This 
> seems to be consistent with what is done in other areas.

Good, this looks much simpler now.

-

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v10]

2021-05-04 Thread Alan Bateman
On Tue, 4 May 2021 12:05:15 GMT, Maurizio Cimadamore  
wrote:

>> This PR contains the API and implementation changes for JEP-412 [1]. A more 
>> detailed description of such changes, to avoid repetitions during the review 
>> process, is included as a separate comment.
>> 
>> [1] - https://openjdk.java.net/jeps/412
>
> Maurizio Cimadamore has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Tweak comment in Module::enableNativeAccess

src/java.base/share/classes/jdk/internal/reflect/Reflection.java line 112:

> 110: Module module = currentClass.getModule();
> 111: if 
> (!SharedSecrets.getJavaLangAccess().isEnableNativeAccess(module)) {
> 112: throw new IllegalCallerException("Illegal native access from 
> module: " + module);

You may want to drop "module" from the exception message as Module::toString is 
specified to return "module " or "unnamed module " so you'll end up 
duplication "module" in the message.

-

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8265448: (zipfs): Reduce read contention in ZipFileSystem

2021-05-04 Thread Alan Bateman
On Tue, 4 May 2021 13:07:34 GMT, Jason Zaugg  wrote:

> If the given Path represents a file, use the overload of read defined
> in FileChannel that accepts an explicit position and avoid serializing
> reads.
> 
> Note: The underlying NIO implementation is not required to implement
> FileChannel.read(ByteBuffer, long) concurrently; Windows still appears
> to lock, as it returns true for NativeDispatcher.needsPositionLock.
> 
> 
> On MacOS X, the enclosed benchmark improves from:
> 
> 
> BenchmarkMode  Cnt   Score   Error  Units
> ZipFileSystemBenchmark.read  avgt   10  75.311 ? 3.301  ms/op
> 
> 
> To:
> 
> 
> BenchmarkMode  Cnt   Score   Error  Units
> ZipFileSystemBenchmark.read  avgt   10  12.520 ? 0.875  ms/op

src/jdk.zipfs/share/classes/jdk/nio/zipfs/ZipFileSystem.java line 2223:

> 2221: synchronized (zfch) {
> : n = zfch.position(pos).read(bb);
> 2223: }

@LanceAndersen Are you planning to look at this? Do you mind checking the async 
close case to make sure that the synchronization isn't masking anything?

Also just to point out that pattern matching for instanceof ca be used here.

-

PR: https://git.openjdk.java.net/jdk/pull/3853


Re: RFR: 8264777: Overload optimized FileInputStream::readAllBytes

2021-05-04 Thread Alan Bateman
On Mon, 3 May 2021 20:33:23 GMT, Brian Burkhalter  wrote:

> Please consider this request to override the `java.io.InputStream` methods 
> `readAllBytes()` and `readNBytes(int)` in `FileInputStream` with more 
> performant implementations. The method overrides attempt to read all 
> requested bytes into a single array of the required size rather than 
> composing the result from a sequence of smaller arrays. An example of the 
> performance improvements is as follows.
> 
> **readAllBytes**
> Before
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   2412.031 
> ±   7.309  ops/s
> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20212.181 
> ±   0.369  ops/s
> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 19.860 
> ±   0.048  ops/s
> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.298 
> ±   0.183  ops/s
> 
> After
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readAllBytesFileInputStream  100  thrpt   20   8218.473 
> ±  43.425  ops/s
> ReadAllBytes.readAllBytesFileInputStream 1000  thrpt   20302.781 
> ±   1.273  ops/s
> ReadAllBytes.readAllBytesFileInputStream1  thrpt   20 22.461 
> ±   0.084  ops/s
> ReadAllBytes.readAllBytesFileInputStream   10  thrpt   20  1.502 
> ±   0.003  ops/s
> 
> 
> **readNBytes**
> 
> `N = file_size / 2`
> 
> Before
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20   5585.500 
> ± 153.353  ops/s
> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20436.164 
> ±   1.104  ops/s
> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 40.167 
> ±   0.141  ops/s
> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  3.291 
> ±   0.211  ops/s
> 
> 
> After
> 
> Benchmark(length)   Mode  Cnt  Score  
>Error  Units
> ReadAllBytes.readHalfBytesFileInputStream 100  thrpt   20  15463.210 
> ±  66.045  ops/s
> ReadAllBytes.readHalfBytesFileInputStream1000  thrpt   20561.752 
> ±   0.951  ops/s
> ReadAllBytes.readHalfBytesFileInputStream   1  thrpt   20 45.043 
> ±   0.102  ops/s
> ReadAllBytes.readHalfBytesFileInputStream  10  thrpt   20  4.629 
> ±   0.035  ops/s

src/java.base/share/classes/java/io/FileInputStream.java line 342:

> 340: 
> 341: private native long length() throws IOException;
> 342: private native long position() throws IOException;

Can you confirm that you've tested with special files? It's very likely that 
there will be cases where lseek will fail.

-

PR: https://git.openjdk.java.net/jdk/pull/3845


Re: RFR: 8260621: (jrtfs) ThreadLocal memory leak in ImageBufferCache when using jrtfs

2021-05-04 Thread Vyom Tewari
On Tue, 4 May 2021 09:05:38 GMT, Athijegannathan Sundararajan 
 wrote:

> Instead of BufferReference class, Map.Entry is used as pair implementation.
> This avoids the metaspace leak seen via thread local.

looks OK to me.

-

Marked as reviewed by vtewari (Committer).

PR: https://git.openjdk.java.net/jdk/pull/3849


Integrated: 8265279: Remove unused RandomGeneratorFactory.all(Class category)

2021-05-04 Thread Jim Laskey
On Thu, 15 Apr 2021 12:48:35 GMT, Jim Laskey  wrote:

> No longer needed

This pull request has now been integrated.

Changeset: 770dfc1e
Author:Jim Laskey 
URL:   
https://git.openjdk.java.net/jdk/commit/770dfc1ec4fe28bc73612c8b0dd8423dd49e1597
Stats: 25 lines in 1 file changed: 0 ins; 25 del; 0 mod

8265279: Remove unused RandomGeneratorFactory.all(Class category)

Reviewed-by: rriggs

-

PR: https://git.openjdk.java.net/jdk/pull/3516


Re: RFR: 8265279: Remove unused RandomGeneratorFactory.all(Class category) [v2]

2021-05-04 Thread Roger Riggs
On Tue, 4 May 2021 12:07:15 GMT, Jim Laskey  wrote:

>> No longer needed
>
> Jim Laskey has updated the pull request with a new target base due to a merge 
> or a rebase. The pull request now contains seven commits:
> 
>  - Merge branch 'master' into 8265279
>  - RandomGeneratorFactory.all(Class category) no longer needed
>  - Remove extraneous references to makeXXXSpliterator
>  - Move makeXXXSpliterator methods to RandomSupport
>  - change static final from 'proxy' to 'PROXY'
>  - Make makeXXXSpliterator final
>  - Move makeXXXSpilterator from public (@hidden) to protected. No API change.

Marked as reviewed by rriggs (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/3516


RFR: 8265448: (zipfs): Reduce read contention in ZipFileSystem

2021-05-04 Thread Jason Zaugg
If the given Path represents a file, use the overload of read defined
in FileChannel that accepts an explicit position and avoid serializing
reads.

Note: The underlying NIO implementation is not required to implement
FileChannel.read(ByteBuffer, long) concurrently; Windows still appears
to lock, as it returns true for NativeDispatcher.needsPositionLock.


On MacOS X, the enclosed benchmark improves from:


BenchmarkMode  Cnt   Score   Error  Units
ZipFileSystemBenchmark.read  avgt   10  75.311 ? 3.301  ms/op


To:


BenchmarkMode  Cnt   Score   Error  Units
ZipFileSystemBenchmark.read  avgt   10  12.520 ? 0.875  ms/op

-

Commit messages:
 - 8265448: Avoid lock contention in reads from zipfs when possible

Changes: https://git.openjdk.java.net/jdk/pull/3853/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3853=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8265448
  Stats: 101 lines in 2 files changed: 97 ins; 0 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3853.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3853/head:pull/3853

PR: https://git.openjdk.java.net/jdk/pull/3853


Re: RFR: JDK-8266227: Fix help text for --mac-signing-keychain

2021-05-04 Thread Andy Herrick
On Fri, 30 Apr 2021 15:25:13 GMT, Andy Herrick  wrote:

> JDK-8266227: Fix help text for --mac-signing-keychain

I updated the bug Description to point out that text formatting and other minor 
wording changes are being applied to the help

-

PR: https://git.openjdk.java.net/jdk/pull/3819


Re: RFR: 8254598: StringDedupTable should use OopStorage

2021-05-04 Thread Thomas Schatzl
On Fri, 23 Apr 2021 19:48:47 GMT, Kim Barrett  wrote:

> Please review this change to the String Deduplication facility.  It is being
> changed to use OopStorage to hold weak references to relevant objects,
> rather than bespoke data structures requiring dedicated processing phases by
> supporting GCs.
> 
> (The Shenandoah update was contributed by Zhengyu Gu.)
> 
> This change significantly simplifies the interface between a given GC and
> the String Deduplication facility, which should make it much easier for
> other GCs to opt in.  However, this change does not alter the set of GCs
> providing support; currently only G1 and Shenandoah support string
> deduplication.  Adding support by other GCs will be in followup RFEs.
> 
> Reviewing via the diffs might not be all that useful for some parts, as
> several files have been essentially completely replaced, and a number of
> files have been added or eliminated.  The full webrev might be a better
> place to look.
> 
> The major changes are in gc/shared/stringdedup/* and in the supporting
> collectors, but there are also some smaller changes in other places, most
> notably classfile/{stringTable,javaClasses}.
> 
> This change is additionally labeled for review by core-libs, although there
> are no source changes there.  This change injects a byte field of bits into
> java.lang.String, using one of the previously unused padding bytes in that
> class.  (There were two unused bytes, now only one.)
> 
> Testing:
> mach5 tier1-2 with and without -XX:+UseStringDeduplication
> 
> Locally (linux-x64) ran all of the existing tests that use string
> deduplication with both G1 and Shenandoah.  Note that
> TestStringDeduplicationInterned.java is disabled for shenandoah, as it
> currently fails, for reasons I haven't figured out but suspect are test
> related.
> 
> - gc/stringdedup/   -- these used to be in gc/g1
> - runtime/cds/SharedStringsDedup.java
> - runtime/cds/appcds/cacheObject/DifferentHeapSizes.java
> - runtime/cds/appcds/sharedStrings/*
> 
> shenandoah-only:
> - gc/shenandoah/jvmti/TestHeapDump.java
> - gc/shenandoah/TestStringDedup.java
> - gc/shenandoah/TestStringDedupStress.java
> 
> Performance tested baseline, baseline + stringdedup, new with stringdedup,
> finding no significant differences.

First pass, just comment suggestions for now.

src/hotspot/share/classfile/javaClasses.hpp line 119:

> 117:   static const uint8_t _deduplication_requested_mask = 1 << 1;
> 118: 
> 119:   static int flags_offset() { CHECK_INIT(_flags_offset); }

Maybe add some description about the injected `flags` field and its contents 
here.

src/hotspot/share/classfile/javaClasses.hpp line 152:

> 150:   static inline void set_value(oop string, typeArrayOop buffer);
> 151: 
> 152:   // Set the no_deduplication flag true.  This flag is sticky; once set 
> it

Initially I was a bit confused of the use of "flag" here and that the field is 
called "flags". Maybe use "deduplication bit" here, or rename the "flags" field 
but feel free to ignore.

src/hotspot/share/classfile/javaClasses.hpp line 154:

> 152:   // Set the no_deduplication flag true.  This flag is sticky; once set 
> it
> 153:   // never gets cleared.  This is set when a string is interned in the
> 154:   // StringTable, to prevent string deduplication from changing the 
> string's

I think this information about the contents of the injected "flags" should be 
collected somewhere else as piecing together what fields "flags" has from 
different method documentation seems wrong.

src/hotspot/share/classfile/javaClasses.hpp line 170:

> 168:   static inline bool hash_is_set(oop string);
> 169:   static inline bool is_latin1(oop java_string);
> 170:   static inline bool no_deduplication(oop java_string);

That identifier is missing a verb to read better, but I do not have a good 
idea. Maybe it would be easier to use the negation of "no_deduplication", 
something like "may_deduplicate"?
Feel free to ignore.

src/hotspot/share/classfile/javaClasses.hpp line 171:

> 169:   static inline bool is_latin1(oop java_string);
> 170:   static inline bool no_deduplication(oop java_string);
> 171:   static inline bool deduplication_requested(oop java_string);

Having a verb at the beginning like `is_deduplication_requested` sounds better.

src/hotspot/share/gc/shared/stringdedup/stringDedup.hpp line 31:

> 29: //
> 30: // String deduplication aims to reduce the heap live-set by deduplicating
> 31: // identical instances of String so that they share the same backing byte

... by deduplicating instances of (java.lang.)String with identical backing 
byte array (the String's value).

src/hotspot/share/gc/shared/stringdedup/stringDedup.hpp line 69:

> 67: // arrays.  This permits reclamation of arrays that become unused.  This 
> is
> 68: // separate from the request storage objects because dead count tracking 
> is
> 69: // used by the table implementation as part of resizing decisions and for

s/table/string table? I.e. which table is 

Re: RFR: 8265279: Remove unused RandomGeneratorFactory.all(Class category) [v2]

2021-05-04 Thread Jim Laskey
> No longer needed

Jim Laskey has updated the pull request with a new target base due to a merge 
or a rebase. The pull request now contains seven commits:

 - Merge branch 'master' into 8265279
 - RandomGeneratorFactory.all(Class category) no longer needed
 - Remove extraneous references to makeXXXSpliterator
 - Move makeXXXSpliterator methods to RandomSupport
 - change static final from 'proxy' to 'PROXY'
 - Make makeXXXSpliterator final
 - Move makeXXXSpilterator from public (@hidden) to protected. No API change.

-

Changes: https://git.openjdk.java.net/jdk/pull/3516/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3516=01
  Stats: 25 lines in 1 file changed: 0 ins; 25 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3516.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3516/head:pull/3516

PR: https://git.openjdk.java.net/jdk/pull/3516


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v7]

2021-05-04 Thread Maurizio Cimadamore
On Tue, 4 May 2021 08:12:23 GMT, Alan Bateman  wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with two 
>> additional commits since the last revision:
>> 
>>  - Revert bad change in benchmark copyright
>>  - Do not apply optimized bound check if accessed offset/length do not fit 
>> in an `int` value
>
> src/java.base/share/classes/jdk/internal/module/IllegalNativeAccessChecker.java
>  line 34:
> 
>> 32: import java.util.Set;
>> 33: 
>> 34: public final class IllegalNativeAccessChecker {
> 
> Are you sure about the name of the this class? It doesn't do any checking and 
> it's not concerned with "illegal native access" either, instead it just 
> provides access to the names of modules that have been granted native access.

I've decided to drop this class and move the logic in ModuleBootstrap. To 
handle unnamed modules, I had to piggy back on the special static ALL_UNNAMED 
module and set the flag there when decoding the command line option. This seems 
to be consistent with what is done in other areas.

-

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v10]

2021-05-04 Thread Maurizio Cimadamore
> This PR contains the API and implementation changes for JEP-412 [1]. A more 
> detailed description of such changes, to avoid repetitions during the review 
> process, is included as a separate comment.
> 
> [1] - https://openjdk.java.net/jeps/412

Maurizio Cimadamore has updated the pull request incrementally with one 
additional commit since the last revision:

  Tweak comment in Module::enableNativeAccess

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3699/files
  - new: https://git.openjdk.java.net/jdk/pull/3699/files/ead71078..2a31da40

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3699=09
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3699=08-09

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3699.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3699/head:pull/3699

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v9]

2021-05-04 Thread Maurizio Cimadamore
> This PR contains the API and implementation changes for JEP-412 [1]. A more 
> detailed description of such changes, to avoid repetitions during the review 
> process, is included as a separate comment.
> 
> [1] - https://openjdk.java.net/jeps/412

Maurizio Cimadamore has updated the pull request incrementally with three 
additional commits since the last revision:

 - Tweak code some more
 - Use uniform naming convention for implementation metods in Module
 - Remove IllegalNativeAccessChecker

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3699/files
  - new: https://git.openjdk.java.net/jdk/pull/3699/files/6a659d87..ead71078

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3699=08
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3699=07-08

  Stats: 169 lines in 5 files changed: 41 ins; 114 del; 14 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3699.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3699/head:pull/3699

PR: https://git.openjdk.java.net/jdk/pull/3699


Integrated: 8265137: java.util.Random suddenly has new public methods nowhere documented

2021-05-04 Thread Jim Laskey
On Tue, 13 Apr 2021 16:33:21 GMT, Jim Laskey  wrote:

> Move makeXXXSpilterator from public (@hidden) to protected. No API ch

This pull request has now been integrated.

Changeset: 05e60174
Author:Jim Laskey 
URL:   
https://git.openjdk.java.net/jdk/commit/05e601748a35de02a33721199a00a3d6c335c6d9
Stats: 340 lines in 4 files changed: 67 ins; 215 del; 58 mod

8265137: java.util.Random suddenly has new public methods nowhere documented

Reviewed-by: uschindler, darcy, smarks

-

PR: https://git.openjdk.java.net/jdk/pull/3469


Re: RFR: 8265137: java.util.Random suddenly has new public methods nowhere documented [v8]

2021-05-04 Thread Jim Laskey
> Move makeXXXSpilterator from public (@hidden) to protected. No API ch

Jim Laskey has updated the pull request with a new target base due to a merge 
or a rebase. The incremental webrev excludes the unrelated changes brought in 
by the merge/rebase. The pull request contains 10 additional commits since the 
last revision:

 - Merge branch 'master' into 8265137
 - Remove unnecessary constructor.
 - Merge branch 'master' into 8265137
 - Remove @hidden
 - Correct the hierarchy of Random
 - Remove extraneous references to makeXXXSpliterator
 - Move makeXXXSpliterator methods to RandomSupport
 - change static final from 'proxy' to 'PROXY'
 - Make makeXXXSpliterator final
 - Move makeXXXSpilterator from public (@hidden) to protected. No API change.

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3469/files
  - new: https://git.openjdk.java.net/jdk/pull/3469/files/482ea0ac..218a7d9d

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3469=07
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3469=06-07

  Stats: 514343 lines in 4172 files changed: 24106 ins; 486284 del; 3953 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3469.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3469/head:pull/3469

PR: https://git.openjdk.java.net/jdk/pull/3469


Re: RFR: 8260621: (jrtfs) ThreadLocal memory leak in ImageBufferCache when using jrtfs

2021-05-04 Thread Jim Laskey
On Tue, 4 May 2021 09:05:38 GMT, Athijegannathan Sundararajan 
 wrote:

> Instead of BufferReference class, Map.Entry is used as pair implementation.
> This avoids the metaspace leak seen via thread local.

Marked as reviewed by jlaskey (Reviewer).

-

PR: https://git.openjdk.java.net/jdk/pull/3849


Re: RFR: 8266179: [macos] jpackage should specify architecture for produced pkg files [v4]

2021-05-04 Thread Kevin Rushforth
On Mon, 3 May 2021 22:52:21 GMT, Alexander Matveev  wrote:

>> jpackage should specify architecture for produced PKG files via 
>> hostArchitectures="x86_x64 or arm64". aarch64 installer will be installable 
>> on x64 without specifying hostArchitectures which is not correct and if 
>> install on arm Mac it will request Rosetta 2. With proposed fix by setting 
>> hostArchitectures="x86_x64" if installer contains x64 binaries, it will be 
>> installable on x64 Mac and will require Rosetta 2 on arm Mac. 
>> hostArchitectures will be set to arm64 if installer contain aarch64 binaries 
>> and will gave error when run on x64 Mac and will be installable on arm Mac 
>> without triggering installation of Rosetta 2.
>
> Alexander Matveev has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   8266179: [macos] jpackage should specify architecture for produced pkg 
> files [v4]

Marked as reviewed by kcr (Author).

-

PR: https://git.openjdk.java.net/jdk/pull/3807


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v8]

2021-05-04 Thread Maurizio Cimadamore
> This PR contains the API and implementation changes for JEP-412 [1]. A more 
> detailed description of such changes, to avoid repetitions during the review 
> process, is included as a separate comment.
> 
> [1] - https://openjdk.java.net/jeps/412

Maurizio Cimadamore has updated the pull request incrementally with two 
additional commits since the last revision:

 - Remove redundant initializer in Module
 - Address review comments

-

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3699/files
  - new: https://git.openjdk.java.net/jdk/pull/3699/files/793ea5c5..6a659d87

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk=3699=07
 - incr: https://webrevs.openjdk.java.net/?repo=jdk=3699=06-07

  Stats: 19 lines in 3 files changed: 6 ins; 11 del; 2 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3699.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3699/head:pull/3699

PR: https://git.openjdk.java.net/jdk/pull/3699


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v7]

2021-05-04 Thread Maurizio Cimadamore
On Tue, 4 May 2021 08:20:43 GMT, Alan Bateman  wrote:

> Just to double, there is no way to enable native access for modules in module 
> layers (other than the boot layer), right?

No, at the moment it is not possible to enable native access programmatically. 
We will explore something along those lines in the future.

-

PR: https://git.openjdk.java.net/jdk/pull/3699


RFR: 8260621: (jrtfs) ThreadLocal memory leak in ImageBufferCache when using jrtfs

2021-05-04 Thread Athijegannathan Sundararajan
Instead of BufferReference class, Map.Entry is used as pair implementation.
This avoids the metaspace leak seen via thread local.

-

Commit messages:
 - added comment. generics cleanup.
 - 8260621: (jrtfs) ThreadLocal memory leak in ImageBufferCache when using jrtfs

Changes: https://git.openjdk.java.net/jdk/pull/3849/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=3849=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8260621
  Stats: 57 lines in 1 file changed: 30 ins; 7 del; 20 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3849.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3849/head:pull/3849

PR: https://git.openjdk.java.net/jdk/pull/3849


Re: RFR: 8264774: Implementation of Foreign Function and Memory API (Incubator) [v7]

2021-05-04 Thread Alan Bateman
On Fri, 30 Apr 2021 15:20:42 GMT, Maurizio Cimadamore  
wrote:

>> This PR contains the API and implementation changes for JEP-412 [1]. A more 
>> detailed description of such changes, to avoid repetitions during the review 
>> process, is included as a separate comment.
>> 
>> [1] - https://openjdk.java.net/jeps/412
>
> Maurizio Cimadamore has updated the pull request incrementally with two 
> additional commits since the last revision:
> 
>  - Revert bad change in benchmark copyright
>  - Do not apply optimized bound check if accessed offset/length do not fit in 
> an `int` value

Just to double, there is no way to enable native access for modules in module 
layers (other than the boot layer), right?

src/java.base/share/classes/java/lang/Module.java line 115:

> 113: 
> 114: // is this module a native module
> 115: private volatile boolean enableNativeAccess = false;

Can you drop "= false", it's not needed and I don't think we want a 
volatile-write here.
Also the comment may date from a previous iteration as there isn't any concept 
of a "native module".

src/java.base/share/classes/java/lang/System.java line 2346:

> 2344: public boolean isEnableNativeAccess(Module m) {
> 2345: return m.isEnableNativeAccess();
> 2346: }

Can you move this up so they are with the other Module methods?

src/java.base/share/classes/jdk/internal/module/IllegalNativeAccessChecker.java 
line 34:

> 32: import java.util.Set;
> 33: 
> 34: public final class IllegalNativeAccessChecker {

Are you sure about the name of the this class? It doesn't do any checking and 
it's not concerned with "illegal native access" either, instead it just 
provides access to the names of modules that have been granted native access.

src/java.base/share/classes/jdk/internal/module/IllegalNativeAccessChecker.java 
line 47:

> 45: private static IllegalNativeAccessChecker checker;
> 46: 
> 47: static Collection enableNativeAccessModules() {

I assume this can be changed to Iterable as you don't want anything 
outside of this class changing the collection.

src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java line 889:

> 887: } else {
> 888: // silently skip.
> 889: // warnUnknownModule(ENABLE_NATIVE_ACCESS, name);

Maybe for later but the other options do emit a warning when unknown module is 
specified. If the decoding of this command line option is moved to 
ModuleBootstrap then most of this class will go away and you will be able to 
use warnUnknownModule.

src/java.base/share/classes/jdk/internal/reflect/Reflection.java line 113:

> 111: if 
> (!SharedSecrets.getJavaLangAccess().isEnableNativeAccess(module)) {
> 112: String moduleName = module.isNamed()?  module.getName() : 
> "UNNAMED";
> 113: throw new IllegalCallerException("Illegal native access from 
> module: " + moduleName);

"UNNAMED" is a bit inconsistent with the other exception messages. Can you just 
use Module::toString here instead, meaning "Illegal native access from " + 
module ?

-

PR: https://git.openjdk.java.net/jdk/pull/3699