RFR: 8285523: The test for JDK-8285445 can be improved

2022-04-24 Thread Sergey Bylokhov
The new test added as part of the 
[JDK-8285445](https://bugs.openjdk.java.net/browse/JDK-8285445) cannot trigger 
that bug and pass w/ and w/o fix.

An updated test validates the "default" case when the `jdk.io.File.enableADS` 
property is not set, in this case the ADS should be 
[accepted](https://github.com/openjdk/jdk/blob/9d9f4e502f6ddc3116ed9b80f7168a1edfce839e/src/java.base/windows/classes/java/io/WinNTFileSystem.java#L59).

-

Commit messages:
 - Initial version of 8285523

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

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


Re: RFR: 8285517: System.getenv() returns unexpected value if environment variable has non ASCII character

2022-04-24 Thread kristylee88
On Sun, 24 Apr 2022 09:18:54 GMT, Ichiroh Takiguchi  
wrote:

> On JDK19 with Linux ja_JP.eucjp locale,
> System.getenv() returns unexpected value if environment variable has Japanese 
> EUC characters.
> It seems this issue happens because of JEP 400.
> Arguments for ProcessBuilder have same kind of issue.

Marked as reviewed by kristyle...@github.com (no known OpenJDK username).

-

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


RFR: 8285517: System.getenv() returns unexpected value if environment variable has non ASCII character

2022-04-24 Thread Ichiroh Takiguchi
On JDK19 with Linux ja_JP.eucjp locale,
System.getenv() returns unexpected value if environment variable has Japanese 
EUC characters.
It seems this issue happens because of JEP 400.
Arguments for ProcessBuilder have same kind of issue.

-

Commit messages:
 - 8285517: System.getenv() returns unexpected value if environment variable 
has non ASCII character

Changes: https://git.openjdk.java.net/jdk/pull/8378/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk=8378=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8285517
  Stats: 188 lines in 4 files changed: 180 ins; 0 del; 8 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8378.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8378/head:pull/8378

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


RFR: 8285519: Simplify TimeUnit.convert calls

2022-04-24 Thread Andrey Turbanov
TimeUnit.toMillis/toNanos/toMicros/toSeconds is shorter and a bit faster.
Compared via JMH benchmark: 150ns -> 125ns/op

Benchamark adapted from 
http://cr.openjdk.java.net/~shade/8152083/TimeUnitBench.java


@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@State(Scope.Thread)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class TimeUnitBench {

static final int SIZE = TimeUnit.values().length * 10;

@Param({"0", "1", "2", "3", "4", "5", "6", "-1"})
int bias;

TimeUnit[] mod;

@Setup
public void setup() {
mod = new TimeUnit[SIZE];

TimeUnit[] vals = TimeUnit.values();
for (int c = 0; c < SIZE; c++) {
if (bias == -1) {
// megamorphic
mod[c] = vals[c % vals.length];
} else {
mod[c] = vals[bias];
}
}

Random r = new Random();
for (int c = 0; c < 1; c++) {
int i = r.nextInt();
for (int o = 0; o < vals.length; o++) {
if (vals[o].toNanos(i) != TimeUnit.NANOSECONDS.convert(i, 
vals[o]))
throw new IllegalStateException("switch " + o);
}
}
}

@Benchmark
public void const_convert(Blackhole bh) {
for (TimeUnit tu : mod) {
bh.consume(do_convert(tu));
}
}

@Benchmark
public void value_convert(Blackhole bh) {
for (TimeUnit tu : mod) {
bh.consume(do_convert(tu, 1L));
}
}

@Benchmark
public void const_toNanos(Blackhole bh) {
for (TimeUnit tu : mod) {
bh.consume(do_toNanos(tu));
}
}

@Benchmark
public void value_toNanos(Blackhole bh) {
for (TimeUnit tu : mod) {
bh.consume(do_toNanos(tu, 1L));
}
}

@CompilerControl(CompilerControl.Mode.DONT_INLINE)
private long do_toNanos(TimeUnit tu) {
return tu.toNanos(1L);
}

@CompilerControl(CompilerControl.Mode.DONT_INLINE)
private long do_toNanos(TimeUnit tu, long value) {
return tu.toNanos(value);
}

@CompilerControl(CompilerControl.Mode.DONT_INLINE)
private long do_convert(TimeUnit tu) {
return TimeUnit.NANOSECONDS.convert(1L, tu);
}

@CompilerControl(CompilerControl.Mode.DONT_INLINE)
private long do_convert(TimeUnit tu, long value) {
return TimeUnit.NANOSECONDS.convert(value, tu);
}
}

Results:

Benchmark(bias)  Mode  CntScoreError  Units
TimeUnitBench.const_convert   0  avgt5  151,856 ± 28,595  ns/op
TimeUnitBench.const_convert   1  avgt5  150,720 ± 23,863  ns/op
TimeUnitBench.const_convert   2  avgt5  151,432 ± 23,184  ns/op
TimeUnitBench.const_convert   3  avgt5  150,959 ± 24,726  ns/op
TimeUnitBench.const_convert   4  avgt5  150,966 ± 25,280  ns/op
TimeUnitBench.const_convert   5  avgt5  150,976 ± 25,542  ns/op
TimeUnitBench.const_convert   6  avgt5  151,118 ± 25,254  ns/op
TimeUnitBench.const_convert  -1  avgt5  152,673 ± 29,861  ns/op
TimeUnitBench.const_toNanos   0  avgt5  121,296 ± 25,236  ns/op
TimeUnitBench.const_toNanos   1  avgt5  121,707 ± 25,364  ns/op
TimeUnitBench.const_toNanos   2  avgt5  121,736 ± 25,726  ns/op
TimeUnitBench.const_toNanos   3  avgt5  121,822 ± 25,491  ns/op
TimeUnitBench.const_toNanos   4  avgt5  121,867 ± 26,090  ns/op
TimeUnitBench.const_toNanos   5  avgt5  121,927 ± 25,611  ns/op
TimeUnitBench.const_toNanos   6  avgt5  121,821 ± 25,843  ns/op
TimeUnitBench.const_toNanos  -1  avgt5  121,923 ± 25,206  ns/op
TimeUnitBench.value_convert   0  avgt5  150,525 ± 25,439  ns/op
TimeUnitBench.value_convert   1  avgt5  151,098 ± 24,024  ns/op
TimeUnitBench.value_convert   2  avgt5  151,259 ± 25,381  ns/op
TimeUnitBench.value_convert   3  avgt5  151,030 ± 25,548  ns/op
TimeUnitBench.value_convert   4  avgt5  151,290 ± 25,998  ns/op
TimeUnitBench.value_convert   5  avgt5  151,006 ± 25,448  ns/op
TimeUnitBench.value_convert   6  avgt5  150,945 ± 25,314  ns/op
TimeUnitBench.value_convert  -1  avgt5  151,186 ± 25,814  ns/op
TimeUnitBench.value_toNanos   0  avgt5  121,556 ± 25,745  ns/op
TimeUnitBench.value_toNanos   1  avgt5  123,410 ± 22,323  ns/op
TimeUnitBench.value_toNanos   2  avgt5  125,452 ± 26,575  ns/op
TimeUnitBench.value_toNanos   3  avgt5  125,297 ± 26,204  ns/op
TimeUnitBench.value_toNanos   4  avgt5  125,357 ± 26,085  ns/op
TimeUnitBench.value_toNanos   5  avgt5  125,165 ± 26,185  ns/op
TimeUnitBench.value_toNanos   6  avgt5  125,536 ± 25,487  ns/op
TimeUnitBench.value_toNanos  -1  avgt5  125,460 ± 25,063  ns/op




-

Commit messages:
 - [PATCH] Simplify