JDK-8056129 : AtomicInteger is treated as primitive number with optimistic compilation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u40,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-08-27
  • Updated: 2015-06-04
  • Resolved: 2014-09-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u40Fixed 9 b30Fixed
Description
This bug report is derived from this email to nashorn-dev alias:

http://mail.openjdk.java.net/pipermail/nashorn-dev/2014-August/003345.html


File: atomic.js

x = new java.util.concurrent.atomic.AtomicInteger()
x.incrementAndGet()
print(x + '\n')

function getAtomic() {
   return new java.util.concurrent.atomic.AtomicInteger()
}

x = getAtomic()
x.incrementAndGet()
print(x + '\n')

Expected output:

1

1

Output seen with jdk8u20:

1

1

Output seen with jdk8u-dev and jdk9-dev:

1

atomic.js:10 TypeError: 0 has no such function "incrementAndGet"

Output with --optimistic-types=false option:

1

1