changeset 406:12d706400981

BigDecimal/BigInteger string conversions thread safety.
author shade
date Thu, 31 Aug 2017 11:54:10 +0200
parents 04bd0247edbb
children f761bd60f8e2
files tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigDecimalString.java tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigDecimalStringLen.java tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigIntegerString.java tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigIntegerStringLen.java
diffstat 4 files changed, 190 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigDecimalString.java	Thu Aug 31 11:54:10 2017 +0200
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress.tests.strings;
+
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.II_Result;
+import org.openjdk.jcstress.infra.results.LL_Result;
+import org.openjdk.jcstress.infra.results.SS_Result;
+
+import java.math.BigDecimal;
+
+@JCStressTest
+@Outcome(id = "0.42, 0.42", expect = Expect.ACCEPTABLE, desc = "The only possible outcome")
+@State
+public class BigDecimalString {
+    private final BigDecimal bd = new BigDecimal("0.42");
+
+    @Actor
+    public void actor1(LL_Result r) {
+        r.r1 = bd.toString();
+    }
+
+    @Actor
+    public void actor2(LL_Result r) {
+        r.r2 = bd.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigDecimalStringLen.java	Thu Aug 31 11:54:10 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress.tests.strings;
+
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.II_Result;
+
+import java.math.BigDecimal;
+
+@JCStressTest
+@Outcome(id = "4, 4", expect = Expect.ACCEPTABLE, desc = "The only possible outcome")
+@State
+public class BigDecimalStringLen {
+    private final BigDecimal bd = new BigDecimal("0.42");
+
+    @Actor
+    public void actor1(II_Result r) {
+        r.r1 = bd.toString().length();
+    }
+
+    @Actor
+    public void actor2(II_Result r) {
+        r.r2 = bd.toString().length();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigIntegerString.java	Thu Aug 31 11:54:10 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress.tests.strings;
+
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.LL_Result;
+
+import java.math.BigInteger;
+
+@JCStressTest
+@Outcome(id = "42, 42", expect = Expect.ACCEPTABLE, desc = "The only possible outcome")
+@State
+public class BigIntegerString {
+    private final BigInteger bi = new BigInteger("42");
+
+    @Actor
+    public void actor1(LL_Result r) {
+        r.r1 = bi.toString();
+    }
+
+    @Actor
+    public void actor2(LL_Result r) {
+        r.r2 = bi.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests-custom/src/main/java/org/openjdk/jcstress/tests/strings/BigIntegerStringLen.java	Thu Aug 31 11:54:10 2017 +0200
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017, Red Hat Inc. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package org.openjdk.jcstress.tests.strings;
+
+import org.openjdk.jcstress.annotations.*;
+import org.openjdk.jcstress.infra.results.II_Result;
+
+import java.math.BigInteger;
+
+@JCStressTest
+@Outcome(id = "2, 2", expect = Expect.ACCEPTABLE, desc = "The only possible outcome")
+@State
+public class BigIntegerStringLen {
+    private final BigInteger bi = new BigInteger("42");
+
+    @Actor
+    public void actor1(II_Result r) {
+        r.r1 = bi.toString().length();
+    }
+
+    @Actor
+    public void actor2(II_Result r) {
+        r.r2 = bi.toString().length();
+    }
+}