diff --git a/testsuite/driver/config/testall.conf b/testsuite/driver/config/testall.conf new file mode 100644 index 0000000000000000000000000000000000000000..fc47b39a6eb3cab5e2e9f1e1e9a444eefe803a56 --- /dev/null +++ b/testsuite/driver/config/testall.conf @@ -0,0 +1,149 @@ +[OPTION_SUITE] + common_option: O0 + +[DEFAULT_SUITE] + java_test/app_test: common_option + java_test/arrayboundary_test: common_option + java_test/clinit_test: common_option + java_test/compact_test: common_option + java_test/eh_test: common_option + java_test/fuzzapi_test: common_option + java_test/other_test: common_option + java_test/parent_test: common_option + java_test/rc_test: common_option + java_test/reflection_test: common_option + java_test/stmtpre_test: common_option + java_test/string_test: common_option + java_test/subsumeRC_test: common_option + java_test/thread_test: common_option + java_test/unsafe_test: common_option + irbuild_test: IR + +[BAN_SUITE] + irbuild_test/I0062-mapleall-irbuild-edge-pregs: IR + irbuild_test/I0069-mapleall-irbuild-edge-struct2: IR + irbuild_test/I0075-mapleall-irbuild-edge-substructinit: IR + java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest: O0 + java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest: O0 + java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest: O0 + java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest: O0 + java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest: O0 + java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest: O0 + java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest: O0 + java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest: O0 + java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest: O0 + java_test/other_test/RT0008-rt-other-PassingFloat: O0 + java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest: O0 + java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest: O0 + java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04: O0 + java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06: O0 + java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest: O0 + java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02: O0 + java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03: O0 + java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06: O0 + java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07: O0 + java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03: O0 + java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest: O0 + java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2: O0 + java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3: O0 + java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4: O0 + java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5: O0 + java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread: O0 + java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6: O0 + java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2: O0 + java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7: O0 + java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3: O0 + java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8: O0 + java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4: O0 + java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2: O0 + java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040: O0 + java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030: O0 + java_test/rc_test/RC0248-rc-function-RC_Finalize_02: O0 + java_test/rc_test/RC0249-rc-function-RC_Finalize_03: O0 + java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B: O0 + java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2: O0 + java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest: O0 + java_test/rc_test/RC0338-rc-Memory-normalTestCase28: O0 + java_test/rc_test/RC0339-rc-rp-cycle_all_weak: O0 + java_test/rc_test/RC0340-rc-rp-cycle_weak_strong: O0 + java_test/rc_test/RC0341-rc-rp-mutator: O0 + java_test/rc_test/RC0342-rc-rp-weak_ref_boundary: O0 + java_test/rc_test/RC0343-rc-rp-wcb_test_ref: O0 + java_test/rc_test/RC0344-rc-rp-test_aged_ref: O0 + java_test/rc_test/RC0345-rc-rp-single_or_more: O0 + java_test/rc_test/RC0346-rc-rp-strong_and_weak: O0 + java_test/rc_test/RC0347-rc-rp-simulthread: O0 + java_test/rc_test/RC0348-rc-rp-simpleweakref_01: O0 + java_test/rc_test/RC0349-rc-rp-simpleweakref_02: O0 + java_test/rc_test/RC0350-rc-rp-simpleweakref_03: O0 + java_test/rc_test/RC0351-rc-rp-simpleweakref_04: O0 + java_test/rc_test/RC0352-rc-rp-simpleweakref_05: O0 + java_test/rc_test/RC0353-rc-rp-simpleweakref_06: O0 + java_test/rc_test/RC0354-rc-rp-simpleweakref_07: O0 + java_test/rc_test/RC0355-rc-rp-simpleweakref_08: O0 + java_test/rc_test/RC0356-rc-rp-simpleweakref_09: O0 + java_test/rc_test/RC0357-rc-rp-simpleweakref_10: O0 + java_test/rc_test/RC0358-rc-rp-simpleweakref_11: O0 + java_test/rc_test/RC0359-rc-rp-simpleweakref_12: O0 + java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01: O0 + java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02: O0 + java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03: O0 + java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04: O0 + java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05: O0 + java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06: O0 + java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest: O0 + java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2: O0 + java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4: O0 + java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest: O0 + java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest: O0 + java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2: O0 + java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle: O0 + java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread: O0 + java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02: O0 + java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04: O0 + java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05: O0 + java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle: O0 + java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread: O0 + java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle: O0 + java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2: O0 + java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread: O0 + java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2: O0 + java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle: O0 + java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2: O0 + java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread: O0 + java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2: O0 + java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3: O0 + java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3: O0 + java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest: O0 + java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest: O0 + java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest: O0 + java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03: O0 + java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04: O0 + java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01: O0 + java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02: O0 + java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04: O0 + java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01: O0 + java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02: O0 + java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03: O0 + java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04: O0 + java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05: O0 + java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06: O0 + java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07: O0 + java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08: O0 + java_test/rc_test/RC0457-rc-GC-TriggerGCTest01: O0 + java_test/rc_test/RC0458-rc-GC-TriggerGCTest02: O0 + java_test/rc_test/RC0459-rc-GC-TriggerGCTest03: O0 + java_test/rc_test/RC0463-rc-GC-TriggerGCTest07: O0 + java_test/rc_test/RC0464-rc-GC-TriggerGCTest08: O0 + java_test/rc_test/RC0465-rc-GC-TriggerGCTest09: O0 + java_test/rc_test/RC0466-rc-GC-TriggerGCTest10: O0 + java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01: O0 + java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02: O0 + java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01: O0 + java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01: O0 + java_test/rc_test/RC0515-GC-FrequentGCTest01: O0 + java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest: O0 + java_test/thread_test/RT0086-rt-thread-ThreadStatewait1: O0 + java_test/thread_test/RT0094-rt-thread-ThreadStateyield: O0 + java_test/thread_test/RT0189-rt-thread-GetAllStackTraceIterating: O0 + java_test/thread_test/RT0200-rt-thread-TestSynchronized: O0 diff --git a/testsuite/driver/script/mm b/testsuite/driver/script/mm new file mode 100755 index 0000000000000000000000000000000000000000..341db8b162db9f439d42765b90ccaecc67719688 --- /dev/null +++ b/testsuite/driver/script/mm @@ -0,0 +1,51 @@ +#!/bin/bash + +OPT=O2 +THREADS=$(cat /proc/cpuinfo| grep "processor"| wc -l) +PWD=$(pwd) +num=${#CASE_ROOT} +let num++ + +#mm OPT=O0 +if [ $# = 1 ] && [[ "x${1}" =~ ^xOPT=.* ]] +then + TARGET=${PWD:${num}} + OPT=${1#*=} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --mod=${OPT} + +#mm clean +elif [ $# = 1 ] && [ "x${1}" = "xclean" ] +then + TARGET=${PWD:${num}} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --clean + +#mm testall +elif [ $# = 1 ] && [ -f ${CASE_ROOT}/driver/config/${1}.conf ] +then + TARGET=${1} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --run-path=${OUT_ROOT}/host/test --j=${THREADS} --retry --report=${MAPLE_ROOT}/report.txt + +#mm testall OPT=O0 +elif [ $# = 2 ] && [ -f ${CASE_ROOT}/driver/config/${1}.conf ] && [[ "x${2}" =~ ^xOPT=.* ]] +then + OPT=${2#*=} + TARGET=${1} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --run-path=${OUT_ROOT}/host/test --mod=${OPT} --j=${THREADS} --retry --report=${MAPLE_ROOT}/report.txt + +#mm app_test +elif [ $# = 1 ] && [ -d ${CASE_ROOT}/${1} ] +then + TARGET=${1} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --run-path=${OUT_ROOT}/host/test --mod=${OPT} --j=${THREADS} --retry --report=${MAPLE_ROOT}/report.txt + +#mm app_test OPT=O2 +elif [ $# = 2 ] && [ -d ${CASE_ROOT}/${1} ] && [[ "x${2}" =~ ^xOPT=.* ]] +then + TARGET=${1} + OPT=${2#*=} + python3 ${CASE_ROOT}/driver/src/driver.py --target=${TARGET} --run-path=${OUT_ROOT}/host/test --mod=${OPT} --j=${THREADS} --retry --report=${MAPLE_ROOT}/report.txt + +else + echo "Input Wrong~!" + exit 1 +fi diff --git a/testsuite/driver/src/__pycache__/case.cpython-35.pyc b/testsuite/driver/src/__pycache__/case.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b21231756a03f5b9a3ada79583dff43407fc1be8 Binary files /dev/null and b/testsuite/driver/src/__pycache__/case.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/env_var.cpython-35.pyc b/testsuite/driver/src/__pycache__/env_var.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec2e172e059f2f6e894ae9c7f3b7b11d11519715 Binary files /dev/null and b/testsuite/driver/src/__pycache__/env_var.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/mod_table.cpython-35.pyc b/testsuite/driver/src/__pycache__/mod_table.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0029e8c6b76a8ac209c90293532dfd363e3cfdc6 Binary files /dev/null and b/testsuite/driver/src/__pycache__/mod_table.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/shell_executor.cpython-35.pyc b/testsuite/driver/src/__pycache__/shell_executor.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0e5fc574141d052ea12f6221cac3d4e08b324c4f Binary files /dev/null and b/testsuite/driver/src/__pycache__/shell_executor.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/target.cpython-35.pyc b/testsuite/driver/src/__pycache__/target.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9b19455b0c40af1dee0018b51a47589b9ef714ce Binary files /dev/null and b/testsuite/driver/src/__pycache__/target.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/task.cpython-35.pyc b/testsuite/driver/src/__pycache__/task.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f735fee50e1fcb4fd987769af958a5d606f9365a Binary files /dev/null and b/testsuite/driver/src/__pycache__/task.cpython-35.pyc differ diff --git a/testsuite/driver/src/__pycache__/test_cfg.cpython-35.pyc b/testsuite/driver/src/__pycache__/test_cfg.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a05d749173631e694a9a01d87aa7e50d2af76f60 Binary files /dev/null and b/testsuite/driver/src/__pycache__/test_cfg.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__init__.py b/testsuite/driver/src/api/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..3a055c3126768375451e1e962ccf8ba049192afc --- /dev/null +++ b/testsuite/driver/src/api/__init__.py @@ -0,0 +1,32 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os + +names = locals() + +my_dir = os.path.dirname(__file__) +for py in os.listdir(my_dir): + if py == '__init__.py': + continue + + if py.endswith('.py'): + name = py[:-3] + + clsn = name.capitalize() + while clsn.find('_') > 0: + h = clsn.index('_') + clsn = clsn[0:h] + clsn[h + 1:].capitalize() + api = __import__("api." + name, fromlist=[clsn]) + names[clsn] = getattr(api, clsn) diff --git a/testsuite/driver/src/api/__pycache__/__init__.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8663fa20b1fec4c6d18ea2383b64f50ce497c57e Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/__init__.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/check_file_equal.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/check_file_equal.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c2856856e95aba4344e32fe273c59b1a46ff1529 Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/check_file_equal.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/dex2mpl.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/dex2mpl.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..570a917163a80273e57465c313dfad541a7e4fad Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/dex2mpl.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/irbuild.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/irbuild.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..771679250c5bdf25d0fdd742fed14590aa92a0c2 Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/irbuild.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/java2dex.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/java2dex.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19013382ea8940abc81bbb65baad87361ffcf202 Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/java2dex.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/linker.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/linker.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e2710b51e7a49066ba41865afe288f2ec5c35db8 Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/linker.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/maple.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/maple.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b8cc5bed029877385d56e9fd07af4c00094d87e Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/maple.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/mplsh.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/mplsh.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e06f689af941ff0d5a8e8a29318471f3f8ca539b Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/mplsh.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/shell.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/shell.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a95f35a949103d34d00161be8daa572aa6f79dcd Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/shell.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/__pycache__/shell_operator.cpython-35.pyc b/testsuite/driver/src/api/__pycache__/shell_operator.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c9e12ff01309251906e5eaf2b2db0f6cc692a220 Binary files /dev/null and b/testsuite/driver/src/api/__pycache__/shell_operator.cpython-35.pyc differ diff --git a/testsuite/driver/src/api/check_file_equal.py b/testsuite/driver/src/api/check_file_equal.py new file mode 100644 index 0000000000000000000000000000000000000000..ef4e000e25cb177f5e9b7559f6b694a874b91110 --- /dev/null +++ b/testsuite/driver/src/api/check_file_equal.py @@ -0,0 +1,27 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class CheckFileEqual(ShellOperator): + + def __init__(self, file1, file2, return_value_list=[0]): + super().__init__(return_value_list) + self.file1 = file1 + self.file2 = file2 + + def get_command(self, variables): + self.command = "diff " + self.file1 + " " + self.file2 + return super().get_final_command(variables) \ No newline at end of file diff --git a/testsuite/driver/src/api/dex2mpl.py b/testsuite/driver/src/api/dex2mpl.py new file mode 100644 index 0000000000000000000000000000000000000000..e272aa24ed049d15f3bfae5677b784af83f68ead --- /dev/null +++ b/testsuite/driver/src/api/dex2mpl.py @@ -0,0 +1,29 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Dex2mpl(ShellOperator): + + def __init__(self, dex2mpl, mplt, litprofile, infile, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.dex2mpl = dex2mpl + self.mplt = mplt + self.litprofile = litprofile + self.infile = infile + + def get_command(self, variables): + self.command = self.dex2mpl + " -mplt=" + self.mplt + " -litprofile=" + self.litprofile + " " + self.infile + return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/irbuild.py b/testsuite/driver/src/api/irbuild.py new file mode 100644 index 0000000000000000000000000000000000000000..28a4da8ab0acbb608e0eff7ca9c5ecf6054d87b6 --- /dev/null +++ b/testsuite/driver/src/api/irbuild.py @@ -0,0 +1,27 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Irbuild(ShellOperator): + + def __init__(self, irbuild, infile, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.irbuild = irbuild + self.infile = infile + + def get_command(self, variables): + self.command = self.irbuild + " " + self.infile + return super().get_final_command(variables) \ No newline at end of file diff --git a/testsuite/driver/src/api/java2dex.py b/testsuite/driver/src/api/java2dex.py new file mode 100644 index 0000000000000000000000000000000000000000..3dc5412ad4731d225ed9b651290238de2c556fe4 --- /dev/null +++ b/testsuite/driver/src/api/java2dex.py @@ -0,0 +1,28 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Java2dex(ShellOperator): + + def __init__(self, jar_file, outfile, infile, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.jar_file = jar_file + self.outfile = outfile + self.infile = infile + + def get_command(self, variables): + self.command = "${OUT_ROOT}/aarch64-clang-release/bin/java2dex -o " + self.outfile + " -p " + ":".join(self.jar_file) + " -i " + ":".join(self.infile) + return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/linker.py b/testsuite/driver/src/api/linker.py new file mode 100644 index 0000000000000000000000000000000000000000..559049d05e02c76ad639d641593232eb9427be29 --- /dev/null +++ b/testsuite/driver/src/api/linker.py @@ -0,0 +1,26 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Linker(ShellOperator): + + def __init__(self, lib, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.lib = lib + + def get_command(self, variables): + self.command = "${MAPLE_ROOT}/tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ -g3 -O2 -x assembler-with-cpp -march=armv8-a -target aarch64-linux-gnu -c ${APP}.VtableImpl.s && ${MAPLE_ROOT}/tools/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang++ ${APP}.VtableImpl.o -L${OUT_ROOT}/aarch64-clang-release/ops/" + self.lib + " -g3 -O2 -march=armv8-a -target aarch64-linux-gnu -fPIC -shared -o ${APP}.so ${OUT_ROOT}/aarch64-clang-release/ops/mrt_module_init.o -fuse-ld=lld -rdynamic -lcore-all -lcommon-bridge -Wl,-z,notext -Wl,-T${OUT_ROOT}/aarch64-clang-release/ops/linker/maplelld.so.lds" + return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/maple.py b/testsuite/driver/src/api/maple.py new file mode 100644 index 0000000000000000000000000000000000000000..0aed6e3403d2bcb01f7e62dd7b485a8c02f81a9d --- /dev/null +++ b/testsuite/driver/src/api/maple.py @@ -0,0 +1,36 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Maple(ShellOperator): + + def __init__(self, maple, run, option, global_option, infile, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.maple = maple + self.run = run + self.option_dict = option + self.global_option = global_option + self.infile = infile + + def get_command(self, variables): + self.command = self.maple + " --run=" + ":".join(self.run) + " " + option = [] + for cmd in self.run: + option.append(self.option_dict[cmd]) + self.command += "--option=\"" + ":".join(option) + "\" " + self.command += self.global_option + " " + self.command += "--infile " + self.infile + return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/mplsh.py b/testsuite/driver/src/api/mplsh.py new file mode 100644 index 0000000000000000000000000000000000000000..9cca1fbfb72d4239786b45cc0578d2dc0513b569 --- /dev/null +++ b/testsuite/driver/src/api/mplsh.py @@ -0,0 +1,47 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Mplsh(ShellOperator): + + def __init__(self, mplsh, xbootclasspath, infile, garbage_collection_kind, return_value_list=[0], env=None, qemu=None, qemu_libc=None, qemu_ld_lib=None, main="${APP}", args=None, redirection=None): + super().__init__(return_value_list, redirection) + self.env = env + self.qemu = qemu + self.qemu_libc = qemu_libc + self.qemu_ld_lib = qemu_ld_lib + self.mplsh = mplsh + self.garbage_collection_kind = garbage_collection_kind + self.xbootclasspath = xbootclasspath + self.infile = infile + self.main = main + self.args = args + + def get_command(self, variables): + self.command = "" + if self.env is not None: + for env_var in self.env.keys(): + self.command += env_var + "=" + self.env[env_var] + " " + if self.qemu is not None: + self.command += self.qemu + " -L " + self.qemu_libc + " -E LD_LIBRARY_PATH=" + ":".join(self.qemu_ld_lib) + " " + self.command += self.mplsh + " " + if self.garbage_collection_kind == "GC": + self.command += "-Xgconly " + if self.args is not None: + self.command +="-Xbootclasspath:" + self.xbootclasspath + " -cp " + self.infile + " " + self.main + " " + self.args + else: + self.command += "-Xbootclasspath:" + self.xbootclasspath + " -cp " + self.infile + " " + self.main + return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/shell.py b/testsuite/driver/src/api/shell.py new file mode 100644 index 0000000000000000000000000000000000000000..cc61ff79bd83c8474cd06ba069a337cad4d99037 --- /dev/null +++ b/testsuite/driver/src/api/shell.py @@ -0,0 +1,25 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api.shell_operator import ShellOperator + + +class Shell(ShellOperator): + + def __init__(self, command, return_value_list=[0], redirection=None): + super().__init__(return_value_list, redirection) + self.command = command + + def get_command(self, variables): + return super().get_final_command(variables) \ No newline at end of file diff --git a/testsuite/driver/src/api/shell_operator.py b/testsuite/driver/src/api/shell_operator.py new file mode 100644 index 0000000000000000000000000000000000000000..1560d614a2814fcd43efd20003c60306492f0f64 --- /dev/null +++ b/testsuite/driver/src/api/shell_operator.py @@ -0,0 +1,49 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +class ShellOperator(object): + + def __init__(self, return_value_list, redirection=None): + self.command = "" + self.return_value_list = return_value_list + self.redirection = redirection + + def get_redirection(self): + if self.redirection is not None: + return " > " + self.redirection + " 2>&1" + else: + return "" + + def get_check_command(self): + if len(self.return_value_list) == 1: + if 0 in self.return_value_list: + return "" + else: + return " || [ $? -eq " + str(self.return_value_list[0]) + " ]" + elif len(self.return_value_list) == 0: + return " || true" + else: + return_value_check_str_list = [] + for return_value in self.return_value_list: + return_value_check_str_list.append("[ ${return_value} -eq " + str(return_value) + " ]") + return " || (return_value=$? && (" + " || ".join(return_value_check_str_list) + "))" + + def get_final_command(self, variables): + final_command = self.command + if variables is not None: + for variable in variables.keys(): + final_command = final_command.replace("${" + variable + "}", variables[variable]) + final_command += self.get_redirection() + final_command += self.get_check_command() + return final_command \ No newline at end of file diff --git a/testsuite/driver/src/basic_tools/__init__.py b/testsuite/driver/src/basic_tools/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/testsuite/driver/src/basic_tools/__pycache__/__init__.cpython-35.pyc b/testsuite/driver/src/basic_tools/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db3d2ce02800906fde681dabc8047cd79d3bbaa1 Binary files /dev/null and b/testsuite/driver/src/basic_tools/__pycache__/__init__.cpython-35.pyc differ diff --git a/testsuite/driver/src/basic_tools/__pycache__/file.cpython-35.pyc b/testsuite/driver/src/basic_tools/__pycache__/file.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e6fde33a49e51efc9162db2e0efc6be979c234f2 Binary files /dev/null and b/testsuite/driver/src/basic_tools/__pycache__/file.cpython-35.pyc differ diff --git a/testsuite/driver/src/basic_tools/__pycache__/string.cpython-35.pyc b/testsuite/driver/src/basic_tools/__pycache__/string.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5df6c3b4ae8ede4205ba3666559b1c0067462e52 Binary files /dev/null and b/testsuite/driver/src/basic_tools/__pycache__/string.cpython-35.pyc differ diff --git a/testsuite/driver/src/basic_tools/__pycache__/string_list.cpython-35.pyc b/testsuite/driver/src/basic_tools/__pycache__/string_list.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3f35b97745d9f2a6410c6c3173d1ae7c9df53f70 Binary files /dev/null and b/testsuite/driver/src/basic_tools/__pycache__/string_list.cpython-35.pyc differ diff --git a/testsuite/driver/src/basic_tools/file.py b/testsuite/driver/src/basic_tools/file.py new file mode 100644 index 0000000000000000000000000000000000000000..878c99269516f46a4b8bb8d667245b613cf2b25d --- /dev/null +++ b/testsuite/driver/src/basic_tools/file.py @@ -0,0 +1,115 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os + +from .string import pre_deal + + +def read_file(file): + f = open(file, 'r') + source_lines = f.readlines() + f.close() + result_lines = [] + for line in source_lines: + result_lines.append(pre_deal(line)) + return result_lines + + +def read_file_in_string(file): + f = open(file, 'r') + str = f.read() + f.close() + return str + + +def file_exist(path, file): + target_file = search_file(path, file, equal) + if target_file == "": + return False + else: + return True + + +def directory_exist(path, dir): + target_file = search_dir(path, dir, equal) + if target_file == "": + return False + else: + return True + + +def lambda_fun(a, b, fun): + return fun(a, b) + + +def contain(a, b): + return True if a in b else False + + +def equal(a, b): + return True if a == b else False + + +def regular(a, b): + return True if a.match(b) else False + + +def search_dir(path, dir_name, type): + """Search directory in certain path""" + target_path = "" + for item in os.listdir(path): + item_path = os.path.join(path, item) + if os.path.isdir(item_path): + if lambda_fun(dir_name, item, type): + target_path = item_path + break + else: + target_path = search_dir(item_path, dir_name, type) + if target_path != "": + break + return target_path + + +def search_file(path, file_name, type): + """Search file in certain path""" + target_path = "" + for item in os.listdir(path): + item_path = os.path.join(path, item) + if os.path.isdir(item_path): + target_path = search_file(item_path, file_name, type) + if target_path != "": + break + elif os.path.isfile(item_path): + if lambda_fun(file_name, item, type): + target_path = item_path + break + return target_path + + +def search_all_file(path, file_name, type): + """Search all file in certain path""" + all_target_path = [] + target_path = [] + for item in os.listdir(path): + item_path = os.path.join(path, item) + if os.path.isdir(item_path): + target_path = search_all_file(item_path, file_name, type) + if target_path != []: + all_target_path += target_path + elif os.path.isfile(item_path): + if lambda_fun(file_name, item, type): + all_target_path.append(item_path) + break + return all_target_path diff --git a/testsuite/driver/src/basic_tools/string.py b/testsuite/driver/src/basic_tools/string.py new file mode 100644 index 0000000000000000000000000000000000000000..21ad8a4b0c6aa3432137c2e4cfca3161cf490664 --- /dev/null +++ b/testsuite/driver/src/basic_tools/string.py @@ -0,0 +1,190 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +def pre_deal(str): + str = rm_outermost_quotes(str) + str = rm_outermost_double_quotes(str) + str = rm_wrap(str) + str = rm_outermost_blank(str) + return str + + +def rm_outermost_blank(str): + return str.strip() + + +def rm_outermost_double_quotes(str): + if str.startswith('"') and str.endswith('"'): + return str[1:-1] + else: + return str + + +def rm_outermost_quotes(str): + if str.startswith("'") and str.endswith("'"): + return str[1:-1] + else: + return str + + +def rm_wrap(str): + if str.endswith('\n'): + return str.strip('\n') + else: + return str + + +def get_char_count(char, str): + count = 0 + for i in str: + if i == char: + count += 1 + return count + + +def get_outermost_layer_with_two_symbols(split_symbol1, split_symbol2, str): + if split_symbol1 not in str or split_symbol2 not in str: + return "" + result_str = "" + start = 0 + num = get_char_count(split_symbol2, str) + for char in str: + if char == split_symbol1: + if start == 0: + start = 1 + else: + result_str += char + elif char == split_symbol2: + num -= 1 + if num > 0 and start == 1: + result_str += char + else: + if num >= 1 and start == 1: + result_str += char + return result_str + + +def get_outermost_layer_with_one_symbol(split_symbol, str): + if split_symbol not in str: + return str + result_str = "" + num = get_char_count(split_symbol, str) + start = 0 + for char in str: + if char == split_symbol: + num -= 1 + if start == 0: + start = 1 + else: + if num > 0: + result_str += char + num -= 1 + else: + if start == 1: + result_str += char + return result_str + + +def get_string_in_outermost_brackets(str): + return get_outermost_layer_with_two_symbols('(', ')', str) + + +def get_string_in_outermost_double_quotes(str): + return get_outermost_layer_with_one_symbol('"', str) + + +def split_string_not_in_two_symbols(symbol1, symbol2, split_symbol, str): + in_or_not = 0 + split_list = [] + tmp = "" + for char in str: + if char == symbol1: + in_or_not += 1 + tmp += char + elif char == symbol2: + in_or_not -= 1 + tmp += char + elif char == split_symbol and in_or_not == 0: + split_list.append(tmp) + tmp = "" + else: + tmp += char + if tmp != "": + split_list.append(tmp) + return split_list + + +def split_string_not_in_the_same_symbols(symbol, split_symbol, str): + in_or_not = 0 + split_list = [] + tmp = "" + old_char = "" + for char in str: + if char == symbol and in_or_not == 0: + in_or_not = 1 + tmp += char + elif char == symbol and in_or_not == 1: + in_or_not = 0 + tmp += char + elif char == split_symbol and old_char != "\\" and in_or_not == 0: + split_list.append(tmp) + tmp = "" + else: + tmp += char + old_char = char + if tmp != "": + split_list.append(tmp) + return split_list + + +def split_string_by_comma_not_in_double_quotes(str): + return split_string_not_in_the_same_symbols('"', ',', str) + + +def contain_symbol_outside_outermost_two_symbols(symbol, symbol1, symbol2, str): + in_or_not = 0 + for char in str: + if char == symbol1: + in_or_not += 1 + elif char == symbol2: + in_or_not -= 1 + elif char == symbol and in_or_not == 0: + return True + else: + continue + return False + + +def contain_symbol_outside_outermost_the_same_symbols(symbol, symbol_in, str): + in_or_not = 0 + for char in str: + if char == symbol_in and in_or_not == 0: + in_or_not = 1 + elif char == symbol_in and in_or_not == 1: + in_or_not = 0 + elif char == symbol and in_or_not == 0: + return True + else: + continue + return False + + +def contain_symbol_outside_outermost_common_symbols(symbol, str): + pre_deal(str) + result1 = contain_symbol_outside_outermost_the_same_symbols(symbol, '"', str) + result2 = contain_symbol_outside_outermost_the_same_symbols(symbol, "'", str) + result3 = contain_symbol_outside_outermost_two_symbols(symbol, '(', ')', str) + result4 = contain_symbol_outside_outermost_two_symbols(symbol, '[', ']', str) + result5 = contain_symbol_outside_outermost_two_symbols(symbol, '{', '}', str) + return result1 & result2 & result3 & result4 diff --git a/testsuite/driver/src/basic_tools/string_list.py b/testsuite/driver/src/basic_tools/string_list.py new file mode 100644 index 0000000000000000000000000000000000000000..e6091fa47dd3a78755fc963ca228df24b5098935 --- /dev/null +++ b/testsuite/driver/src/basic_tools/string_list.py @@ -0,0 +1,30 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +def rm_wrap(string_list): + for index in range(len(string_list)): + string_list[index] = string_list[index].strip('\n') + + +def rm_note(string_list): + string_list_tmp = string_list + for line in string_list_tmp: + if line.startswith("#"): + string_list.remove(line) + + +def rm_outermost_double_quotes(string_list): + for item in range(len(string_list)): + if string_list[item].startswith('"') and string_list[item].endswith('"'): + string_list[item] = string_list[item][1:-1] diff --git a/testsuite/driver/src/case.py b/testsuite/driver/src/case.py new file mode 100644 index 0000000000000000000000000000000000000000..9c9f50b232aa544ef88b00326b7e6ba80c82d88f --- /dev/null +++ b/testsuite/driver/src/case.py @@ -0,0 +1,129 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os +import stat +import sys + +from api.shell import Shell +from test_cfg import TestCFG +from env_var import EnvVar +from mod import * +from shell_executor import ShellExecutor + + +class Case(object): + + def __init__(self, case_name, mods): + self.case_name = case_name + self.mods = mods + self.case_timeout = 900 + self.case_cpu = 0.7 + self.case_memory = 0 + self.test_cfg = TestCFG(os.path.join(EnvVar.TEST_SUITE_ROOT, self.case_name, "test.cfg")) + self.test_cfg_content = self.test_cfg.test_cfg + self.shell_command_suite = {} + + def parse_config_file(self): + for mod in self.mods: + self.shell_command_suite[mod] = [] + global_variables = {"CASE": self.case_name, "OPT": mod} + if mod in self.test_cfg_content.keys(): + mod_cfg_content = self.test_cfg_content[mod] + else: + mod_cfg_content = self.test_cfg_content["default"] + for line in mod_cfg_content: + if line[0] == "global": + global_variables.update(line[1]) + elif line[0] == "shell": + self.shell_command_suite[mod].append(Shell(line[1]).get_command(global_variables)) + else: + local_variables = line[1] + variables = global_variables.copy() + variables.update(local_variables) + phase = line[0] + if phase in globals()[mod].keys(): + for command_object in globals()[mod][phase]: + self.shell_command_suite[mod].append(command_object.get_command(variables)) + else: + print(line[0] + " not found !") + os._exit(1) + + def generate_test_script(self): + for mod in self.mods: + mod_file_path = os.path.join(EnvVar.TEST_SUITE_ROOT, self.case_name, "." + mod + "_test.sh") + f = open(mod_file_path, 'w') + f.write("#!/bin/bash\n") + f.write("set -e\n") + f.write("set -x\n") + for line in self.shell_command_suite[mod]: + f.write(line + '\n') + f.close() + os.chmod(mod_file_path, stat.S_IRWXU) + + def clean(self): + os.chdir(os.path.join(EnvVar.TEST_SUITE_ROOT, self.case_name)) + for mod in self.shell_command_suite.keys(): + for command in self.shell_command_suite[mod]: + if command.startswith("rm "): + os.system(command) + + def get_case_package(self): + case_list = [] + for mod in self.mods: + case_list.append({ + "name": self.case_name, + "memory": self.case_memory, + "cpu": self.case_cpu, + "option": mod, + "cmd": "cd ${WORKSPACE}/out/host/test/" + self.case_name + ";export OUT_ROOT=${WORKSPACE}/out;bash ." + mod + "_test.sh", + "timeout": self.case_timeout + }) + return case_list + + def run(self, detail = False): + result_table = {} + for mod in self.mods: + result, result_in_color = "PASSED", "\033[1;32mPASSED\033[0m" + log_file = open(os.path.join(EnvVar.TEST_SUITE_ROOT, self.case_name, mod + "_run.log"), "w+") + for command in self.shell_command_suite[mod]: + log_file.write("[[ CMD : " + command + " ]]\n") + if detail: + print("\033[1;32m[[ CMD : " + command + " ]]\033[0m") + exe = ShellExecutor(command=command, workdir=os.path.join(EnvVar.TEST_SUITE_ROOT, self.case_name), timeout=300) + exe.shell_execute() + if exe.com_out is not None and len(exe.com_out) != 0: + if detail: + print(exe.com_out) + log_file.write(exe.com_out + "\n") + if exe.com_err is not None and len(exe.com_err) != 0: + if detail: + print(exe.com_err) + log_file.write(exe.com_err + "\n") + if exe.return_code == 124: + if detail: + print("ERROR : TIMEOUT !") + log_file.write("ERROR : TIMEOUT !\n") + result, result_in_color = "TIMEOUT", "\033[1;33mTIMEOUT\033[0m" + break + elif exe.return_code != 0: + if detail: + print("ERROR : FAILED !") + log_file.write("ERROR : FAILED !\n") + result, result_in_color = "FAILED", "\033[1;31mFAILED\033[0m" + break + print(self.case_name + " " + mod + " " + result_in_color) + sys.stdout.flush() + result_table[mod] = result + return {self.case_name: result_table} diff --git a/testsuite/driver/src/driver.py b/testsuite/driver/src/driver.py new file mode 100644 index 0000000000000000000000000000000000000000..28b813bb53c7f0c02e80403590d269c8962c757d --- /dev/null +++ b/testsuite/driver/src/driver.py @@ -0,0 +1,154 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import json +import os +import sys +import shutil +import optparse +import multiprocessing + +from env_var import EnvVar +from target import Target +from mod_table import ModTable +from case import Case +from task import RunCaseTask, RunCasesTask, CleanCaseTask, GenShellScriptTask + +init_optparse = optparse.OptionParser() +env_args = init_optparse.add_option_group("Environment options") +env_args.add_option('--sdk-root', dest="sdk_root", default=None, help='Sdk location') +env_args.add_option('--test-suite-root', dest="test_suite_root", default=None, help='Test suite location') +env_args.add_option('--source-code-root', dest="source_code_root", default=None, help='Source code location') + +target_args = init_optparse.add_option_group("Target options") +target_args.add_option('--target', dest="target", help='Target. It can be a case, a module or a target suite') +env_args.add_option('--cmd-json-output', dest="cmd_json_output", default=None, help='Cmd json output location') +env_args.add_option('--report', dest="report", default=None, help="Report output location") +# TODO: Add executor +target_args.add_option('-j', '--jobs', dest="jobs", type=int, default=multiprocessing.cpu_count(), help='Number of parallel jobs') +target_args.add_option('--retry', dest="retry", action='store_true', default=False, help='Rerun failed and timeout cases') +target_args.add_option('--run-path', dest="run_path", default=None, help='Where to run cases') +target_args.add_option('--mod', dest="mod", default=None, help='Which mod to run') +# TODO: Add phone test +target_args.add_option('--platform', dest="platform", default="qemu", help='qemu or phone') +target_args.add_option('--clean', dest="clean", action='store_true', default=False, help='clean the path') + +package = { + 'container_image': "cpl-eqm-docker-sh.rnd.huawei.com/valoran-run:0.6", + 'case_retry_num': 4, + 'total_retry_num': 1000 +} + + +# TODO: Only Copy dirs to be used +def prebuild(run_path): + if run_path is not None: + if os.path.exists(run_path): + shutil.rmtree(run_path) + os.makedirs(run_path) + for dir in os.listdir(EnvVar.TEST_SUITE_ROOT): + if dir.endswith("_test"): + shutil.copytree(os.path.join(EnvVar.TEST_SUITE_ROOT, dir), os.path.join(run_path, dir)) + EnvVar.TEST_SUITE_ROOT = run_path + +def main(orig_args): + opt, args = init_optparse.parse_args(orig_args) + if args: + init_optparse.print_usage() + sys.exit(1) + + sdk_root = opt.sdk_root + test_suite_root = opt.test_suite_root + source_code_root = opt.source_code_root + run_path = opt.run_path + target = opt.target + clean = opt.clean + cmd_json_output = opt.cmd_json_output + jobs = opt.jobs + retry = opt.retry + mod = opt.mod + report = opt.report + + EnvVar(sdk_root, test_suite_root, source_code_root) + prebuild(run_path) + + mod_tables = {} + if target + ".conf" in os.listdir(EnvVar.CONFIG_FILE_PATH): + mod_tables[target] = ModTable(os.path.join(EnvVar.CONFIG_FILE_PATH, target + ".conf")) + else: + for file in os.listdir(EnvVar.CONFIG_FILE_PATH): + if file.endswith("conf") and file != "testallops.conf" : + mod_tables[file.split(".")[0]] = ModTable(os.path.join(EnvVar.CONFIG_FILE_PATH, file)) + + if clean: + target_mod_set = set() + for mod_table in mod_tables.keys(): + target_mod_set = target_mod_set.union(mod_tables[mod_table].get_target_mod_set(target)) + the_case = Case(target, target_mod_set) + task = CleanCaseTask(the_case) + task.run() + sys.exit(0) + + if target in mod_tables.keys(): + targets = mod_tables[target].get_targets() + elif os.path.exists(os.path.join(EnvVar.TEST_SUITE_ROOT, target)): + targets = [target] + else: + print("Target " + target + " doesn't exist !") + sys.exit(1) + + case_names = set() + cases = [] + for target in targets: + the_target = Target(target) + case_names = case_names.union(the_target.get_cases()) + + for case_name in case_names: + mod_set = set() + default_mod_set = set() + for mod_table in mod_tables.keys(): + default_mod_set = default_mod_set.union(mod_tables[mod_table].get_target_mod_set(case_name)) + if mod is not None: + if mod in default_mod_set: + mod_set = {mod} + elif len(case_names) == 1: + print(case_name + " doesn't have OPT " + mod) + print(case_name + " OPT : " + str(default_mod_set)) + sys.exit(1) + else: + mod_set = default_mod_set + if len(mod_set) != 0: + cases.append(Case(case_name, mod_set)) + + if cmd_json_output is not None: + task = GenShellScriptTask(cases) + task.run() + package["tasks"] = task.get_command_package() + with open(opt.cmd_json_output, 'w') as f: + json.dump(package, f) + elif len(cases) == 1: + task = RunCaseTask(cases[0], detail=True) + task.run() + else: + task = RunCasesTask(cases, process_num=jobs, detail=False) + task.run() + task.result_parse() + if retry: + task.run_again() + if report is not None: + task.gen_report(report) + sys.exit(1) + +if __name__ == '__main__': + main(sys.argv[1:]) diff --git a/testsuite/driver/src/env_var.py b/testsuite/driver/src/env_var.py new file mode 100644 index 0000000000000000000000000000000000000000..88976b94c00685eb58d7f00ddcaee8f54640a2ff --- /dev/null +++ b/testsuite/driver/src/env_var.py @@ -0,0 +1,51 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os +import sys + +class EnvVar(object): + + SDK_ROOT = None + TEST_SUITE_ROOT = None + SOURCE_CODE_ROOT = None + #TODO:Delete + CONFIG_FILE_PATH = None + + def __init__(self, sdk_root, test_suite_root, source_code_root): + if sdk_root is None: + if "OUT_ROOT" in os.environ.keys(): + EnvVar.SDK_ROOT = os.environ["OUT_ROOT"] + else: + print("Please source zeiss/envsetup.sh") + sys.exit(1) + else: + EnvVar.SDK_ROOT = sdk_root + if test_suite_root is None: + if "CASE_ROOT" in os.environ.keys(): + EnvVar.TEST_SUITE_ROOT = os.environ["CASE_ROOT"] + else: + print("Please source zeiss/envsetup.sh") + sys.exit(1) + else: + EnvVar.TEST_SUITE_ROOT = test_suite_root + if source_code_root is None: + if "MAPLE_ROOT" in os.environ.keys(): + EnvVar.SOURCE_CODE_ROOT = os.environ["MAPLE_ROOT"] + else: + print("Please source zeiss/envsetup.sh") + sys.exit(1) + else: + EnvVar.SOURCE_CODE_ROOT = source_code_root + EnvVar.CONFIG_FILE_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "config") \ No newline at end of file diff --git a/testsuite/driver/src/mod/IR.py b/testsuite/driver/src/mod/IR.py new file mode 100644 index 0000000000000000000000000000000000000000..bec21265c3f0c24b1f5503672b81777bf71a770c --- /dev/null +++ b/testsuite/driver/src/mod/IR.py @@ -0,0 +1,37 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api import * + +IR = { + "clean": [ + Shell( + "rm -rf *.irb.mpl" + ) + ], + "compile": [ + Irbuild( + irbuild="${OUT_ROOT}/aarch64-clang-release/bin/irbuild", + infile="${APP}.mpl" + ), + Irbuild( + irbuild="${OUT_ROOT}/aarch64-clang-release/bin/irbuild", + infile="${APP}.irb.mpl" + ), + CheckFileEqual( + file1="${APP}.irb.mpl", + file2="${APP}.irb.irb.mpl" + ) + ] +} diff --git a/testsuite/driver/src/mod/O0.py b/testsuite/driver/src/mod/O0.py new file mode 100644 index 0000000000000000000000000000000000000000..6cd43dcff0060a66c15bf3db7ffc9bc928b418ee --- /dev/null +++ b/testsuite/driver/src/mod/O0.py @@ -0,0 +1,73 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +from api import * + +O0 = { + "clean": [ + Shell( + "rm -rf *.mpl *.dex *.class *.mplt *.s *.so *.o *.log *.jar" + ) + ], + "compile": [ + Java2dex( + jar_file=[ + "${OUT_ROOT}/aarch64-clang-release/ops/third_party/JAVA_LIBRARIES/core-oj_intermediates/classes.jar", + "${OUT_ROOT}/aarch64-clang-release/ops/third_party/JAVA_LIBRARIES/core-libart_intermediates/classes.jar" + ], + outfile="${APP}.dex", + infile=["${APP}.java","${EXTRA_JAVA_FILE}"] + ), + Dex2mpl( + dex2mpl="${OUT_ROOT}/aarch64-clang-release/bin/dex2mpl", + mplt="${OUT_ROOT}/aarch64-clang-release/libjava-core/libcore-all.mplt", + litprofile="${MAPLE_ROOT}/src/mrt/codetricks/profile.pv/meta.list", + infile="${APP}.dex" + ), + Maple( + maple="${OUT_ROOT}/aarch64-clang-release/bin/maple", + run=["me", "mpl2mpl", "mplcg"], + option={ + "me": "--quiet", + "mpl2mpl": "--quiet --regnativefunc --maplelinker --emitVtableImpl", + "mplcg": "--quiet --no-pie --fpic --verbose-asm --maplelinker" + }, + global_option="", + infile="${APP}.mpl" + ), + Linker( + lib="host-x86_64-O2", + ) + ], + "run": [ + Mplsh( + qemu="/usr/bin/qemu-aarch64", + qemu_libc="/usr/aarch64-linux-gnu", + qemu_ld_lib=[ + "${OUT_ROOT}/aarch64-clang-release/ops/third_party", + "${OUT_ROOT}/aarch64-clang-release/ops/host-x86_64-O2", + "./" + ], + mplsh="${OUT_ROOT}/aarch64-clang-release/ops/mplsh", + garbage_collection_kind="RC", + xbootclasspath="libcore-all.so", + infile="${APP}.so", + redirection="output.log" + ), + CheckFileEqual( + file1="output.log", + file2="expected.txt" + ) + ] +} diff --git a/testsuite/driver/src/mod/__init__.py b/testsuite/driver/src/mod/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..be57481822a245ede96d64336c323752b4053ecd --- /dev/null +++ b/testsuite/driver/src/mod/__init__.py @@ -0,0 +1,26 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os + +mod_dict = locals() +my_dir = os.path.dirname(__file__) +for py in os.listdir(my_dir): + if py == '__init__.py': + continue + + if py.endswith('.py'): + name = py[:-3] + mod = __import__(__name__, globals(), locals(), ['%s' % name]) + mod_dict[name] = getattr(getattr(mod, name), name) \ No newline at end of file diff --git a/testsuite/driver/src/mod/__pycache__/IR.cpython-35.pyc b/testsuite/driver/src/mod/__pycache__/IR.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eaec7124a87cac5bca08788287f6d34dde377e2c Binary files /dev/null and b/testsuite/driver/src/mod/__pycache__/IR.cpython-35.pyc differ diff --git a/testsuite/driver/src/mod/__pycache__/O0.cpython-35.pyc b/testsuite/driver/src/mod/__pycache__/O0.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..587283e7b69521dfca7737f9557de8c14b0920c4 Binary files /dev/null and b/testsuite/driver/src/mod/__pycache__/O0.cpython-35.pyc differ diff --git a/testsuite/driver/src/mod/__pycache__/__init__.cpython-35.pyc b/testsuite/driver/src/mod/__pycache__/__init__.cpython-35.pyc new file mode 100644 index 0000000000000000000000000000000000000000..07fa443c291699471c1a5d25dc23fefd869d7e9c Binary files /dev/null and b/testsuite/driver/src/mod/__pycache__/__init__.cpython-35.pyc differ diff --git a/testsuite/driver/src/mod_table.py b/testsuite/driver/src/mod_table.py new file mode 100644 index 0000000000000000000000000000000000000000..1884a62a42017b232332e540ddabfe30d490a66e --- /dev/null +++ b/testsuite/driver/src/mod_table.py @@ -0,0 +1,71 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os + +from basic_tools.file import read_file + +class ModTable(object): + + def __init__(self, table_file): + global key + mod_table_content_tmp = read_file(table_file) + self.mod_table_content = {} + for line in mod_table_content_tmp: + line = line.replace(" ", "") + if line == "" or line.startswith("#"): + continue + elif line.startswith("["): + key = line.split("[")[1].split("]")[0] + self.mod_table_content[key] = {} + elif line.endswith(":all"): + target = line.split(":")[0] + self.mod_table_content[key][target] = {"all"} + else: + target = line.split(":")[0] + mod_set = set(line.split(":")[1].split(",")) + if target in self.mod_table_content[key].keys(): + self.mod_table_content[key][target] = self.mod_table_content[key][target].union(mod_set) + else: + self.mod_table_content[key][target] = mod_set + self.mod_table = {} + self._parse() + + def _parse(self): + self.mod_table = self.mod_table_content["DEFAULT_SUITE"] + if "OPTION_SUITE" in self.mod_table_content.keys(): + for options in self.mod_table_content["OPTION_SUITE"].keys(): + for target in self.mod_table.keys(): + if options in self.mod_table[target]: + self.mod_table[target].remove(options) + self.mod_table[target] = self.mod_table[target].union(self.mod_table_content["OPTION_SUITE"][options]) + if "BAN_SUITE" in self.mod_table_content.keys(): + for target in self.mod_table_content["BAN_SUITE"].keys(): + if "all" in self.mod_table_content["BAN_SUITE"][target]: + self.mod_table[target] = set() + continue + father_target = target + while father_target not in self.mod_table.keys(): + father_target = os.path.dirname(father_target) + self.mod_table[target] = self.mod_table[father_target] - self.mod_table_content["BAN_SUITE"][target] + + def get_target_mod_set(self, target): + while target not in self.mod_table.keys() and len(target) != 0: + target = os.path.dirname(target) + if len(target) == 0: + return set() + return self.mod_table[target] + + def get_targets(self): + return self.mod_table.keys() diff --git a/testsuite/driver/src/shell_executor.py b/testsuite/driver/src/shell_executor.py new file mode 100644 index 0000000000000000000000000000000000000000..b2a0b66d38fa10cb681d06d9992fb85a98a37809 --- /dev/null +++ b/testsuite/driver/src/shell_executor.py @@ -0,0 +1,48 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os +import locale +import subprocess +import signal + + +class ShellExecutor(object): + + def __init__(self, command, workdir, timeout): + self.command = command + self.workdir = workdir + self.timeout = timeout + self.return_code = None + self.com_out = None + self.com_err = None + + def shell_execute(self): + process_command = subprocess.Popen(self.command, shell=True, cwd=self.workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + try: + self.com_out, self.com_err = process_command.communicate(timeout=self.timeout) + except subprocess.CalledProcessError as err: + self.return_code, self.com_out, self.com_err = err.returncode, "", err + except subprocess.TimeoutExpired: + self.return_code, self.com_out, self.com_err = 124, "", "timeout" + else: + self.return_code = process_command.returncode + self.com_out = self.com_out.decode(locale.getpreferredencoding(False), errors="strict").strip() + self.com_err = self.com_err.decode(locale.getpreferredencoding(False), errors="strict").strip() + finally: + process_command.kill() + try: + os.killpg(process_command.pid, signal.SIGTERM) + except ProcessLookupError: + pass \ No newline at end of file diff --git a/testsuite/driver/src/target.py b/testsuite/driver/src/target.py new file mode 100644 index 0000000000000000000000000000000000000000..5000a111c2794d4de3a3e0b15c93d7220ebd0dad --- /dev/null +++ b/testsuite/driver/src/target.py @@ -0,0 +1,41 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import os +import re + +from env_var import EnvVar + +class Target(object): + + case_regx = re.compile('^[A-Z]{1,5}[0-9]{3,10}-[a-zA-Z0-9_.]') + module_regx = re.compile('^[a-z0-9_]{1,20}_test$') + + def __init__(self, target): + self.target = target + self.cases = set() + + def get_cases(self): + if Target.case_regx.match(self.target.split('/')[-1]): + self.cases.add(self.target) + elif Target.module_regx.match(self.target.split('/')[-1]): + subtarget_list = [self.target] + while subtarget_list: + subtarget = subtarget_list.pop(0) + for dir in os.listdir(os.path.join(EnvVar.TEST_SUITE_ROOT, subtarget)): + if Target.case_regx.match(dir): + self.cases.add(os.path.join(subtarget, dir)) + elif Target.module_regx.match(dir): + subtarget_list.append(os.path.join(subtarget, dir)) + return self.cases diff --git a/testsuite/driver/src/task.py b/testsuite/driver/src/task.py new file mode 100644 index 0000000000000000000000000000000000000000..b7a7061d977bab6f747e0062910248a6cfcfbb7b --- /dev/null +++ b/testsuite/driver/src/task.py @@ -0,0 +1,154 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import sys +import time + +from multiprocessing import Pool, cpu_count, Manager +from case import Case + +class Task(object): + + def __init__(self, cases): + self.cases = cases + + def run(self): + pass + + + +class CleanCaseTask(Task): + + def __init__(self, case): + super().__init__(case) + self.case = case + + def run(self): + self.case.parse_config_file() + self.case.clean() + +class GenShellScriptTask(Task): + + def __init__(self, cases): + super().__init__(cases) + self.command_pachage = [] + + def run(self): + for case in self.cases: + case.parse_config_file() + case.generate_test_script() + self.command_pachage += case.get_case_package() + + def get_command_package(self): + return self.command_pachage + + +class RunCaseTask(Task): + + def __init__(self, case, detail): + super().__init__(case) + self.case = case + self.detail = detail + + def run(self): + sys.stdout.flush() + self.case.parse_config_file() + return self.case.run(self.detail) + +class RunCasesTask(Task): + + def __init__(self, cases, process_num, detail): + super().__init__(cases) + self.process_num = process_num + self.detail = detail + self.pass_num = 0 + self.fail_num = 0 + self.timeout_num = 0 + self.fail_cases_list = [] + self.timeout_cases_list = [] + self.again_cases = [] + self.results = {} + + def run(self): + pool = Pool(min(cpu_count(), self.process_num)) + return_results = [] + for case in self.cases: + task = RunCaseTask(case, self.detail) + return_results.append(pool.apply_async(task.run, ())) + finished = 0 + total = len(self.cases) + while total != finished: + time.sleep(1) + finished = sum([return_result.ready() for return_result in return_results]) + self.get_results(return_results) + pool.close() + pool.join() + + def get_results(self, return_results: list): + for return_result in return_results: + self.results.update(return_result.get()) + + def result_parse(self): + for case_name in self.results.keys(): + again_mod = set() + for mod in self.results[case_name].keys(): + if self.results[case_name][mod] == "PASSED": + self.pass_num += 1 + elif self.results[case_name][mod] == "FAILED": + self.fail_cases_list.append(case_name + " " + mod) + again_mod.add(mod) + elif self.results[case_name][mod] == "TIMEOUT": + self.timeout_cases_list.append(case_name + " " + mod) + again_mod.add(mod) + if len(again_mod) != 0: + self.again_cases.append(Case(case_name, again_mod)) + self.fail_num = len(self.fail_cases_list) + self.timeout_num = len(self.timeout_cases_list) + if len(self.again_cases) == 0: + print("============ ALL CASE RUN SUCCESSFULLY ================") + sys.exit(0) + print("=========== case total num : " + str(self.pass_num + self.fail_num + self.timeout_num) + " passed num : " + str(self.pass_num) + " failed num : " + str(self.fail_num) + " timeout num : " + str(self.timeout_num) + " ================") + print() + if self.fail_num != 0: + print("failed case list:") + for index in self.fail_cases_list: + print(index) + print() + if self.timeout_num != 0: + print("timeout case list:") + for index in self.timeout_cases_list: + print(index) + print() + + def run_again(self): + print("========== Retry Begin =============") + sub_task = RunCasesTask(self.again_cases, process_num=1, detail=True) + sub_task.run() + sub_task.result_parse() + + def gen_report(self, report): + if len(self.again_cases) != 0: + f = open(report, 'w') + f.write("=========== case total num : " + str(self.pass_num + self.fail_num + self.timeout_num) + " passed num : " + str(self.pass_num) + " failed num : " + str(self.fail_num) + " timeout num : " + str(self.timeout_num) + " ================\n") + f.write("\n") + if self.fail_num != 0: + f.write("failed case list:\n") + for index in self.fail_cases_list: + f.write(index + "\n") + f.write("\n") + if self.timeout_num != 0: + f.write("timeout case list:\n") + for index in self.timeout_cases_list: + f.write(index + "\n") + f.close() diff --git a/testsuite/driver/src/test_cfg.py b/testsuite/driver/src/test_cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..b6e0c86f2cc802443035c6c2980bd93394bada33 --- /dev/null +++ b/testsuite/driver/src/test_cfg.py @@ -0,0 +1,62 @@ +# +# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. +# +# OpenArkCompiler is licensed under Mulan PSL v2. +# You can use this software according to the terms and conditions of the Mulan PSL v2. +# +# http://license.coscl.org.cn/MulanPSL2 +# +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR +# FIT FOR A PARTICULAR PURPOSE. +# See the Mulan PSL v2 for more details. +# + +import re + +from basic_tools.file import read_file +from basic_tools.string_list import * +from basic_tools.string import split_string_by_comma_not_in_double_quotes, get_string_in_outermost_brackets + +class TestCFG(object): + + mod_phase_pattern = re.compile('^[0-9a-zA-Z_]+$') + + def __init__(self, test_cfg_path): + self.test_cfg_content = read_file(test_cfg_path) + rm_note(self.test_cfg_content) + rm_wrap(self.test_cfg_content) + self.test_cfg = {"default":[]} + self.parse_test_cfg_contest() + + def parse_test_cfg_contest(self): + mod_list = ["default"] + for line in self.test_cfg_content: + if line.endswith(":"): + mod_list = line[:-1].split(",") + for mod in mod_list: + self.test_cfg[mod] = [] + else: + for mod in mod_list: + if "(" in line and line[-1] == ")" and TestCFG.mod_phase_pattern.match(line.split("(")[0]): + phase = line.split("(")[0] + variable_table = {} + variables_list = split_string_by_comma_not_in_double_quotes(get_string_in_outermost_brackets(line)) + for variable in variables_list: + if "=" in variable: + variable_name = variable.split("=")[0] + variable_value = "=".join(variable.split("=")[1:]) + if variable_value.startswith('"') and variable_value.endswith('"'): + variable_value = variable_value[1:-1] + variable_table[variable_name] = variable_value + else: + variable_table["APP"] = variable + self.test_cfg[mod].append((phase, variable_table)) + elif "=" in line and " " not in line: + global_variable_name = line.split("=")[0] + global_variable_value = "=".join(line.split("=")[1:]) + if global_variable_value.startswith('"') and global_variable_value.endswith('"'): + global_variable_value = global_variable_value[1:-1] + self.test_cfg[mod].append(("global", {global_variable_name: global_variable_value})) + else: + self.test_cfg[mod].append(("shell", line)) \ No newline at end of file diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Info.txt b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Info.txt new file mode 100644 index 0000000000000000000000000000000000000000..e57ec8eb2c11638fc8a0375f3dcc1bfa5bfb70ee --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Info.txt @@ -0,0 +1,2 @@ +#Addf32 test +#Test case for fload add with 32bit architecture diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Main.mpl b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..ed1c250fcdf70fc71419fbbb69e39c86aa0c1180 --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/Main.mpl @@ -0,0 +1,15 @@ + func &addf32r( + var %i f32, var %j f32 + ) f32 { + return ( + add f32(dread f32 %i, dread f32 %j))} + + func &addf32I ( + var %i f32 + ) f32 { + return ( + add f32(dread f32 %i, + constval f32 1.234f))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/addf32_main.c b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/addf32_main.c new file mode 100644 index 0000000000000000000000000000000000000000..03bade47fe2ea55bc5caf37468c49fa4ea5443ea --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/addf32_main.c @@ -0,0 +1,8 @@ +extern float addf32r(float, float); +extern float addf32I(float); + +int main(){ + printf("%f vs %f\n", addf32r(1.2345, -1.234f), 1.2345 - 1.234); + printf("%f vs %f\n", addf32I(-2.2222), -2.2222 + 1.234f); +} + diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.mplme.txt b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.txt b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/test.cfg b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0001-mapleall-irbuild-edge-addf32/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/Main.mpl b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..b93dc8e37e7b9e31edbb1d181f3d54481aea05fe --- /dev/null +++ b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/Main.mpl @@ -0,0 +1,15 @@ + func $fooi64 ( + var %i i64, var %j i64 + ) i64 { + return ( + add i64(dread i64 %i, dread i64 %j))} + + func $addi64I ( + var %i i64 + ) i64 { + return ( +#add i64(dread i64 %i, constval i64 0x123456789))} + add i64(dread i64 %i, constval i64 0x800000115))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/addi64_main.c b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/addi64_main.c new file mode 100644 index 0000000000000000000000000000000000000000..62dbc25137f80b54c278f6b30c2d540ada391a7c --- /dev/null +++ b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/addi64_main.c @@ -0,0 +1,22 @@ +#include "typedef.h" +extern int64 fooi64(int64 a ,int64 b); +extern int64 addi64I(int64 a); + +int main() { + if (fooi64(0x1234343, 0x123456789) == (0x1234343+0x123456789)) + printf("%llx pass\n", fooi64(0x1234343, 0x123456789)); + else + printf("failed\n"); + if (addi64I(0x1234343) == (0x1234343+0x123456789)) + printf("pass\n"); + else { + printf("failed\n"); + printf("%llx vs 0x12468aacc\n", addi64I(0x1234343)); + } + if (addi64I(0x800000008) == (0x800000008 + 0x800000008)) + printf("pass3\n"); + else { + printf("failed3\n"); + printf("%llx\n", addi64I(0x800000008)); + } +} diff --git a/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.mplme.txt b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.txt b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/test.cfg b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0002-mapleall-irbuild-edge-addi64/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/Main.mpl b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..4164e27feb5fcfc12b594bec646e87429eb9e62b --- /dev/null +++ b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/Main.mpl @@ -0,0 +1,17 @@ + func $foo1 ( + var %i i32, var %j i32 + ) i32 { + return ( + add i32(dread i32 %i, dread i32 %j))} + + func $addi32I ( + var %i i32 + ) i32 { + return ( + add i32(dread i32 %i, +#constval i32 0xfff))} +# constval i32 0xffff))} + constval i32 0xfffff))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/addi_main.c b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/addi_main.c new file mode 100644 index 0000000000000000000000000000000000000000..f5d09d7e4c2a705e14caf5eae026749eeb7c1ac9 --- /dev/null +++ b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/addi_main.c @@ -0,0 +1,7 @@ +extern int foo1(int a ,int b); +extern int addi32I(int a); + +int main() { + printf("%d\n", foo1(7,5)); + printf("%d\n", addi32I(7)); +} diff --git a/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.mplme.txt b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.txt b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/test.cfg b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0003-mapleall-irbuild-edge-addi/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/Main.mpl b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..f0229b09393423172997ee3f56ca7795d711216a --- /dev/null +++ b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/Main.mpl @@ -0,0 +1,69 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + add i32(dread i32 %i, + constval i32 -998))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + add i32(dread i32 %i, dread i32 %j))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + add i32(dread i32 %i, constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + add i64(dread i64 %i, constval i64 0x111111111))} + + func $foo4 ( + var %i i64, var %j i64, var %k i32 + )i64 { + return ( + add i64(dread i64 %i, dread i64 %j))} + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + add i64(dread i64 %i, constval i64 0x11111))} + + func $foo6 ( + var %i f64, var %j f64, var %k i32 + ) f64 { + return ( + add f64(dread f64 %i, constval f64 2.237))} + + func $foo66 ( + var %i f64, var %j f64, var %k i32 + ) f64 { + return ( + add f64(dread f64 %i, constval f64 2.237))} + func $foo7 ( + var %i f32, var %j f32, var %k i32 + ) f32 { + return ( + add f32(dread f32 %i, dread f32 %j))} + + func $foo8 ( + var %i f32, var %j f32, var %k i32 + ) f32 { + return ( + add f32(dread f32 %i, constval f32 2.237f))} + + func $foo9 ( + var %i i8, var %j u8, var %k i32) i32 { + return ( + add i32(dread i32 %i, dread u32 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/add_main.c b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/add_main.c new file mode 100644 index 0000000000000000000000000000000000000000..ec1c66e3ded3f37403bbddf9bc66c091b4afd82b --- /dev/null +++ b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/add_main.c @@ -0,0 +1,5 @@ +extern int foo1(int a ,int b); + +int main() { + return foo1(7,5); +} diff --git a/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.mplme.txt b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.txt b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/test.cfg b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0004-mapleall-irbuild-edge-add/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/Main.mpl b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..6a12bf5e8c4014a5c556bf8d1f8946cad643fbc1 --- /dev/null +++ b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/Main.mpl @@ -0,0 +1,24 @@ +var $arr1 <[10] i32> +var $arr2 <[10] i32> +var $arr3 <[10] i32> + +func $ArrayAdd () void { + var %i i32 + doloop %i ( + constval i32 0, + lt i32 i32 (dread i32 %i, constval i32 10), + add i32(dread i32 %i, constval i32 1)){ + iassign <* [10] i32>( + array 1 a32 <* [10] i32>(addrof a32 $arr1, dread i32 %i), + add i32( + iread i32 <* [10] i32>( + array 1 a32 <* [10] i32>(addrof a32 $arr2, dread i32 %i)), + iread i32 <* [10] i32>( + array 1 a32 <* [10] i32>(addrof a32 $arr3, dread i32 %i)) + )) + } + return() +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.mplme.txt b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.txt b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/test.cfg b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0005-mapleall-irbuild-edge-arrayadd/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/Main.mpl b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3f0dd9f3814eb67a6c31c9f1bb03414579ba1105 --- /dev/null +++ b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/Main.mpl @@ -0,0 +1,12 @@ +var $iconst1 <[4] [4] i32> = [ [1007, 707, -273, 75], [0113, 0x4b, 75u, 75l], [75ul, 75lu, 31425926, 60223], [60223, 1619, 30, 314159]] +var $fconst1 <[4] [4] f64> = [ [1007.0, 707.0, -273.0, 75.0], [113.1, 4.0, 75.0, 75.1], [75.0, 75.1, 3.1425926, 6.02e23], [6.02e+23, 1.6e-19, 3.0, 3.14159]] +func &printf (var %p1 <* i8>)void +func &main ( ) i32 { + call &printf (addrof a32 $fconst1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.mplme.txt b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.txt b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/test.cfg b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0006-mapleall-irbuild-edge-arrayinit/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/Main.mpl b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..82200c59f71e249301b6c4fefb811eb4b7a8dae3 --- /dev/null +++ b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/Main.mpl @@ -0,0 +1,19 @@ +var $i i32 align(4) = 987 +type $SS1 +var $iconst1 <[4] [4] i32> const = [ [1007, 707, -273, 75], [0113, 0x4b, 75u, 75l], [75ul, 75lu, 31425926, 60223], [60223, 1619, 30, 314159]] +var $fconst1 <[4] [4] f64 > volatile = [ [1007.0, 707.0, -273.0, 75.0], [113.1, 4.0, 75.0, 75.1], [75.0, 75.1, 3.1425926, 6.02e23], [6.02e+23, 1.6e-19, 3.0, 3.14159]] +func &printf const static varargs (var %p1 <* i8 > volatile const, var %p2 <* i32> volatile)void +func &noarg varargs ( ... ) void +func $main static ( ) i32 { + var %jj i32 volatile align(16) + call &printf (addrof a32 $fconst1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.mplme.txt b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.txt b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/test.cfg b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0007-mapleall-irbuild-edge-attributes/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/Main.mpl b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..6b716d0e83ed8c381af78ebf3ce46eb3f8e73b8d --- /dev/null +++ b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/Main.mpl @@ -0,0 +1,41 @@ + func $band32I ( + var %i i32 + ) i32 { + return ( + band i32(dread i32 %i, + constval i32 0x12))} + func $band32I_2 ( + var %i i32 + ) i32 { + return ( + band i32(dread i32 %i, + constval i32 0x112))} + func $band32RR ( + var %i i32, var %j i32 + ) i32 { + return ( + band i32(dread i32 %i, + dread i32 %j))} + + func $band64I ( + var %i i64 + ) i64 { + return ( + band i64(dread i64 %i, + constval i64 0x1200000015))} + func $band64I_2 ( + var %i i64 + ) i64 { + return ( + band i64(dread i64 %i, + constval i64 0x1200000115))} + func $band64RR ( + var %i i64, + var %j i64 + ) i64 { + return ( + band i64(dread i64 %i, + dread i64 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/band_main.c b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/band_main.c new file mode 100644 index 0000000000000000000000000000000000000000..a6133cf67aee7d52a51069c9234628efe7adfac7 --- /dev/null +++ b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/band_main.c @@ -0,0 +1,48 @@ +extern int band32I(int a); +extern int band32I_2(int a); +extern int band32RR(int a, int b); + +extern long long band64I(long long a); +extern long long band64I_2(long long a); +extern long long band64RR(long long a, long long b); + +int main() { + + if((7 & 0x12)== band32I(7)) + printf("band32I pass.\n"); + else { + printf("band32I false.\n"); + return 1; + } + if((7 & 0x112)== band32I_2(7)) + printf("band32I_2 pass.\n"); + else { + printf("band32I_2 false.\n"); + return 1; + } + if((7 & 5)== band32RR(7, 5)) + printf("band32RR pass.\n"); + else { + printf("band32RR false.\n"); + return 1; + } + if((0x1200000007 & 0x1200000015)== band64I(0x1200000007)) + printf("band64I pass.\n"); + else { + printf("band64I false.\n"); + return 1; + } + if((0x1200000115 & 0x11200000127)== band64I_2(0x11200000127)) + printf("band64I_2 pass.\n"); + else { + printf("band64I_2 false.\n"); + return 1; + } + if((0x1200000007 & 0x11200000127)== band64RR(0x1200000007, 0x11200000127)) + printf("band64RR pass.\n"); + else { + printf("band64RR false.\n"); + return 1; + } + return 0; +} diff --git a/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.mplme.txt b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.txt b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/test.cfg b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0008-mapleall-irbuild-edge-band/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/Main.mpl b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..1dcae2c67515a5a94043e0e666c2d37414537327 --- /dev/null +++ b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/Main.mpl @@ -0,0 +1,32 @@ + # a function returning (i + j) * -998 + func $foo ( +# var %i xxx, + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + assertge (dread i32 %i, constval i32 0) + assertlt (dread i32 %i, dread i32 %k) + return ( + ashr i32( + mul i32 ( + add i32 ( + band i32 (dread i32 %i, dread i32 %j), + bior i32 ( + bxor i32(dread i32 %i1, dread i32 %k1), + eq i32 i32 ( + depositbits i32 1 23 ( + land i32 (dread i32 %j1, dread i32 %k), + lior i32 ( + min i32 ( + shl i32 (dread i32 %k1, dread i32 %j), + sub i32 (dread i32 %j1, dread i32 %i)), + rem i32 (dread i32 %i, dread i32 %k))), + div i32( + lshr i32 ( dread i32 %k, dread i32 %i), + max i32 ( dread i32 %i, dread i32 %j))))), + constval i32 -998), + dread i32 %i))} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.mplme.txt b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.txt b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/test.cfg b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0009-mapleall-irbuild-edge-binary/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/Main.mpl b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..7f5f81bb65f0dc026ae77f120f478fde986cc779 --- /dev/null +++ b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/Main.mpl @@ -0,0 +1,41 @@ + func $bior32I ( + var %i i32 + ) i32 { + return ( + bior i32(dread i32 %i, + constval i32 0x12))} + func $bior32I_2 ( + var %i i32 + ) i32 { + return ( + bior i32(dread i32 %i, + constval i32 0x112))} + func $bior32RR ( + var %i i32, var %j i32 + ) i32 { + return ( + bior i32(dread i32 %i, + dread i32 %j))} + + func $bior64I ( + var %i i64 + ) i64 { + return ( + bior i64(dread i64 %i, + constval i64 0x1200000015))} + func $bior64I_2 ( + var %i i64 + ) i64 { + return ( + bior i64(dread i64 %i, + constval i64 0x1200000115))} + func $bior64RR ( + var %i i64, + var %j i64 + ) i64 { + return ( + bior i64(dread i64 %i, + dread i64 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/bior_main.c b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/bior_main.c new file mode 100644 index 0000000000000000000000000000000000000000..93f9db2cc8b4c565008e4d04b5c55fac39924d51 --- /dev/null +++ b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/bior_main.c @@ -0,0 +1,48 @@ +extern int bior32I(int a); +extern int bior32I_2(int a); +extern int bior32RR(int a, int b); + +extern long long bior64I(long long a); +extern long long bior64I_2(long long a); +extern long long bior64RR(long long a, long long b); + +int main() { + + if((7 | 0x12)== bior32I(7)) + printf("bior32I pass.\n"); + else { + printf("bior32I false.\n"); + return 1; + } + if((7 | 0x112)== bior32I_2(7)) + printf("bior32I_2 pass.\n"); + else { + printf("bior32I_2 false.\n"); + return 1; + } + if((7 | 5)== bior32RR(7, 5)) + printf("bior32RR pass.\n"); + else { + printf("bior32RR false.\n"); + return 1; + } + if((0x1200000007 | 0x1200000015)== bior64I(0x1200000007)) + printf("bior64I pass.\n"); + else { + printf("bior64I false.\n"); + return 1; + } + if((0x1200000115 | 0x11200000127)== bior64I_2(0x11200000127)) + printf("bior64I_2 pass.\n"); + else { + printf("bior64I_2 false.\n"); + return 1; + } + if((0x1200000007 | 0x11200000127)== bior64RR(0x1200000007, 0x11200000127)) + printf("bior64RR pass.\n"); + else { + printf("bior64RR false.\n"); + return 1; + } + return 0; +} diff --git a/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.mplme.txt b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.txt b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/test.cfg b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0010-mapleall-irbuild-edge-bior/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/Main.mpl b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..67004f9cf3559aadc39fd54273cbebf9b4e74884 --- /dev/null +++ b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/Main.mpl @@ -0,0 +1,37 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + bnot i32(dread i32 %i))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + bnot i32(dread i32 %i))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + bnot i32(constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + bnot i64(dread i64 %i))} + + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + bnot i64(constval i64 0x11111))} + +# todo float bnot + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.mplme.txt b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.txt b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/test.cfg b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0011-mapleall-irbuild-edge-bnot/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/Main.mpl b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..1ab362e93145a2e23cdce26fa55806c416ca0f45 --- /dev/null +++ b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/Main.mpl @@ -0,0 +1,12 @@ +func $fact ( + var %n i32) i32 { +@fred2 + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + brfalse @fred2 (dread i32 %n) +@fred1 + return (constval i32 0) } + else { + return (constval i32 1) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.mplme.txt b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.txt b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/test.cfg b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0012-mapleall-irbuild-edge-br/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/Main.mpl b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8f622b06a1ec5b674f9bebea4bd9ed0b8a34f242 --- /dev/null +++ b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/Main.mpl @@ -0,0 +1,23 @@ +func $singlefoo(var %a i32) i32 { + return (dread i32 %a) +} + +func $fact(var %n i32) i32 { + var %m i32 + var %r1 i32 + var %r2 i32 + var %r3 i32 + callassigned &singlefoo(dread i32 %n) { + dassign %m 0 + } + # Not correct, but for parse and dump test. + callassigned &singlefoo(dread i32 %n) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + return (dread i32 %n) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.mplme.txt b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.txt b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/test.cfg b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0013-mapleall-irbuild-edge-callassigned/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/Main.mpl b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..452853a54d985de2e3cdffec63b7965ff8661cf3 --- /dev/null +++ b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/Main.mpl @@ -0,0 +1,29 @@ + func $ceilf64toi32 ( + var %i f64 + ) i32 { + return ( + ceil i32 f64(dread f64 %i))} + + func $ceilf64toi64 ( + var %i f64 + ) i64 { + return ( + ceil i64 f64(dread f64 %i))} + + func $ceilf32toi32 ( + var %i f32 + ) i32 { + return ( + ceil i32 f32(dread f32 %i))} + + + func $ceilf32toi64 ( + var %i f32 + ) i64 { + return ( + ceil i64 f32(dread f32 %i))} + +# todo float ceil + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/ceilmain.c b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/ceilmain.c new file mode 100644 index 0000000000000000000000000000000000000000..eb2343458ec010336dcb4052325ed7f2dfedc8e5 --- /dev/null +++ b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/ceilmain.c @@ -0,0 +1,36 @@ +extern int ceilf64toi32(double x); +extern int ceilf32toi32(float x); +extern long long int ceilf64toi64(double x); +extern long long int ceilf32toi64(float x); + +int main(void) { + printf("%d\n", ceilf64toi32(1.22)); + printf("%d\n", ceilf64toi32(1.00f)); + printf("%d\n", ceilf64toi32(0)); + printf("%d\n", ceilf64toi32(-1)); + printf("%d\n", ceilf64toi32(-1.22)); + printf("%d\n", ceilf64toi32(-111.22)); + + printf("%d\n", ceilf32toi32(1.22)); + printf("%d\n", ceilf32toi32(1.00f)); + printf("%d\n", ceilf32toi32(0)); + printf("%d\n", ceilf32toi32(-1)); + printf("%d\n", ceilf32toi32(-1.22)); + printf("%d\n", ceilf32toi32(-111.22)); + + printf("%lld\n", ceilf64toi64(111111111111.21)); + printf("%lld\n", ceilf64toi64(1.22)); + printf("%lld\n", ceilf64toi64(1.00f)); + printf("%lld\n", ceilf64toi64(0)); + printf("%lld\n", ceilf64toi64(-1)); + printf("%lld\n", ceilf64toi64(-1.22)); + printf("%lld\n", ceilf64toi64(-111.22)); + printf("%lld\n", ceilf32toi64(1.22)); + printf("%lld\n", ceilf32toi64(1.00f)); + printf("%lld\n", ceilf32toi64(0)); + printf("%lld\n", ceilf32toi64(-1)); + printf("%lld\n", ceilf32toi64(-1.22)); + printf("%lld\n", ceilf32toi64(-111.22)); + return 0; +} + diff --git a/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.mplme.txt b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.txt b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/test.cfg b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0014-mapleall-irbuild-edge-ceil/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/Main.mpl b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8e05e65c4c36851a22091b6477713bfaa2c83c03 --- /dev/null +++ b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/Main.mpl @@ -0,0 +1,21 @@ + flavor 1 + func &ciori32 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + if (cior i32 ( cior i32(dread i32 %i, dread i32 %j), dread i32 %k)) { + return (constval i32 1) + } + return ( + cior i32(dread i32 %i, dread i32 %j))} + + func &candi64 ( + var %i i64, var %j i64, var %k i64 + ) i32 { + if (cand i32 (cand i32(dread i32 %i, dread i32 %j), dread i32 %k)) { + return (constval i32 1) + } + return ( + cand i64(dread i64 %i, dread i64 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.mplme.txt b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.txt b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/test.cfg b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0015-mapleall-irbuild-edge-ciorcand/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/Main.mpl b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..a2c9a0952c01e35aa66c27e97e3cbae948813cd4 --- /dev/null +++ b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/Main.mpl @@ -0,0 +1,11 @@ +type $RR +type $SS {@f1 i32, @f2 i8, @f3 i8}> +type $TT +type $UU {@f1 i32, @f2 i8, @f3 i8}> +func &foo ( var %x <$SS>) void { + var %y <$UU> + dassign %y 0 ( dread agg %x 0 ) + return () } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.mplme.txt b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.txt b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/test.cfg b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0016-mapleall-irbuild-edge-classequal/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/Main.mpl b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..5c446b85b76fe2954a1e5951ade166130449e877 --- /dev/null +++ b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/Main.mpl @@ -0,0 +1,10 @@ +type $RR +type $SS {@f1 i32, @f2 i8, @f3 i8}> +javaclass $TT <$SS> public static +func &foo ( + var %x <$SS>) i32 { + dassign %x 2 ( constval i32 32 ) + return ( dread i32 %x 2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.mplme.txt b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.txt b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/test.cfg b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0017-mapleall-irbuild-edge-class_type/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/Main.mpl b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..d476e46c4586f3ba3a39abfb9bae814690b0fe04 --- /dev/null +++ b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/Main.mpl @@ -0,0 +1,15 @@ +var $nan_f32 = nanf +var $nan_f64 = nan +var $inf_f32 = -inff +var $inf_f64 = inf +var $g_f32 = -1.2f +var $g_f64 = 1.2 +func $add_f32 () f32 { + return ( + add f32(dread f32 $g_f32, constval f32 inff))} +func $add_f64 () f64 { + return ( + add f64(dread f64 $g_f64, constval f64 -inf))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/constfloatmain.c b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/constfloatmain.c new file mode 100644 index 0000000000000000000000000000000000000000..51ffc37d5eb8708950bc6d4850ea1e1c4addb3ed --- /dev/null +++ b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/constfloatmain.c @@ -0,0 +1,18 @@ +#include +extern float add_f32(); +extern double add_f64(); +int main(){ + float fresult = add_f32(); + printf ("%f\n", fresult); + if(fabsf(1.7f - fresult) > 0.00001) { + printf("FAIL : f32 test fail.\n"); + return 1; + } + double dresult = add_f64(); + if(fabs(1.7 - dresult) > 0.0000000001){ + printf("%lf, FAIL : f64 test fail.\n", add_f64()); + return 1; + } + printf("PASS : emit constant f32&f64 test pass.\n"); + return 0; +} diff --git a/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.mplme.txt b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.txt b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/test.cfg b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0018-mapleall-irbuild-edge-constfloat/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/Main.mpl b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..d0b562cc934797ab3ecb9e62d007de68e85cb57c --- /dev/null +++ b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/Main.mpl @@ -0,0 +1,582 @@ +# 1 + 8 -> 9 +func $testSum (var %i i32) i32 { + return ( + add i32(constval i32 1, constval i32 8)) +} + +# sqrt(4.0) -> 2.0 +func $testSqrt (var %i i32) f32 { + return ( + sqrt f32(constval f32 4.0f)) +} + +# 5 + (5 + a) -> a + 10 +func &testConstVarFold00 (var %a i32) i32 { + return (add i32 ( + constval i32 5, + add i32 (constval i32 5, dread i32 %a))) +} + +# 5 + (5 - a) -> 10 - a +func &testConstVarFold01 (var %a i32) i32 { + return (add i32 ( + constval i32 5, + sub i32 (constval i32 5, dread i32 %a))) +} + +# 5 + (a + 5) -> a + 10 +func &testConstVarFold02 (var %a i32) i32 { + return (add i32 ( + constval i32 5, + add i32 (dread i32 %a, constval i32 5))) +} + +# 6 + (a - 5) -> a + 1 +func &testConstVarFold03 (var %a i32) i32 { + return (add i32 ( + constval i32 6, + sub i32 (dread i32 %a, constval i32 5))) +} + +# 5 * (5 * a) -> 5 * (5 * a) +func &testConstVarFold04 (var %a i32) i32 { + return (mul i32 ( + constval i32 5, + mul i32 (constval i32 5, dread i32 %a))) +} + +# 5 * (a * 5) -> 5 * (a * 5) +func &testConstVarFold05 (var %a i32) i32 { + return (mul i32 ( + constval i32 5, + mul i32 (dread i32 %a, constval i32 5))) +} + +# 3 - (2 - a) -> a + 1 +func &testConstVarFold06 (var %a i32) i32 { + return (sub i32 ( + constval i32 3, + sub i32 (constval i32 2, dread i32 %a))) +} + +# 3 - (2 + a) -> 1 - a +func &testConstVarFold07 (var %a i32) i32 { + return (sub i32 ( + constval i32 3, + add i32 (constval i32 2, dread i32 %a))) +} + +# 3 - (a + 2) -> 1 - a +func &testConstVarFold08 (var %a i32) i32 { + return (sub i32 ( + constval i32 3, + add i32 (dread i32 %a, constval i32 2))) +} + +# 3 - (a - 2) -> 5 - a +func &testConstVarFold09 (var %a i32) i32 { + return (sub i32 ( + constval i32 3, + sub i32 (dread i32 %a, constval i32 2))) +} + +# (2 + a) - 3 -> a - 1 +func &testConstVarFold10 (var %a i32) i32 { + return (sub i32 ( + add i32 (constval i32 2, dread i32 %a), + constval i32 3)) +} + +# (2 - a) - 3 -> -a - 1 +func &testConstVarFold11 (var %a i32) i32 { + return (sub i32 ( + sub i32 (constval i32 2, dread i32 %a), + constval i32 3)) +} + +# (a + 2) - 3 -> a - 1 +func &testConstVarFold12 (var %a i32) i32 { + return (sub i32 ( + add i32 (dread i32 %a, constval i32 2), + constval i32 3)) +} + +# (a - 2) - 3 -> a - 5 +func &testConstVarFold13 (var %a i32) i32 { + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 2), + constval i32 3)) +} + +# 1 + (5 + ((5 - a) - 3)) -> 8 - a +func &testConstVarFold15 (var %a i32) i32 { + return (add i32 ( + constval i32 1, + add i32 ( + constval i32 5, + sub i32 ( + sub i32 (constval i32 5, dread i32 %a), + constval i32 3)))) +} + +# 1 + (5 + ((5 - a) * 3)) -> ((5 - a) * 3) + 6 +func &testConstVarFold16 (var %a i32) i32 { + return (add i32 ( + constval i32 1, + add i32 ( + constval i32 5, + mul i32 ( + sub i32 (constval i32 5, dread i32 %a), + constval i32 3)))) +} + +# (-a) + b --> (-a) + b +func &testConstantFoldAdd00 (var %a i32, var %b i32) i32 { + return (add i32 ( + neg i32 (dread i32 %a), + dread i32 %b)) +} + +# a + (-b) --> a + (-b) +func &testConstantFoldAdd01 (var %a i32, var %b i32) i32 { + return (add i32 ( + dread i32 %a, + neg i32 (dread i32 %b))) +} + + +# 5.0f + (5 - a) -> same, no folding with floating point numbers +func &testConstVarFold20 (var %a i32) i32 { + return (add f32 ( + constval f32 5.0f, + sub i32 (constval i32 5, dread i32 %a))) +} + + +func &testConstFold0 (var %a i32, var %b i32, var %c i32) i32 { + # ((a + 5) + ((2 + c) + (4 + 2))) -> ((a + c) + 13) + return (add i32 ( + add i32 (dread i32 %a, constval i32 0x5), + add i32 ( + add i32 (constval i32 0x2, dread i32 %c), + add i32 (constval i32 0x4, constval i32 0x2)))) +} + +func &testConstFold1 (var %a i32, var %b i32, var %c i32) i32 { + # ((a + 5) + (2 + c)) -> ((a + c) + 7) + return (add i32 ( + add i32 (dread i32 %a, constval i32 0x5), + add i32 (constval i32 0x2, dread i32 %c))) +} + +func &testConstFold2 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) - ((b - c) - (4 - 2))) -> ((a - (b - c)) - 3) + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + sub i32 (dread i32 %b, dread i32 %c), + sub i32 (constval i32 0x4, constval i32 0x2)))) +} + +func &testConstFold3 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) + ((b - c) - (4 - 2))) -> ((a + (b - c)) - 7) + return (add i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + sub i32 (dread i32 %b, dread i32 %c), + sub i32 (constval i32 0x4, constval i32 0x2)))) +} + +func &testConstFold4 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) - ((4 - 2) - (4 - b))) -> ((a - b) - 3) + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + sub i32 (constval i32 0x4, constval i32 0x2), + sub i32 (constval i32 0x4, dread i32 %b)))) +} + +func &testConstFold5 (var %a i32, var %b i32, var %c i32) i32 { + # ((5 - a) - ((b - 4) - (4 - b))) -> (((-a) - (b - (-b))) + 13) + return (sub i32 ( + sub i32 (constval i32 0x5, dread i32 %a), + sub i32 ( + sub i32 (dread i32 %b, constval i32 0x4), + sub i32 (constval i32 0x4, dread i32 %b)))) +} + +func &testConstFold6 (var %a i32, var %b i32, var %c i32) i32 { + # ((5 - a) - ((4 - b) - (b - 4))) -> (((-a) - ((-b) - b)) - 3) + return (sub i32 ( + sub i32 (constval i32 0x5, dread i32 %a), + sub i32 ( + sub i32 (constval i32 0x4, dread i32 %b), + sub i32 (dread i32 %b, constval i32 0x4)))) +} + +func &testConstFold7 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) - ((4 + 2) - (4 - (b - c)))) -> ((a - (b - c)) - 7) + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + sub i32 ( + constval i32 0x4, + sub i32 (dread i32 %b, dread i32 %c))))) +} + +func &testConstFold8 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) - ((4 + 2) - (4 * (b - c)))) -> ((a - (-(4 * (b - c)))) - 11) + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + mul i32 ( + constval i32 0x4, + sub i32 (dread i32 %b, dread i32 %c))))) +} + +func &testConstFold9 (var %a i32, var %b i32, var %c i32) i32 { + # ((a - 5) - ((4 + 2) - (-(4 - (b - c))))) -> ((a - (-(b - c))) - 15) + return (sub i32 ( + sub i32 (dread i32 %a, constval i32 0x5), + sub i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + neg i32 (sub i32 ( + constval i32 0x4, + sub i32 (dread i32 %b, dread i32 %c)))))) +} + +func &testConstFold10 (var %a i32, var %b i32, var %c i32) i32 { + # ((4 + 2) * (-(4 - (3 - c)))) -> (6 * ((-c) - 1)) + return (mul i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + neg i32 (sub i32 ( + constval i32 0x4, + sub i32 (constval i32 0x3, dread i32 %c))))) +} + +func &testConstFold11 (var %a i32, var %b i32, var %c i32) i32 { + # ((4 + 2) * (4 - (3 - c))) -> (6 * (c + 1)) + return (mul i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + sub i32 ( + constval i32 0x4, + sub i32 (constval i32 0x3, dread i32 %c)))) +} + +func &testConstFold12 (var %a i32, var %b i32, var %c i32) i32 { + # ((4 + 2) * (~(4 - (3 - c)))) -> (6 * (~(c + 1))) + return (mul i32 ( + add i32 (constval i32 0x4, constval i32 0x2), + bnot i32 (sub i32 ( + constval i32 0x4, + sub i32 (constval i32 0x3, dread i32 %c))))) +} + +func &testConstFold13 (var %a i32, var %b i32, var %c i32) i32 { + # (5 * (((4 - 2) + (2 & 4)) - (4 - (c | 3)))) -> (5 * ((c | 3) - 2)) + return (mul i32 ( + constval i32 0x5, + sub i32 ( + add i32 ( + sub i32 (constval i32 0x4, constval i32 0x2), + band i32 (constval i32 0x2, constval i32 0x4)), + sub i32 ( + constval i32 0x4, + bior i32 (dread i32 %c, constval i32 0x3))))) +} + +func &testConstFold14 (var %a i32, var %b i32, var %c i32) i32 { + # (5 * (((4 - 2) + (2 & 4)) * (4 - (c | 3)))) -> (5 * (2 * (4 - (c | 3)))) + return (mul i32 ( + constval i32 0x5, + mul i32 ( + add i32 ( + sub i32 (constval i32 0x4, constval i32 0x2), + band i32 (constval i32 0x2, constval i32 0x4)), + sub i32 ( + constval i32 0x4, + bior i32 (dread i32 %c, constval i32 0x3))))) +} + +func &testConstFold15 (var %a i32, var %b i32, var %c i32) i32 { + # ((1 + 0) * (~(4 - (0 * c)))) -> (~4) + return (mul i32 ( + add i32 (constval i32 0x1, constval i32 0x0), + bnot i32 (sub i32 ( + constval i32 0x4, + mul i32 (constval i32 0x0, dread i32 %c))))) +} + +func &testConstFold16 (var %a i32, var %b i32, var %c i32) i32 { + # ((~(4 - (c * 0))) * (1 + 0)) -> (~4) + return (mul i32 ( + bnot i32 (sub i32 ( + constval i32 0x4, + mul i32 (dread i32 %c, constval i32 0x0))), + add i32 (constval i32 0x1, constval i32 0x0))) +} + + +func &testConstFoldDiv0 (var %a i32, var %b i32, var %c i32) i32 { + # (5 / 0) * (1 + 1) -> 2 + return (mul i32 ( + div i32 (constval i32 0x5, constval i32 0x0), + add i32 (constval i32 0x1, constval i32 0x1))) +} + +func &testConstFoldFloor00 (var %a i32, var %b i32, var %c i32) i32 { + # (floor(4.25) + c) * (1 + 1) -> (c + 4) * 2 + return (mul i32 ( + add i32 (floor i32 f32 (constval f32 4.25f), dread i32 %c), + add i32 (constval i32 0x1, constval i32 0x1))) +} + +func &testConstFoldFloor01 (var %a i32, var %b i32, var %c i32) i32 { + # (floor(4.25) + 2) * (1 + 1) -> 12 + return (mul i32 ( + add i32 (floor i32 f32 (constval f32 4.25f), constval i32 0x2), + add i32 (constval i32 0x1, constval i32 0x1))) +} + +func &testConstFoldFloor02 (var %a i32, var %b i32, var %c i32) i32 { + # floor((floor(4.25) + 1) + (1 + a)) -> floor(a + 6) + return (floor i32 i32 (add i32 ( + add i32 (floor i32 f32 (constval f32 4.25f), constval i32 0x1), + add i32 (constval i32 0x1, dread i32 %a)))) +} + +func &testConstFoldExtractbitsNode00 () i32 { + # 487 = 00111100111 + # extractbits i32 6 5 (487) = 7 = 0111 + return (extractbits i32 6 5 (constval i32 487)) +} + +func &testConstFoldExtractbitsNode01 () i32 { + # 487 = 00111100111 + # extractbits i32 4 5 (487) = -2 = 0xfffffffffffffffe + return (extractbits i32 4 5 (constval i32 487)) +} + +func &testConstFoldExtractbitsNode02 (var %a i32, var %b i32, var %c i32) i32 { + # 487 = 00111100111 + # extractbits i32 4 5 (487) = -2 = 0xfffffffffffffffe + # extractbits((extractbits(487) + 1) + (1 + a)) -> extractbits(a) + return (extractbits i32 4 5 (add i32 ( + add i32 (extractbits i32 4 5 (constval i32 487), constval i32 0x1), + add i32 (constval i32 0x1, dread i32 %a)))) +} + +func &testConstFoldExtractbitsNode03 (var %a i32, var %b i32, var %c i32) i32 { + # 487 = 00111100111 + # extractbits i32 6 5 (487) = 7 = 0111 + # extractbits((extractbits(487) + 1) + (1 + a)) -> extractbits(a + 9) + return (extractbits i32 6 5 (add i32 ( + add i32 (extractbits i32 6 5 (constval i32 487), constval i32 0x1), + add i32 (constval i32 0x1, dread i32 %a)))) +} + +func &testConstFoldCompareNode00 (var %a i32, var %b i32, var %c i32) i32 { + # (ge(6, 2) + 1) + (1 + 2) -> 5 + return (add i32 ( + add i32 ( + ge i32 i32 (constval i32 6, constval i32 2), + constval i32 1), + add i32 (constval i32 1, constval i32 2))) +} + +func &testConstFoldCompareNode01 (var %a i32, var %b i32, var %c i32) i32 { + # ge((ge(6, 2) + 1), (1 + a)) -> ge(2, a + 1) + return (ge i32 i32 ( + add i32 ( + ge i32 i32 (constval i32 6, constval i32 2), + constval i32 1), + add i32 (constval i32 1, dread i32 %a))) +} + +func &testConstFoldTernaryNode00 (var %a i32, var %b i32, var %c i32) i32 { + # (6 > 2 ? 5 : 0) + (1 + 2) -> 8 + return ( add i32 ( + select i32 ( + ge i32 i32 (constval i32 6, constval i32 2), + constval i32 5, + constval i32 0), + add i32 (constval i32 1, constval i32 2))) +} + +func &testConstFoldTernaryNode01 (var %a i32, var %b i32, var %c i32) i32 { + # (6 > 10 ? 5 : 0) + (1 + a) -> (a + 1) + return ( add i32 ( + select i32 ( + ge i32 i32 (constval i32 6, constval i32 10), + constval i32 5, + constval i32 0), + add i32 (constval i32 1, dread i32 %a))) +} + +func &testConstFoldTernaryNode02 (var %a i32, var %b i32, var %c i32) i32 { + # 6 > a ? (1 + 6) + (1 + a) : 0 -> 6 > a ? a + 8 : 0 + return ( select i32 ( + ge i32 i32 (constval i32 6, dread i32 %a), + add i32 ( + add i32 (constval i32 1, constval i32 6), + add i32 (constval i32 1, dread i32 %a)), + constval i32 0)) +} + +type $Hello + +type $Person , + @sex u1}> + + +func &testConstFoldIassignNode00 (var %a i32) void { + # this is equivalent to dassign %a 0 (constval i32 0x6) + iassign <* i32> 0 (addrof ptr %a 0, add i32 (constval i32 1, constval i32 5)) +} + +func &testConstFoldIassignNode01 (var %a i32) void { + var %bob $Person + + # this is equivalent to dassign %bob 5 (constval i32 0x6) + iassign <* $Hello> 3 (addrof ptr %bob 2, add i32 (constval i32 1, constval i32 5)) +} + + +func &testConstFoldIassignNode02 (var %a i32) void { + # this is equivalent to dassign %a 0 (constval i32 0x6) + iassign <* i32> 0 ( + iaddrof ptr <* i32> 0 (addrof ptr %a 0), + add i32 (constval i32 1, constval i32 5)) +} + +func &testConstFoldIassignNode03 (var %a i32) void { + + var %bob $Person + # this is equivalent to dassign %bob 5 (constval i32 0x6) + iassign <* <$Hello>> 3 ( + iaddrof ptr <* <$Person>> 2 (addrof ptr %bob 0), + add i32 (constval i32 1, constval i32 5)) +} + +func &testConstFoldIassignNode04 (var %a i32) void { + + var %bob $Person + # this is equivalent to dassign %bob 5 (constval i32 0x6) + iassign <* <$Hello>> 3 ( + iaddrof ptr <* <$Hello>> 0 (addrof ptr %bob 2), + add i32 (constval i32 1, constval i32 5)) +} + + +func &testConstFoldIassignNode05 (var %a i32) void { + var %b <* i32> + + dassign %b (addrof ptr %a 0) + + # this is equivalent to iassign <* i32> 0 (dread ptr %a, constval i32 0x6) + iassign <* i32> 0 ( + iaddrof ptr <* i32> 0 (dread ptr %a), + add i32 (constval i32 1, constval i32 5)) +} + +func &testConstFoldIassignNode06 (var %a i32) void { + var %bob $Person + # this is equivalent to dassign %a 0 (dread i32 %bob 1) + dassign %a 0 (iread agg <* <$Person>> 1 (addrof ptr %bob 0)) +} + +func &testConstFoldSwitchNode00 () void { + # switch (1+4) ... -> goto @lab1 + switch ( add i32 (constval i32 1, constval i32 4)) @labdft { + -2: goto @lab0 + 5: goto @lab1 + 8: goto @lab9 } + + @lab0 + return (constval i32 1) + @labdft + return (constval i32 2) + @lab9 + return (constval i32 3) + @lab1 + return (constval i32 4) +} + +func &testConstFoldSwitchNode01 () void { + # switch (1 + 10) ... -> goto @labdft + switch ( add i32 (constval i32 1, constval i32 10)) @labdft { + -2: goto @lab0 + 5: goto @lab1 + 8: goto @lab9 } + + @lab0 + return (constval i32 1) + @labdft + return (constval i32 2) + @lab9 + return (constval i32 3) + @lab1 + return (constval i32 4) +} + +func &testConstFoldSwitchNode02 (var %a i32) void { + # switch (5 + (5 - a)) ... -> switch (10 - a) ... + switch (add i32 ( + constval i32 5, + sub i32 (constval i32 5, dread i32 %a))) @labdft { + -2: goto @lab0 + 5: goto @lab1 + 8: goto @lab9 } + + @lab0 + return (constval i32 1) + @labdft + return (constval i32 2) + @lab9 + return (constval i32 3) + @lab1 + return (constval i32 4) +} + + +func &testConstFoldArrayNode00 (var %x i32) void { + var %a <* [15][15] i32> + # fold indexes -> array ptr <* <[15][15] i32>> (constval i32 0x6, constval i32 0x4) + dassign %x ( + iread i32 <* i32> ( + array 1 ptr <* [15][15] i32> (addrof ptr %a, + add i32 (constval i32 1, constval i32 5), + sub i32 (constval i32 5, constval i32 1)))) +} + +func &testDepositbitsNodeNode00 (var %a i32, var %c i32) i32 { + return ( depositbits i32 1 23 ( + add i32 ( + add i32 (dread i32 %a, constval i32 0x5), + add i32 ( + add i32 (constval i32 0x2, dread i32 %c), + add i32 (constval i32 0x4, constval i32 0x2))), + add i32 (constval i32 0x4, constval i32 0x8))) +} + +func &testDepositbitsNodeNode01 () i32 { + return ( depositbits i32 1 23 ( + add i32 ( + add i32 (constval i32 0x5, constval i32 0x5), + add i32 ( + add i32 (constval i32 0x2, constval i32 0x2), + add i32 (constval i32 0x4, constval i32 0x2))), + add i32 (constval i32 0x4, constval i32 0x8))) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/constFoldTest.expected b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/constFoldTest.expected new file mode 100644 index 0000000000000000000000000000000000000000..f737a0d29b03c72439fad32cdffe2219a3aaed86 --- /dev/null +++ b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/constFoldTest.expected @@ -0,0 +1,508 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same +id 65535 +numfuncs 0 +type $Hello +type $Person , + @sex u1}> +func &testSum (var %i i32) i32 +func &testSqrt (var %i i32) f32 +func &testConstVarFold00 (var %a i32) i32 +func &testConstVarFold01 (var %a i32) i32 +func &testConstVarFold02 (var %a i32) i32 +func &testConstVarFold03 (var %a i32) i32 +func &testConstVarFold04 (var %a i32) i32 +func &testConstVarFold05 (var %a i32) i32 +func &testConstVarFold06 (var %a i32) i32 +func &testConstVarFold07 (var %a i32) i32 +func &testConstVarFold08 (var %a i32) i32 +func &testConstVarFold09 (var %a i32) i32 +func &testConstVarFold10 (var %a i32) i32 +func &testConstVarFold11 (var %a i32) i32 +func &testConstVarFold12 (var %a i32) i32 +func &testConstVarFold13 (var %a i32) i32 +func &testConstVarFold15 (var %a i32) i32 +func &testConstVarFold16 (var %a i32) i32 +func &testConstantFoldAdd00 (var %a i32, var %b i32) i32 +func &testConstantFoldAdd01 (var %a i32, var %b i32) i32 +func &testConstVarFold20 (var %a i32) i32 +func &testConstFold0 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold1 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold2 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold3 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold4 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold5 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold6 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold7 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold8 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold9 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold10 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold11 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold12 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold13 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold14 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold15 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFold16 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldDiv0 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldFloor00 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldFloor01 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldFloor02 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldExtractbitsNode00 () i32 +func &testConstFoldExtractbitsNode01 () i32 +func &testConstFoldExtractbitsNode02 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldExtractbitsNode03 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldCompareNode00 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldCompareNode01 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldTernaryNode00 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldTernaryNode01 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldTernaryNode02 (var %a i32, var %b i32, var %c i32) i32 +func &testConstFoldIassignNode00 (var %a i32) void +func &testConstFoldIassignNode01 (var %a i32) void +func &testConstFoldIassignNode02 (var %a i32) void +func &testConstFoldIassignNode03 (var %a i32) void +func &testConstFoldIassignNode04 (var %a i32) void +func &testConstFoldIassignNode05 (var %a i32) void +func &testConstFoldIassignNode06 (var %a i32) void +func &testConstFoldSwitchNode00 () void +func &testConstFoldSwitchNode01 () void +func &testConstFoldSwitchNode02 (var %a i32) void +func &testConstFoldArrayNode00 (var %x i32) void +func &testDepositbitsNodeNode00 (var %a i32, var %c i32) i32 +func &testDepositbitsNodeNode01 () i32 +func &testSum (var %i i32) i32 { + funcid 0 + # 1 + 8 -> 9 + return (constval i32 0x9) +} +func &testSqrt (var %i i32) f32 { + funcid 0 + # sqrt(4.0) -> 2.0 + return (constval f32 2f) +} +func &testConstVarFold00 (var %a i32) i32 { + funcid 0 + # 5 + (5 + a) -> a + 10 + return (add i32 (dread i32 %a, constval i32 0xa)) +} +func &testConstVarFold01 (var %a i32) i32 { + funcid 0 + # 5 + (5 - a) -> 10 - a + return (sub i32 (constval i32 0xa, dread i32 %a)) +} +func &testConstVarFold02 (var %a i32) i32 { + funcid 0 + # 5 + (a + 5) -> a + 10 + return (add i32 (dread i32 %a, constval i32 0xa)) +} +func &testConstVarFold03 (var %a i32) i32 { + funcid 0 + # 6 + (a - 5) -> a + 1 + return (add i32 (dread i32 %a, constval i32 0x1)) +} +func &testConstVarFold04 (var %a i32) i32 { + funcid 0 + # 5 * (5 * a) -> 5 * (5 * a) + return (mul i32 ( + constval i32 0x5, + mul i32 (constval i32 0x5, dread i32 %a))) +} +func &testConstVarFold05 (var %a i32) i32 { + funcid 0 + # 5 * (a * 5) -> 5 * (a * 5) + return (mul i32 ( + constval i32 0x5, + mul i32 (dread i32 %a, constval i32 0x5))) +} +func &testConstVarFold06 (var %a i32) i32 { + funcid 0 + # 3 - (2 - a) -> a + 1 + return (add i32 (dread i32 %a, constval i32 0x1)) +} +func &testConstVarFold07 (var %a i32) i32 { + funcid 0 + # 3 - (2 + a) -> 1 - a + return (sub i32 (constval i32 0x1, dread i32 %a)) +} +func &testConstVarFold08 (var %a i32) i32 { + funcid 0 + # 3 - (a + 2) -> 1 - a + return (sub i32 (constval i32 0x1, dread i32 %a)) +} +func &testConstVarFold09 (var %a i32) i32 { + funcid 0 + # 3 - (a - 2) -> 5 - a + return (sub i32 (constval i32 0x5, dread i32 %a)) +} +func &testConstVarFold10 (var %a i32) i32 { + funcid 0 + # (2 + a) - 3 -> a - 1 + return (sub i32 (dread i32 %a, constval i32 0x1)) +} +func &testConstVarFold11 (var %a i32) i32 { + funcid 0 + # (2 - a) - 3 -> -a - 1 + return (sub i32 ( + neg i32 (dread i32 %a), + constval i32 0x1)) +} +func &testConstVarFold12 (var %a i32) i32 { + funcid 0 + # (a + 2) - 3 -> a - 1 + return (sub i32 (dread i32 %a, constval i32 0x1)) +} +func &testConstVarFold13 (var %a i32) i32 { + funcid 0 + # (a - 2) - 3 -> a - 5 + return (sub i32 (dread i32 %a, constval i32 0x5)) +} +func &testConstVarFold15 (var %a i32) i32 { + funcid 0 + # 1 + (5 + ((5 - a) - 3)) -> 8 - a + return (sub i32 (constval i32 0x8, dread i32 %a)) +} +func &testConstVarFold16 (var %a i32) i32 { + funcid 0 + # 1 + (5 + ((5 - a) * 3)) -> ((5 - a) * 3) + 6 + return (add i32 ( + mul i32 ( + sub i32 (constval i32 0x5, dread i32 %a), + constval i32 0x3), + constval i32 0x6)) +} +func &testConstantFoldAdd00 (var %a i32, var %b i32) i32 { + funcid 0 + # (-a) + b --> (-a) + b + return (add i32 ( + neg i32 (dread i32 %a), + dread i32 %b)) +} +func &testConstantFoldAdd01 (var %a i32, var %b i32) i32 { + funcid 0 + # a + (-b) --> a + (-b) + return (add i32 ( + dread i32 %a, + neg i32 (dread i32 %b))) +} +func &testConstVarFold20 (var %a i32) i32 { + funcid 0 + # 5.0f + (5 - a) -> same, no folding with floating point numbers + return (add f32 ( + constval f32 5f, + sub i32 (constval i32 0x5, dread i32 %a))) +} +func &testConstFold0 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a + 5) + ((2 + c) + (4 + 2))) -> ((a + c) + 13) + return (add i32 ( + add i32 (dread i32 %a, dread i32 %c), + constval i32 0xd)) +} +func &testConstFold1 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a + 5) + (2 + c)) -> ((a + c) + 7) + return (add i32 ( + add i32 (dread i32 %a, dread i32 %c), + constval i32 0x7)) +} +func &testConstFold2 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) - ((b - c) - (4 - 2))) -> ((a - (b - c)) - 3) + return (sub i32 ( + sub i32 ( + dread i32 %a, + sub i32 (dread i32 %b, dread i32 %c)), + constval i32 0x3)) +} +func &testConstFold3 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) + ((b - c) - (4 - 2))) -> ((a + (b - c)) - 7) + return (sub i32 ( + add i32 ( + dread i32 %a, + sub i32 (dread i32 %b, dread i32 %c)), + constval i32 0x7)) +} +func &testConstFold4 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) - ((4 - 2) - (4 - b))) -> ((a - b) - 3) + return (sub i32 ( + sub i32 (dread i32 %a, dread i32 %b), + constval i32 0x3)) +} +func &testConstFold5 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((5 - a) - ((b - 4) - (4 - b))) -> (((-a) - (b - (-b))) + 13) + return (add i32 ( + sub i32 ( + neg i32 (dread i32 %a), + sub i32 ( + dread i32 %b, + neg i32 (dread i32 %b))), + constval i32 0xd)) +} +func &testConstFold6 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((5 - a) - ((4 - b) - (b - 4))) -> (((-a) - ((-b) - b)) - 3) + return (sub i32 ( + sub i32 ( + neg i32 (dread i32 %a), + sub i32 ( + neg i32 (dread i32 %b), + dread i32 %b)), + constval i32 0x3)) +} +func &testConstFold7 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) - ((4 + 2) - (4 - (b - c)))) -> ((a - (b - c)) - 7) + return (sub i32 ( + sub i32 ( + dread i32 %a, + sub i32 (dread i32 %b, dread i32 %c)), + constval i32 0x7)) +} +func &testConstFold8 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) - ((4 + 2) - (4 * (b - c)))) -> ((a - (-(4 * (b - c)))) - 11) + return (sub i32 ( + sub i32 ( + dread i32 %a, + neg i32 (mul i32 ( + constval i32 0x4, + sub i32 (dread i32 %b, dread i32 %c)))), + constval i32 0xb)) +} +func &testConstFold9 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((a - 5) - ((4 + 2) - (-(4 - (b - c))))) -> ((a - (-(b - c))) - 15) + return (sub i32 ( + sub i32 ( + dread i32 %a, + neg i32 (sub i32 (dread i32 %b, dread i32 %c))), + constval i32 0xf)) +} +func &testConstFold10 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((4 + 2) * (-(4 - (3 - c)))) -> (6 * ((-c) - 1)) + return (mul i32 ( + constval i32 0x6, + sub i32 ( + neg i32 (dread i32 %c), + constval i32 0x1))) +} +func &testConstFold11 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((4 + 2) * (4 - (3 - c))) -> (6 * (c + 1)) + return (mul i32 ( + constval i32 0x6, + add i32 (dread i32 %c, constval i32 0x1))) +} +func &testConstFold12 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((4 + 2) * (~(4 - (3 - c)))) -> (6 * (~(c + 1))) + return (mul i32 ( + constval i32 0x6, + bnot i32 (add i32 (dread i32 %c, constval i32 0x1)))) +} +func &testConstFold13 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (5 * (((4 - 2) + (2 & 4)) - (4 - (c | 3)))) -> (5 * ((c | 3) - 2)) + return (mul i32 ( + constval i32 0x5, + sub i32 ( + bior i32 (dread i32 %c, constval i32 0x3), + constval i32 0x2))) +} +func &testConstFold14 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (5 * (((4 - 2) + (2 & 4)) * (4 - (c | 3)))) -> (5 * (2 * (4 - (c | 3)))) + return (mul i32 ( + constval i32 0x5, + mul i32 ( + constval i32 0x2, + sub i32 ( + constval i32 0x4, + bior i32 (dread i32 %c, constval i32 0x3))))) +} +func &testConstFold15 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((1 + 0) * (~(4 - (0 * c)))) -> (~4) + return (constval i32 0xfffffffffffffffb) +} +func &testConstFold16 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ((~(4 - (c * 0))) * (1 + 0)) -> (~4) + return (constval i32 0xfffffffffffffffb) +} +func &testConstFoldDiv0 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (5 / 0) * (1 + 1) -> 2 + return (constval i32 0x2) +} +func &testConstFoldFloor00 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (floor(4.25) + c) * (1 + 1) -> (c + 4) * 2 + return (mul i32 ( + add i32 (dread i32 %c, constval i32 0x4), + constval i32 0x2)) +} +func &testConstFoldFloor01 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (floor(4.25) + 2) * (1 + 1) -> 12 + return (constval i32 0xc) +} +func &testConstFoldFloor02 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # floor((floor(4.25) + 1) + (1 + a)) -> floor(a + 6) + return (floor i32 i32 (add i32 (dread i32 %a, constval i32 0x6))) +} +func &testConstFoldExtractbitsNode00 () i32 { + funcid 0 + # 487 = 00111100111 + # extractbits i32 6 5 (487) = 7 = 0111 + return (constval i32 0x7) +} +func &testConstFoldExtractbitsNode01 () i32 { + funcid 0 + # 487 = 00111100111 + # extractbits i32 4 5 (487) = -2 = 0xfffffffffffffffe + return (constval i32 0xfffffffffffffffe) +} +func &testConstFoldExtractbitsNode02 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # 487 = 00111100111 + # extractbits i32 4 5 (487) = -2 = 0xfffffffffffffffe + # extractbits((extractbits(487) + 1) + (1 + a)) -> extractbits(a) + return (extractbits i32 4 5 (dread i32 %a)) +} +func &testConstFoldExtractbitsNode03 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # 487 = 00111100111 + # extractbits i32 6 5 (487) = 7 = 0111 + # extractbits((extractbits(487) + 1) + (1 + a)) -> extractbits(a + 9) + return (extractbits i32 6 5 (add i32 (dread i32 %a, constval i32 0x9))) +} +func &testConstFoldCompareNode00 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (ge(6, 2) + 1) + (1 + 2) -> 5 + return (constval u1 0x5) +} +func &testConstFoldCompareNode01 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # ge((ge(6, 2) + 1), (1 + a)) -> ge(2, a + 1) + return (ge i32 i32 ( + constval u1 0x2, + add i32 (dread i32 %a, constval i32 0x1))) +} +func &testConstFoldTernaryNode00 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (6 > 2 ? 5 : 0) + (1 + 2) -> 8 + return (constval i32 0x8) +} +func &testConstFoldTernaryNode01 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # (6 > 10 ? 5 : 0) + (1 + a) -> (a + 1) + return (add i32 (dread i32 %a, constval i32 0x1)) +} +func &testConstFoldTernaryNode02 (var %a i32, var %b i32, var %c i32) i32 { + funcid 0 + # 6 > a ? (1 + 6) + (1 + a) : 0 -> 6 > a ? a + 8 : 0 + return (select i32 ( + ge i32 i32 (constval i32 0x6, dread i32 %a), + add i32 (dread i32 %a, constval i32 0x8), + constval i32 0x0)) +} +func &testConstFoldIassignNode00 (var %a i32) void { + funcid 0 + # this is equivalent to dassign %a 0 (constval i32 0x6) + dassign %a 0 (constval i32 0x6) +} +func &testConstFoldIassignNode01 (var %a i32) void { + funcid 0 + var %bob <$Person> + # this is equivalent to dassign %bob 5 (constval i32 0x6) + dassign %bob 5 (constval i32 0x6) +} +func &testConstFoldIassignNode02 (var %a i32) void { + funcid 0 + # this is equivalent to dassign %a 0 (constval i32 0x6) + dassign %a 0 (constval i32 0x6) +} +func &testConstFoldIassignNode03 (var %a i32) void { + funcid 0 + var %bob <$Person> + # this is equivalent to dassign %bob 5 (constval i32 0x6) + dassign %bob 5 (constval i32 0x6) +} +func &testConstFoldIassignNode04 (var %a i32) void { + funcid 0 + var %bob <$Person> + # this is equivalent to dassign %bob 5 (constval i32 0x6) + dassign %bob 5 (constval i32 0x6) +} +func &testConstFoldIassignNode05 (var %a i32) void { + funcid 0 + var %b <* i32> + dassign %b 0 (addrof ptr %a) + # this is equivalent to iassign <* i32> 0 (dread ptr %a, constval i32 0x6) + iassign <* i32> 0 (dread ptr %a, constval i32 0x6) +} +func &testConstFoldIassignNode06 (var %a i32) void { + funcid 0 + var %bob <$Person> + # this is equivalent to dassign %a 0 (dread i32 %bob 1) + dassign %a 0 (dread i32 %bob 1) +} +func &testConstFoldSwitchNode00 () void { + funcid 0 + # switch (1+4) ... -> goto @lab1 + goto @lab1 +@lab0 return (constval i32 0x1) +@labdft return (constval i32 0x2) +@lab9 return (constval i32 0x3) +@lab1 return (constval i32 0x4) +} +func &testConstFoldSwitchNode01 () void { + funcid 0 + # switch (1 + 10) ... -> goto @labdft + goto @labdft +@lab0 return (constval i32 0x1) +@labdft return (constval i32 0x2) +@lab9 return (constval i32 0x3) +@lab1 return (constval i32 0x4) +} +func &testConstFoldSwitchNode02 (var %a i32) void { + funcid 0 + # switch (5 + (5 - a)) ... -> switch (10 - a) ... + switch (sub i32 (constval i32 0xa, dread i32 %a)) @labdft { + -2: goto @lab0 + 5: goto @lab1 + 8: goto @lab9 } +@lab0 return (constval i32 0x1) +@labdft return (constval i32 0x2) +@lab9 return (constval i32 0x3) +@lab1 return (constval i32 0x4) +} +func &testConstFoldArrayNode00 (var %x i32) void { + funcid 0 + var %a <* <[15][15] i32>> + # fold indexes -> array ptr <* <[15][15] i32>> (constval i32 0x6, constval i32 0x4) + dassign %x 0 (iread i32 <* i32> 0 (array ptr <* <[15][15] i32>> (constval i32 0x6, constval i32 0x4))) +} +func &testDepositbitsNodeNode00 (var %a i32, var %c i32) i32 { + funcid 0 + return (depositbits i32 1 23 ( + add i32 ( + add i32 (dread i32 %a, dread i32 %c), + constval i32 0xd), + constval i32 0xc)) +} +func &testDepositbitsNodeNode01 () i32 { + funcid 0 + return (constval i32 0x18) +} diff --git a/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.mplme.txt b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.txt b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/test.cfg b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0019-mapleall-irbuild-edge-constFoldTest/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/Main.mpl b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..b3a908413eb2eed59812f58d46face8b5c1503f3 --- /dev/null +++ b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/Main.mpl @@ -0,0 +1,8 @@ + func $cvtu64tof32 ( + var %i u64 + ) f32 { + return ( + cvt f32 u64(dread u64 %i))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/cvtu64tof32main.c b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/cvtu64tof32main.c new file mode 100644 index 0000000000000000000000000000000000000000..7610b6ef691f6f64fa4d20b72bb592babeb88a8b --- /dev/null +++ b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/cvtu64tof32main.c @@ -0,0 +1,8 @@ +extern float cvtu64tof32(unsigned long long int x); + +int main(){ + //printf("%f\n", cvtu64tof32(0xffffffff)); + //printf("%f\n", cvtu64tof32(0xfffffffffffff)); + //printf("%f\n", cvtu64tof32(1)); + printf("%f\n", cvtu64tof32(-1)); +} diff --git a/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.mplme.txt b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.txt b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/test.cfg b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0020-mapleall-irbuild-edge-cvtllutof32/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/Main.mpl b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8cfabdb80ae05938b81b862982b79bb3bcdccb07 --- /dev/null +++ b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/Main.mpl @@ -0,0 +1,8 @@ + func $cvtu64tof64 ( + var %i u64 + ) f64 { + return ( + cvt f64 u64(dread u64 %i))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/cvtu64tof64main.c b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/cvtu64tof64main.c new file mode 100644 index 0000000000000000000000000000000000000000..0c2e7a63b2557ba653e490c3da68cceb319a3bfa --- /dev/null +++ b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/cvtu64tof64main.c @@ -0,0 +1,14 @@ +extern double cvtu64tof64(unsigned long long int x); + +int main(){ + //printf("%f\n", cvtu64tof32(0xffffffff)); + //printf("%f\n", cvtu64tof32(0xfffffffffffff)); + //printf("%f\n", cvtu64tof32(1)); + printf("%f\n", cvtu64tof64(-1)); + printf("%f\n", cvtu64tof64(-111111111111111111)); + printf("%f\n", cvtu64tof64(1343423432)); + printf("%f\n", cvtu64tof64(44444444444444444444)); + printf("%f\n", cvtu64tof64(0)); + printf("%f\n", cvtu64tof64(0xffffffffffffffff)); + printf("%f\n", cvtu64tof64(1)); +} diff --git a/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.mplme.txt b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.txt b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/test.cfg b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0021-mapleall-irbuild-edge-cvtllutof64/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/Main.mpl b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..80efe03affd5546fc7b9db7a81a16ba23539695e --- /dev/null +++ b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/Main.mpl @@ -0,0 +1,10 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + depositbits i32 1 23( + constval i32 0xfff, constval i32 0x11))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.mplme.txt b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.txt b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/test.cfg b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0022-mapleall-irbuild-edge-depositbits1/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/DirectStorageAccess.c b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/DirectStorageAccess.c new file mode 100644 index 0000000000000000000000000000000000000000..803deea20c742d1dad23c4cad66dfeff699a31b4 --- /dev/null +++ b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/DirectStorageAccess.c @@ -0,0 +1,47 @@ +#include +#include +//Define a struct +typedef struct{ + char *address; + char name[10]; + int age; +}People; + +typedef struct{ + int number; + People employee; +}Info; + +int main() +{ + //direct read and assign + //direct read from scalar + char a = 'x'; + char b = a; + + int i = 5; + int ii = i; + + float j = 12.9; + float jj = j; + + double k = 20.5; + double kk = k; + + //direct read/write to fields inside a structure + //Structure field assign + People p, pp; + p.age = 25; + p.address = NULL; + strcpy(p.name,"Huawei"); + + //structure field read + pp.age = p.age; + pp.address = p.address; + strcpy(pp.name, p.name); + + Info info, info2; + info.employee = p; + info2.employee = info.employee; + return 1; +} diff --git a/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/Main.mpl b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..daf3d347ea19797fdba977e824add6046ea88b6a --- /dev/null +++ b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/Main.mpl @@ -0,0 +1,61 @@ +#This test case covers the following items: + +#MapleIR Direct read/write +#Direct acfgrecesses are associated with scalar variables and fixed fields inside +#structures. Direct accesses can be mapped to pseudo-register if the variable +#or field has no alias. +#In MAPLE IR, dassign and dread are the opcodes for direct assignments and +#direct references; + +#Syntax +#dread +#dassign() +#Type syntax +#type +func $strcpy ( var %dest <*i8>, var %src <*i8> ) <*i8> + +type $People < struct{ + @name <[10] i8>, + @age i8 }> + +type $Info < struct{ + @number i32, + @employee <$People> }> + +var $p <$People> +var $temp<[6] i8>= [ 104, 117, 97, 119, 101, 105 ] + +func $main ( )i32 { + var %a i8 + dassign %a ( constval i8 120 ) + var %b i8 + dassign %b ( dread i32 %a ) + var %i i32 + dassign %i ( constval i32 5 ) + var %ii i32 + dassign %ii ( dread i32 %i ) + var %j f32 + dassign %j ( constval f32 12.9f ) + var %jj f32 + dassign %jj ( dread f32 %j ) + var %k f64 + dassign %k ( constval f64 20.5 ) + var %kk f64 + dassign %kk ( dread f64 %k ) + var %p < $People > + var %pp < $People > + dassign $p 2 ( constval i32 25) + # dassign $p 1 ( constval i32 0 ) + #call (,...,) + call &strcpy ( addrof a64 %p, addrof a64 $temp) + call &strcpy ( addrof a64 %pp, addrof a64 %p) + var %info < $Info > + var %info2 < $Info > + dassign %info 2( dread agg %p ) + dassign %info2 2( dread agg %info 2) + return ( constval i32 444 ) +} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.mplme.txt b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.txt b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/test.cfg b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0023-mapleall-irbuild-edge-DirectStorageAccess/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/Main.mpl b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..67b210a10c947e8fefa363e1db8c5c391e3bd07d --- /dev/null +++ b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/Main.mpl @@ -0,0 +1,12 @@ +func $foo (var %i i32) i32 { + dowhile { + dassign %i ( + mul i32 (dread i32 %i, dread i32 %i)) + dassign %i ( + add i32 (dread i32 %i, constval i32 1) )} ( + lt i32 i32 ( dread i32 %i, constval i32 10) ) + return ( constval i32 0 ) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.mplme.txt b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.txt b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/test.cfg b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0024-mapleall-irbuild-edge-dowhile/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/Main.mpl b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..880fd8705f0a5a85ed6f46d5721c1bcb79334cd8 --- /dev/null +++ b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/Main.mpl @@ -0,0 +1,7 @@ +var $g <*ptr> +var $h <*ptr> = addrof ptr $g +var $g <*ptr> = addrof ptr $h +var $h <*ptr> + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.mplme.txt b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.txt b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/test.cfg b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0025-mapleall-irbuild-edge-dupvardecl/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/Main.mpl b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3a797ae50b147b854397f72ee724e260840ae412 --- /dev/null +++ b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/Main.mpl @@ -0,0 +1,19 @@ +func $foo ( var %i i32 ) i32 +func $fact ( var %n i32) i32 +func $fact ( var %n i32) i32 +func $foo ( var %i i32 ) i32 + +func $fact ( + var %n i32) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + call &foo( + sub i32 (dread i32 %n, constval i32 1)) + return (regread i32 %%retval)} + else { + return (constval i32 1) } } + +func $foo ( var %i i32 ) i32 { + return (dread i32 %i) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.mplme.txt b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.txt b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/test.cfg b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0026-mapleall-irbuild-edge-externfunc/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/Main.mpl b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8739173e937d4869d8ea5bf327a6ddbaadbbab8e --- /dev/null +++ b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/Main.mpl @@ -0,0 +1,7 @@ +var $extern_var extern i32 public + +func $test_extern_var ( var %i i32 ) i32 { + return (dread i32 $extern_var) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.mplme.txt b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.txt b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/test.cfg b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0027-mapleall-irbuild-edge-externvar/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/Main.mpl b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..4b33225b45ac0c3615f02dc00297bde74bd6d9ef --- /dev/null +++ b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/Main.mpl @@ -0,0 +1,83 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + extractbits i32 1 23( + constval i32 -998))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + extractbits i32 0 5(dread i32 %i))} + + func $foo11 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) u32 { + return ( + extractbits u32 0 5(dread i32 %i))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + extractbits i32 3 20(constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + extractbits i64 5 50(dread i64 %i))} + + func $foo4 ( + var %i i64, var %j i64, var %k i32 + )i64 { + return ( + extractbits i64 6 44 (dread i64 %i))} + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + extractbits i64 1 10(constval i64 0x11111))} + + func $foo9 ( + var %i i8, var %j u8, var %k i32) u32 { + return ( + extractbits u32 1 31(dread u32 %j))} + + func $foo51 ( + var %i u64 + ) u64 { + return ( + extractbits u64 0 15(constval i64 0x11111))} + + func $foo52 ( + var %i i32 + ) i32 { + return ( + sext i32 11 (constval i32 99))} + + func $foo53 ( + var %i u64 + ) u64 { + return ( + zext u64 11 (constval u64 88))} + + func $foo54 ( + var %i i32 + ) i32 { + return ( + sext i32 11 (dread i32 %i))} + + func $foo55 ( + var %i u64 + ) u64 { + return ( + zext u64 41 (dread u64 %i))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.mplme.txt b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.txt b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/test.cfg b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0028-mapleall-irbuild-edge-extractbits/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/Main.mpl b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..31a0f83b6c8f2854e8adf0bc09555df2d874588b --- /dev/null +++ b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/Main.mpl @@ -0,0 +1,17 @@ +#int fact(int n) { +# if (n == 1) +# return 1; +# return n * fact(n-1); +#} + +func $fact (var %n i32) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + call &fact (sub i32 (dread i32 %n, constval i32 1)) + return (mul i32 (dread i32 %n, regread i32 %%retval)) + } + return (constval i32 1) +} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.mplme.txt b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.txt b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/factmain.c b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/factmain.c new file mode 100644 index 0000000000000000000000000000000000000000..25af761793ad29628b894bdea4d5ccf3a0aa0739 --- /dev/null +++ b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/factmain.c @@ -0,0 +1,7 @@ +extern int fact(int n); + +int main(void) { + printf("%d\n", fact(5)); + return 0; +} + diff --git a/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/test.cfg b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0029-mapleall-irbuild-edge-fact/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/Main.mpl b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..a329387a2862f5e25d90e3bbf08806dfe07918d4 --- /dev/null +++ b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/Main.mpl @@ -0,0 +1,18 @@ +# typedef struct { int f1, char f2, unsigned short f3[]} SS; +# void foo(SS *x, SS *y) { +# int i, j; +# x->f3[ij] = y->f3[j]; +# } + +type $SS }> +func $foo ( var %x <*<$SS>>, var %y <*<$SS>>) void { + var %i i32 + var %j i32 + iassign <* u16> ( array 1 ptr <*[]u16> ( + iaddrof ptr <* <$SS>> 3 (dread ptr %x), dread i32 %i), + iread u16 <* u16> ( array 1 ptr <*[]u16> ( + iaddrof ptr <* <$SS>> 3 (dread ptr %y), dread i32 %j))) + return() } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.mplme.txt b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.txt b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/test.cfg b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0030-mapleall-irbuild-edge-farray/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/Main.mpl b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..5bb0c2903e534d3fa66d7c2c16a6a0067464d350 --- /dev/null +++ b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/Main.mpl @@ -0,0 +1,38 @@ +fileinfo{ + @magic 345, + @filename "adir/thisisafile.dex", + @dexoffset 560, + @flags 0x01ef, + @linksize 100 +} +type $SS +var $sconst1 , + @f33 i32, + @accessflag 0x45e, + @classdataoffset 118, + @f44 i32, + @f55 f32, + @f66 f32, + @superclassid 3333 + }> +func $fact () i32 { + funcinfo{ + @funcname "afunc", + @registers 345, + @ins 560, + @outs 444 + } + return (dread i32 $sconst1 1) + funcinfo{ + @funcidx 345, + @classidx 560 + } +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.mplme.txt b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.txt b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/test.cfg b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0031-mapleall-irbuild-edge-fileinfo/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/Main.mpl b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..911d3a1d307e80de543ab6d0bfe28b53c46b3306 --- /dev/null +++ b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/Main.mpl @@ -0,0 +1,13 @@ + # a function returning (i + j) * -998 + func $foo ( +# var %i xxx, + var %i i32, + var %j i32) i32 { + return ( + mul i32 ( + add i32 ( dread i32 %i, dread i32 %j), + constval i32 -998))} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.mplme.txt b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.txt b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/test.cfg b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0032-mapleall-irbuild-edge-first/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/Main.mpl b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..9e14dbb7d094b91c67fec8de6880f6d23143eef9 --- /dev/null +++ b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/Main.mpl @@ -0,0 +1,29 @@ + func $floorf64toi32 ( + var %i f64 + ) i32 { + return ( + floor i32 f64(dread f64 %i))} + + func $floorf64toi64 ( + var %i f64 + ) i64 { + return ( + floor i64 f64(dread f64 %i))} + + func $floorf32toi32 ( + var %i f32 + ) i32 { + return ( + floor i32 f32(dread f32 %i))} + + + func $floorf32toi64 ( + var %i f32 + ) i64 { + return ( + floor i64 f32(dread f32 %i))} + +# todo float floor + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.mplme.txt b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.txt b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/test.cfg b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0033-mapleall-irbuild-edge-floor/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/Main.mpl b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3a903d4dfd942181c787ac7bbe5183f6f39c0e89 --- /dev/null +++ b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/Main.mpl @@ -0,0 +1,14 @@ +var $arr1 <[10] f32> + +func $ArrayAdd () f32 { + var %ff i32 + var %sum f32 + dassign %sum ( constval f32 0.0f ) + foreachelem %ff $arr1 { + dassign %sum ( add f32 ( dread f32 %sum, dread f32 %ff ) ) + } + return ( dread f32 %sum ) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.mplme.txt b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.txt b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/test.cfg b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0034-mapleall-irbuild-edge-foreachelem/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/Main.mpl b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..f84b8d638026709ef8f764f798d49cefa5f40550 --- /dev/null +++ b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/Main.mpl @@ -0,0 +1,10 @@ +var $test_var i32 public + +func $test_extern_var ( var %i i32 ) i32 { + return (dread i32 $test_var) +} + +var $test_var i32 public = 0 + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.mplme.txt b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.txt b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/test.cfg b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0035-mapleall-irbuild-edge-forwarddeclare/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/Main.mpl b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..20e537607e60a307e1a9f6d4046efdfbe7292903 --- /dev/null +++ b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/Main.mpl @@ -0,0 +1,12 @@ +func $fact ( + var %n i32) i32 { + var %foo + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + icall ( dread a64 %foo, + sub i32 (dread i32 %n, constval i32 1)) + return (regread i32 %%retval)} + else { + return (constval i32 1) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.mplme.txt b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.txt b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/test.cfg b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0036-mapleall-irbuild-edge-funcptr/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/Main.mpl b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..d3875879ee5b2321a4c34fd2828552cc283e5549 --- /dev/null +++ b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/Main.mpl @@ -0,0 +1,31 @@ +type $ss1 , + @x <* f32>}> +type $ss2 , + @x <* f32>}>, + @pa <* }>>, + @x1 <[10] f64>, + @dx }> +type $ss3 <[] > +func &foo (var %x ) i32 { + var %y + dassign %y (dread agg %x) + return (dread i32 %y 1) +} +var $g <$ss1{!T=i32}> +var $h <$ss2{!U=i32,!SS=<$ss1{!T=f32}>}> +func &bar () i32 { + var %i i32 + callinstant &foo<{!W=<$ss2{!U=f32,!SS=i32}>}>( dread agg $g ) + callinstantassigned &foo<{!W=<$ss1{!T=i32}>}>( dread agg $g ) { dassign %i 0 } + virtualcallinstant &foo<{!W=<$ss2{!U=f32,!SS=i32}>}>( dread agg $g ) + virtualcallinstantassigned &foo<{!W=<$ss1{!T=i32}>}>( dread agg $g ) { dassign %i 0 } + superclasscallinstant &foo<{!W=<$ss2{!U=f32,!SS=i32}>}>( dread agg $g ) + superclasscallinstantassigned &foo<{!W=<$ss1{!T=i32}>}>( dread agg $g ) { dassign %i 0 } + interfacecallinstant &foo<{!W=<$ss2{!U=f32,!SS=i32}>}>( dread agg $g ) + interfacecallinstantassigned &foo<{!W=<$ss1{!T=i32}>}>( dread agg $g ) { dassign %i 0 } + return ( dread i32 %i ) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.mplme.txt b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.txt b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/test.cfg b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0037-mapleall-irbuild-edge-generics/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/Main.mpl b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..37e344e4952365c8ef1546107276b9eb9e6356ac --- /dev/null +++ b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/Main.mpl @@ -0,0 +1,114 @@ +var $g_i8_u +var $g_i8 = 8 +var $g_u8_u +var $g_u8 = 8 + +var $g_i16_u +var $g_i16 = 16 +var $g_u16_u +var $g_u16 = 16 + +var $g_i32_u +var $g_i32 = 32 +var $g_u32_u +var $g_u32 = 32 + +var $g_i64_u +var $g_i64 = 0x123456789a +var $g_u64_u +var $g_u64 = 0x123456789a + +var $g_f32_u +var $g_f32 = 1.2f + +var $g_f64_u +var $g_f64 = 2.4 + +# i8/u8 +func $add_i8_u () i8 { + return ( + add i32(dread i32 $g_i8_u, constval i32 0))} + +func $add_i8 () i8 { + return ( + add i32(dread i32 $g_i8, constval i32 0))} + +func $add_u8_u () u8 { + return ( + add u32(dread u32 $g_u8_u, constval u32 0))} + +func $add_u8 () u8 { + return ( + add u32(dread u32 $g_u8, constval u32 0))} + +# i16/u16 +func $add_i16_u () i16 { + return ( + add i32(dread i32 $g_i16_u, constval i32 0))} + +func $add_i16 () i16 { + return ( + add i32(dread i32 $g_i16, constval i32 0))} + +func $add_u16_u () u16 { + return ( + add u32(dread u32 $g_u16_u, constval u32 0))} + +func $add_u16 () u16 { + return ( + add u32(dread u32 $g_u16, constval u32 0))} + +# i32/u32 +func $add_i32_u () i32 { + return ( + add i32(dread i32 $g_i32_u, constval i32 0))} + +func $add_i32 () i32 { + return ( + add i32(dread i32 $g_i32, constval i32 0))} + +func $add_u32_u () u32 { + return ( + add u32(dread u32 $g_u32_u, constval u32 0))} + +func $add_u32 () u32 { + return ( + add u32(dread u32 $g_u32, constval u32 0))} + +# i64/u64 +func $add_i64_u () i64 { + return ( + add i64(dread i64 $g_i64_u, constval i64 0))} + +func $add_i64 () i64 { + return ( + add i64(dread i64 $g_i64, constval i64 0))} + +func $add_u64_u () u64 { + return ( + add u64(dread u64 $g_u64_u, constval u64 0))} + +func $add_u64 () u64 { + return ( + add u64(dread u64 $g_u64, constval u64 0))} + +# # f32 +# func $add_f32_u () f32 { + # return ( + # add f32(dread f32 $g_f32_u, constval f32 0.0f))} + +# func $add_f32 () f32 { + # return ( + # add f32(dread f32 $g_f32, constval f32 0.0f))} + +# # f64 +# func $add_f64_u () f64 { + # return ( + # add f64(dread f64 $g_f64_u, constval f64 0))} + +# func $add_f64 () f64 { + # return ( + # add f64(dread f64 $g_f64, constval f64 0))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.mplme.txt b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.txt b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/global.mpl.c b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/global.mpl.c new file mode 100644 index 0000000000000000000000000000000000000000..584ef81e2f4da6db7756844f221c88ebd056ec02 --- /dev/null +++ b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/global.mpl.c @@ -0,0 +1,127 @@ +#include +extern char add_i8_u(); +extern char add_i8(); +extern unsigned char add_u8_u(); +extern unsigned char add_u8(); + +extern short add_i16_u(); +extern short add_i16(); +extern unsigned short add_u16_u(); +extern unsigned short add_u16(); + +extern int add_i32_u(); +extern int add_i32(); +extern unsigned int add_u32_u(); +extern unsigned int add_u32(); + +extern long long add_i64_u(); +extern long long add_i64(); +extern unsigned long long add_u64_u(); +extern unsigned long long add_u64(); + +extern float add_f32_u(); +extern float add_f32(); + +extern double add_f64_u(); +extern double add_f64(); + +int main(){ + char g_i8_u = add_i8_u(); + char g_i8 = add_i8(); + unsigned char g_u8_u = add_u8_u(); + unsigned char g_u8 = add_u8(); + short g_i16_u = add_i16_u(); + short g_i16 = add_i16(); + unsigned short g_u16_u = add_u16_u(); + unsigned short g_u16 = add_i16(); + int g_i32_u = add_i32_u(); + int g_i32 = add_i32(); + unsigned int g_u32_u = add_u32_u(); + unsigned int g_u32 = add_u32(); + + long long g_i64_u = add_i64_u(); + long long g_i64 = add_i64(); + unsigned long long g_u64_u = add_u64_u(); + unsigned long long g_u64 = add_u64(); + + // float g_f32_u = add_f32_u(); + // float g_f32 = add_f32(); + + // double g_f64_u = add_f64_u(); + // double g_f64 = add_f64(); + // i8/u8 + printf("%d\n",g_i8_u); + printf("%d\n",g_i8); + if (8 != g_i8) { + printf("FAIL : g_i8 is not correct\n"); + return 1; + } + printf("%d\n",g_u8_u); + printf("%d\n",g_u8); + if (8 != g_u8) { + printf("FAIL : g_i8 is not correct\n"); + return 1; + } + + // i16/u16 + printf("%d\n",g_i16_u); + printf("%d\n",g_i16); + if (16 != g_i16) { + printf("FAIL : g_i16 is not correct\n"); + return 1; + } + printf("%d\n",g_u16_u); + printf("%d\n",g_u16); + if (16 != g_u16) { + printf("FAIL : g_u16 is not correct\n"); + return 1; + } + + // i32/u32 + printf("%d\n",g_i32_u); + printf("%d\n",g_i32); + if (32 != g_i32) { + printf("FAIL : g_i32 is not correct\n"); + return 1; + } + printf("%d\n",g_u32_u); + printf("%d\n",g_u32); + if (32 != g_u32) { + printf("FAIL : g_u32 is not correct\n"); + return 1; + } + + // i64/u64 + printf("%lld\n",g_i64_u); + printf("0x%llx\n",g_i64); + if (0x123456789a != g_i64) { + printf("FAIL : g_i64 is not correct\n"); + return 1; + } + printf("%lld\n",g_u64_u); + printf("0x%llx\n",g_u64); + if (0x123456789a != g_u64) { + printf("FAIL : g_u64 is not correct\n"); + return 1; + } + + // // f32 + // printf("%f\n",g_f32_u); + // printf("%f\n",g_f32); + // if (1.2f != g_f32) { + // printf("FAIL : g_f32 is not correct\n"); + // return 1; + // } + + // // f64 + // printf("%lf\n",g_f64_u); + // printf("%lf\n",g_f64); + // if (2.4 != g_f64) { + // printf("FAIL : g_f64 is not correct\n"); + // return 1; + // } + + printf("PASS : Scalar global variables initialization test.\n"); + + return 0; +} diff --git a/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/test.cfg b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0038-mapleall-irbuild-edge-global/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/Main.mpl b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..6983956b7ccf14a7801288ec8887bf70579dbfc1 --- /dev/null +++ b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/Main.mpl @@ -0,0 +1,11 @@ +var $const1 <[13] i8> = [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 10, 0 ] +func $printf (var %p1 <* i8>)void +func $main ( ) i32 { + call &printf (addrof a32 $const1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.mplme.txt b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.txt b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/test.cfg b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0039-mapleall-irbuild-edge-hello/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/Main.mpl b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..0a253eb2ee7cc4a4b61403d9a4c2734562f855ba --- /dev/null +++ b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/Main.mpl @@ -0,0 +1,24 @@ +func $fact ( + var %n i32) i32 { + var %foo + var %r1 i32 + var %r2 i32 + var %r3 i32 + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + icallassigned ( dread a64 %foo, + sub i32 (dread i32 %n, constval i32 1)) { + dassign %r1 0 + } + # Not correct, but for parse and dump test. + icallassigned ( dread a64 %foo, + sub i32 (dread i32 %n, constval i32 1)) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + return (dread i32 %n) + } +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.mplme.txt b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.txt b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/test.cfg b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0040-mapleall-irbuild-edge-icallassigned/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/Main.mpl b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..cf4e726d1e75fab5eeec53aa40476ff0470a8ec4 --- /dev/null +++ b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/Main.mpl @@ -0,0 +1,13 @@ +#int fact (int n) { +# if(n != 1) +# return foo(n - 1); +# else return 1; +#} + +func $fact ( + var %n i32) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + return (constval i32 0) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.mplme.txt b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.txt b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/test.cfg b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0041-mapleall-irbuild-edge-if1/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/Main.mpl b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..640bba9d4007aff19ef3460b6c74d17c05b3d301 --- /dev/null +++ b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/Main.mpl @@ -0,0 +1,15 @@ +#int fact (int n) { +# if(n != 1) +# return foo(n - 1); +# else return 1; +#} + +func $fact ( + var %n i32) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + return (constval i32 0) } + else { + return (constval i32 1) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.mplme.txt b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.txt b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/test.cfg b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0042-mapleall-irbuild-edge-if/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/Main.mpl b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..7d4bd99632214a9fe0305f2eab1400df55637c22 --- /dev/null +++ b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/Main.mpl @@ -0,0 +1,21 @@ +type $atyp <[10] f32> +var $fff = 7789 +func $foo ( var %i i32 )i32 +type $i32ty + +func $fact ( + var %n i32, var %m f32) i32 { + var %alocal <$i32ty> + dassign %alocal (constval i32 999) + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + eval (dread i32 %n) + call &foo( + add i32 (dread i32 %n, constval i32 1)) + return (regread i32 %%retval)} + else { + return (constval i32 1) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl \ No newline at end of file diff --git a/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.mplme.txt b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.txt b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/test.cfg b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0043-mapleall-irbuild-edge-if_then_else/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/Main.mpl b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..a6810f4fe2fd556964c776f3e9bd713f9a3aadbb --- /dev/null +++ b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/Main.mpl @@ -0,0 +1,11 @@ +importpath "." +importpath ".." +importpath "../ff" +var $x i32 +importpath "/a/bb/ccc/" +func $foo (var %y i32) void { + dassign $x (dread i32 %y) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.mplme.txt b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.txt b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/test.cfg b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0044-mapleall-irbuild-edge-importpath/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/Main.mpl b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..743f6913fa4ad0756e9812d8b312871e93ca51e4 --- /dev/null +++ b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/Main.mpl @@ -0,0 +1,12 @@ +var $p <* i32> +func $Foo (var %i i32) void { + iassign <* i32>( + dread a64 $p, + add i32( + iread i32 <* i32> ( dread a64 $p ), + dread i32 %i)) + return() +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.mplme.txt b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.txt b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/test.cfg b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0045-mapleall-irbuild-edge-indirect/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/InDirectStorageAccess.c b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/InDirectStorageAccess.c new file mode 100644 index 0000000000000000000000000000000000000000..f857f2abd815cb139eb1960a58cfd75f05d38c87 --- /dev/null +++ b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/InDirectStorageAccess.c @@ -0,0 +1,78 @@ +#include +#include +#include + +typedef struct{ + char *name; + int *number; +}People; + +int addition(int a, int b) +{ + return a+b; +} +int main() +{ + //pointers + //reference + char *cPtr = NULL; + char name[] = "Huawei"; + cPtr = name; + + //Pointer arithematic + char cPtr1 = *cPtr++; + char *cPtr2 = ++cPtr; + + //dereference + int *iPtr1, *iPtr2; + *iPtr1 = 10; + *iPtr2 = *iPtr1; + + People *sPtr; + sPtr = new People(); + strcpy(sPtr->name, "huawei"); + *(sPtr->number) = 5; + + //arrays + int i, j; + int aPtr1[10]; + int aPtr2[10][10]; + int aPtr3[10][10][10]; + + //1D array + for(i=0;i<10;i++){ + aPtr1[i] = 10; //constant + aPtr1[i] = i; //varaible + aPtr1[i] = *iPtr1; //pointer dereference + } + + //2D array + for(i=0;i<10;i++){ + for(j=0;j<10;j++){ + aPtr2[i][j] = 10; //constant value + aPtr2[i][j] = i*j; //variable arithmatic + aPtr2[i][j] = aPtr1[(i*j)%10]; //pointer access + } + } + + //3D array + int k; + for(i=0;i<10;i++){ + for(j=0;j<10;j++){ + for(k=0;k<10;k++){ + aPtr3[i][j][k] = 10; + aPtr3[i][j][k] = i*j*k; + aPtr3[i][j][k] = aPtr2[i][j]*10; + } + } + } + + //function pointer + int (*fPtr1)(int, int); + int (*fPtr2)(int, int); + fPtr1 = addition; + fPtr2 = &addition; + int result = fPtr1(2,3); + + return result; +} diff --git a/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/Main.mpl b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..7abf80f7dd59d7f1a0f09af448f8e3ef9340269d --- /dev/null +++ b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/Main.mpl @@ -0,0 +1,191 @@ +#indirect access are associated with pionters and arrays +#iassign(, ) +# type gives the high level type of and must be a pointer type +# is computed to return an address +# return a value +#iread() +# +func $new ( var %n i32 )a64 +func $strcpy ( var %dest <*i8>, var %src <*i8> )<*i8> +type $People < struct{ + @name < * i8 >, + @number < * i32> }> +func $addition ( var %a i32, var %b i32 )i32 { + return( + add i32( dread i32 %a, dread i32 %b ))} +var $name < [6] i8 > = [ 104, 117, 97, 119, 101, 105 ] +var $temp<[6] i8> = [ 104, 117, 97, 119, 101, 105 ] +func $main ( ) i32 { + var %cPtr < * i8 > + dassign %cPtr ( constval a64 0) + dassign %cPtr ( + addrof a64 $name) + + var %cPtr1 i8 + dassign %cPtr1( + iread i32 < * i8 >( dread a64 %cPtr )) + dassign %cPtr( + add u64( + dread a64 %cPtr, + constval u64 1)) + var %cPtr2 <* i8> + dassign %cPtr2( + add u64( + dread a64 %cPtr, + constval u64 1)) + + var %iPtr1 <* i32 > + var %iPtr2 <* i32 > + iassign < * i32>( + dread a64 %iPtr1, + constval i32 10) + iassign < * i32 >( + dread a64 %iPtr2, + iread i32 < * i32> ( + dread a64 %iPtr1)) + var %sPtr <* $People > + #call $new( + # iread <>) + call &new (constval u32 128) + dassign %sPtr( + regread a64 %%retval + ) + call &strcpy ( dread a64 %sPtr 0 , + addrof a64 $temp) + iassign <* i32>( + dread a64 %sPtr 0, + constval i32 5) + var %i i32 + var %j i32 + var %aPtr1 < [10] i32 > + var %aPtr2 < [10][10] i32 > + var %aPtr3 < [10][10][10] i32 > + dassign %i ( constval i32 0 ) + while( + lt i32 i32 ( dread i32 %i, constval i32 10 )){ + iassign < *[10] i32 >( + array 1 a64 < *[10] i32 >(addrof a64 %aPtr1, + dread i32 %i), + constval i32 10 ) + + iassign< *[10] i32 >( + array 1 a64 < *[10] i32 >( addrof a64 %aPtr1, + dread i32 %i), + dread i32 %i ) + + iassign < *[10] i32 >( + array 1 a64 < *[10] i32 >( addrof a64 %aPtr1, + dread i32 %i ), + iread i32 <* i32 >( + addrof a64 %aPtr1 )) + dassign %i( + add i32( + dread i32 %i, + constval i32 1))} + + + dassign %i ( constval i32 0 ) + while( + lt i32 i32 ( dread i32 %i, constval i32 10 )){ + dassign %j ( constval i32 0 ) + while( + lt i32 i32 ( dread i32 %j, constval i32 10 )){ + iassign < *[10][10] i32 >( + array 1 a64 < *[10][10] i32 >( addrof a64 %aPtr2, + dread i32 %i, + dread i32 %j), + constval i32 10 ) + iassign < *[10][10] i32 >( + array 1 a64< *[10][10] i32 >( addrof a64 %aPtr2, + dread i32 %i, + dread i32 %j), + mul i32 ( + dread i32 %i, + dread i32 %j)) + iassign< *[10][10] i32 >( + array 1 a64 < *[10][10] i32 >( addrof a64 %aPtr2, + dread i32 %i, + dread i32 %j), + iread i32 < *[10] i32 >( + array 1 a64< *[10] i32 >( + addrof a64 %aPtr1, + rem i32 ( + mul i32 ( + dread i32 %i, + dread i32 %j), + constval i32 10)))) + dassign %j( + add i32( + dread i32 %j, + constval i32 1))} + dassign %i( + add i32( + dread i32 %i, + constval i32 1))} + var %k i32 + dassign %i ( constval i32 0) + while( + lt i32 i32 ( dread i32 %i, constval i32 10 )){ + dassign %j ( constval i32 0) + while( + lt i32 i32 ( dread i32 %j, constval i32 10)){ + while( + lt i32 i32 ( dread i32 %k, constval i32 10)){ + iassign < *[10][10][10] i32 >( + array 1 a64 < *[10][10][10] i32 >(addrof a64 %aPtr3, + dread i32 %i, + dread i32 %j, + dread i32 %k), + constval i32 10) + iassign < *[10][10][10] i32 >( + array 1 a64 < *[10][10][10] i32>(addrof a64 %aPtr3, + dread i32 %i, + dread i32 %j, + dread i32 %k), + mul i32 ( + mul i32 ( + dread i32 %i, + dread i32 %j), + dread i32 %k)) + iassign < *[10][10][10] i32 >( + array 1 a64 < *[10][10][10] i32 >(addrof a64 %aPtr3, + dread i32 %i, + dread i32 %j, + dread i32 %k), + mul i32 ( + iread i32 < *[10][10] i32>( + array 1 a64 <*[10][10] i32>( addrof a64 %aPtr1, + dread i32 %i, + dread i32 %j)), + constval i32 10)) + dassign %k( + add i32( + dread i32 %k, + constval i32 1))} + dassign %j( + add i32( + dread i32 %j, + constval i32 1))} + dassign %i( + add i32( + dread i32 %i, + constval i32 1))} + + var %fPtr1 + var %fPtr2 + + dassign %fPtr1( + addrof a64 $addition) + dassign %fPtr2( + addrof a64 $addition) + var %result i32 + icall ( dread a64 %fPtr1, constval i32 2, constval i32 3) + dassign %result( + regread i32 %%retval) + return ( dread i32 %result)} + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.mplme.txt b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.txt b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/test.cfg b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0046-mapleall-irbuild-edge-InDirectStorageAccess/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/Main.mpl b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..f4c0354e7f513018cdfffc17dc64f8cd1a7b09c0 --- /dev/null +++ b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/Main.mpl @@ -0,0 +1,9 @@ +type $I1 +type $I2 +type $RR <$I2> {@e1 i32, &method1(agg)agg, &method2(void)void}> +javainterface $UU <$RR> public static +type $CC +type $TT {@f1 i32, @f2 i8, @f3 i8, $I1, $I2, $RR}> + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.mplme.txt b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.txt b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/test.cfg b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0047-mapleall-irbuild-edge-interface/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/Main.mpl b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..02dfd61c5161647183736fddc408c1032e8cab79 --- /dev/null +++ b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/Main.mpl @@ -0,0 +1,13 @@ +srclang 3 +type $SS }> +func $foo ( var %x <*<$SS>>, var %y <*<$SS>>) void { + var %i i32 + var %j i32 + iassign <* u16> ( array 1 ptr <*[]u16> ( + iaddrof ptr <* <$SS>> 3 (dread ptr %x), dread i32 %i), + iread u16 <* u16> ( array 1 ptr <*[]u16> ( + iaddrof ptr <* <$SS>> 3 (dread ptr %y), dread i32 %j))) + return() } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.mplme.txt b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.txt b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/test.cfg b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0048-mapleall-irbuild-edge-jarray/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/Main.mpl b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..1a95394d113ffa191e4887dfe1fd0b536d2389c3 --- /dev/null +++ b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/Main.mpl @@ -0,0 +1,10 @@ +type $atyp <[10] f32> +var $fff = 7789 +func $foo ( var %i i32 )i32 + +func $fact ( + var %n i32, var %m f32) void { + return () } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.mplme.txt b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.txt b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/test.cfg b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0049-mapleall-irbuild-edge-just_ret/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/Main.mpl b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..a69899900b708d617827eb390e793be96bb06431 --- /dev/null +++ b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/Main.mpl @@ -0,0 +1,14 @@ + func $landi32 ( + var %i i32, var %j i32 + ) i32 { + return ( + land i32(dread i32 %i, dread i32 %j))} + + func $landi64 ( + var %i i64, var %j i64 + ) i32 { + return ( + land i64(dread i64 %i, dread i64 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.mplme.txt b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.txt b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/test.cfg b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0050-mapleall-irbuild-edge-land/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/Main.mpl b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..900ffdf6706556ad56c9170525f2e0a7f332c8ea --- /dev/null +++ b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/Main.mpl @@ -0,0 +1,14 @@ + func $liori32 ( + var %i i32, var %j i32 + ) i32 { + return ( + lior i32(dread i32 %i, dread i32 %j))} + + func $liori64 ( + var %i i64, var %j i64 + ) i32 { + return ( + lior i64(dread i64 %i, dread i64 %j))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.mplme.txt b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.txt b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/test.cfg b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0051-mapleall-irbuild-edge-lior/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/Main.mpl b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..84b8db30091eeeb9ba22d273cdad94f6a7d5c0c6 --- /dev/null +++ b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/Main.mpl @@ -0,0 +1,37 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + lnot i32(dread i32 %i))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + lnot i32(dread i32 %i))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + lnot i32(constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + lnot i64(dread i64 %i))} + + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + lnot i64(constval i64 0x11111))} + +# todo float lnot + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.mplme.txt b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.txt b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/test.cfg b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0052-mapleall-irbuild-edge-lnot/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/Main.mpl b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3b8711cb5f6b2307bf4a3e30da208114bc67be4a --- /dev/null +++ b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/Main.mpl @@ -0,0 +1,22 @@ +# float a[10]; +# void init(void) { +# int i; +# for (i=0; i<10; i++) +# a[i] = i*3; +# } + +var $a <[10] f32> +var $f1 f32 +func $init () void { + var %i i32 + dassign %i ( constval i32 0 ) + while ( + lt i32 i32 ( dread i32 %i, constval i32 10) ) { + iassign <* [10] f32> ( + array 1 a32 <* [10] f32> (addrof a32 $a, dread i32 %i), + mul f32 (dread f32 $f1, constval f32 3.33f) ) + dassign %i ( + add i32 (dread i32 %i, constval i32 1) )} } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.mplme.txt b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.txt b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/test.cfg b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0053-mapleall-irbuild-edge-loop/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/Main.mpl b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..9f93b5a3d9b94f69fb189e2aa8609e0e562f288e --- /dev/null +++ b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/Main.mpl @@ -0,0 +1,12 @@ +func &foo ( var %i i32 ) void { + var %p ptr + dassign %p ( malloc ptr ( constval i32 8 )) + dassign %p ( alloca ptr ( constval i32 16 )) + dassign %p ( gcmalloc ref i32 ) + dassign %p ( gcmallocjarray ref <[] i32> ( constval i32 5 )) + free ( dread ref %p) +} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.mplme.txt b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.txt b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/test.cfg b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0054-mapleall-irbuild-edge-malloc/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/Main.mpl b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..96ff02f6b439a646334b5bff704ed4d7f77b361e --- /dev/null +++ b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/Main.mpl @@ -0,0 +1,15 @@ +type $RR +type $SS { @accessflag 1234, + &method1(agg)agg, + &method2(void)void}> +func $foo ( + var %x <$SS>) i32 { + dassign %x 2 ( constval i32 32 ) + return ( dread i32 %x 2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.mplme.txt b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.txt b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/test.cfg b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0055-mapleall-irbuild-edge-methods2/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/Main.mpl b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..178efb2aacea200a522e16652939f486bc6bf9d7 --- /dev/null +++ b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/Main.mpl @@ -0,0 +1,21 @@ +func &meth1() void +func &meth3() i32 +var $sconst1 = [ 6=10.07f, 2=699, 3=-273, 4=75, 1=31425926, 5=6.02e+23f ] +func &printf (var %p1 <* i8>)void +func &main ( ) i32 { + call &printf (addrof a32 $sconst1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.mplme.txt b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.txt b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/test.cfg b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0056-mapleall-irbuild-edge-methods/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/Main.mpl b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..bf7891e3f110b036719a3e9487acf6baf492f50b --- /dev/null +++ b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/Main.mpl @@ -0,0 +1,20 @@ +var $g i32 +var $h i32 +func $multiwayfunc ( var %n i32) i32 { + multiway (dread i32 %n) @labdft { + (add i32 (dread i32 $g, dread i32 $h)): goto @lab0 + (dread i32 $h): goto @lab1 + (constval i32 888): goto @lab0 + (constval i32 'Y'): goto @lab0 + (neg i32 (dread i32 $h)) : goto @lab9 } +@lab0 + return (constval i32 -3) +@labdft + return (constval i32 100) +@lab9 + return (constval i32 9) +@lab1 + return (constval i32 1) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.mplme.txt b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.txt b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/test.cfg b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0057-mapleall-irbuild-edge-multiway/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/Main.mpl b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..de974cbccd567b7c4d3b64835b2104cf7a1d1da1 --- /dev/null +++ b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/Main.mpl @@ -0,0 +1,18 @@ +var $g ptr +var $h i32 +func $multiwayfunc ( var %p ptr) ptr { + multiway (dread ptr %p) @labdft { + (dread ptr $g): goto @lab1 + (add ptr (dread i32 $g, dread i32 $h)): goto @lab0 + (conststr ptr "world"): goto @lab9 } +@lab0 + return (dread ptr $g) +@labdft + return (conststr ptr "hello") +@lab9 + return (add ptr (conststr ptr "foo", dread i32 $h)) +@lab1 + return (addrof ptr $h) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.mplme.txt b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.txt b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/test.cfg b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0058-mapleall-irbuild-edge-multiwaystr/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/Main.mpl b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..c06bc9c2dc1ae05dea9f5f4fe868265d9c01833e --- /dev/null +++ b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/Main.mpl @@ -0,0 +1,60 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + neg i32(dread i32 %i))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + neg i32(dread i32 %i))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + neg i32(constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + neg i64(dread i64 %i))} + + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + neg i64(constval i64 0x11111))} + + func $foo6 ( + var %i f64 + ) f64 { + return ( + neg f64(dread f64 %i))} + + func $foo7 ( + var %i f32 + ) f32 { + return ( + neg f32(dread f32 %i))} + + func $foo8 ( + var %i f64 + ) f64 { + return ( + neg f64(constval f64 -1.24))} + + func $foo9 ( + var %i f32 + ) f32 { + return ( + neg f32(constval f32 -1.24f))} +# todo float neg + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.mplme.txt b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.txt b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/test.cfg b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0059-mapleall-irbuild-edge-neg/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/Main.mpl b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..d10a0c552fb09ee5e75b886b371159aa59d9d2a9 --- /dev/null +++ b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/Main.mpl @@ -0,0 +1,10 @@ +type $RR +type $SS {^f1 i32, @f2 i8, ^f3 i8}> +javaclass $TT <$SS> public static +func &foo ( + var %x <$SS>) i32 { + dassign %x -1 ( constval i32 32 ) + return ( dread i32 %x -2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.mplme.txt b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.txt b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/test.cfg b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0060-mapleall-irbuild-edge-parentfields/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/Main.mpl b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..693163aa4e9b8647df64e52ee812ac1e311a4351 --- /dev/null +++ b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/Main.mpl @@ -0,0 +1,15 @@ +type $SS +javaclass $TT <$SS> public static + +func &bar (var %y i32) i32 { + return (dread i32 %y) +} + +func &foo (var %x <$SS>) i32 { + var %ret i32 + polymorphiccallassigned &bar (dread i32 %x 1) {dassign %ret 0} + return (dread i32 %ret) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.mplme.txt b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.txt b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/test.cfg b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0061-mapleall-irbuild-edge-polymorphiccallassigned/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/Main.mpl b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..cb0fed58de37945afa50bf4e958e411d7e8d77cd --- /dev/null +++ b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/Main.mpl @@ -0,0 +1,20 @@ +type $atyp <[10] f32> +type $aaaa +var $fff <$atyp> +func $foo ( var %i i32 )i32 + +func $fact ( + var %n i32, var %m f32) i32 { + regassign i32 %987 (constval i32 '0') + if (ne i32 i32 (regread i32 %987, constval i32 10)) { + eval (regread i32 %987) + call &foo( + sub i32 (regread i32 %1, constval i32 1)) + return (regread i32 %%retval)} + else { + regassign i32 %987 (constval i32 111) + return (constval i32 '1') } + } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.mplme.txt b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.txt b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/test.cfg b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0062-mapleall-irbuild-edge-pregs/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/Main.mpl b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8222d5e88729be1684f178d5341f398d7ff92176 --- /dev/null +++ b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/Main.mpl @@ -0,0 +1,46 @@ +var $myStruct < struct{ + @number i32, + @p <* i8> }> +func $main ()i32{ + #Character + var %sChar i8 + var %usChar i8 + #signed and unsigned short integer + var %shortInt i16 + var %shortInt2 i16 + var %sShortInt i16 + var %sShortInt2 i16 + var %usShortInt i16 + var %usShortInt2 i16 + #signed and unsigned integer + var %int1 i32 + var %sInt i32 + var %usInt i32 + var %usInt2 i32 + #signed and unsigned long integer + var %long1 i64 + var %long2 i64 + var %sLong1 i64 + var %sLong2 i64 + var %usLong i64 + var %usLong2 i64 + var %lLong1 i64 + var %iLong2 i64 + var %sLlong1 i64 + var %sLlonog2 i64 + var %usLlong i64 + var %usLlong2 i64 + #float + var %Float f32 + #double + var %Double f64 + #long double + var %lDouble f64 + #Address + var %array <[10] i8> + iassign<* i8>( + array 1 a64<*[10] i8>(addrof a64 %array, constval i64 1), + constval i32 120)} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/PrimTypes.c b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/PrimTypes.c new file mode 100644 index 0000000000000000000000000000000000000000..cb2ecce7834ab2c5a5c23366e3b4935e116cb32c --- /dev/null +++ b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/PrimTypes.c @@ -0,0 +1,52 @@ +//This testcase covers all mapleIR's primitive types +#include +#include + +struct{ + int number; + char *p + }myStruct; + +int main() +{ + + //Character + char sChar; + signed char sChar2; + unsigned char usChar; + //signed and unsigned short Integer + short shortInt; + short int shortInt2; + signed short sShortInt; + signed short int sShortInt2; + unsigned short usShortInt; + unsigned short int usShortInt2; + //signed and unsigned integer + int int1; + signed int sInt; + unsigned usInt; + unsigned int usInt2; + //signed and unsigned long integer + long long1; + long int long2; + signed long sLong1; + signed long int sLong2; + unsigned long usLong; + unsigned long int usLong2; + long long lLong1; + long long int lLong2; + signed long long sLlong1; + signed long long int sLlong2; + unsigned long long usLlong; + unsigned long long usLlong2; + //float + float Float; + //double + double Double; + //long double + long double lDouble; + //Address + char array[10]; + array[1] = 'x'; + return; +} diff --git a/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.mplme.txt b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.txt b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/test.cfg b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0063-mapleall-irbuild-edge-PrimTypes/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/Main.mpl b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..e1f91e8403cba11e0be313b1778910f20a6976ae --- /dev/null +++ b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/Main.mpl @@ -0,0 +1,27 @@ + func $foo6 ( + var %i f64 + ) f64 { + return ( + recip f64(dread f64 %i))} + + func $foo7 ( + var %i f32 + ) f32 { + return ( + recip f32(dread f32 %i))} + + func $foo8 ( + var %i f64 + ) f64 { + return ( + recip f64(constval f64 -1.24))} + + func $foo9 ( + var %i f32 + ) f32 { + return ( + recip f32(constval f32 -1.24f))} +# todo float recip + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.mplme.txt b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.txt b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/test.cfg b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0064-mapleall-irbuild-edge-recip/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/Main.mpl b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..7ac65fa78234fc15668f4661677acc4ff28ee764 --- /dev/null +++ b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/Main.mpl @@ -0,0 +1,26 @@ + func $retypef64toi64 ( + var %i f64 + ) i64 { + return ( + retype i64 (dread f64 %i))} + + func $retypei64tof64 ( + var %i i64 + ) f64 { + return ( + retype f64 (dread i64 %i))} + + func $retypef32toi32 ( + var %i f32 + ) i32 { + return ( + retype i32 (dread f32 %i))} + + func $retypei32tof32 ( + var %i i32 + ) f32 { + return ( + retype f32 (dread i32 %i))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.mplme.txt b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.txt b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/retypemain.c b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/retypemain.c new file mode 100644 index 0000000000000000000000000000000000000000..6c6b7a7d055c515ee20ae6f4984c62aa07f12bc2 --- /dev/null +++ b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/retypemain.c @@ -0,0 +1,19 @@ +extern int retypef32toi32(float x); +extern float retypei32tof32(int x); +extern long long int retypef64toi64(double x); +extern double retypei64tof64(long long int x); + +int main(void) { + union {float f1; int i1;} valf1, valf2; + union {double d1; long long int i1;} vald1, vald2; + valf1.f1 = 1.2343; + valf2.f1 = 22.222; + vald1.d1 = 1111111111111.1234343434; + vald2.d1 = 222222222222222222.22222222222222; + printf("%d vs %d\n", valf1.i1, retypef32toi32(valf1.f1)); + printf("%f vs %f\n", valf1.f1, retypei32tof32(valf1.i1)); + printf("%lld vs %lld\n", vald1.i1, retypef64toi64(vald1.d1)); + printf("%f vs %f\n", vald1.d1, retypei64tof64(vald1.i1)); + return 0; +} + diff --git a/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/test.cfg b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0065-mapleall-irbuild-edge-retype/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/Main.mpl b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..6a5e4beebaa091088129cf5c4f9b621a9cbfe697 --- /dev/null +++ b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/Main.mpl @@ -0,0 +1,42 @@ + func $selecti32 ( + var %i i32, + var %j i32, + var %k i32) i32 { + return ( + select i32 ( + dread i32 %i, + dread i32 %j, + dread i32 %k))} + + func $selecti64 ( + var %i i32, + var %j i64, + var %k i64) i64 { + return ( + select i64 ( + dread i32 %i, + dread i64 %j, + dread i64 %k))} + + func $selectf32 ( + var %i i32, + var %j f32, + var %k f32) f32 { + return ( + select f32 ( + dread i32 %i, + dread f32 %j, + dread f32 %k))} + + func $selectf64 ( + var %i i32, + var %j f64, + var %k f64) f64 { + return ( + select f64 ( + dread i32 %i, + dread f64 %j, + dread f64 %k))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.mplme.txt b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.txt b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/test.cfg b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0066-mapleall-irbuild-edge-select/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/Main.mpl b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..741f792157a2a19c6c36b013260e4b746d45a159 --- /dev/null +++ b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/Main.mpl @@ -0,0 +1,10 @@ +# ;, / and | are allowed name characters, but they cannot be the starting char + func $foo ( + var %i; i32, + var %j|/ i32 + ) i32 { + return ( + add i32(dread i32 %i;, dread i32 %j|/))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.mplme.txt b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.txt b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/test.cfg b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0067-mapleall-irbuild-edge-specialchar/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/Main.mpl b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..5ce01267dbaf3f0ef76a58313b389d49e89b76c9 --- /dev/null +++ b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/Main.mpl @@ -0,0 +1,27 @@ + func $foo6 ( + var %i f64 + ) f64 { + return ( + sqrt f64(dread f64 %i))} + + func $foo7 ( + var %i f32 + ) f32 { + return ( + sqrt f32(dread f32 %i))} + + func $foo8 ( + var %i f64 + ) f64 { + return ( + sqrt f64(constval f64 4.0))} + + func $foo9 ( + var %i f32 + ) f32 { + return ( + sqrt f32(constval f32 4.0f))} +# todo float sqrt + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.mplme.txt b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.txt b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/test.cfg b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0068-mapleall-irbuild-edge-sqrt/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/Main.mpl b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..6996dfacb541147bc0e40680b8d1ac0f26384817 --- /dev/null +++ b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/Main.mpl @@ -0,0 +1,16 @@ +type $SS +var $sconst1 , + @f33 i32, + @f44 i32, + @f55 f32, + @f66 f32}> = [ 1=1007, 2= [1=11.11f, 2=22.22f], 5=-273, 6=75, 4=6023.1f ] +func $fact () i32 { + return (dread i32 $sconst1 1) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.mplme.txt b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.txt b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/test.cfg b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0069-mapleall-irbuild-edge-struct2/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/Main.mpl b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..41ff062188c1aedd365c357399d0f84399d9d0de --- /dev/null +++ b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/Main.mpl @@ -0,0 +1,13 @@ +type $__field_meta__ , + @type <* void>}> +var $v1 <* void> public +var $v2 <* void> public +var $vs <[1] <$__field_meta__>> public = [[1= 0x35ad1b, 2= 0xabcd, 3= addrof ptr $v2, 4= addrof ptr $v1]] +var $vvs <[2][1] <$__field_meta__>> public = [[[1= 11, 2= 22, 3= addrof ptr $v1, 4= addrof ptr $v1]], + [[1= 33, 2= 44, 3= addrof ptr $v2, 4= addrof ptr $v2]]] + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.mplme.txt b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.txt b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/test.cfg b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0070-mapleall-irbuild-edge-structarrayinit/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/Main.mpl b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..84c7a1cebd7852237570d41822cce2f7c25c634f --- /dev/null +++ b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/Main.mpl @@ -0,0 +1,17 @@ +var $sconst1 = [ 6=10.07f, 2=699, 3=-273, 4=75, 1=31425926, 5=6.02e+23f ] +func &printf (var %p1 <* i8>)void +func &main ( ) i32 { + call &printf (addrof a32 $sconst1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.mplme.txt b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.txt b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/test.cfg b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0071-mapleall-irbuild-edge-structinit/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/Main.mpl b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..972dfaabacc967135306ac668068391c9d282ad7 --- /dev/null +++ b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/Main.mpl @@ -0,0 +1,17 @@ +# typedef struct ss { +# int f1; +# char f2:3; +# char f3:5; +# } SS; +# SS foo(SS x) { +# x.f2 = 32; +# return x; +# } +type $SS +func $foo ( + var %x <$SS>) i32 { + dassign %x 2 ( constval i32 32 ) + return ( dread i32 %x 2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.mplme.txt b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.txt b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/test.cfg b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0072-mapleall-irbuild-edge-struct/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/Main.mpl b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8ec155e6f829f1a086a61fa49f3f0df909bddc44 --- /dev/null +++ b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/Main.mpl @@ -0,0 +1,54 @@ +#struct aa{ +# double b; +# float *x; +#}; + +#struct bb { +# struct aa b1; +# struct aa *pa; +# double x1[10]; +# double dx; +#}; + +#typedef struct ss { +# int f1; +# char f2:3; +# struct aa a3; +# struct aa *pa1; +# char f3:5; +# struct bb *b3; +# struct bb *b2; +# struct aa xt[23]; +# struct aa(* funcc)(int, int, double); +#}SS; + +type $unname1 }> +type $unname2 }>, + @pa <* }>>, + @x1 <[10] f64>, + @dx f64}> +type $SS }>, + @pa1 <* } >>, + @f3:5 i32, + @b3 <* }>, + @pa <* }>>, + @x1 <[10] f64>, + @dx f64}>>, + @b2 <* $unname2>, + @xt <[23] }>>, + @funcc }>>}> + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.mplme.txt b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.txt b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/test.cfg b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0073-mapleall-irbuild-edge-struct_type/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/Main.mpl b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3d75348527b70cb616949e1d317070b8870a1152 --- /dev/null +++ b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/Main.mpl @@ -0,0 +1,64 @@ + func $foo ( + var %i i32 +#var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + sub i32(dread i32 %i, + constval i32 -998))} + + func $foo1 ( + var %i i32, var %j i32, var %k i32, + var %i1 i32, var %j1 i32, var %k1 i32 + ) i32 { + return ( + sub i32(dread i32 %i, dread i32 %j))} + + func $foo2 ( + var %i i32, var %j i32, var %k i32 + ) i32 { + return ( + sub i32(dread i32 %i, constval i32 0x111111111))} + + func $foo3 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + sub i64(dread i64 %i, constval i64 0x111111111))} + + func $foo4 ( + var %i i64, var %j i64, var %k i32 + )i64 { + return ( + sub i64(dread i64 %i, dread i64 %j))} + + func $foo5 ( + var %i i64, var %j i64, var %k i32 + ) i64 { + return ( + sub i64(dread i64 %i, constval i64 0x11111))} + + func $foo6 ( + var %i f64, var %j f64, var %k i32 + ) f64 { + return ( + sub f64(dread f64 %i, constval f64 2.237))} + + func $foo66 ( + var %i f64, var %j f64, var %k i32 + ) f64 { + return ( + sub f64(dread f64 %i, constval f64 2.237))} + func $foo7 ( + var %i f32, var %j f32, var %k i32 + ) f32 { + return ( + sub f32(dread f32 %i, dread f32 %j))} + + func $foo8 ( + var %i f32, var %j f64, var %k i32 + ) f32 { + return ( + sub f32(dread f32 %i, constval f32 2.237f))} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.mplme.txt b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.txt b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/test.cfg b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0074-mapleall-irbuild-edge-sub/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/Main.mpl b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..710e9b1d5713fa553519a09d822e5d319392e5e2 --- /dev/null +++ b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/Main.mpl @@ -0,0 +1,20 @@ +type $SS +var $sconst1 , + @f33 i32, + @f44 i32, + @f55 f32, + @f66 f32}> = [ 6=1007, 2= [1=11.11f, 2=22.22f], 3=-273.2f, 4=75.3f, 1=1425926, 5=6023 ] +func $printf (var %p1 <* i8>)void +func $main ( ) i32 { + call &printf (addrof a32 $sconst1) + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.mplme.txt b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.txt b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/test.cfg b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0075-mapleall-irbuild-edge-substructinit/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/Main.mpl b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..8750d119201ac691f3c2c067808eb86ec0f2c23b --- /dev/null +++ b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/Main.mpl @@ -0,0 +1,17 @@ +func $switchfunc ( var %n i32) i32 { + var %alocal i32 + switch (dread i32 %n) @labdft { + -3: goto @lab0 + 1: goto @lab1 + 9: goto @lab9 } +@lab0 + return (constval i32 -3) +@labdft + return (constval i32 100) +@lab9 + return (constval i32 9) +@lab1 + return (constval i32 1) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.mplme.txt b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.txt b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/switch_main.c b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/switch_main.c new file mode 100644 index 0000000000000000000000000000000000000000..0b30d2724f21aab6020c8cd770677c39ad14b132 --- /dev/null +++ b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/switch_main.c @@ -0,0 +1,11 @@ +extern int switchfunc(int n); +int main(){ + printf("%d\n", switchfunc(1)); + printf("%d\n", switchfunc(-3)); + printf("%d\n", switchfunc(1)); + printf("%d\n", switchfunc(9)); + printf("%d\n", switchfunc(1)); + printf("%d\n", switchfunc(100)); + printf("%d\n", switchfunc(-4)); + printf("%d\n", switchfunc(-5)); +} diff --git a/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/test.cfg b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0076-mapleall-irbuild-edge-switch/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/Main.mpl b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..bac9bc95caf5a9ae4a8d54c0fd0735f5c063ada5 --- /dev/null +++ b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/Main.mpl @@ -0,0 +1,42 @@ +# 1 public class sync { +# 2 private Object go = new Object(); +# 3 private int waiters = 0; +# 4 +# 5 public void foo() { +# 6 synchronized (go) { +# 7 waiters++; +# 8 } +# 9 } +# 10 } + +# some unrelated functions are removed +type $Ljava/lang/Object; +type $Lsync; { + @go <* <$Ljava/lang/Object;>> private, + @waiters i32 private, + &Lsync;|foo|__V|(<* <$Lsync;>>) void}> +func &Lsync;|foo|__V| (var %_this <* <$Lsync;>>) void { + var %Reg1_R33 <* <$Ljava/lang/Object;>> + var %Reg0_I i32 + var %Reg0_R38 <* void> + #LINE sync.java:6 + dassign %Reg1_R33 0 (iread ptr <* <$Lsync;>> 1 (dread ptr %_this 0)) + syncenter (dread ptr %Reg1_R33 0) + #LINE sync.java:7 + dassign %Reg0_I 0 (iread i32 <* <$Lsync;>> 2 (dread ptr %_this 0)) + dassign %Reg0_I 0 (add i32 ( + dread i32 %Reg0_I 0, + cvt i32 i8 (constval i8 1))) + iassign <* <$Lsync;>> 2 (dread ptr %_this 0, dread i32 %Reg0_I 0) + #LINE sync.java:8 + syncexit (dread ptr %Reg1_R33 0) + #LINE sync.java:9 + return () + #LINE sync.java:8 + dassign %Reg0_R38 0 (regread ptr %%thrownval) + syncexit (dread ptr %Reg1_R33 0) + throw (dread ptr %Reg0_R38 0) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.mplme.txt b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.txt b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/test.cfg b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0077-mapleall-irbuild-edge-sync/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/Main.mpl b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..12acd02e4a9d9cc1617d25cfab42c5ff660b8eb0 --- /dev/null +++ b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/Main.mpl @@ -0,0 +1,15 @@ + # a function returning (i + j) * -998 + func $foo ( +# var %i xxx, + var %i i32, + var %j i32, + var %k i32) i32 { + return ( + select i32 ( + dread i32 %i, + dread i32 %j, + dread i32 %k))} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.mplme.txt b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.txt b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/test.cfg b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0078-mapleall-irbuild-edge-ternary/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/Main.mpl b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..e88694db1e68f23b1867e83018b1fe3fd68b2783 --- /dev/null +++ b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/Main.mpl @@ -0,0 +1,15 @@ +#var $const1 <[13] i8> [ 104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 10, 0 ] +var $fconst1 <[18] f64> = [ 1007, 707, -273, 75, 0113, 0x4b, 75u, 75l, 75ul, 75lu, 3.1425926, 6.02e23, 6.02e+23, 1.6e-19, 3.0, 3.14159, 6.02e23, .233 ] +func $printf (var %p1 <* i8>)void +func $main ( ) i32 { + call &printf (addrof a32 $fconst1) + call &printf (conststr ptr "\"hello maple\"", conststr a32 "\nworld\n") + # 你好: E4 BD A0 E5 A5 BD 中国: E4 B8 AD E5 9B BD + call &printf (conststr16 ptr "\xE4\xBD\xA0\xE5\xA5\xBD", conststr16 a32 "\xE4\xB8\xAD\xE5\x9B\xBD") + return (constval i32 0) } + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.mplme.txt b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.txt b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/test.cfg b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0079-mapleall-irbuild-edge-testconst/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/Main.mpl b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..9f79476c5eae1a8a1a207845375cb1bbae5a9114 --- /dev/null +++ b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/Main.mpl @@ -0,0 +1,50 @@ +func $foo1 (var %p1 i8, var %p2 i16, var %p3 i32, var %p4 i64, ...)i32 { + return ( + constval i32 33)} +func $foo2 (var %p1 u8, var %p2 u16, var %p3 u32, var %p4 u64,...) i32 { + return ( + constval i32 33)} +func $foo4 (var %p1 f32, var %p2 f64, ... ) i32 { + return ( + constval i32 33)} + +func $foo5 (var %p1 a32, var %p2 a64,...) i32 +func $foo6 (var %p1 c64, var %p2 c128, ...) i32 + +func $foo7 (var %p1 <* i8>, var %p2 <* i16>, var %p3 <* i32>, var %p4 <* i64>) i32 { + return ( + constval i32 33)} +func $foo8 (var %p1 <* u8>, var %p2 <* u16>, var %p3 <* u32>, var %p4 <* u64>) i32 { + return ( + constval i32 33)} +func $foo9 (var %p1 <* u1>) i32 { + return ( + constval i32 33)} +func $foo10 (var %p1 <* f32>, var %p2 <* f64>) i32 { + return ( + constval i32 33)} +func $foo11 (var %p1 <* void>)void + +func $foo12 (var %p1 <[10] i8>) i32 { + return ( + constval i32 33)} +func $foo13 (var %p1 <[10][32] i32>) i32 { + return ( + constval i32 33)} +func $foo14 (var %p1 <[10][32][43] i32>) i32 { + return ( + constval i32 33)} +func $foo15 (var %p1 <[10][32][43][54][56][78][90][122][223][334] i32>) i32 { + return ( + constval i32 33)} + +type $SS +func $foo16 (var %x <$SS>) i32 { + return ( + constval i32 33)} + + + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.mplme.txt b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.txt b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/test.cfg b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0081-mapleall-irbuild-edge-test_type/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/Main.mpl b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3aa3c48c666596cdfeb9f0a77fe301eadaeebc5b --- /dev/null +++ b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/Main.mpl @@ -0,0 +1,21 @@ +#int fact (int n) { +# if(n != 1) +# return foo(n - 1); +# else return 1; +#} +func $foo varargs ( var %i i32, ... ) i32 { + return (dread i32 %i) } +func $foo1 varargs ( ... ) i32 { + return (constval i32 99) } + +func $fact ( + var %n i32) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + call &foo( + sub i32 (dread i32 %n, constval i32 1)) + return (regread i32 %%retval)} + else { + return (constval i32 1) } } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.mplme.txt b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.txt b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/test.cfg b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0082-mapleall-irbuild-edge-twofunc/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/Main.mpl b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..1ee6f5f094c9ebf9bc4d9b8c82986505690ee583 --- /dev/null +++ b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/Main.mpl @@ -0,0 +1,13 @@ + # a function returning unary(i + j) * -998 +#type $SS + func $foo ( + var %k , + var %f f32, + var %i i32, + var %j i32)i64 { + return ( + cvt i64 i32 (constval i32 12345))} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.mplme.txt b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.txt b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/test.cfg b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0083-mapleall-irbuild-edge-tyconvertion/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/Main.mpl b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..a6e95d9cb500cfd1abc4b544e778c26dc97f53ea --- /dev/null +++ b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/Main.mpl @@ -0,0 +1,15 @@ + # a function returning unary(i + j) * -998 + func $foo ( + var %i i32, + var %j i32) f32 { + return ( + recip f32( + sqrt f32( + cvt f32 i32( + mul i32 ( + extractbits i32 1 23 ( add i32 ( bnot i32 (dread i32 %i), lnot i32 (dread i32 %j))), + neg i32 ( constval i32 -998))))))} + + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.mplme.txt b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.txt b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/test.cfg b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0084-mapleall-irbuild-edge-unary/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/Main.mpl b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..3529c000291396e1a9125c91d7d3294bff33d3da --- /dev/null +++ b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/Main.mpl @@ -0,0 +1,29 @@ +type $RR +type $SS { &method1(agg)agg, + &method2(void)void}> +func $foo ( + var %x <$SS>) i32 { + var %r1 i32 + var %r2 i32 + var %r3 i32 + dassign %x 2 ( constval i32 32 ) + # Not correct, but for parse and dump test. + virtualcallassigned &method2(addrof ptr %x) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + superclasscallassigned &method2(addrof ptr %x) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + interfacecallassigned &method2(addrof ptr %x) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + return ( dread i32 %x 2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.mplme.txt b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.txt b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/test.cfg b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0085-mapleall-irbuild-edge-virtualcallassigned/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/Main.mpl b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..02a30ee4d9a7178e22106ac402dbbe802fda2db8 --- /dev/null +++ b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/Main.mpl @@ -0,0 +1,13 @@ +type $RR +type $SS { &method1(agg)agg, + &method2(void)void}> +func $foo ( + var %x <$SS>) i32 { + dassign %x 2 ( constval i32 32 ) + virtualcall &method2(addrof ptr %x) + superclasscall &method2(addrof ptr %x) + interfacecall &method2(addrof ptr %x) + return ( dread i32 %x 2 ) } + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.mplme.txt b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.txt b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/test.cfg b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0086-mapleall-irbuild-edge-virtualcall/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/Main.mpl b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..b00128d06ff9aa81b73e85db6abae1a9bf934348 --- /dev/null +++ b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/Main.mpl @@ -0,0 +1,19 @@ +# int foo(void) { +# int n = 1; +# int i; +# for (i=1; i<10; i++) +# n = n * i; +# } + +func $foo (var %i i32) i32 { + while ( + lt i32 i32 ( dread i32 %i, constval i32 10) ) { + dassign %i ( + mul i32 (dread i32 %i, dread i32 %i)) + dassign %i ( + add i32 (dread i32 %i, constval i32 1) )} + return ( constval i32 1 ) +} + # EXEC: %irbuild Main.mpl + # EXEC: %irbuild Main.irb.mpl + # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl diff --git a/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.mplme.txt b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.txt b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/test.cfg b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b88b39455dd77d8470c1502ff07c23c193ff1314 --- /dev/null +++ b/testsuite/irbuild_test/I0087-mapleall-irbuild-edge-while/test.cfg @@ -0,0 +1,2 @@ +clean() +compile(Main) diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/Main.mpl b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..52cc6d496af49400438b0f7279cd85fae52995f5 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/Main.mpl @@ -0,0 +1,17 @@ + +func $fact ( + var %n i32, var %p1 a64, var %p2 a64) i32 { + var %r1 i32 + var %r2 i32 + var %r3 i32 + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + # Not correct, but for parse and dump test. + intrinsiccallassigned JSOP_ADD ( + dread a64 %p1, dread a64 %p2, dread i32 %n) { + dassign %r1 1 + dassign %r2 2 + dassign %r3 3 + } + return (constval i32 0) + } +} diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.mplme.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..aded01e0942a507d16571767ed86e039aaf8a1cf --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.mplme.txt @@ -0,0 +1,3 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-all-assigned/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/Main.mpl b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..5d2cc9848044c2b377785d8ab6b97e252b4c204f --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/Main.mpl @@ -0,0 +1,14 @@ +#int fact (int n) { +# if(n != 1) +# return foo(n - 1); +# else return 1; +#} + +func $fact ( + var %n i32, var %p1 a64, var %p2 a64) i32 { + if (ne i32 i32 (dread i32 %n, constval i32 1)) { + intrinsiccall JSOP_ADD ( + dread a64 %p1, dread a64 %p2, dread i32 %n) + return (regread i32 %%retval)} + else { + return (constval i32 1) } } diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.mplme.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-call/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/Main.mpl b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..850291610ccba8ebfe93733ebd6d8cf47285da0c --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/Main.mpl @@ -0,0 +1,61 @@ +type $Ljava/lang/Object; +type $Leh; { + @DEXINFO_isuserclass 1, + &foo public static (<* <$Leh;>>,<* <[0] <* <$Ljava/lang/String;>>>>) void}> +type $Ljava/lang/String; +type $Ljava/io/PrintStream; +type $Ljava/lang/System; >}> +type $Ljava/lang/Exception; + javaclass $javaclass|Leh; <$Leh;> + +func &foo public static (var %_this <* <$Leh;>>, var %Reg2_R39 <* <[0] <* <$Ljava/lang/String;>>>>) void +var $const_array_0 <[3] i32> readonly = [1, 2, 3] +var $static|Ljava/lang/System;|out|Ljava/io/PrintStream;| <* <$Ljava/io/PrintStream;>> +func &Ljava/io/PrintStream;|print|_I_V| (var %_this <* <$Ljava/io/PrintStream;>>, var %Reg1_I i32) void +var $const_chars_1 <[11] u8> const readonly = [0, 0, 7, 0, 101, 114, 114, 111, 114, 49, 10] +func &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (var %_this <* <$Ljava/io/PrintStream;>>, var %Reg1_R37 <* <$Ljava/lang/String;>>) void +var $const_chars_2 <[11] u8> const readonly = [0, 0, 7, 0, 101, 114, 114, 111, 114, 50, 10] + +func &foo public static (var %_this <* <$Leh;>>, var %Reg2_R39 <* <[0] <* <$Ljava/lang/String;>>>>) void { + var %Reg0_I i32 + var %Reg0_R45 <* <[3] i32>> + var %Reg1_I i32 + var %Reg1_R47 <* <$Ljava/io/PrintStream;>> + var %Reg0_R51 <* <$Ljava/lang/Exception;>> + var %Reg0_R47 <* <$Ljava/io/PrintStream;>> + var %Reg1_R53 <* u8> + var %Reg0_R55 <* dynany> + dassign %Reg0_I 0 (cvt i32 i8 (constval i8 3)) + javatry { @label1 } + dassign %Reg0_R45 0 (malloc ptr (mul i32 (dread i32 %Reg0_I, sizeoftype u32 i32))) + endtry + intrinsiccallassigned DEX_ARRAY_SETELEM (dread ptr %Reg0_R45, constval i32 3, addrof ptr $const_array_0) {} + dassign %Reg1_I 0 (cvt i32 i8 (constval i8 4)) + javatry { @label1 @label2 } + dassign %Reg0_I 0 (iread i32 <* <[3] i32>> 0 (array ptr <* <[3] i32>> (dread ptr %Reg0_R45, dread i32 %Reg1_I))) + dassign %Reg1_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|) + virtualcallassigned &Ljava/io/PrintStream;|print|_I_V| (dread ptr %Reg1_R47, dread i32 %Reg0_I) {} + endtry +@label0 return () +@label2 javacatch <* <$Ljava/lang/Exception;>> + dassign %Reg0_R51 0 (regread ptr %%thrownval) + javatry { @label1 } + dassign %Reg0_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|) + dassign %Reg1_R53 0 (addrof ptr $const_chars_1) + virtualcallassigned &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (dread ptr %Reg0_R47, dread ptr %Reg1_R53) {} + endtry + goto @label0 +@label1 javacatch <* <$Ljava/lang/Exception;>> + dassign %Reg0_R51 0 (regread ptr %%thrownval) + dassign %Reg0_R47 0 (dread ptr $static|Ljava/lang/System;|out|Ljava/io/PrintStream;|) + dassign %Reg1_R53 0 (addrof ptr $const_chars_2) + virtualcallassigned &Ljava/io/PrintStream;|print|_Ljava/lang/String;_V| (dread ptr %Reg0_R47, dread ptr %Reg1_R53) {} + goto @label0 +} + diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.mplme.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..aded01e0942a507d16571767ed86e039aaf8a1cf --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.mplme.txt @@ -0,0 +1,3 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e8ea2f49dfcc306508ba60744b7d32a8caf69377 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-javaeh/expected.txt @@ -0,0 +1 @@ +Compare irbuild result! diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/Main.mpl b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..db947da0c98e284834ccdc594826d6dcf447242c --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/Main.mpl @@ -0,0 +1,9 @@ +type $ClassA +type $ClassB + +func $foo() void { + var %Reg1 <* <$ClassB>> + dassign %Reg1 0 (intrinsicopwithtype ptr <* <$ClassB>> DEX_CONST_CLASS ()) + intrinsiccallwithtype <* <$ClassA>> DEX_CHECK_CAST (dread ptr %Reg1 0) +} + diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.mplme.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..aded01e0942a507d16571767ed86e039aaf8a1cf --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.mplme.txt @@ -0,0 +1,3 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic-with-type/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/Main.mpl b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/Main.mpl new file mode 100644 index 0000000000000000000000000000000000000000..fcbebfcd68934bcf4bcee96bed96e0eef85e9108 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/Main.mpl @@ -0,0 +1,7 @@ +func $foo ( var %i i32, var %j i32, var %k i32) i32 { + return ( + intrinsicop i32 JSOP_STRICTEQ ( + dread i32 %i, + intrinsicop i32 JS_NUMBER (dread i32 %k))) +} + diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.mplme.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.txt b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c876141802aeeff6a10f38274a0d5c0167e6dda5 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0088-mapleall-irbuild-edge-intrinsic/expected.txt @@ -0,0 +1,2 @@ +Compare irbuild result! +Main.irb.mpl and Main.irb.irb.mpl are the same diff --git a/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.mplme.txt b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.mplme.txt new file mode 100644 index 0000000000000000000000000000000000000000..7d05948d001e19172b191ae6049fae148ad0c11f --- /dev/null +++ b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.mplme.txt @@ -0,0 +1,4 @@ +Test if programe got passed! +condition is value, goto assertEqual +Check if condition value would be Zero +expected:0 and actual:0 are equal diff --git a/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.txt b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..10fc75a29e5c00059ca003d7396a83b751f2125d --- /dev/null +++ b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/expected.txt @@ -0,0 +1,128 @@ +LHelloWorld;|main|(Ljava/lang/String;)V + +Info 00: Test passed. + +Ldalvik/system/BlockGuard$1;|onWriteToDisk|()V + +Info 00: Test passed. + +Ldalvik/system/BlockGuard;|getThreadPolicy|()Ldalvik/system/BlockGuard$Policy; + +Info 00: Test passed. + +Ldalvik/system/VMRuntime;|registerNativeAllocation|(I)V + +Info 00: Test passed. + +Ljava/io/BufferedWriter;||()V + +Info 00: Test passed. + +Ljava/io/BufferedWriter;||(Ljava/io/Writer;I)V + +Info 00: Test passed. + +Ljava/io/BufferedWriter;|write|(Ljava/lang/String;II)V + +Info 00: Test passed. + +Ljava/io/FileOutputStream;||(Ljava/lang/String;)V + +Info 00: Test passed. + +Ljava/io/FileOutputStream;|write|([BII)V + +Info 00: Test passed. + +Ljava/lang/Daemons$FinalizerDaemon;|-get0|()Ljava/lang/Daemons$FinalizerDaemon; + +Info 00: Test passed. + +Ljava/lang/ref/Reference;|get|()Ljava/lang/Object; + +Info 00: Test passed. + +Ljava/lang/ref/Reference;|getReferent|()Ljava/lang/Object; + +Info 00: Test passed. + +Ljava/lang/ref/Reference;||(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V + +Info 00: Test passed. + +Ljava/lang/String;|getChars|(II[CI)V + +Info 00: Test passed. + +Ljava/lang/ThreadLocal;|getMap|(Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap; + +Info 00: Test passed. + +Ljava/lang/ThreadLocal$ThreadLocalMap;|getEntry|(Ljava/lang/ThreadLocal;)Ljava/lang/ThreadLocal$ThreadLocalMap$Entry; + +Info 00: Test passed. + +Ljava/lang/ThreadLocal$ThreadLocalMap;|-wrap0|(Ljava/lang/ThreadLocal$ThreadLocalMap;Ljava/lang/ThreadLocal;)Ljava/lang/ThreadLocal$ThreadLocalMap$Entry; + +Info 00: Test passed. + +Ljava/nio/Buffer;||(IIIII)V + +Info 00: Test passed. + +Ljava/nio/ByteBuffer;|array|()[B + +Info 00: Test passed. + +Ljava/nio/ByteBuffer;||(IIII[BI)V + +Info 00: Test passed. + +Ljava/nio/CharBuffer;|wrap|([CII)Ljava/nio/CharBuffer; + +Info 00: Test passed. + +Ljava/nio/charset/CharsetEncoderICU;||(Ljava/nio/charset/Charset;FF[BJ)V + +Info 00: Test passed. + +Ljava/nio/charset/Charset;||(Ljava/lang/String;[Ljava/lang/String;)V + +Info 00: Test passed. + +Llibcore/icu/ICU;|U_FAILURE|(I)Z + +Info 00: Test passed. + +Llibcore/icu/NativeConverter;|encode|(J[CI[BI[IZ)I + +Info 00: Test passed. + +Llibcore/icu/NativeConverter;|setCallbackEncode|(JII[B)V + +Info 00: Test passed. + +Llibcore/io/BlockGuardOs;|write|(Ljava/io/FileDescriptor;[BII)I + +Info 00: Test passed. + +Llibcore/io/Posix;|writeBytes|(Ljava/io/FileDescriptor;Ljava/lang/Object;II)I + +Info 00: Test passed. + +Lsun/nio/cs/StreamEncoder;|implWrite|([CII)V + +Info 00: Test passed. + +Ljava/lang/StringFactory;|newStringFromChars|(II[C)Ljava/lang/String; + +Info 00: Test passed. + +Llibcore/icu/NativeConverter;|getSubstitutionBytes|(J)[B + +Info 00: Test passed. + +LA;|fooALA|([I[LA;J)LA; + +Info 00: Test passed. + diff --git a/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/java_signature_test.txt b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/java_signature_test.txt new file mode 100644 index 0000000000000000000000000000000000000000..dfbdd3b9224afdfe46f2ed67c1f18a1506482454 --- /dev/null +++ b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/java_signature_test.txt @@ -0,0 +1,32 @@ +LHelloWorld;|main|(Ljava/lang/String;)V +Ldalvik/system/BlockGuard$1;|onWriteToDisk|()V +Ldalvik/system/BlockGuard;|getThreadPolicy|()Ldalvik/system/BlockGuard$Policy; +Ldalvik/system/VMRuntime;|registerNativeAllocation|(I)V +Ljava/io/BufferedWriter;||()V +Ljava/io/BufferedWriter;||(Ljava/io/Writer;I)V +Ljava/io/BufferedWriter;|write|(Ljava/lang/String;II)V +Ljava/io/FileOutputStream;||(Ljava/lang/String;)V +Ljava/io/FileOutputStream;|write|([BII)V +Ljava/lang/Daemons$FinalizerDaemon;|-get0|()Ljava/lang/Daemons$FinalizerDaemon; +Ljava/lang/ref/Reference;|get|()Ljava/lang/Object; +Ljava/lang/ref/Reference;|getReferent|()Ljava/lang/Object; +Ljava/lang/ref/Reference;||(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V +Ljava/lang/String;|getChars|(II[CI)V +Ljava/lang/ThreadLocal;|getMap|(Ljava/lang/Thread;)Ljava/lang/ThreadLocal$ThreadLocalMap; +Ljava/lang/ThreadLocal$ThreadLocalMap;|getEntry|(Ljava/lang/ThreadLocal;)Ljava/lang/ThreadLocal$ThreadLocalMap$Entry; +Ljava/lang/ThreadLocal$ThreadLocalMap;|-wrap0|(Ljava/lang/ThreadLocal$ThreadLocalMap;Ljava/lang/ThreadLocal;)Ljava/lang/ThreadLocal$ThreadLocalMap$Entry; +Ljava/nio/Buffer;||(IIIII)V +Ljava/nio/ByteBuffer;|array|()[B +Ljava/nio/ByteBuffer;||(IIII[BI)V +Ljava/nio/CharBuffer;|wrap|([CII)Ljava/nio/CharBuffer; +Ljava/nio/charset/CharsetEncoderICU;||(Ljava/nio/charset/Charset;FF[BJ)V +Ljava/nio/charset/Charset;||(Ljava/lang/String;[Ljava/lang/String;)V +Llibcore/icu/ICU;|U_FAILURE|(I)Z +Llibcore/icu/NativeConverter;|encode|(J[CI[BI[IZ)I +Llibcore/icu/NativeConverter;|setCallbackEncode|(JII[B)V +Llibcore/io/BlockGuardOs;|write|(Ljava/io/FileDescriptor;[BII)I +Llibcore/io/Posix;|writeBytes|(Ljava/io/FileDescriptor;Ljava/lang/Object;II)I +Lsun/nio/cs/StreamEncoder;|implWrite|([CII)V +Ljava/lang/StringFactory;|newStringFromChars|(II[C)Ljava/lang/String; +Llibcore/icu/NativeConverter;|getSubstitutionBytes|(J)[B +LA;|fooALA|([I[LA;J)LA; diff --git a/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/run b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/run new file mode 100755 index 0000000000000000000000000000000000000000..b292266d8c3762fb3dccd15fe8f839e2559059ed --- /dev/null +++ b/testsuite/irbuild_test/issue-I0089-mapleall-irbuild-edge-java-signature-test/run @@ -0,0 +1,16 @@ +#! /usr/bin/python3 +import os +import subprocess + +f = open('./java_signature_test.txt', 'r') +data = f.readlines() + +for line in data: + print(line) + cmd = "mplverf --javaname '"+line + "'" + cmd = cmd.split() + result = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + print(result.decode("utf-8")) + + + diff --git a/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/HelloWorld.java b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/HelloWorld.java new file mode 100644 index 0000000000000000000000000000000000000000..cb4f7beb10589aaaf0fe6ac5456ed42ba6ea2b8b --- /dev/null +++ b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/HelloWorld.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +public class HelloWorld { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} + diff --git a/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/expected.txt b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..980a0d5f19a64b4b30a87d4206aade58726b60e3 --- /dev/null +++ b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/expected.txt @@ -0,0 +1 @@ +Hello World! diff --git a/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/test.cfg b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e75536c83593b42d88ec96a160b4fcb8627ef13 --- /dev/null +++ b/testsuite/java_test/app_test/APP0001-app-Application-Application-helloworld/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(HelloWorld) +run(HelloWorld) diff --git a/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/ThreadHelloWorld.java b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/ThreadHelloWorld.java new file mode 100644 index 0000000000000000000000000000000000000000..94bbafa1c40ca0a405108a7e95aaca33657878e9 --- /dev/null +++ b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/ThreadHelloWorld.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import java.lang.Thread; + +public class ThreadHelloWorld implements Runnable { + + private final String helloworld; + + public static void main(String args[]) throws InterruptedException { + Thread thread = new Thread(new ThreadHelloWorld("Hello, World")); + thread.start(); + thread.join(); + } + + public ThreadHelloWorld(String str){ + helloworld = str; + } + + public void run(){ + System.out.println(helloworld); + } +} + + diff --git a/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/expected.txt b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3fa0d4b98289a95a7cd3a45c9545e622718f8d2b --- /dev/null +++ b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/expected.txt @@ -0,0 +1 @@ +Hello, World diff --git a/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/test.cfg b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ab3470e386c147394047bc89b43486a6a2193553 --- /dev/null +++ b/testsuite/java_test/app_test/APP0002-app-Application-Application-ThreadhelloWorld/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadHelloWorld) +run(ThreadHelloWorld) diff --git a/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/HelloWorld.java b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/HelloWorld.java new file mode 100755 index 0000000000000000000000000000000000000000..9f99189dad839c9d9c475ca22a42dfa69526909d --- /dev/null +++ b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/HelloWorld.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import java.lang.reflect.*; +class Pertnn { + public Pertnn() { + age = 1234; + } + public int getAge() { + return age; + } + public void setAge(int age) { + this.age = age; + } + public int age; +} + +class Person { + public Person() { + System.out.println("Invoking Person Constructor!"); + age = 5678; + } + public int getAge() { + System.out.println("Invoking Person getAge!"); + return age; + } + public void setAge(int age) { + this.age = age; + } + public int age; +} +public final class HelloWorld { + public static void main(String [] args) { + System.out.println("HelloWorld!"); + Class demo=null; + try{ + demo=Class.forName("Person"); + }catch (Exception e) { + System.out.println("ex1"); + } + + try{ + Method method=demo.getMethod("getAge"); + Object o = demo.newInstance(); + method.invoke(o); + Field field = demo.getDeclaredField("age"); + long value = field.getLong(o); + if(value == 5678) + System.out.println("Good Value Before Setting!"); + /* field.setLong(o, 9876); // This should throw exception + value = field.getLong(o); + if(value == 9876) + System.out.println("Good Value After Setting!"); */ + }catch (Exception e) { + System.out.println("ex2"); + } +} +} + diff --git a/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/expected.txt b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2c7fa253e3b942963b527d44739d0bb13c156640 --- /dev/null +++ b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/expected.txt @@ -0,0 +1,4 @@ +HelloWorld! +Invoking Person Constructor! +Invoking Person getAge! +Good Value Before Setting! diff --git a/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/test.cfg b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e75536c83593b42d88ec96a160b4fcb8627ef13 --- /dev/null +++ b/testsuite/java_test/app_test/APP0003-app-Application-Application-reflection/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(HelloWorld) +run(HelloWorld) diff --git a/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/ABCOcatchArrayIndexOutOfBoundsException.java b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/ABCOcatchArrayIndexOutOfBoundsException.java new file mode 100755 index 0000000000000000000000000000000000000000..b70b7da790b0a17b4b67ca99e6319b56db0df32c --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/ABCOcatchArrayIndexOutOfBoundsException.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOcatchArrayIndexOutOfBoundsException { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + try { + func(); + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } catch (Exception e) { + res = res + 2; + } + return res; + } + public static void func() throws Exception { + int[] a = new int[1024]; + int c = a[1024]; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/expected.txt b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/test.cfg b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a134d7d288a55271722fc87ef425be4fd8c189b6 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0001-rt-arrayboundary-ABCOcatchArrayIndexOutOfBoundsException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOcatchArrayIndexOutOfBoundsException) +run(ABCOcatchArrayIndexOutOfBoundsException) diff --git a/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/ABCOcatchIndexOutOfBoundsException.java b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/ABCOcatchIndexOutOfBoundsException.java new file mode 100755 index 0000000000000000000000000000000000000000..b8ed315046297ca89eed9c42873b9aa6d0a901c9 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/ABCOcatchIndexOutOfBoundsException.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOcatchIndexOutOfBoundsException { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + try { + func(); + } catch (IndexOutOfBoundsException e) { + res--; + } catch (Exception e) { + res = res + 2; + } + return res; + } + public static void func() throws Exception { + int[] a = new int[1024]; + int c = a[1024]; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/expected.txt b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/test.cfg b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9daf81842038c8baf53d513fc567f06b4ccb24a9 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0002-rt-arrayboundary-ABCOcatchIndexOutOfBoundsException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOcatchIndexOutOfBoundsException) +run(ABCOcatchIndexOutOfBoundsException) diff --git a/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/ABCOcatchStringIndexOutOfBoundsException.java b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/ABCOcatchStringIndexOutOfBoundsException.java new file mode 100755 index 0000000000000000000000000000000000000000..cbc9fb2eefde71bbd9ab6c0f3542cfc0e7303096 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/ABCOcatchStringIndexOutOfBoundsException.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOcatchStringIndexOutOfBoundsException { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + try { + func(); + } catch (StringIndexOutOfBoundsException e) { + res--; + } catch (Exception e) { + res = res + 2; + } + return res; + } + public static void func() throws Exception { + char[] a = new char[1024]; + int index = 0; + for (int i = 0; i < a.length; i++) { + a[i] = 'a'; + index++; + } + String joinLine = a.toString(); + char c = joinLine.charAt(index); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/expected.txt b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/test.cfg b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..62fb57e380b81d9d9c883e8bd146dd37caee8f5b --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0003-rt-arrayboundary-ABCOcatchStringIndexOutOfBoundsException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOcatchStringIndexOutOfBoundsException) +run(ABCOcatchStringIndexOutOfBoundsException) diff --git a/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/ABCOconstOperation.java b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/ABCOconstOperation.java new file mode 100755 index 0000000000000000000000000000000000000000..ea2a5214a61688d324687d5dd9ae5d4588266f64 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/ABCOconstOperation.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOconstOperation { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 10 /*STATUS_FAILED*/; + int[] arr1 = new int[15]; + for (int i = 0; i < arr1.length; i++) { + arr1[i] = i; + } + int index = 1; + int y = 6; + try { + index = index + y + 9; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = y - 16 - index; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = y * y * index; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = index + 937; + index = (y / index) * y; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = (y + 9) & 15; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = y | index; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = ~index; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = 15; + index = index ^ 16; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + index = index % 16; + int c = arr1[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/expected.txt b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/test.cfg b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cbcbb6f5c75ef82df5d44f9f40d7cbc7844c1016 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0004-rt-arrayboundary-ABCOconstOperation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOconstOperation) +run(ABCOconstOperation) diff --git a/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/ABCOcustomClass.java b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/ABCOcustomClass.java new file mode 100755 index 0000000000000000000000000000000000000000..d85ccd6ba72ee23ee0b9a77b82047950169d15c0 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/ABCOcustomClass.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOcustomClass { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + People p = new People(3); + int x = p.n; + try { + Student a = p.s[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +class People { + int n; + Student s[] = new Student[n]; + public People(int n) { + this.n = n; + } +} +class Student { + int number; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/expected.txt b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/test.cfg b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b977425aed2568ff9df102c7c857073d42c39d03 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0005-rt-arrayboundary-ABCOcustomClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOcustomClass) +run(ABCOcustomClass) diff --git a/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/ABCOdoWhile.java b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/ABCOdoWhile.java new file mode 100755 index 0000000000000000000000000000000000000000..fa64aceb7ad353ceb2248fda4ee877fc3307a9f8 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/ABCOdoWhile.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOdoWhile { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] c = new int[a.length]; + int x = 0; + int y = a.length; + try { + do { + c[x] = a[x]; + x++; + } while (x <= y); + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/expected.txt b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/test.cfg b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b9fbbd1b1a74ade771ed827df960f4d651c72ac --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0006-rt-arrayboundary-ABCOdoWhile/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOdoWhile) +run(ABCOdoWhile) diff --git a/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/ABCOemptyArray.java b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/ABCOemptyArray.java new file mode 100755 index 0000000000000000000000000000000000000000..bfc3de11dc0f6012a420907ff4d0a60be216f2cc --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/ABCOemptyArray.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOemptyArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + int result2 = 4; + try { + result = test1(); + result2 = test2(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && result2 == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + Object[] a = new Object[0]; + try { + a[0] = new Object[0]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + Object c = a[-1]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static int test2() { + int res = 2 /*STATUS_FAILED*/; + String[] data; + try { + data = new String[] {}; // 初始化 + data[0] = "lisi"; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..99708d6b8f76644fc6a31a15f7ec82136fef23f5 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0007-rt-arrayboundary-ABCOemptyArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOemptyArray) +run(ABCOemptyArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/ABCOemptyString.java b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/ABCOemptyString.java new file mode 100755 index 0000000000000000000000000000000000000000..4c4a6a0dd91b030dcd34902196f202e9ad2dbb5b --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/ABCOemptyString.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOemptyString { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + try { + String string = ""; + char c = string.charAt(0); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + String string = new String(""); + int c = string.codePointAt(0); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/expected.txt b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/test.cfg b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..396f2328947c5eb2ec06d0064546172f65521882 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0008-rt-arrayboundary-ABCOemptyString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOemptyString) +run(ABCOemptyString) diff --git a/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/ABCOfor.java b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/ABCOfor.java new file mode 100755 index 0000000000000000000000000000000000000000..066f667f95a21226a55382877bba2b74b261f1a5 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/ABCOfor.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOfor { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[1024]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i; + } + int[] b = new int[a.length]; + try { + for (int i = 0; i <= a.length; i++) { + b[i] = a[i]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/expected.txt b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/test.cfg b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..070361392e598709d54abada2213ead50f3886bf --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0009-rt-arrayboundary-ABCOfor/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOfor) +run(ABCOfor) diff --git a/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/ABCOglobalArray.java b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/ABCOglobalArray.java new file mode 100755 index 0000000000000000000000000000000000000000..3fd53d6c5d131719965a5f2b93827996229bf9e3 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/ABCOglobalArray.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOglobalArray { + static int RES_PROCESS = 99; + static int[] a = new int[5]; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] b = new int[6]; + Arrays.fill(a, 9); + for (int i = 0; i <= a.length; i++) { + b[i] = i; + } + int[] c = new int[6]; + try { + for (int j = 0; j <= a.length; j++) { + int x = b[j]; + c[x] = a[x]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..932f317dddcc072b903362896434d2739e872071 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0010-rt-arrayboundary-ABCOglobalArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOglobalArray) +run(ABCOglobalArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/ABCOglobalIndex.java b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/ABCOglobalIndex.java new file mode 100755 index 0000000000000000000000000000000000000000..e3bffc1bed533c3c8a9241b759ef792d29b43fcf --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/ABCOglobalIndex.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOglobalIndex { + static int RES_PROCESS = 99; + static int x = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[1024]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i; + } + int y = a.length; + try { + while (x < y) { + x = a[x + 1]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/expected.txt b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/test.cfg b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2975e0a3a992e6e2efb916a05189e36843b1bbf1 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0011-rt-arrayboundary-ABCOglobalIndex/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOglobalIndex) +run(ABCOglobalIndex) diff --git a/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/ABCOglobalString.java b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/ABCOglobalString.java new file mode 100755 index 0000000000000000000000000000000000000000..18fcb6539db351072525fd7450a08da9a516bea4 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/ABCOglobalString.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOglobalString { + static int RES_PROCESS = 99; + static String joinLine = new String(); + static int index = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + joinLine = a.toString(); + char[] b = new char[joinLine.length()]; + try { + for (int j = 0; j <= joinLine.length(); j++) { + index = j; + b[index] = joinLine.charAt(index); + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/expected.txt b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/test.cfg b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1d7bc82197fc067c868369b641f20645723509b2 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0012-rt-arrayboundary-ABCOglobalString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOglobalString) +run(ABCOglobalString) diff --git a/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/ABCOif.java b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/ABCOif.java new file mode 100755 index 0000000000000000000000000000000000000000..db709b45dffaa511ac5949adfe43f783012b2526 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/ABCOif.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOif { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] arr = new int[5]; + int[] arrCp = arr; + for (int i = 0; i < arr.length; i++) { + arrCp[i] = i; + } + int y = arr.length; + try { + if (y >= 0) { + int c = arr[y]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/expected.txt b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/test.cfg b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3264b4e0c213964da1a48f29a47d943ed2f5ddd4 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0013-rt-arrayboundary-ABCOif/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOif) +run(ABCOif) diff --git a/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/ABCOincreaseArray.java b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/ABCOincreaseArray.java new file mode 100755 index 0000000000000000000000000000000000000000..1fa947c454107fc3cb0a6fb2f3bf019d18abc304 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/ABCOincreaseArray.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Array; +import java.util.Arrays; +public class ABCOincreaseArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + int[] a = new int[10]; + Arrays.fill(a, 20); + int[] newArray = (int[]) func(a); + int index = newArray[0]; + try { + int c = a[index - 11]; + } catch (ArrayIndexOutOfBoundsException e) { + res = 5; + } + try { + int c = newArray[index]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static Object func(Object array) { + Class clazz = array.getClass(); + if (clazz.isArray()) { + Class componentType = clazz.getComponentType(); + int length = Array.getLength(array); + Object newArray = Array.newInstance(componentType, length + 10); + System.arraycopy(array, 0, newArray, 0, length); + return newArray; + } + return null; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b8000c2338f61daa69b0006ced17913ba869a56d --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0014-rt-arrayboundary-ABCOincreaseArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOincreaseArray) +run(ABCOincreaseArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/ABCOindexAssociation.java b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/ABCOindexAssociation.java new file mode 100755 index 0000000000000000000000000000000000000000..ec6ff2658537fe9c716201653d91346459364be4 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/ABCOindexAssociation.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOindexAssociation { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + int result2 = 4; + try { + result = test1(); + result2 = test2(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && result2 == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] c = a; + try { + for (int i = 0; i <= a.length; i++) { + c[i] = i; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int test2() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i; + } + try { + for (int j = 1; j <= a.length; j++) { + if (a[j] > a[j - 1]) { + j = a[j]; + } + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/expected.txt b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/test.cfg b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d9d3ee36009479486c5ec3d6ce29a039dd8b3af --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0015-rt-arrayboundary-ABCOindexAssociation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexAssociation) +run(ABCOindexAssociation) diff --git a/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/ABCOindexDoWhile.java b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/ABCOindexDoWhile.java new file mode 100755 index 0000000000000000000000000000000000000000..2734deb425f4ccc71b0de024d83d50e919efb6e1 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/ABCOindexDoWhile.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOindexDoWhile { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + // catch ArrayIndexOutOfBoundsException + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[1000]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i; + } + int[] b = new int[a.length]; + int x = funx(100); + int y = funx(1000); + try { + do { + b[x] = a[x]; + x++; + } while (x <= y); + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int funx(int maxFlag) { + int endIndex = maxFlag + 5; + int index = 0; + do { + index = funy(index); + } while (index < endIndex); + return index; + } + public static int funy(int forIdx) { + int idx = forIdx + 100; + return idx; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/expected.txt b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/test.cfg b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..acb4fec1aa142d66a12c4074399790060bc1dd25 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0016-rt-arrayboundary-ABCOindexDoWhile/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexDoWhile) +run(ABCOindexDoWhile) diff --git a/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/ABCOindexFor.java b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/ABCOindexFor.java new file mode 100755 index 0000000000000000000000000000000000000000..70fa28b99e666a5a1ec72a13dd43a8e701be4e23 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/ABCOindexFor.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOindexFor { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[1000]; + int[] c = a; + for (int ii = 0; ii < a.length; ii++) { + c[ii] = ii; + } + int[] b = new int[a.length]; + try { + for (int i = funx(100); i <= funx(1000); i++) { + if (i >= 1000) { + for (int j = i; j > 0; j--) { + int index = funx(1000); + b[index] = a[index]; + } + } + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int funx(int maxFlag) { + int endIndex = maxFlag + 5; + int index; + for (index = 0; index <= endIndex; index++) { + index = funy(index); + } + return index; + } + public static int funy(int forIdx) { + int idx = forIdx + 100; + return idx; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/expected.txt b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/test.cfg b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..24eb4128ee472160dd05ffcce49eb04e4958d305 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0017-rt-arrayboundary-ABCOindexFor/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexFor) +run(ABCOindexFor) diff --git a/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/ABCOindexFromArrayFromParam.java b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/ABCOindexFromArrayFromParam.java new file mode 100755 index 0000000000000000000000000000000000000000..02b073671711b41cae0ecf3fcd94bbd47d203e74 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/ABCOindexFromArrayFromParam.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOindexFromArrayFromParam { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + int num = 5; + result = test1(num); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1(int num) { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + a[4] = num; + int[] c = a.clone(); + int x = c[4]; + try { + int b = a[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/expected.txt b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/test.cfg b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9cc782016ad1279dafd9283a46909a7a67cc8bd7 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0018-rt-arrayboundary-ABCOindexFromArrayFromParam/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexFromArrayFromParam) +run(ABCOindexFromArrayFromParam) diff --git a/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/ABCOindexIf.java b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/ABCOindexIf.java new file mode 100755 index 0000000000000000000000000000000000000000..c1425bc4b222a1bc4ab116323474a7dd72c1d421 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/ABCOindexIf.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Random; +public class ABCOindexIf { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] arr = new int[5]; + int[] arrCp = arr; + for (int i = 0; i < arr.length; i++) { + arrCp[i] = i; + } + int y = func(); + try { + if (y >= 0) { + int c = arr[y]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func() { + Random r = new Random(); + int get = r.nextInt(6); + if (get >= 5) { + return get; + } else { + get = func(); + return get; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/expected.txt b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/test.cfg b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5998eed130813313cb0a40a5be93b9c5dab8e6f4 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0019-rt-arrayboundary-ABCOindexIf/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexIf) +run(ABCOindexIf) diff --git a/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/ABCOindexMutiLoop.java b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/ABCOindexMutiLoop.java new file mode 100755 index 0000000000000000000000000000000000000000..94f497baa2d6eb7dfe891147017958fcfd43a25e --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/ABCOindexMutiLoop.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOindexMutiLoop { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + int[] a = new int[5]; + Arrays.fill(a, 8000); + int x; + try { + x = func(); + int c = a[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static int func() { + int index = 0; + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 5; k++) { + for (int ii = 0; ii < 5; ii++) { + for (int jj = 0; jj < 5; jj++) { + for (int kk = 0; kk < 5; kk++) { + for (int iii = 0; iii < 5; iii++) { + for (int jjj = 0; jjj < 5; jjj++) { + for (int kkk = 0; kkk < 5; kkk++) { + for (int n = 0; n < 5; n++) { + index = index + n; + } + } + } + } + } + } + } + } + } + } + return index; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/expected.txt b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/test.cfg b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2dab83710077cd4d97ea4d11c8b11260bf79022a --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0020-rt-arrayboundary-ABCOindexMutiLoop/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexMutiLoop) +run(ABCOindexMutiLoop) diff --git a/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/ABCOindexNesting.java b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/ABCOindexNesting.java new file mode 100755 index 0000000000000000000000000000000000000000..3fc7f00ea9501f98d546f1e23314849a2d8af3ea --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/ABCOindexNesting.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOindexNesting { + static int RES_PROCESS = 99; + static int arrNum = 1023; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[arrNum]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i; + } + int index = 0; + try { + for (int j = 1; j <= a.length; j++) { + if (j == a.length) { + index = func(j, index); + j = a[index]; + } + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func(int index, int getIndex) { + getIndex = funx(getIndex, index); + getIndex = getIndex + 10; + if (getIndex < index) { + getIndex = func(index, getIndex); + } + return getIndex; + } + public static int funx(int getIndex, int index) { + getIndex = getIndex + index; + getIndex = funy(getIndex, index); + return getIndex; + } + public static int funy(int getIndex, int index) { + getIndex = getIndex * index; + getIndex = funz(getIndex, index); + return getIndex; + } + public static int funz(int getIndex, int index) { + getIndex = getIndex / index; + getIndex = funw(getIndex, index); + return getIndex; + } + public static int funw(int getIndex, int index) { + getIndex = getIndex - index; + return getIndex; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/expected.txt b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/test.cfg b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..689ebc371859ebbcf59e01d8933132c0a391c905 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0021-rt-arrayboundary-ABCOindexNesting/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexNesting) +run(ABCOindexNesting) diff --git a/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/ABCOindexSwitch.java b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/ABCOindexSwitch.java new file mode 100755 index 0000000000000000000000000000000000000000..feffa2ec7f4785cc97402d784555fa860e9bb064 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/ABCOindexSwitch.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Random; +public class ABCOindexSwitch { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] arrCp = a; + for (int i = 0; i < a.length; i++) { + arrCp[i] = i; + } + int c; + int x = func(); + try { + c = a[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func() { + Random r = new Random(); + int getI = r.nextInt(3); + int y = getI % 3; + getI = getI + 5; + switch (y) { + case 0: + getI = getI + 0; + break; + case 1: + getI = getI + 1; + break; + default: + getI = getI + 2; + } + return getI; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/expected.txt b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/test.cfg b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b18173cd940c2dd775215e4bbd15e961cd74d48e --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0022-rt-arrayboundary-ABCOindexSwitch/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOindexSwitch) +run(ABCOindexSwitch) diff --git a/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/ABCOlength.java b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/ABCOlength.java new file mode 100755 index 0000000000000000000000000000000000000000..91b471564f31ac8b04fab549836a84cb630f01cb --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/ABCOlength.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOlength { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + int[] a = new int[5]; + try { + int b = a.length; + int c = a[b]; + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/expected.txt b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/test.cfg b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..576dbcf4148b24901e0296a4ebaae9f7b1040c50 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0023-rt-arrayboundary-ABCOlength/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOlength) +run(ABCOlength) diff --git a/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/ABCOlistToArray.java b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/ABCOlistToArray.java new file mode 100755 index 0000000000000000000000000000000000000000..0e4dfa7a17f9fbbca6a385b81f60eca65dd908d9 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/ABCOlistToArray.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +public class ABCOlistToArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + String[] a = func(); + int x = -1; + try { + String c = a[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + x = Integer.parseInt(a[a.length - 1]); + try { + String c = a[x]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static String[] func() { + List list = new ArrayList<>(); + list.add("1"); + list.add("2"); + list.add("3"); + list.add("4"); + list.add("5"); + String[] arr = new String[list.size()]; + try { + list.toArray(arr); + } catch (Exception e) { + e.printStackTrace(); + } + return arr; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..84cf6d0cd087858ae26e8149a14857560535f742 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0024-rt-arrayboundary-ABCOlistToArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOlistToArray) +run(ABCOlistToArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/ABCOlocalArray.java b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/ABCOlocalArray.java new file mode 100755 index 0000000000000000000000000000000000000000..ecd66d9d7c70518594b681abc5400273504d4170 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/ABCOlocalArray.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOlocalArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[][] arr = {{1, 2, 3}, {4, 5}, {6, 7, 8, 9}, {0}}; + int y = arr.length - 1; + try { + int c = arr[-1][y]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + int c = arr[y][1]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ec1a114d5d31c7840227d93343c45c6d7ddcb76d --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0025-rt-arrayboundary-ABCOlocalArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOlocalArray) +run(ABCOlocalArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/ABCOlocalIndex.java b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/ABCOlocalIndex.java new file mode 100755 index 0000000000000000000000000000000000000000..5d34228a8ea1cd597524a47d2b70fa7d24b5d234 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/ABCOlocalIndex.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOlocalIndex { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[][] arr = {{1, 2, 3}, {4, 5}, {6, 7, 8, 9}, {0}}; + int y = func(); + try { + int c = arr[0][y]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + int c = arr[y][0]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static int func() { + int getRand = 0; + for (int i = 0; i < 100; i++) { + getRand = getRand + i; + if (getRand > 100) { + break; + } + } + getRand = getRand + 4; + return getRand; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/expected.txt b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/test.cfg b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4bc49f889f9754b4790a4a411eed63a3b051413e --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0026-rt-arrayboundary-ABCOlocalIndex/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOlocalIndex) +run(ABCOlocalIndex) diff --git a/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/ABCOnewArraySize.java b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/ABCOnewArraySize.java new file mode 100755 index 0000000000000000000000000000000000000000..d89ff31bbbfa109a6884df69088b40480d2bbf95 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/ABCOnewArraySize.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOnewArraySize { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] d = {0, 1, -1, 5}; + try { + int b = d[2]; + int c = a[b]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + int b = d[3]; + int c = a[b]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/expected.txt b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/test.cfg b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b594b7c74d197a9565d94252f748ef016f317619 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0027-rt-arrayboundary-ABCOnewArraySize/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOnewArraySize) +run(ABCOnewArraySize) diff --git a/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/ABCOnormal.java b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/ABCOnormal.java new file mode 100755 index 0000000000000000000000000000000000000000..1cc7e8fbedf7cc0bcf65f41dfdd3980f9f8a58af --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/ABCOnormal.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOnormal { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + try { + int c = a[-1]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + int c = a[6]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/expected.txt b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/test.cfg b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ef232f75af2c1a7fc3a1afdbb9e60379ef419e69 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0028-rt-arrayboundary-ABCOnormal/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOnormal) +run(ABCOnormal) diff --git a/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/ABCOparamIndex.java b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/ABCOparamIndex.java new file mode 100755 index 0000000000000000000000000000000000000000..93312b0ccb2971489359ab492a1b7289404d3c3a --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/ABCOparamIndex.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOparamIndex { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + int[] a = new int[5]; + int[] c = a; + for (int i = 0; i < a.length; i++) { + c[i] = i + 1; + } + int y = c[4]; + result = test1(a, y); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1(int[] arr, int index) { + int res = 3 /*STATUS_FAILED*/; + try { + if (index >= 0) { + int c = arr[index]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/expected.txt b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/test.cfg b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e7ff3fdbcf569f2074bc4fc2d6a96bcf362f98b4 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0029-rt-arrayboundary-ABCOparamIndex/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOparamIndex) +run(ABCOparamIndex) diff --git a/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/ABCOparam.java b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/ABCOparam.java new file mode 100755 index 0000000000000000000000000000000000000000..53a4913edbadd9a238cbe6bf177fd98bfca79b02 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/ABCOparam.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOparam { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + int[] arr = new int[5]; + result = test1(arr); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1(int[] arr) { + int res = 3 /*STATUS_FAILED*/; + int y = arr.length; + try { + if (y >= 0) { + int c = arr[y]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/expected.txt b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/test.cfg b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c43d2e804ef706a3dad77350c16e558826371994 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0030-rt-arrayboundary-ABCOparam/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOparam) +run(ABCOparam) diff --git a/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/ABCOreflectArray.java b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/ABCOreflectArray.java new file mode 100755 index 0000000000000000000000000000000000000000..b91bf73c8db7ec587939bc7c6f315aeff03edfde --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/ABCOreflectArray.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Array; +public class ABCOreflectArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + Array.setInt(a, 4, 5); + int x = (int) Array.get(a, 4); + try { + int c = (int) Array.get(a, x); + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + Array.setInt(a, x, 5); + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f2f357d689ada66e07c7c11e6546d7af3e291350 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0031-rt-arrayboundary-ABCOreflectArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOreflectArray) +run(ABCOreflectArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/ABCOreturnArray.java b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/ABCOreturnArray.java new file mode 100755 index 0000000000000000000000000000000000000000..8e63ae447c2d1ad9f08b57fb64b1affc9c18108c --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/ABCOreturnArray.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOreturnArray { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int[] func() { + int[] arr = new int[5]; + return arr; + } + public static int test1() { + int[] arr = func(); + int res = 3 /*STATUS_FAILED*/; + int y = arr.length; + try { + if (y >= 0) { + int c = arr[y]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/expected.txt b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/test.cfg b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..656b8acbad67fff75cd5e8fc70c87c48960b8938 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0032-rt-arrayboundary-ABCOreturnArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOreturnArray) +run(ABCOreturnArray) diff --git a/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/ABCOreturnIndex.java b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/ABCOreturnIndex.java new file mode 100755 index 0000000000000000000000000000000000000000..ed860664e767cac33de3b1da65b468d941f86fbc --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/ABCOreturnIndex.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOreturnIndex { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int func() { + int getRand = 0; + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 10; k++) { + getRand = getRand + k; + if (getRand > 200) { + break; + } + } + } + } + return getRand; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] arr = new int[100]; + int[] arrCopy = arr; + for (int i = 0; i < arr.length; i++) { + arrCopy[i] = i; + } + int y = func(); + try { + if (y >= 0) { + int c = arr[y]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/expected.txt b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/test.cfg b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d9d789501215b3626102625b492cbf9ae0062d86 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0033-rt-arrayboundary-ABCOreturnIndex/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOreturnIndex) +run(ABCOreturnIndex) diff --git a/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/ABCOreturnString.java b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/ABCOreturnString.java new file mode 100755 index 0000000000000000000000000000000000000000..5465694bd16dbe46f1d492385f9102943c9d6913 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/ABCOreturnString.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOreturnString { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + String joinLine = funx(); + int y = func(); + try { + if (y >= 0) { + char c = joinLine.charAt(y); + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func() { + int getRand = 0; + for (int i = 0; i < 10; i++) { + for (int j = 0; j < 10; j++) { + for (int k = 0; k < 10; k++) { + getRand = getRand + k; + if (getRand > 300) { + break; + } + } + } + } + return getRand; + } + public static String funx() { + char[] a = new char[100]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + return joinLine; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/expected.txt b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/test.cfg b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b95cc6ec78e63c7bfa9965fa37b96a9dd9d5e7ca --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0034-rt-arrayboundary-ABCOreturnString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOreturnString) +run(ABCOreturnString) diff --git a/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/ABCOStringBuilderCatchEx.java b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/ABCOStringBuilderCatchEx.java new file mode 100755 index 0000000000000000000000000000000000000000..61cb16cbc1036f00030510c8817f280b7feac9e9 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/ABCOStringBuilderCatchEx.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.List; +public class ABCOStringBuilderCatchEx { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + try { + func(); + } catch (StringIndexOutOfBoundsException e) { + res--; + } catch (Exception e) { + res = res + 2; + } + return res; + } + public static void func() throws Exception { + StringBuilder sbu = new StringBuilder(); + List lii = new ArrayList<>(); + lii.add("welcome"); + lii.add("to"); + lii.add("hang"); + lii.add("zhou"); + lii.add("huawei"); + lii.add("company"); + for (String str : lii) { + sbu.append(str).append(","); + } + int endIndex = (sbu.toString()).length() + 1; + String getStr = sbu.toString().substring(0, endIndex); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/expected.txt b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/test.cfg b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..40514756c9557a5a7ece75d9ccd5e9c901a09b0f --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0035-rt-arrayboundary-ABCOStringBuilderCatchEx/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOStringBuilderCatchEx) +run(ABCOStringBuilderCatchEx) diff --git a/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/ABCOStringConstOperation.java b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/ABCOStringConstOperation.java new file mode 100755 index 0000000000000000000000000000000000000000..a1c1245796a7166f13a6e546fb71c62ba3d45572 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/ABCOStringConstOperation.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOStringConstOperation { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 10 /*STATUS_FAILED*/; + byte[] a = new byte[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = '1'; + } + String joinLine = Arrays.toString(a); + int index = 1; + int y = joinLine.length(); + try { + index = index + y + 9; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = y - joinLine.length() - index; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = y * y * index; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = index + 167772161; + index = (y / index) * y; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = index & index; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = y | index; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = ~index; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = y + y; + index = index ^ y; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + index = index + index; + y = 8195; + index = index % y; + String c = joinLine.substring(index); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/expected.txt b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/test.cfg b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1d09fb64ff7200deb29c447d43a691ca4df5f846 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0036-rt-arrayboundary-ABCOStringConstOperation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOStringConstOperation) +run(ABCOStringConstOperation) diff --git a/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/ABCOstringDoWhile.java b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/ABCOstringDoWhile.java new file mode 100755 index 0000000000000000000000000000000000000000..84ec19ce098473d54c9a21a4403b85d86dbfdebb --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/ABCOstringDoWhile.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOstringDoWhile { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + String aCp = new String(); + int x = 0; + do { + aCp = aCp + "hashl@^&@&2894684"; + x++; + } while (x <= 9999); + String a = aCp; + x = funx(1000); + int y = funx(170000); + try { + do { + char c = a.charAt(x); + x++; + } while (x <= y); + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int funx(int maxFlag) { + int endIndex = maxFlag + 5; + int index = 0; + do { + index = funy(index); + } while (index < endIndex); + return index; + } + public static int funy(int forIdx) { + int idx = forIdx + 100; + return idx; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/expected.txt b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/test.cfg b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..be1fd3237a18f06812d6156e77f82f4f8c366d73 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0037-rt-arrayboundary-ABCOstringDoWhile/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringDoWhile) +run(ABCOstringDoWhile) diff --git a/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/ABCOstringFor.java b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/ABCOstringFor.java new file mode 100755 index 0000000000000000000000000000000000000000..91b68191850d2c4430c3a17f41250c2eff4505ef --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/ABCOstringFor.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOstringFor { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + char[] b = new char[joinLine.length()]; + try { + for (int i = 0; i <= joinLine.length(); i++) { + int index = funx(i); + b[index] = joinLine.charAt(index); + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int funx(int maxFlag) { + int endIndex = maxFlag + 5; + int index; + for (index = 0; index <= endIndex; index++) { + index = funy(index); + } + return index; + } + public static int funy(int forIdx) { + int idx = forIdx + 100; + return idx; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/expected.txt b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/test.cfg b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d8c4a5d99c151dde0f90d71d1157a0d5de811be9 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0038-rt-arrayboundary-ABCOstringFor/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringFor) +run(ABCOstringFor) diff --git a/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/ABCOstringIf.java b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/ABCOstringIf.java new file mode 100755 index 0000000000000000000000000000000000000000..6d15bc47cc80f9d23f78a69846ff167de8731f8a --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/ABCOstringIf.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Random; +public class ABCOstringIf { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + int result2 = 4; + try { + result = test1(); + result2 = test2(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && result2 == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + int y = func(); + try { + if (y >= 0) { + char c = joinLine.charAt(y); + ; + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int test2() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + try { + for (int i = 0; i < joinLine.length(); i++) { + if (joinLine.charAt(i) == joinLine.charAt(i + 1)) { + char c = joinLine.charAt(i); + } + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func() { + Random r = new Random(); + int get = r.nextInt(6); + if (get >= 5) { + return get + 3072; + } else { + return get + 3072; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/expected.txt b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/test.cfg b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b8b549c5a5d9abf76c589730a1eb9f38c17da92 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0039-rt-arrayboundary-ABCOstringIf/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringIf) +run(ABCOstringIf) diff --git a/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/ABCOstringIndexNesting.java b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/ABCOstringIndexNesting.java new file mode 100755 index 0000000000000000000000000000000000000000..0e57e5d44d7331ad6df5e98eb8b7b215ff31c117 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/ABCOstringIndexNesting.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOstringIndexNesting { + static int RES_PROCESS = 99; + static int arrNum = 1023; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'w'; + } + String joinLine = Arrays.toString(a); + int index = 0; + try { + for (int j = 1; j <= joinLine.length(); j++) { + if (j == joinLine.length()) { + index = func(j, index); + char c = joinLine.charAt(index); + } + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func(int index, int getIndex) { + getIndex = funx(getIndex, index); + getIndex = getIndex + 10; + if (getIndex < index) { + getIndex = func(index, getIndex); + } + return getIndex; + } + public static int funx(int getIndex, int index) { + getIndex = getIndex + index; + getIndex = funy(getIndex, index); + return getIndex; + } + public static int funy(int getIndex, int index) { + getIndex = getIndex * index; + getIndex = funz(getIndex, index); + return getIndex; + } + public static int funz(int getIndex, int index) { + getIndex = getIndex / index; + getIndex = funw(getIndex, index); + return getIndex; + } + public static int funw(int getIndex, int index) { + getIndex = getIndex - index; + return getIndex; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/expected.txt b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/test.cfg b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e2da7b2ecc9ae66e4ea0e8575efcd9575bc35345 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0040-rt-arrayboundary-ABCOstringIndexNesting/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringIndexNesting) +run(ABCOstringIndexNesting) diff --git a/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/ABCOStringMaxValue.java b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/ABCOStringMaxValue.java new file mode 100755 index 0000000000000000000000000000000000000000..f24b0849a9ad6b227187fd5aa14004c5092df2c0 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/ABCOStringMaxValue.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOStringMaxValue { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 5 /*STATUS_FAILED*/; + char[] a = new char[1024]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + int max = Integer.MAX_VALUE; + int min = Integer.MIN_VALUE; + try { + int c = joinLine.codePointCount(min, 2); + } catch (IndexOutOfBoundsException e) { + res--; + } + try { + char c = joinLine.charAt(min); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + try { + int c = joinLine.codePointCount(0, max); + } catch (IndexOutOfBoundsException e) { + res--; + } + try { + char c = joinLine.charAt(max); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/expected.txt b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/test.cfg b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b331652d0e15244d6e22daf6f3a9f523fb928ef2 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0041-rt-arrayboundary-ABCOStringMaxValue/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOStringMaxValue) +run(ABCOStringMaxValue) diff --git a/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/ABCOstringMutiLoop.java b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/ABCOstringMutiLoop.java new file mode 100755 index 0000000000000000000000000000000000000000..5f9a4e9c8b495b567474ee11750c0d5879e90194 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/ABCOstringMutiLoop.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOstringMutiLoop { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 2 /*STATUS_FAILED*/; + char[] a = new char[8000]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + int x; + try { + x = func(); + char c = joinLine.charAt(x); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + return res; + } + public static int func() { + int index = 0; + for (int i = 0; i < 5; i++) { + for (int j = 0; j < 5; j++) { + for (int k = 0; k < 5; k++) { + for (int ii = 0; ii < 5; ii++) { + for (int jj = 0; jj < 5; jj++) { + for (int kk = 0; kk < 5; kk++) { + for (int iii = 0; iii < 5; iii++) { + for (int jjj = 0; jjj < 5; jjj++) { + for (int kkk = 0; kkk < 5; kkk++) { + for (int n = 0; n < 5; n++) { + index = index + n; + } + } + } + } + } + } + } + } + } + } + return index; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/expected.txt b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/test.cfg b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fa89daaa3a9aaca9e9fdce2d0b9c0e0ea52be7de --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0042-rt-arrayboundary-ABCOstringMutiLoop/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringMutiLoop) +run(ABCOstringMutiLoop) diff --git a/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/ABCOstringSwitch.java b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/ABCOstringSwitch.java new file mode 100755 index 0000000000000000000000000000000000000000..2a009cfa5c24f71e4e2bacfcd4284715950ae5a0 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/ABCOstringSwitch.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +import java.util.Random; +public class ABCOstringSwitch { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[3000]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + char c; + int x = func(); + int y = x % 2; + try { + switch (y) { + case 0: + c = joinLine.charAt(x); + break; + default: + c = joinLine.charAt(x); + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int func() { + Random r = new Random(); + int getI = r.nextInt(3); + int y = getI % 3; + getI = getI + 9000; + switch (y) { + case 0: + getI = getI + 0; + break; + case 1: + getI = getI + 1; + break; + default: + getI = getI + 2; + } + return getI; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/expected.txt b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/test.cfg b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4362058861f252d105e077d5ba86454ba2b35f8e --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0043-rt-arrayboundary-ABCOstringSwitch/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOstringSwitch) +run(ABCOstringSwitch) diff --git a/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/ABCOswitch.java b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/ABCOswitch.java new file mode 100755 index 0000000000000000000000000000000000000000..111a23866595893196ad8a8e8c2bf9d305e22645 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/ABCOswitch.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Random; +public class ABCOswitch { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int c; + Random r = new Random(); + int x = r.nextInt(2); + int y = x % 2; + x = x + 5; + try { + switch (y) { + case 0: + c = a[x]; + break; + default: + c = a[x]; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/expected.txt b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/test.cfg b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ed1548bfb548effc1511f654540061e3c6e9f64 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0044-rt-arrayboundary-ABCOswitch/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOswitch) +run(ABCOswitch) diff --git a/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/ABCOtryExtEh.java b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/ABCOtryExtEh.java new file mode 100755 index 0000000000000000000000000000000000000000..3471dd336374d6c24fd7c27a6af0a12a67318ab5 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/ABCOtryExtEh.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOtryExtEh { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + try { + int c = a[-1]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } catch (IndexOutOfBoundsException e) { + res++; + } + try { + int c = a[6]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } catch (IndexOutOfBoundsException e) { + res++; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/expected.txt b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/test.cfg b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..30720aee920a2ec7e49400631a7b635d42cfa11d --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0045-rt-arrayboundary-ABCOtryExtEh/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOtryExtEh) +run(ABCOtryExtEh) diff --git a/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/ABCOmaxValue.java b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/ABCOmaxValue.java new file mode 100755 index 0000000000000000000000000000000000000000..403ca4653ba8a44b19ab9d76c1722a6722642614 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/ABCOmaxValue.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOmaxValue { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int max = Integer.MAX_VALUE; + int min = Integer.MIN_VALUE; + try { + int c = a[min]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + try { + int c = a[max]; + } catch (ArrayIndexOutOfBoundsException e) { + res--; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/expected.txt b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/test.cfg b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..789b79c1f14bf67ac9ccea4a55600302ea52c40b --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0046-rt-arrayboundary-ABCOmaxValue/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOmaxValue) +run(ABCOmaxValue) diff --git a/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/ABCOwhile.java b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/ABCOwhile.java new file mode 100755 index 0000000000000000000000000000000000000000..5a4f724ed124539f3ba4f6702b83b9a17175deea --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/ABCOwhile.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ABCOwhile { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); // + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + int[] a = new int[5]; + int[] c = new int[a.length]; + int x = 0; + int y = a.length; + try { + while (x <= y) { + c[x] = a[x]; + x++; + } + } catch (ArrayIndexOutOfBoundsException e) { + res = 1; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/expected.txt b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/test.cfg b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4dac3d38983c79ac8cf08ca4bb44f3c30a867753 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0047-rt-arrayboundary-ABCOwhile/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOwhile) +run(ABCOwhile) diff --git a/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/ABCOwhileString.java b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/ABCOwhileString.java new file mode 100755 index 0000000000000000000000000000000000000000..f7f0cb012e29c86c7a783396e9fd7ce76097dc2b --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/ABCOwhileString.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Arrays; +public class ABCOwhileString { + static int RES_PROCESS = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 4 /*STATUS_FAILED*/; + try { + result = test1(); + } catch (Exception e) { + RES_PROCESS -= 10; + } + if (result == 1 && RES_PROCESS == 99) { + result = 0; + } + return result; + } + public static int test1() { + int res = 3 /*STATUS_FAILED*/; + char[] a = new char[100]; + for (int i = 0; i < a.length; i++) { + a[i] = 'h'; + } + String joinLine = Arrays.toString(a); + char[] c = new char[joinLine.length()]; + int x = funx(1000); + int y = funx(170000); + try { + while (x <= y) { + c[x] = joinLine.charAt(y); + ; + x++; + } + } catch (StringIndexOutOfBoundsException e) { + res = 1; + } + return res; + } + public static int funx(int maxFlag) { + int endIndex = maxFlag + 5; + int index = 0; + while (index < endIndex) { + index = funy(index); + } + return index; + } + public static int funy(int forIdx) { + int idx = forIdx + 100; + return idx; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/expected.txt b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/test.cfg b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fd910ca38443e8135cde1694d0423bd455801730 --- /dev/null +++ b/testsuite/java_test/arrayboundary_test/RT0048-rt-arrayboundary-ABCOwhileString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ABCOwhileString) +run(ABCOwhileString) diff --git a/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/ClinitBase001.java b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/ClinitBase001.java new file mode 100644 index 0000000000000000000000000000000000000000..934141f965a43d58e5ccf2aa72f7253e558e25cd --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/ClinitBase001.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class TopLevelClass1 { + static int field; + static { + if (ClinitBase001.getCount() == 3) { + field = ClinitBase001.getCount(); + } + } + int getField() { + return field; + } + static class StaticClass { + static int field; + static { + if (ClinitBase001.getCount() == 5) { + field = ClinitBase001.getCount(); + } + } + int getField() { + return field; + } + static class StaticNestClass { + static int field; + static { + if (ClinitBase001.getCount() == 7) { + field = ClinitBase001.getCount(); + } + } + int getField() { + return field; + } + static class StaticInnerClass { + static int field; + static { + if (ClinitBase001.getCount() == 1) { + field = ClinitBase001.getCount(); + } + } + int getField() { + return field; + } + } + } + } +} +public class ClinitBase001 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0/*STATUS_PASSED*/; + // 创建内部静态类实例,触发内部静态类初始化,不触发外部类的初始化 + TopLevelClass1.StaticClass.StaticNestClass.StaticInnerClass case4 = + new TopLevelClass1.StaticClass.StaticNestClass.StaticInnerClass(); + // 创建外部类实例,触发外部类初始化,不触发内部类的初始化 + TopLevelClass1 case1 = new TopLevelClass1(); + // 创建内部静态类的实例,触发内部静态类初始化,不触发它内部类的初始化 + TopLevelClass1.StaticClass case2 = new TopLevelClass1.StaticClass(); + TopLevelClass1.StaticClass.StaticNestClass case3 = + new TopLevelClass1.StaticClass.StaticNestClass(); + if (case1.getField() != 4) { + out.println("Error: TopLevelClass1 initialized Failed"); + res = 2; + } + if (case2.getField() != 6) { + out.println("Error: TopLevelClass1.StaticClass initialized Failed"); + res = 2; + } + if (case3.getField() != 8) { + out.println("Error: TopLevelClass1.StaticClass.StaticNestClass initialized Failed"); + res = 2; + } + if (case4.getField() != 2) { + out.println("Error: TopLevelClass1.StaticClass.StaticNestClass initialized Failed"); + res = 2; + } + // new数组不触发对应类的初始化 + TopLevelClass1[] array = new TopLevelClass1[4]; + if (array.length != 4) { + res = 2; + } + if (count != 8) { + out.println("Error: class initialized should not be invoked twice"); + res = 2; + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/expected.txt b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/test.cfg b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a8e0b4ee2f4ef694504d04944d1703d7e5050518 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0001-rt-clinit-clinit_base_001/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase001) +run(ClinitBase001) diff --git a/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/ClinitBase002.java b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/ClinitBase002.java new file mode 100644 index 0000000000000000000000000000000000000000..91bf2ee0f31c8b12b7d91a072e755b45a92bbc91 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/ClinitBase002.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +abstract class CaseClass { + static float field; + static { + if (ClinitBase002.getCount() == 3) { + field = ClinitBase002.getCount(); + } + } + static float getField() { + return (float) (field * 1.2); + } + public abstract int uselessFunction(); + static class StaticClass { + static float field; + static { + if (ClinitBase002.getCount() == 1) { + field = ClinitBase002.getCount(); + } + } + static float getField() { + return (float) (field * 1.2); + } + } +} +public class ClinitBase002 { + static private float count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static float getCount() { + count += 1.0f; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + // 创建继承内部静态类的局部类 + class AnonymousClass extends CaseClass.StaticClass { + } + // 访问局部类的静态方法,触发父类初始化 + if (AnonymousClass.getField() != 2.4f) { + res = 2; + out.println("Error: CaseClass.StaticClass not initialized"); + } + // 创建继承外部类的局部类 + class ClassChild extends CaseClass { + public int uselessFunction() { + return 0; + } + } + // 访问局部类的静态方法,触发父类初始化 + if (ClassChild.getField() != 4.8f) { + res = 2; + out.println("Error: CaseClass not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/expected.txt b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/test.cfg b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8ac647d4661932731ce1aafedfb8d648cdb9afec --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0002-rt-clinit-clinit_base_002/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase002) +run(ClinitBase002) diff --git a/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/ClinitBase003.java b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/ClinitBase003.java new file mode 100644 index 0000000000000000000000000000000000000000..b0302d343eadfc98f5b64fa279116540d4cd95ed --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/ClinitBase003.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class CaseClass { + static float field; + static { + if (ClinitBase003.getCount() == 3) { + field = ClinitBase003.getCount(); + } + } + public static class StaticClass { + public static float field; + static { + if (ClinitBase003.getCount() == 1) { + field = ClinitBase003.getCount(); + } + } + } +} +public class ClinitBase003 { + static private float count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static float getCount() { + count += 1.0f; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + class CaseChild extends CaseClass { + class CaseStaticChild extends StaticClass { + } + } + // 对局部类的内部类的静态字段赋值,触发此类的初始化 + CaseChild.CaseStaticChild.field = 20.0f; + // 对局部类的静态字段赋值,触发此类的初始化 + CaseChild.field = 10.0f; + if (CaseClass.field != 10.0f) { + res = 2; + out.println("Error: CaseClass not initialized"); + } + if (CaseClass.StaticClass.field != 20.0f) { + out.println(CaseClass.StaticClass.field); + res = 2; + out.println("Error: CaseClass.StaticClass not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/expected.txt b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/test.cfg b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bec572d818e2085ad190bc7005d94fd2d63ef55a --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0003-rt-clinit-clinit_base_003/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase003) +run(ClinitBase003) diff --git a/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/ClinitBase004.java b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/ClinitBase004.java new file mode 100644 index 0000000000000000000000000000000000000000..930c482a7318ceb0b5134d9b945e2799734f6de7 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/ClinitBase004.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class Other { +} +class CaseClass { + static final float FIELD1 = ClinitBase004.getCount1(); + static final String FIELD2 = ClinitBase004.getCount2(); + static Other field3; + static { + if (ClinitBase004.count == 12) { + field3 = ClinitBase004.getCount3(); + } + } +} +public class ClinitBase004 { + public static int count; + static { + count = 10; + } + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static float getCount1() { + count += 1; + return (float) count; + } + static String getCount2() { + count += 1; + return String.valueOf(count); + } + static Other getCount3() { + count += 1; + return new Other(); + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + // 访问静态常量不应该触发类初始化 + if (CaseClass.FIELD1 != 11.0f) { + res = 2; + out.println("Error1: CaseClass should not be initialized"); + } + count++; + if (!CaseClass.FIELD2.equals("12")) { + res = 2; + out.println("Error2: CaseClass should not be initialized"); + } + count++; + // 访问静态变量触发类初始化 + if (CaseClass.field3 == null || count != 15) { + res = 2; + out.println("Error3: CaseClass not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/expected.txt b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/test.cfg b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b1d272a9373f14bc5731ad308f60f5290f6a9a9 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0004-rt-clinit-clinit_base_004/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase004) +run(ClinitBase004) diff --git a/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/ClinitBase005.java b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/ClinitBase005.java new file mode 100644 index 0000000000000000000000000000000000000000..5d4522341a08a811bc26e27d546b98dec0a07ad0 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/ClinitBase005.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface CaseInterface { + float FIELD1 = ClinitBase005.getCount1(); + String FIELD2 = ClinitBase005.getCount2(); + OtherCase FIELD3 = (ClinitBase005.count == 12) ? ClinitBase005.getCount3() : null; +} +class OtherCase { +} +class CaseClass implements CaseInterface { +} +public class ClinitBase005 { + public static int count; + static { + count = 10; + } + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static float getCount1() { + count += 1; + return (float) count; + } + static String getCount2() { + count += 1; + return String.valueOf(count); + } + static OtherCase getCount3() { + count += 1; + return new OtherCase(); + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + if (CaseClass.FIELD1 != 11.0f) { + res = 2; + out.println("Error1: interface should not be initialized"); + } + count++; + if (!CaseClass.FIELD2.equals("12")) { + res = 2; + out.println("Error2: interface should not be initialized"); + } + count++; + if (CaseClass.FIELD3 == null || count != 15) { + res = 2; + out.println("Error3: interface not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/expected.txt b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/test.cfg b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7ed865461f7e09b75f0f84f62535b8539ea1c4a7 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0005-rt-clinit-clinit_base_005/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase005) +run(ClinitBase005) diff --git a/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/ClinitBase006.java b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/ClinitBase006.java new file mode 100644 index 0000000000000000000000000000000000000000..0a55e17d7aa8b22649bc3cd5113bd14f82a7ba50 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/ClinitBase006.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class CaseForName1 { + static int field; + static { + if (ClinitBase006.getCount() == 1) { + field = ClinitBase006.getCount(); + } + } +} +class CaseForName2 { + static int field; + static { + if (ClinitBase006.getCount() == 3) { + field = ClinitBase006.getCount(); + } + } +} +class CaseForName3 { + static int field; + static { + if (ClinitBase006.getCount() == 5) { + field = ClinitBase006.getCount(); + } + } +} +class CaseClassInstance { + static int field; + static { + if (ClinitBase006.getCount() == 7) { + field = ClinitBase006.getCount(); + } + } +} +class CaseClassMethod { + static int field; + static { + if (ClinitBase006.getCount() == 5) { + field = ClinitBase006.getCount(); + } + System.out.println("hello"); + } + static int getField() { + return field; + } +} +public class ClinitBase006 { + public static int count; + public static void main(String[] argv) { + ClinitBase006 test = new ClinitBase006(); + System.out.println(test.run(argv, System.out)/*STATUS_TEMP*/); + } + static int getCount() { + count += 1; + return count; + } + private int run(String[] argv, PrintStream out) { + int res = 0; + try { + Class forName1 = Class.forName("CaseForName1"); + if (count != 2 || forName1.getDeclaredField("field").getInt(null) != 2) { + res = 2; + out.println("Error, CaseForName1 not initialized"); + } + Class forName2 = Class.forName("CaseForName2", true, this.getClass().getClassLoader()); + if (count != 4 || forName2.getDeclaredField("field").getInt(null) != 4) { + res = 2; + out.println("Error, CaseForName2 not initialized"); + } + Class forName3 = Class.forName("CaseForName3", false, this.getClass().getClassLoader()); + if (count != 4 || forName3.getDeclaredField("field").getInt(null) != 6) { + res = 2; + out.println("Error, CaseForName3 not initialized"); + } + CaseClassInstance caseInstance = CaseClassInstance.class.newInstance(); + if (count != 8 || CaseClassInstance.field != 8) { + res = 2; + out.println("Error, case6_instance not initialized"); + } + } catch (Exception e) { + res = 2; + out.println(e); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/expected.txt b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/test.cfg b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0a9c3d1f3285488237a065bffe111298d1626503 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0006-rt-clinit-clinit_base_006/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase006) +run(ClinitBase006) diff --git a/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/ClinitBase007.java b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/ClinitBase007.java new file mode 100755 index 0000000000000000000000000000000000000000..93eb7d3506134bc7322837d0a76e544f5b3131b9 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/ClinitBase007.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClinitBase007 { + static int res = 2; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + ClinitBaseB.testAsserts(); + return res; + } +} +class ClinitBaseA { + static { + ClinitBaseB.testAsserts(); + } +} +class ClinitBaseB extends ClinitBaseA { + static void testAsserts() { + boolean enable = false; + assert enable = true; + if (!enable) { + ClinitBase007.res -= 1; + } else { + System.out.println("Asserts enable"); + } + } +} diff --git a/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/expected.txt b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/test.cfg b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cab43642706f2c16e7022b299d6575c43f66dc0b --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0007-rt-clinit-clinit_base_007/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase007) +run(ClinitBase007) diff --git a/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/ClinitBase008.java b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/ClinitBase008.java new file mode 100644 index 0000000000000000000000000000000000000000..e5b9bc63995744a52d908901461249a6f42ac20e --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/ClinitBase008.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClinitBase008 { + static int res = 0; + static { + res = 1; + } + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + if (res == 1) { + return 0; + } else { + return 1; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/expected.txt b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/test.cfg b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..aed38cae51418be927d4a1a2fd54ba8da1f48dce --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0008-rt-clinit-clinit_base_008/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitBase008) +run(ClinitBase008) diff --git a/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/ClinitSeq001.java b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/ClinitSeq001.java new file mode 100644 index 0000000000000000000000000000000000000000..f6312ee00f63a9187d7b40fcffd7c833601fcc8e --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/ClinitSeq001.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class FatherClass { + static int field; + static { + if (ClinitSeq001.getCount() == 1) { + field = ClinitSeq001.getCount(); + } + } +} +class ChildClass extends FatherClass { + static int field; + static { + if (ClinitSeq001.getCount() == 3) { + field = ClinitSeq001.getCount(); + } + } +} +public class ClinitSeq001 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out) /*STATUS_TEMP*/); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0/*STATUS_PASSED*/; + if (ChildClass.field != 4) { + res = 2; + out.println("Error, ChildClass not initialized"); + } + if (FatherClass.field != 2) { + res = 2; + out.println("Error, FatherClass not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/expected.txt b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/test.cfg b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d1389a618b52387be4ac4a81d166372cd651ef42 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0009-rt-clinit-clinit_seq_001/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitSeq001) +run(ClinitSeq001) diff --git a/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/ClinitSeq002.java b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/ClinitSeq002.java new file mode 100644 index 0000000000000000000000000000000000000000..dbf40ccb35cbc5e8ffbec094396621612be82d0c --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/ClinitSeq002.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface CaseInterface { + int FIELD = ClinitSeq002.getCount(); + CaseOtherClass MEMBER = new CaseOtherClass(); + default int uselessFunction(int a, int b) { + return a + b; + } +} +class CaseOtherClass { + static int field; + static { + if (ClinitSeq002.getCount() == 2) { + field = ClinitSeq002.getCount(); + } + } +} +class CaseChild implements CaseInterface { + static int field; + static { + if (ClinitSeq002.getCount() == 4) { + field = ClinitSeq002.getCount(); + } + } +} +public class ClinitSeq002 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out) /*STATUS_TEMP*/); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + // 访问child field触发类初始化 + if (CaseChild.field != 5) { + res = 2; + out.println("Error, child not initialized"); + } + // 访问CaseOtherClass field触发类初始化 + if (CaseOtherClass.field != 3) { + res = 2; + out.println("Error, other not initialized"); + } + // 访问interface常量,触发初始化 + if (CaseInterface.FIELD != 1) { + res = 2; + out.println("Error, interface not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/expected.txt b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/test.cfg b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d901b5bcd88264e9b0ffb6682329c54ce22c6301 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0010-rt-clinit-clinit_seq_002/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitSeq002) +run(ClinitSeq002) diff --git a/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/ClinitSeq003.java b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/ClinitSeq003.java new file mode 100644 index 0000000000000000000000000000000000000000..f566a75ebcc475d5479d2e4d8211487b97b4984b --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/ClinitSeq003.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface CaseInterface { + int FIELD = ClinitSeq003.getCount(); + CaseOtherClass MEMBER = new CaseOtherClass(); + default int uselessFunction(int a, int b) { + return a + b; + } +} +class CaseOtherClass { + static int field; + static { + if (ClinitSeq003.getCount() == 4) { + field = ClinitSeq003.getCount(); + } + } +} +class CaseFather { + static int field; + static { + if (ClinitSeq003.getCount() == 1) { + field = ClinitSeq003.getCount(); + } + } +} +class CaseChild extends CaseFather implements CaseInterface { + static int field; + static { + if (ClinitSeq003.getCount() == 6) { + field = ClinitSeq003.getCount(); + } + } +} +public class ClinitSeq003 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out) /*STATUS_TEMP*/); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + // 访问子类的字段 + if (CaseChild.field != 7) { + res = 2; + out.println(CaseChild.field); + out.println("Error, child not initialized"); + } + // 接口中的字段对应的类被触发初始化 + if (CaseOtherClass.field != 5) { + res = 2; + out.println("Error, other not initialized"); + } + // 包含有default方法的接口被触发初始化 + if (CaseInterface.FIELD != 3) { + res = 2; + out.println("Error, interface not initialized"); + } + // 父类被触发初始化 + if (CaseFather.field != 2) { + res = 2; + out.println("Error, father not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/expected.txt b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/test.cfg b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..122cb35d04e9e2d5df3574e6152bea90238c30f9 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0011-rt-clinit-clinit_seq_003/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitSeq003) +run(ClinitSeq003) diff --git a/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/ClinitSeq004.java b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/ClinitSeq004.java new file mode 100644 index 0000000000000000000000000000000000000000..df053c7d6a41585d35d8d53c5813293d6b4342aa --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/ClinitSeq004.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface CaseInterface { + int FIELD = ClinitSeq004.getCount(); + CaseOtherClass MEMBER = new CaseOtherClass(); + default int uselessFunction(int a, int b) { + return a + b; + } +} +interface CaseChild extends CaseInterface { + int FIELD_CHILD = ClinitSeq004.getCount(); +} +class CaseOtherClass { + static int field; + static { + if (ClinitSeq004.getCount() == 3) { + field = ClinitSeq004.getCount(); + } + } +} +public class ClinitSeq004 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + if (CaseChild.FIELD_CHILD != 1) { + res = 2; + out.println("Error, child not initialized"); + } + if (CaseInterface.FIELD != 2) { + res = 2; + out.println("Error, interface not initialized"); + } + if (CaseOtherClass.field != 4) { + res = 2; + out.println("Error, other not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/expected.txt b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/test.cfg b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b974cc63367a2cf801971ce88401691819f34d3b --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0012-rt-clinit-clinit_seq_004/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitSeq004) +run(ClinitSeq004) diff --git a/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/ClinitSeq005.java b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/ClinitSeq005.java new file mode 100644 index 0000000000000000000000000000000000000000..f7360622ffa7de94a9d53d9490611395636fec98 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/ClinitSeq005.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface CaseInterface { + int FIELD = ClinitSeq005.getCount(); + CaseOtherClass MEMBER = new CaseOtherClass(); + int uselessFunction(int a, int b); +} +class CaseOtherClass { + static int field; + static { + if (ClinitSeq005.getCount() == 4) { + field = ClinitSeq005.getCount(); + } + } +} +class CaseChild implements CaseInterface { + static int field; + static { + if (ClinitSeq005.getCount() == 1) { + field = ClinitSeq005.getCount(); + } + } + public int uselessFunction(int a, int b) { + return a + b; + } +} +public class ClinitSeq005 { + static private int count = 0; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static int getCount() { + count += 1; + return count; + } + private static int run(String[] argv, PrintStream out) { + int res = 0; + if (CaseChild.field != 2) { + res = 2; + out.println("Error, child not initialized"); + } + if (CaseInterface.MEMBER.field != 5) { + res = 2; + out.println("Error, other not initialized"); + } + if (CaseInterface.FIELD != 3) { + res = 2; + out.println("Error, interface not initialized"); + } + return res; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/expected.txt b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/test.cfg b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d4991295e7702a47ca9eeae2e7e126f31b7becc3 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0013-rt-clinit-clinit_seq_005/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitSeq005) +run(ClinitSeq005) diff --git a/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/ClinitEh001.java b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/ClinitEh001.java new file mode 100755 index 0000000000000000000000000000000000000000..493d32aa16b960ad57c550a05e940e1d7b6143be --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/ClinitEh001.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class ThreadCaseClass { + static volatile int field; + static { + int temp = ClinitEh001.getCount(); + if (temp == 0) { + int a = ClinitEh001.getCount(); + int b = ClinitEh001.getCount(); + field = a / (b - 2); + } + System.out.println("Only be invoked once"); + } +} +public class ClinitEh001 { + private static final int THREAD_COUNT = 10; + private static int count = 0; + static volatile private int initErrCount = 0; + static volatile private int notDefCount = 0; + // CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的 + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + static int getCount() { + return count++; + } + static synchronized void InitializerErrorCnt() { + initErrCount += 1; + } + static synchronized void NotDefErrorCnt() { + notDefCount += 1; + } + public static void main(String[] args) { + ClinitEh001 test = new ClinitEh001(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (count != 3) { + System.out.println(1); + } else { + System.out.println(0); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + System.out.println(1); + } + if (count != 3) { + System.out.println("Error, ClinitEh001 initialized error"); + } + if (initErrCount != 1) { + System.out.println("Should be only invoked once, but actual invoked " + + initErrCount); + } + if (notDefCount != (THREAD_COUNT - 1)) { + System.out.println("Should be invoked " + (THREAD_COUNT - 1) + + ", but actual invoked " + notDefCount); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + try { + if (ThreadCaseClass.field == 2) { + ThreadCaseClass.field = ClinitEh001.getCount(); + } + } catch (ExceptionInInitializerError e) { + ClinitEh001.InitializerErrorCnt(); + } catch (NoClassDefFoundError e) { + ClinitEh001.NotDefErrorCnt(); + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/expected.txt b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/test.cfg b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2bc09fe7e733511c7d2bc5b7d4a82521e9b435fa --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0014-rt-clinit-clinit_eh_001/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitEh001) +run(ClinitEh001) diff --git a/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/ClinitEh002.java b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/ClinitEh002.java new file mode 100755 index 0000000000000000000000000000000000000000..63d7bf68b782e1f344a0f2cba3f705694c3ea749 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/ClinitEh002.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class ThreadFatherClass { + static volatile int field; + static { + int temp = ClinitEh002.getCount(); + if (temp == 0) { + int a = ClinitEh002.getCount(); + int b = ClinitEh002.getCount(); + field = a / (b - 2); + } + System.out.println("Only be invoked once"); + } +} +class ThreadChildClass extends ThreadFatherClass { + static volatile int field = ClinitEh002.getCount(); +} +public class ClinitEh002 { + private static final int THREAD_COUNT = 10; + private static int count = 0; + static volatile private int initErrCount = 0; + static volatile private int notDefCount = 0; + // CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的 + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + static int getCount() { + return count++; + } + static synchronized void InitializerErrorCnt() { + initErrCount += 1; + } + static synchronized void NotDefErrorCnt() { + notDefCount += 1; + } + public static void main(String[] args) { + ClinitEh002 test = new ClinitEh002(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (count != 3) { + System.out.println(1); + } else { + System.out.println(0); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + System.out.println(1); + } + if (count != 3) { + System.out.println("Error, ClinitEh002 initialized error"); + } + if (initErrCount != 1) { + System.out.println("Should be only invoked once, but actual invoked " + + initErrCount); + } + if (notDefCount != (THREAD_COUNT - 1)) { + System.out.println("Should be invoked " + (THREAD_COUNT - 1) + + ", but actual invoked " + notDefCount); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + try { + if (ThreadChildClass.field == 2) { + ThreadFatherClass.field = ClinitEh002.getCount(); + } + } catch (ExceptionInInitializerError e) { + ClinitEh002.InitializerErrorCnt(); + } catch (NoClassDefFoundError e) { + ClinitEh002.NotDefErrorCnt(); + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/expected.txt b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/test.cfg b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..362c675adde2a6c84c88c721c45917bfc14dc813 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0015-rt-clinit-clinit_eh_002/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitEh002) +run(ClinitEh002) diff --git a/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/ClinitEh003.java b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/ClinitEh003.java new file mode 100755 index 0000000000000000000000000000000000000000..9a74c3ff30068999964c364ec2fe662c0e48585a --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/ClinitEh003.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class ThreadClass { + static volatile int field; + static { + try { + int temp = ClinitEh003.getCount(); + if (temp == 0) { + int a = ClinitEh003.getCount(); + int b = ClinitEh003.getCount(); + field = a / (b - 2); + } + } catch (Exception e) { + ClinitEh003.getCount(); + } + } +} +public class ClinitEh003 { + private static final int THREAD_COUNT = 10; + private static int count = 0; + static volatile private int initErrCount = 0; + static volatile private int notDefCount = 0; + // CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的 + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + static int getCount() { + return count++; + } + static synchronized void InitializerErrorCnt() { + initErrCount += 1; + } + static synchronized void NotDefErrorCnt() { + notDefCount += 1; + } + public static void main(String[] args) { + ClinitEh003 test = new ClinitEh003(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (count != 4) { + System.out.println(1); + } else { + System.out.println(0); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + } + if (initErrCount != 0) { + System.out.println("Should be only invoked once, but actual invoked " + + initErrCount); + } + if (notDefCount != 0) { + System.out.println("Should be invoked " + (THREAD_COUNT - 1) + + ", but actual invoked " + notDefCount); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + try { + if (ThreadClass.field == 0) { + ThreadClass.field = 5; + } + } catch (ExceptionInInitializerError e) { + ClinitEh003.InitializerErrorCnt(); + } catch (NoClassDefFoundError e) { + ClinitEh003.NotDefErrorCnt(); + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/expected.txt b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/test.cfg b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e5c4508395df9212a9ea68b9cbfda59f814f91dc --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0016-rt-clinit-clinit_eh_003/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitEh003) +run(ClinitEh003) diff --git a/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/ClinitThread001.java b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/ClinitThread001.java new file mode 100755 index 0000000000000000000000000000000000000000..274d11d2110828b3ac80d1454232ca8bde0cdca9 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/ClinitThread001.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class CaseThreadClass { + static CaseThreadClass member; + static int field; + static { + if (ClinitThread001.getCount() == 0) { + // 不会重复触发初始化 + member = new CaseThreadClass(); + field = ClinitThread001.getCount(); + } + } + CaseThreadClass() { + ClinitThread001.getCount(); + } +} +class ClassA { + static ClassB member; + static int field; + static { + if (ClinitThread001.getCount() == 3) { + field = ClinitThread001.getCount(); + member = new ClassB(); + } + } + ClassA() { + ClinitThread001.getCount(); + } +} +class ClassB { + static ClassA member; + static int field; + static { + if (ClinitThread001.getCount() == 5) { + member = new ClassA(); + field = ClinitThread001.getCount(); + } + } + ClassB() { + ClinitThread001.getCount(); + } +} +public class ClinitThread001 { + private static final int THREAD_COUNT = 10; + private static int count = 0; + // CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的 + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + static int getCount() { + return count++; + } + public static void main(String[] args) { + ClinitThread001 test = new ClinitThread001(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (count != 9) { + System.out.println(1); + } else { + System.out.println(0); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + System.out.println(1); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + if (CaseThreadClass.field != 2) { + System.out.println("Error, CaseThreadClass not initialized"); + } + if (ClassA.field != 4) { + System.out.println("Error, ClassA not initialized"); + } + if (ClassB.field != 7) { + System.out.println("Error, ClassB not initialized"); + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/expected.txt b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/test.cfg b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ae5de606c3fd75723c78edf3023c5a0ef8fde98e --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0017-rt-clinit-clinit_thread_001/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitThread001) +run(ClinitThread001) diff --git a/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/ClinitGC001.java b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/ClinitGC001.java new file mode 100644 index 0000000000000000000000000000000000000000..3146026dca8b76c5920386271433fcf6376bf2ed --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/ClinitGC001.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import java.io.PrintStream; +class TemplateClassTest { + static { + Runtime.getRuntime().gc(); + } + public TemplateClassTest(T init) { + field = init; + } + private T field; + public void Show() { + System.out.println(field); + } +} +public class ClinitGC001 { + public static void main(String[] argv) { + ArrayList al = new ArrayList(); + TemplateClassTest test = new TemplateClassTest(0); + try { + test.Show(); + al.add(1); + } catch (NullPointerException e) { + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/expected.txt b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/test.cfg b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..17689e1b707a0893e552a7e29b92983008edee84 --- /dev/null +++ b/testsuite/java_test/clinit_test/RT0018-rt-clinit-clinit_gc_001/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitGC001) +run(ClinitGC001) diff --git a/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/ClinitThread002.java b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/ClinitThread002.java new file mode 100755 index 0000000000000000000000000000000000000000..7363c6029bd71c406da82f5daff7d64a714f9882 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/ClinitThread002.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class ThreadCaseClass { + static int field; + static { + field = ClinitThread002.getCount(); + field++; + } +} +public class ClinitThread002 { + private static final int THREAD_COUNT = 4096; + private static int count = 0; + // CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的 + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + static int getCount() { + return count++; + } + public static void main(String[] args) { + ClinitThread002 test = new ClinitThread002(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (count != 1 || ThreadCaseClass.field != 1) { + System.out.println(1/*STATUS_TEMP*/); + } else { + System.out.println(0/*STATUS_TEMP*/); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + System.out.println(1/*STATUS_TEMP*/); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + if (ThreadCaseClass.field != 1) { + count++; + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/expected.txt b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/test.cfg b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b90eb1c944e5a0a0da32da824ea57726d4423d55 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0018-rt-clinit-clinit_thread_002/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitThread002) +run(ClinitThread002) diff --git a/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/ClinitThread003.java b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/ClinitThread003.java new file mode 100755 index 0000000000000000000000000000000000000000..3a97daf11e29b7c3b77fdbac32153889ff4e1073 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/ClinitThread003.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.concurrent.BrokenBarrierException; +import java.util.concurrent.CyclicBarrier; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +class ThreadCaseClassA { + private static int field = 1; + static { + field = ThreadCaseClassB.getField(); + field++; + } + public static int getField() { + return field; + } +} +class ThreadCaseClassB { + private static int field = 2; + static { + field = ThreadCaseClassA.getField(); + field++; + } + public static int getField() { + return field; + } +} +public class ClinitThread003 { + private static final int THREAD_COUNT = 4096; + private int result = 0; + /** + * CyclicBarrier 适用再多线程相互等待,直到到达一个屏障点。并且CyclicBarrier是可重用的。 + */ + + private CyclicBarrier cyclicBarrier = new CyclicBarrier(THREAD_COUNT); + public static void main(String[] args) { + ClinitThread003 test = new ClinitThread003(); + ExecutorService executorService = test.runThread(); + executorService.shutdown(); + try { + if (executorService.awaitTermination(10, TimeUnit.SECONDS)) { + if (ThreadCaseClassA.getField() != 3 || ThreadCaseClassB.getField() != 2) { + System.out.println(1/*STATUS_TEMP*/); + } else { + System.out.println(0/*STATUS_TEMP*/); + } + } + } catch (InterruptedException ex) { + ex.printStackTrace(); + System.out.println(1/*STATUS_TEMP*/); + } + } + private ExecutorService runThread() { + ExecutorService executorService = Executors.newFixedThreadPool(THREAD_COUNT); + for (int i = 0; i < THREAD_COUNT; i++) { + executorService.submit(createThread(i)); + } + return executorService; + } + private Thread createThread(int i) { + return new Thread(new Runnable() { + @Override + public void run() { + try { + cyclicBarrier.await(); + if (ThreadCaseClassA.getField() != 3) { + result = ThreadCaseClassB.getField(); + } + } catch (InterruptedException | BrokenBarrierException e) { + e.printStackTrace(); + } + } + }); + } +} diff --git a/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/expected.txt b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/test.cfg b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9fbd9e412b5851d3dd06fc48bf4757cd5cdafb99 --- /dev/null +++ b/testsuite/java_test/clinit_test/issue-RT0019-rt-clinit-clinit_thread_003/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClinitThread003) +run(ClinitThread003) diff --git a/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/ReflectingGetConstructor1.java b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/ReflectingGetConstructor1.java new file mode 100755 index 0000000000000000000000000000000000000000..801e0cef1a1314bc4ec285e6afcbff28efcdabf5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/ReflectingGetConstructor1.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructor1 { + public GetConstructor1() { + } + public GetConstructor1(String name) { + } + public GetConstructor1(String name, int number) { + } + GetConstructor1(int number) { + } +} +public class ReflectingGetConstructor1 { + public static void main(String[] args) { + try { + Class getConstructor1 = Class.forName("GetConstructor1"); + Constructor constructor1 = getConstructor1.getConstructor(String.class); + Constructor constructor2 = getConstructor1.getConstructor(); + Constructor constructor3 = getConstructor1.getConstructor(String.class, int.class); + if (constructor1.toString().equals("public GetConstructor1(java.lang.String)") + && constructor2.toString().equals("public GetConstructor1()") + && constructor3.toString().equals("public GetConstructor1(java.lang.String,int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/expected.txt b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/maple.prof b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4612f79292d7ea26c43d14e8c11b7357ef366140 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/test.cfg b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e78181523fee681686685e50b337def7df9854aa --- /dev/null +++ b/testsuite/java_test/compact_test/RT0001-rt-compact-ReflectingetConstructor1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructor1) +run(ReflectingGetConstructor1) diff --git a/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/ReflectingGetConstructor2.java b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/ReflectingGetConstructor2.java new file mode 100755 index 0000000000000000000000000000000000000000..ce57a58609be63609721633a94c8dc1127a3ca5b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/ReflectingGetConstructor2.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructor2 { + public GetConstructor2() { + } + public GetConstructor2(String name) { + } + public GetConstructor2(String name, int number) { + } + GetConstructor2(int number) { + } +} +public class ReflectingGetConstructor2 { + public static void main(String[] args) { + try { + Class getConstructor21 = Class.forName("GetConstructor2"); + Constructor constructor1 = getConstructor21.getConstructor(int.class); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e) { + try { + Class getConstructor22 = Class.forName("GetConstructor2"); + Constructor constructor2 = getConstructor22.getConstructor(String.class, char.class, int.class); + System.out.println(2); + } catch (ClassNotFoundException ee) { + System.err.println(ee); + System.out.println(2); + } catch (NoSuchMethodException ee) { + System.out.println(0); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/expected.txt b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/maple.prof b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..72ea063b6c7afd7ffde71b93970d4c0d6d15a9ec Binary files /dev/null and b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/test.cfg b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..589142c7fb9dc4297d55cd00322db451975edd8e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0002-rt-compact-ReflectingetConstructor2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructor2) +run(ReflectingGetConstructor2) diff --git a/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/ReflectingGetConstructors.java b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/ReflectingGetConstructors.java new file mode 100755 index 0000000000000000000000000000000000000000..6e063cae22f458bcdeb5755f5f7e2a8f17dc151e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/ReflectingGetConstructors.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructors { + public GetConstructors() { + } + public GetConstructors(String name) { + } + public GetConstructors(String name, int number) { + } + GetConstructors(int number) { + } + GetConstructors(double id) { + } + public GetConstructors(double id, String name) { + } +} +class GetConstructors_a extends GetConstructors { + public GetConstructors_a() { + } + public GetConstructors_a(String name) { + } + public GetConstructors_a(String name, int number) { + } + GetConstructors_a(int number) { + } +} +public class ReflectingGetConstructors { + public static void main(String[] args) { + try { + Class getConstructors_a = Class.forName("GetConstructors_a"); + Constructor[] constructors = getConstructors_a.getConstructors(); + if (constructors.length == 3) { + for (int i = 0; i < constructors.length; i++) { + if (constructors[i].toString().indexOf("GetConstructors_a(int)") != -1) { + System.out.println(2); + } + } + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (ArrayIndexOutOfBoundsException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/expected.txt b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/maple.prof b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..9bf9d41056e64150ab6c43d18a3f956dc2689826 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/test.cfg b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0dc5a7c7dc38f9dc115882f03d7aa67bfeb91aac --- /dev/null +++ b/testsuite/java_test/compact_test/RT0003-rt-compact-ReflectingetConstructors/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructors) +run(ReflectingGetConstructors) diff --git a/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java new file mode 100755 index 0000000000000000000000000000000000000000..da947533320e533fca3a5b23c9530906994d7ebf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructor1 { + public GetDeclaredConstructor1() { + } + private GetDeclaredConstructor1(String name) { + } + protected GetDeclaredConstructor1(String name, int number) { + } + GetDeclaredConstructor1(int number) { + } +} +public class ReflectingGetDeclaredConstructor1 { + public static void main(String[] args) { + try { + Class getDeclaredConstructor1 = Class.forName("GetDeclaredConstructor1"); + Constructor constructor1 = getDeclaredConstructor1.getDeclaredConstructor(String.class); + Constructor constructor2 = getDeclaredConstructor1.getDeclaredConstructor(); + Constructor constructor3 = getDeclaredConstructor1.getDeclaredConstructor(String.class, int.class); + Constructor constructor4 = getDeclaredConstructor1.getDeclaredConstructor(int.class); + if (constructor1.toString().equals("private GetDeclaredConstructor1(java.lang.String)") + && constructor2.toString().equals("public GetDeclaredConstructor1()") + && constructor3.toString().equals("protected GetDeclaredConstructor1(java.lang.String,int)") + && constructor4.toString().equals("GetDeclaredConstructor1(int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/expected.txt b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/maple.prof b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..6447924aea62fef7dd8726ffd2c5ef4e541356d0 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/test.cfg b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..39d8ab0b1995690f410344eec43690149be8c6b4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0004-rt-compact-ReflectingetDeclaredConstructor1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructor1) +run(ReflectingGetDeclaredConstructor1) diff --git a/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java new file mode 100755 index 0000000000000000000000000000000000000000..7545445a44b97a5111513b9ed3595a4d03e66373 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructor2 { + public GetDeclaredConstructor2() { + } + private GetDeclaredConstructor2(String name) { + } + protected GetDeclaredConstructor2(String name, int number) { + } + GetDeclaredConstructor2(int number) { + } +} +public class ReflectingGetDeclaredConstructor2 { + public static void main(String[] args) { + try { + Class getDeclaredConstructor2 = Class.forName("GetDeclaredConstructor2"); + Constructor constructor = getDeclaredConstructor2.getDeclaredConstructor(String.class, char.class, int.class); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/expected.txt b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/maple.prof b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f18872c6311c1d512348968c60aa5f4588e7a74c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/test.cfg b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eb35ae24eed507013e995fa6d052f5d85f5261b8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0005-rt-compact-ReflectingetDeclaredConstructor2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructor2) +run(ReflectingGetDeclaredConstructor2) diff --git a/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java new file mode 100755 index 0000000000000000000000000000000000000000..e81e536fb84642ecb42b2040269755f83517fe05 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructors { + public GetDeclaredConstructors() { + } + private GetDeclaredConstructors(String name) { + } + protected GetDeclaredConstructors(String name, int number) { + } + GetDeclaredConstructors(int number) { + } +} +public class ReflectingGetDeclaredConstructors { + public static void main(String[] args) { + try { + Class getDeclaredConstructors = Class.forName("GetDeclaredConstructors"); + Constructor[] constructors = getDeclaredConstructors.getDeclaredConstructors(); + if (constructors.length == 4) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/expected.txt b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/maple.prof b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8f249fa42d13f42c5842afd565ef8e16e542df32 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/test.cfg b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..37a637c82ad4eb4d65181b7742dd2eb95d08b967 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0006-rt-compact-ReflectingetDeclaredConstructors/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructors) +run(ReflectingGetDeclaredConstructors) diff --git a/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/ReflectionAsSubclass1.java b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/ReflectionAsSubclass1.java new file mode 100755 index 0000000000000000000000000000000000000000..1ce216e7f483801d06e059ecf70a3a77eefb77ae --- /dev/null +++ b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/ReflectionAsSubclass1.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface A { +} +class A1 implements A { +} +class A2 extends A1 { +} +public class ReflectionAsSubclass1 { + public static void main(String[] args) { + try { + Class a2 = Class.forName("A1").asSubclass(A.class); + Class a1 = Class.forName("A2").asSubclass(A.class); + if (a2.newInstance() instanceof A) { + if (a1.newInstance() instanceof A) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.out.println(e1); + } catch (InstantiationException e2) { + System.out.println(e2); + } catch (IllegalAccessException e3) { + System.out.println(e3); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/expected.txt b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/maple.prof b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f523fa51ed819044613423a2ba7103c2874b60eb Binary files /dev/null and b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/test.cfg b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3190733f5121fb0be8aafa5fb483e876ad04beff --- /dev/null +++ b/testsuite/java_test/compact_test/RT0007-rt-compact-ReflectionasSubclass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass1) +run(ReflectionAsSubclass1) diff --git a/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/ReflectionAsSubclass2.java b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/ReflectionAsSubclass2.java new file mode 100755 index 0000000000000000000000000000000000000000..a9c7fab8e77d8e37ea99331959071efa5304566b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/ReflectionAsSubclass2.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class B { +} +class B_1 extends B { +} +public class ReflectionAsSubclass2 { + public static void main(String[] args) { + try { + Class.forName("B_1").asSubclass(B.class); + } catch (ClassCastException e) { + System.out.println(2); + } catch (ClassNotFoundException e) { + System.out.println(2); + } + System.out.println(0); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/expected.txt b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/maple.prof b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..de7b6e92c282a5146c08ee3979b003000b1457d9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/test.cfg b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7028ea169f87e4452e831d3c40276aac35ec2dc8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0008-rt-compact-ReflectionasSubclass2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass2) +run(ReflectionAsSubclass2) diff --git a/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/ReflectionAsSubclass3.java b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/ReflectionAsSubclass3.java new file mode 100755 index 0000000000000000000000000000000000000000..499c886e2cadc484f3c345c4807ccd875a8e7e0d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/ReflectionAsSubclass3.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface C { +} +class C_1 implements C { +} +class C_2 extends C_1 { +} +class D { +} +class D_1 extends D { +} +public class ReflectionAsSubclass3 { + public static void main(String[] args) { + try { + Class.forName("C_1").asSubclass(D.class); + } catch (ClassCastException e1) { + try { + Class.forName("C_2").asSubclass(D.class); + } catch (ClassCastException e2) { + try { + Class.forName("D_1").asSubclass(C.class); + } catch (ClassCastException e3) { + System.out.println(0); + } catch (ClassNotFoundException e4) { + System.out.println(2); + } + } catch (ClassNotFoundException e5) { + System.out.println(2); + } + } catch (ClassNotFoundException e6) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/expected.txt b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/maple.prof b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..054ad8e7fd39d1859e9965f47f034630abfc8e6b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/test.cfg b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a7f3e3c67cdd821a99dbe2976b275d1657b9e5cb --- /dev/null +++ b/testsuite/java_test/compact_test/RT0009-rt-compact-ReflectionasSubclass3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass3) +run(ReflectionAsSubclass3) diff --git a/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/ReflectionCast1.java b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/ReflectionCast1.java new file mode 100755 index 0000000000000000000000000000000000000000..c8c9a1dcb995f37895317be7803a468cb09b4dc0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/ReflectionCast1.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast1 { +} +class Cast1_a extends Cast1 { +} +public class ReflectionCast1 { + public static void main(String[] args) { + Cast1_a cast1_a = new Cast1_a(); + Cast1 cast1 = new Cast1(); + cast1 = Cast1.class.cast(cast1_a); + if (cast1.getClass().toString().equals("class Cast1_a")) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/expected.txt b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/maple.prof b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..9c4bd2fd1a81aed16d85fd478c43db9bc12e2010 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/test.cfg b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..034d26a26182f4b8ad9f28cae17730998f36271a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0010-rt-compact-Reflectioncast1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast1) +run(ReflectionCast1) diff --git a/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/ReflectionCast2.java b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/ReflectionCast2.java new file mode 100755 index 0000000000000000000000000000000000000000..0a5c13948b20fef7de74793a3aa0407fee72daf7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/ReflectionCast2.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast2 { +} +class Cast2_a extends Cast2 { +} +public class ReflectionCast2 { + public static void main(String[] args) { + Cast2_a cast2_a = new Cast2_a(); + Cast2 cast2 = new Cast2(); + try { + cast2_a = Cast2_a.class.cast(cast2); + } catch (ClassCastException e) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/expected.txt b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/maple.prof b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5420427eaef756263311612c9e60245dce5f4f66 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/test.cfg b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..85638f07cef5c0e7e447ab71d7e623fb396eb421 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0011-rt-compact-Reflectioncast2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast2) +run(ReflectionCast2) diff --git a/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/ReflectionCast3.java b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/ReflectionCast3.java new file mode 100755 index 0000000000000000000000000000000000000000..cb03e46e21c67605f2e71f59cb0b842b44437346 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/ReflectionCast3.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast3 { +} +class Cast3_a { +} +public class ReflectionCast3 { + public static void main(String[] args) { + Cast3_a cast3_a = new Cast3_a(); + Cast3 cast3 = new Cast3(); + try { + cast3_a = Cast3_a.class.cast(cast3); + } catch (ClassCastException e) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/expected.txt b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/maple.prof b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3faa10d6b519dbeeefdf11bc8a645bf54ab1500b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/test.cfg b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6ef93961c9e20d658f5e2878edf0d41b5128636f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0012-rt-compact-Reflectioncast3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast3) +run(ReflectionCast3) diff --git a/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/ReflectionCast4.java b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/ReflectionCast4.java new file mode 100755 index 0000000000000000000000000000000000000000..6eced584c14b614262d877f97cc035e47be88f42 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/ReflectionCast4.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast4 { +} +public class ReflectionCast4 { + public static void main(String[] args) { + Object object = null; + Cast4 cast4 = new Cast4(); + cast4 = Cast4.class.cast(object); + if (cast4 == null) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/expected.txt b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/maple.prof b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a464b6f8dbe707fff17b7a160fa0dbeb10c03032 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/test.cfg b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..089c34315ad92054d04f4c61c4a49dfd124af168 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0013-rt-compact-Reflectioncast4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast4) +run(ReflectionCast4) diff --git a/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java new file mode 100755 index 0000000000000000000000000000000000000000..73da000272effdae2fdc9b55cf0bb8873bf41922 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionDesiredAssertionStatus { + public static void main(String[] args) { + ReflectionDesiredAssertionStatus reflectionDesiredAssertionStatus = new ReflectionDesiredAssertionStatus(); + Class clazz = reflectionDesiredAssertionStatus.getClass(); + if (!clazz.desiredAssertionStatus()) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/expected.txt b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/maple.prof b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..02d7ff77d4dcd150b63e5855df82892a4d53a306 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/test.cfg b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3024136a06677336b5d02f91a3fec177365dec37 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0014-rt-compact-ReflectiondesiredAssertionStatus/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionDesiredAssertionStatus) +run(ReflectionDesiredAssertionStatus) diff --git a/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/ReflectionForName1.java b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/ReflectionForName1.java new file mode 100755 index 0000000000000000000000000000000000000000..cd8f9f5e3dd2cab1e8c0a3339b8f359af7914917 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/ReflectionForName1.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ForName1 { +} +public class ReflectionForName1 { + public static void main(String[] args) throws ClassNotFoundException { + Class clazz = Class.forName("ForName1"); + if (clazz.toString().equals("class ForName1")) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/expected.txt b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/maple.prof b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..15c26afbe540e27c971d8561f068ce3d99a0fc09 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/test.cfg b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..11c1b7e56224622ffba91540b41ae90e7cea14ec --- /dev/null +++ b/testsuite/java_test/compact_test/RT0015-rt-compact-ReflectionforName1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName1) +run(ReflectionForName1) diff --git a/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/ReflectionForName4.java b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/ReflectionForName4.java new file mode 100755 index 0000000000000000000000000000000000000000..124822946c4c7d403fac64cf306ea378671832a4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/ReflectionForName4.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ForName4 { + static { + } +} +class ForName4_a { + static { + } +} +public class ReflectionForName4 extends Thread { + public static void main(String[] args) { + try { + Class clazz = Class.forName("for*", true, ForName4_a.class.getClassLoader()); + } catch (ClassNotFoundException e) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/expected.txt b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/maple.prof b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a5610cef452b56e6ff0b11f27b7189b7e9f8374e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/test.cfg b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f80d81f34bc25f06b88175e11e5e268cc4f4689 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0016-rt-compact-ReflectionforName4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName4) +run(ReflectionForName4) diff --git a/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/ReflectionForName5.java b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/ReflectionForName5.java new file mode 100755 index 0000000000000000000000000000000000000000..30bb2fc5336dfbd82a376b86bcd57a2322c7494d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/ReflectionForName5.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface ForName55_c { +} +class ForName55_b implements ForName55_c { +} +class ForName55_a extends ForName55_b { +} +class ForName55 extends ForName55_a { +} +class ForName5_e { +} +class ForName5_d extends ForName5_e { +} +class ForName5_c extends ForName5_d { +} +class ForName5_b extends ForName5_c { +} +class ForName5_a extends ForName5_b { +} +class ForName5 extends ForName5_a { +} +public class ReflectionForName5 { + public static void main(String[] args) throws ClassNotFoundException { + Class clazz = Class.forName("ForName5"); + if (clazz.toString().equals("class ForName5")) { + Class clazz2 = Class.forName("ForName55"); + if (clazz2.toString().equals("class ForName55")) { + System.out.println(0); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/expected.txt b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/maple.prof b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cd38a79b514f768c30f7223f15234c903a4ef887 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/test.cfg b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0fad02aa1edc519d8a7c985e631de97d2d747618 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0017-rt-compact-ReflectionforName5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName5) +run(ReflectionForName5) diff --git a/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..62a6f3e8f42b430cdb5e7f78e229f405492fe985 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz1 { +int i() default 0; +String t() default ""; +} +@Zzz1(i = 333, t = "getAnnotation") +class GetAnnotation1_a { +} +class GetAnnotation1_b { +} +public class ReflectionGetAnnotation1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetAnnotation1_a"); + Class clazz2 = Class.forName("GetAnnotation1_b"); + if (clazz1.getAnnotation(Zzz1.class).toString().indexOf("t=getAnnotation") != -1 + && clazz1.getAnnotation(Zzz1.class).toString().indexOf("i=333") != -1 + && clazz2.getAnnotation(Zzz1.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/expected.txt b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/maple.prof b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3dc54069082d9792db16614895577ac3aef44728 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/test.cfg b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..97f14563a4ff4981b724676736bc50ab2f68230a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0018-rt-compact-ReflectiongetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation1) +run(ReflectionGetAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..0a76bdd67d65025399add05cf1bef062286b08dd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +class GetAnnotation2_a { + @IF2(i = 333, t = "getAnnotation") + public int i_a; + public String t_a; +} +class GetAnnotation2_b { + public int i_b; + public String t_b; +} +public class ReflectionGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls1 = Class.forName("GetAnnotation2_a"); + Class cls2 = Class.forName("GetAnnotation2_b"); + Field instance1 = cls1.getField("i_a"); + Field instance2 = cls1.getField("t_a"); + Field instance3 = cls2.getField("i_b"); + if (instance1.getAnnotation(IF2.class).i() == 333 && instance1.getAnnotation(IF2.class). + t().equals("getAnnotation") && instance2.getAnnotation(IF2.class) == null && + instance3.getAnnotation(IF2.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/expected.txt b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/maple.prof b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cd013302038cc0344c7db0b7262cc888f85c8821 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/test.cfg b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d04c630e90e4c4f11bf0d71d5335ef98832c9a2e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0019-rt-compact-ReflectiongetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation2) +run(ReflectionGetAnnotation2) diff --git a/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java new file mode 100755 index 0000000000000000000000000000000000000000..3bf294fd0d7456eccb20861bd2c011065ba845d9 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz3 { + int i() default 0; + String t() default ""; +} +class GetAnnotation3_a { + @Zzz3(i = 333, t = "getAnnotation") + public void qqq() { + }; + public void rrr() { + }; +} +class GetAnnotation3_b { + public void www() { + }; +} +public class ReflectionGetAnnotation3 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation3_a"); + Method zhu1 = zqp1.getMethod("qqq"); + Method zhu2 = zqp1.getMethod("rrr"); + zhu1.getAnnotation(Zzz3.class).t(); + zhu2.getAnnotation(Zzz3.class).i(); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + try { + Class zqp2 = Class.forName("GetAnnotation3_b"); + Method zhu3 = zqp2.getMethod("www"); + zhu3.getAnnotation(Zzz3.class).i(); + System.out.println(2); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + System.out.println(2); + } catch (NoSuchMethodException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NullPointerException e5){ + System.out.println(0); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/expected.txt b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/maple.prof b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..62128a5aafb047e536bf5feac2d199d784b95dc7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/test.cfg b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9e294b580cbfe68aeb7e7ad3df28b05b5bdc166 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0020-rt-compact-ReflectiongetAnnotation3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation3) +run(ReflectionGetAnnotation3) diff --git a/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java new file mode 100755 index 0000000000000000000000000000000000000000..d1115f2633c22f41dfaa6dfc1651a0fcb0bb54cd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz4 { + int i() default 0; + String t() default ""; +} +@interface Zzz4_a { +int ii() default 0; +String tt() default ""; +} +class GetAnnotation4_a { + @Zzz4(i = 333, t = "getAnnotation") + public void qqq() { + }; + @Zzz4_a(ii = 555, tt = "test") + public void rrr() { + }; +} +public class ReflectionGetAnnotation4 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation4_a"); + Method zhu1 = zqp1.getMethod("qqq"); + Method zhu2 = zqp1.getMethod("rrr"); + if (zhu1.getAnnotation(Zzz4_a.class) == null && zhu2.getAnnotation(Zzz4.class) == null) { + zhu1.getAnnotation(Zzz4_a.class).ii(); + System.out.println(2); + } + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/expected.txt b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/maple.prof b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7ef50e69467a56c33c768029e0bca5cb2da375f4 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/test.cfg b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8c874d0f7c02b9b785d3ffae813365eaea583143 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0021-rt-compact-ReflectiongetAnnotation4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation4) +run(ReflectionGetAnnotation4) diff --git a/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java new file mode 100755 index 0000000000000000000000000000000000000000..46a8164fecde1d499fea9e1291b8dafee8f6e9e9 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz5 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz5_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzz5(i = 333, t = "test1") +class GetAnnotation5 { + public int i; + public String t; +} +@Zzz5_a(i_a = 666, t_a = "right1") +class GetAnnotation5_a extends GetAnnotation5 { + public int i_a; + public String t_a; +} +class GetAnnotation5_b extends GetAnnotation5_a { +} +public class ReflectionGetAnnotation5 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation5_b"); + if (zqp1.getAnnotation(Zzz5.class).toString().indexOf("t=test1") != -1 && zqp1.getAnnotation(Zzz5.class). + toString().indexOf("i=333") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/expected.txt b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/maple.prof b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..53c1bd10131e9fd176f5230cc8585dbccfd3aed2 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/test.cfg b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..577377a7252228975396fdadaf6a74d5488d7a5d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0022-rt-compact-ReflectiongetAnnotation5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation5) +run(ReflectionGetAnnotation5) diff --git a/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java new file mode 100755 index 0000000000000000000000000000000000000000..810b4e4a268d400bdb4895f625d5cd315483dfbd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz6 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz6_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzz6(i = 333, t = "test1") +class GetAnnotation6 { + public int i; + public String t; + @Zzz6_a(i_a = 666, t_a = "right1") + public static class GetAnnotation6_a { + public int j; + } +} +public class ReflectionGetAnnotation6 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation6"); + Class[] zhu1 = zqp1.getDeclaredClasses(); + if (zhu1[0].getAnnotation(Zzz6_a.class).toString().indexOf("t_a=right1") != -1 && zhu1[0]. + getAnnotation(Zzz6_a.class).toString().indexOf("i_a=666") != -1) { + if (zhu1[0].getAnnotation(Zzz6.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/expected.txt b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/maple.prof b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ca557fb09c1adfdff701411a401fbe20a12eb4df Binary files /dev/null and b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/test.cfg b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c585f054466737dae1c4a74b45c109d539d38e44 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0023-rt-compact-ReflectiongetAnnotation6/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation6) +run(ReflectionGetAnnotation6) diff --git a/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java new file mode 100755 index 0000000000000000000000000000000000000000..82e1cba5eabad10d4a53249df54ad9ee6110cc54 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +class GetAnnotation7 { + @Deprecated + public int aa(int num) { + return 0; + } +} +class GetAnnotation7_a extends GetAnnotation7 { + @Override + public int aa(int num) { + return 2; + } +} +public class ReflectionGetAnnotation7 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation7_a"); + Method zhu1 = zqp1.getMethod("aa", int.class); + Annotation[] j = zhu1.getAnnotations(); + if (j.length == 0) { + try { + Class zqp2 = Class.forName("GetAnnotation7"); + Method zhu2 = zqp2.getMethod("aa", int.class); + if (zhu2.getAnnotation(Deprecated.class).toString().indexOf("Deprecated") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/expected.txt b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/maple.prof b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8eb1d6934fd8bdf1c455b62fdb4bc2934fd49648 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/test.cfg b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..17d3edcb5e2ebe6fd5a04cf9c1a49abf97959b66 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0024-rt-compact-ReflectiongetAnnotation7/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation7) +run(ReflectionGetAnnotation7) diff --git a/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..ef8640cca4f5b79bb9f63d94cfe6c99c131bbc48 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz1 { + int i() default 0; + String t() default ""; +} +@interface Zzzz1_a { +} +@interface Zzzz1_b { +} +class GetAnnotationsByType1_a { + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_a; + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_aa; + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_aaa; + public String t_a; + @Zzzz1_a + public String t_aa; + @Zzzz1_b + public String t_aaa; +} +public class ReflectionGetAnnotationsByType1 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType1_a"); + Field zhu1 = zqp1.getField("i_a"); + Field zhu2 = zqp1.getField("t_a"); + if (zqp1.getAnnotationsByType(Zzzz1.class).length == 0) { + if (zhu2.getAnnotationsByType(Zzzz1_a.class).length == 0) { + Annotation[] k = zhu1.getAnnotationsByType(Zzzz1.class); + if (k[0].toString().indexOf("t=GetAnnotationsByType") != -1 && k[0].toString().indexOf("i=333") + != -1) { + System.out.println(0); + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/expected.txt b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/maple.prof b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3e706dc6ec666d0bd978984f533291082cdd796c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/test.cfg b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1f5a8bb5c15419f349fb590f058e328897a7bfd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0025-rt-compact-ReflectiongetAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType1) +run(ReflectionGetAnnotationsByType1) diff --git a/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java new file mode 100755 index 0000000000000000000000000000000000000000..d534366640e81c6e0b37d2a5e0b5fa4645bc4906 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz2 { + int i() default 0; + String t() default ""; +} +class GetAnnotationsByType2_a { + @Zzzz2(i = 333, t = "GetAnnotationsByType") + public int i_a; + public String t_a; +} +class GetAnnotationsByType2_b { + public int i_b; + public String t_b; +} +public class ReflectionGetAnnotationsByType2 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType2_a"); + Field zhu1 = zqp1.getField("t_a"); + Annotation[] j = zhu1.getAnnotationsByType(null); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + try { + Class zqp2 = Class.forName("GetAnnotationsByType2_b"); + Field zhu2 = zqp2.getField("i_b"); + Annotation[] k = zhu2.getAnnotationsByType(null); + System.out.println(2); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + System.out.println(2); + } catch (NoSuchFieldException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NullPointerException e5) { + System.out.println(0); + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/expected.txt b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/maple.prof b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c5fc5d1aefba966b506e49af001597a9dac92e3f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/test.cfg b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..919ce3fc129d389228b8c4e1e6d3bdd2bd92c7d4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0026-rt-compact-ReflectiongetAnnotationsByType2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType2) +run(ReflectionGetAnnotationsByType2) diff --git a/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java new file mode 100755 index 0000000000000000000000000000000000000000..72e09dda2465a3284f78f6f699b1cfba18a9ece3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz3 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz3_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzzz3(i = 333, t = "test1") +class GetAnnotationsByType3 { + public int i; + public String t; +} +@Zzzz3_a(i_a = 666, t_a = "right1") +class GetAnnotationsByType3_a extends GetAnnotationsByType3 { + public int i_a; + public String t_a; +} +class GetAnnotationsByType3_b extends GetAnnotationsByType3_a { +} +public class ReflectionGetAnnotationsByType3 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType3_b"); + Annotation[] j = zqp1.getAnnotationsByType(Zzzz3.class); + if (j[0].toString().indexOf("t=test1") != -1 && j[0].toString().indexOf("i=333") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/expected.txt b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/maple.prof b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7d4d043608b922002515c2cc27b1993a9dbfca0c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/test.cfg b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5037e188e2880b6b55813e9476a9022996751290 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0027-rt-compact-ReflectiongetAnnotationsByType3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType3) +run(ReflectionGetAnnotationsByType3) diff --git a/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java new file mode 100755 index 0000000000000000000000000000000000000000..3878c6a85d65ca8b73ee074b7e35bdc36d4a1b85 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetCanonicalNameTest { +} +public class ReflectionGetCanonicalName { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetCanonicalNameTest"); + if (zqp.getCanonicalName().equals("GetCanonicalNameTest")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/expected.txt b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/maple.prof b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..0477cf9c4717809f8eaf32cdace2db3e696d74ea Binary files /dev/null and b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/test.cfg b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d9d6b51144684385a0738614b4f4fbe5b60fdba --- /dev/null +++ b/testsuite/java_test/compact_test/RT0028-rt-compact-ReflectiongetCanonicalName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetCanonicalName) +run(ReflectionGetCanonicalName) diff --git a/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/ReflectionGetComponentType.java b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/ReflectionGetComponentType.java new file mode 100755 index 0000000000000000000000000000000000000000..5da606df77a3ff3a363b658976217f9f052b8d03 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/ReflectionGetComponentType.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionGetComponentType { + public static void main(String[] args) { + if (char.class.getComponentType() == null && String[].class.getComponentType().toString(). + equals("class java.lang.String") && int[].class.getComponentType().toString().equals("int")) { + System.out.println(0); + }else{ + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/expected.txt b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/maple.prof b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..36654133782c4608216f204feb75aa2e2c5472a6 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/test.cfg b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..abfd96af7079ca17ed9937a595b4d57b92d98967 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0029-rt-compact-ReflectiongetComponentType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetComponentType) +run(ReflectionGetComponentType) diff --git a/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..24bd4a63a8b138a0bd72783b9802ba22ccdaa955 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd1_a { + int i_a() default 2; + String t_a() default ""; +} +@Ddd1(i = 333, t = "test1") +class GetDeclaredAnnotations1 { + public int i; + public String t; +} +@Ddd1_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotations1_a extends GetDeclaredAnnotations1 { + public int i_a; + public String t_a; +} +public class ReflectionGetDeclaredAnnotations1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotations1_a"); + if (zqp1.getDeclaredAnnotations().length == 1) { + Annotation[] j = zqp1.getDeclaredAnnotations(); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + result = 0; + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4a5863e672c91d69286335102ebe0041c1b42464 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b14075f4b5caa6b487c2feb3be2519afbb70c69c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0030-rt-compact-ReflectiongetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotations1) +run(ReflectionGetDeclaredAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..7e67d42f9bad470921331f34b74512c7875ae129 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd2_a { + int i_a() default 2; + String t_a() default ""; +} +@Ddd2(i = 333, t = "test1") +class GetDeclaredAnnotations2 { + public int i; + public String t; +} +@Ddd2_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotations2_a extends GetDeclaredAnnotations2 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotations2_b extends GetDeclaredAnnotations2_a { +} +public class ReflectionGetDeclaredAnnotations2 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotations2_b"); + if (zqp1.getDeclaredAnnotations().length == 0) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/expected.txt b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/maple.prof b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..eafe35dfa89e5e6005f3beb8f4cef93cd5870c65 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/test.cfg b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f3dd5d9e78c93d2155517151f561ccbc15c8d5fd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0031-rt-compact-ReflectiongetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotations2) +run(ReflectionGetDeclaredAnnotations2) diff --git a/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..f7ee97cd5c7ad080f86209dcbdbd9832aa151c8a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd1_a { + int i_a() default 2; + String t_a() default ""; +} +@Dddd1(i = 333, t = "test1") +class GetDeclaredAnnotationsByType1 { + public int i; + public String t; +} +@Dddd1_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotationsByType1_a extends GetDeclaredAnnotationsByType1 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotationsByType1_b extends GetDeclaredAnnotationsByType1_a { +} +public class ReflectionGetDeclaredAnnotationsByType1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotationsByType1_b"); + Class zqp2 = Class.forName("GetDeclaredAnnotationsByType1_a"); + if (zqp1.getDeclaredAnnotationsByType(Dddd1.class).length == 0) { + Annotation[] j = zqp2.getDeclaredAnnotationsByType(Dddd1_a.class); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + result = 0; + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/expected.txt b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/maple.prof b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ae82812dfc8a5a83501f2b888d5f0a09a913e840 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/test.cfg b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..494c73cc3227fb64110a4baa90ca4db85496dad3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0032-rt-compact-ReflectiongetDeclaredAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotationsByType1) +run(ReflectionGetDeclaredAnnotationsByType1) diff --git a/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..209b49b7a64c215ab8b1a481f77d960a84c73a93 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd2_a { + int i_a() default 2; + String t_a() default ""; +} +@Dddd2(i = 333, t = "test1") +class GetDeclaredAnnotationsByType2 { + public int i; + public String t; +} +@Dddd2_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotationsByType2_a extends GetDeclaredAnnotationsByType2 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotationsByType2_b extends GetDeclaredAnnotationsByType2_a { +} +public class ReflectionGetDeclaredAnnotationsByTypeNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotationsByType2_b"); + Annotation[] j = zqp1.getDeclaredAnnotationsByType(null); + result = 0; + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + result = 0; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/maple.prof b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4e0c92a0c36e2c1884f641948b7ecfe63d3be968 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e797e0a7dce87f039355389610d222fae54cecab --- /dev/null +++ b/testsuite/java_test/compact_test/RT0033-rt-compact-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotationsByTypeNullPointerException) +run(ReflectionGetDeclaredAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java new file mode 100755 index 0000000000000000000000000000000000000000..d5511f15b728f76c124f3465f265b362a1a1ac53 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ReflectiongetDeclaredClasses_a { + public class getDeclaredClasses_a1 { + } + private class getDeclaredClasses_a2 { + } + protected class getDeclaredClasses_a3 { + } +} +public class ReflectionGetDeclaredClasses extends ReflectiongetDeclaredClasses_a { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ReflectionGetDeclaredClasses"); + Class[] j = zqp.getDeclaredClasses(); + if (j.length == 3) { + for (int i = 0; i < j.length; i++) { + if (j[i].getName().indexOf("getDeclaredClasses_a") != -1) { + result = -1; + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } + System.out.println(result); + } + public class getDeclaredClassestest1 { + } + private class getDeclaredClassestest2 { + } + protected class getDeclaredClassestest3 { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/expected.txt b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/maple.prof b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a7fb4f084db9c4c3f0f4e0d85a89c22358a88e17 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/test.cfg b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..45d87ff524cabd44f63a7873b84645323b152598 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0034-rt-compact-ReflectiongetDeclaredClasses/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredClasses) +run(ReflectionGetDeclaredClasses) diff --git a/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java new file mode 100755 index 0000000000000000000000000000000000000000..d79e0b0cbe601e8d50d327b18ef2fd2a2d1befd6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredField1 { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +public class ReflectionGetDeclaredField1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetDeclaredField1"); + Field zhu1 = zqp.getDeclaredField("i"); + Field zhu2 = zqp.getDeclaredField("s"); + Field zhu3 = zqp.getDeclaredField("d"); + Field zhu4 = zqp.getDeclaredField("f"); + if (zhu1.getName().equals("i") && zhu2.getName().equals("s") && zhu3.getName().equals("d") && + zhu4.getName().equals("f")) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NoSuchFieldException e2) { + System.err.println(e2); + result = -1; + } catch (NullPointerException e3) { + System.err.println(e3); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/expected.txt b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/maple.prof b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..14a6a3fba2fc33591b65da325706499f7a18c0ec Binary files /dev/null and b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/test.cfg b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7fa639743885b0365442e53eedd5c6bcc4303ef5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0035-rt-compact-ReflectiongetDeclaredField1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredField1) +run(ReflectionGetDeclaredField1) diff --git a/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..e73b2081748c744a38822b1308a8984373937782 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredField2_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredField2 extends GetDeclaredField2_a { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +public class ReflectionGetDeclaredFieldNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetDeclaredField2"); + Field zhu1 = zqp.getDeclaredField("i_a"); + result = -1; + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } catch (NoSuchFieldException e3) { + try { + Class zqp = Class.forName("GetDeclaredField2"); + Field zhu1 = zqp.getDeclaredField(null); + result = -1; + } catch (ClassNotFoundException e4) { + System.err.println(e4); + result = -1; + } catch (NoSuchFieldException e5) { + System.err.println(e5); + result = -1; + } catch (NullPointerException e6) { + result = 0; + } + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/expected.txt b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/maple.prof b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3b3dd1ac09fbec894e8a3cea682695c1132c49e4 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/test.cfg b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..456364c6e3d5f150d0a8e47b7e68d348f2a04d2b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0036-rt-compact-ReflectionGetDeclaredFieldNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFieldNullPointerException) +run(ReflectionGetDeclaredFieldNullPointerException) diff --git a/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java new file mode 100755 index 0000000000000000000000000000000000000000..4a2597c3cdb4ca9f2fffb3e46c7f0ea5d67e2ce3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredFields1_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredFields1 extends GetDeclaredFields1_a { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +interface GetDeclaredFields1_b { + public int i_b = 2; + String s_b = "ccc"; +} +public class ReflectionGetDeclaredFields1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredFields1"); + Class zqp2 = Class.forName("GetDeclaredFields1_b"); + Field[] j = zqp1.getDeclaredFields(); + Field[] k = zqp2.getDeclaredFields(); + if (j.length == 4 && k.length == 2) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/expected.txt b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/maple.prof b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fdf18a38498e2274eb0b09045e796eb480a61f15 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/test.cfg b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7aebf1cf72d5b66e48c831042b1507b7a5d844ba --- /dev/null +++ b/testsuite/java_test/compact_test/RT0037-rt-compact-ReflectiongetDeclaredFields1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFields1) +run(ReflectionGetDeclaredFields1) diff --git a/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java new file mode 100755 index 0000000000000000000000000000000000000000..974e9279941c73844398efcd657865fbb34df029 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredFields_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredFields extends GetDeclaredFields_a { +} +enum GetDeclaredFields_b { + i_b, s_b, f_b +} +public class ReflectionGetDeclaredFields { + public static void main(String[] args) { + int result = 0; + try { + Class zqp1 = Class.forName("GetDeclaredFields"); + Class zqp2 = Class.forName("GetDeclaredFields_b"); + Field[] j = zqp1.getDeclaredFields(); + Field[] k = zqp2.getDeclaredFields(); + if (j.length == 0 && k.length == 4) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/expected.txt b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/maple.prof b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7a4ce3710f2ecc4f29f9439d3c98487c02da6b88 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/test.cfg b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cf5722ba04e0283473639f9a82f36e4c7ce2e663 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0038-rt-compact-ReflectiongetDeclaredFields2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFields) +run(ReflectionGetDeclaredFields) diff --git a/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java new file mode 100755 index 0000000000000000000000000000000000000000..dc49bcf36a4cdfeaedbbc053361f36f286d2331b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethod1 { + public void empty1() { + } + void empty2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void empty1(int number) { + } + int getZero(String name) { + return 2; + } +} +public class ReflectionGetDeclaredMethod1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethod1"); + Method method1 = clazz.getDeclaredMethod("empty1", int.class); + Method method2 = clazz.getDeclaredMethod("getDd"); + Method method3 = clazz.getDeclaredMethod("empty1"); + Method method4 = clazz.getDeclaredMethod("empty2"); + Method method5 = clazz.getDeclaredMethod("getZero"); + Method method6 = clazz.getDeclaredMethod("getZero", String.class); + if (method1.toString().equals("public void GetDeclaredMethod1.empty1(int)") + && method2.toString().equals("private java.lang.String GetDeclaredMethod1.getDd()") + && method3.toString().equals("public void GetDeclaredMethod1.empty1()") + && method4.toString().equals("void GetDeclaredMethod1.empty2()") + && method5.toString().equals("int GetDeclaredMethod1.getZero()") + && method6.toString().equals("int GetDeclaredMethod1.getZero(java.lang.String)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/expected.txt b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/maple.prof b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..63f79a286941dc03785b6117ca573c0aa930d3f8 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/test.cfg b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b2502837ef9ddd003e0cb64b41b9ff3e07c77fd3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0039-rt-compact-ReflectiongetDeclaredMethod1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod1) +run(ReflectionGetDeclaredMethod1) diff --git a/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java new file mode 100755 index 0000000000000000000000000000000000000000..d8be6287d3568dcb7234a25d08f1db37bb555c49 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethod2_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethod2 extends GetDeclaredMethod2_a { + public void void1() { + } + void void2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void setNumber(int number) { + } + int setName(String name) { + return 2; + } +} +public class ReflectionGetDeclaredMethod2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetDeclaredMethod2"); + Method method1 = clazz1.getDeclaredMethod("empty1"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + try { + Class clazz2 = Class.forName("GetDeclaredMethod2"); + Method method2 = clazz2.getDeclaredMethod(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchMethodException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/expected.txt b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/maple.prof b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..bb3ff4a53fd614bc7fa458dbc3b3f5db46fca83f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/test.cfg b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..94b2ec7c0193d8a648c215fa1d21fee87c8eed26 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0040-rt-compact-ReflectiongetDeclaredMethod2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod2) +run(ReflectionGetDeclaredMethod2) diff --git a/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java new file mode 100755 index 0000000000000000000000000000000000000000..9762c1c34f796fa7cb4ddae3c8af8b2ddc9bd1ff --- /dev/null +++ b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +abstract class GetDeclaredMethod3 { + abstract void empty1(); + abstract public int empty2(); +} +public class ReflectionGetDeclaredMethod3 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethod3"); + Method method1 = clazz.getDeclaredMethod("empty1"); + Method method2 = clazz.getMethod("empty2"); + if (method1.toString().equals("abstract void GetDeclaredMethod3.empty1()") + && method2.toString().equals("public abstract int GetDeclaredMethod3.empty2()")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/expected.txt b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/maple.prof b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..d41107a4c1cf9d78dabb51e5f9aba3d1f09bd91d Binary files /dev/null and b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/test.cfg b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5ea743940941993986756e6761a6984e23aa2533 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0041-rt-compact-ReflectiongetDeclaredMethod3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod3) +run(ReflectionGetDeclaredMethod3) diff --git a/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java new file mode 100755 index 0000000000000000000000000000000000000000..d367eb2f3c7615d86314f03a875fd21a31b2db93 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethods1_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethods1 extends GetDeclaredMethods1_a { + public void void1() { + } + void void2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void setNumber(int number) { + } + int setName(String name) { + return 2; + } +} +interface GetDeclaredMethods1_b { + public default void test1() { + } + default void test2() { + } +} +public class ReflectionGetDeclaredMethods1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetDeclaredMethods1"); + Class clazz2 = Class.forName("GetDeclaredMethods1_b"); + Method[] methods1 = clazz1.getDeclaredMethods(); + Method[] methods2 = clazz2.getDeclaredMethods(); + if (methods1.length == 6 && methods2.length == 2) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/expected.txt b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/maple.prof b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..582e2d9ee3bfe6da38602010a660ac0da783b0ee Binary files /dev/null and b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/test.cfg b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..93a9f3a34a2014c19f243a5869657b3f242d52ac --- /dev/null +++ b/testsuite/java_test/compact_test/RT0042-rt-compact-ReflectiongetDeclaredMethods1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethods1) +run(ReflectionGetDeclaredMethods1) diff --git a/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java new file mode 100755 index 0000000000000000000000000000000000000000..49b2cbf28dad446cdb555dac260d11d04c2fe661 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethods2_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethods2 extends GetDeclaredMethods2_a { +} +public class ReflectionGetDeclaredMethods2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethods2"); + Method[] method = clazz.getDeclaredMethods(); + if (method.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/expected.txt b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/maple.prof b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3b83dd67a34c1271440997f3089328ec2e3f11c6 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/test.cfg b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a989e717a854f36c333fe01d757add682a0f29f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0043-rt-compact-ReflectiongetDeclaredMethods2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethods2) +run(ReflectionGetDeclaredMethods2) diff --git a/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java new file mode 100755 index 0000000000000000000000000000000000000000..e483bd074bc7227410f5ae4001bf7e87d09b24f3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +class GetDeclaringClass { + public int num; + String str; + float fNum; + public GetDeclaringClass() { + } + GetDeclaringClass(int number) { + } + GetDeclaringClass(String name) { + } + GetDeclaringClass(int number, String name) { + } +} +class GetDeclaringClass_a { +} +public class ReflectionGetDeclaringClass { + public static void main(String[] args) { + try { + int num = 0; + Class clazz = Class.forName("GetDeclaringClass"); + Field[] fields = clazz.getDeclaredFields(); + Constructor[] constructors = clazz.getDeclaredConstructors(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].getDeclaringClass().getName().equals("GetDeclaringClass")) { + for (int j = 0; j < constructors.length; j++) { + if (constructors[j].getDeclaringClass().getName().equals("GetDeclaringClass")) { + Class clazz2 = Class.forName("GetDeclaringClass_a"); + if (clazz2.getDeclaringClass() == null) { + num++; + } + } + } + } + } + if (num == 12) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/expected.txt b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/maple.prof b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c677bfc6f555f1f15dbda77cb46cd1b3189b6420 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/test.cfg b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7fd6ced2648e46b38a92004e94caef561133f04b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0044-rt-compact-ReflectiongetDeclaringClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaringClass) +run(ReflectionGetDeclaringClass) diff --git a/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java new file mode 100755 index 0000000000000000000000000000000000000000..7d333556f3754ebaae06e5ee7c4b77e40a61da41 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionGetEnclosingClass1 { + public static void main(String[] args) { + Class clazz1 = (new GetEnclosingClassTest1()).test1().getClass(); + Class clazz2 = (new GetEnclosingClassTest1()).test2().getClass(); + if (clazz1.getEnclosingClass().getName().equals("ReflectionGetEnclosingClass1$GetEnclosingClassTest1") + && clazz2.getEnclosingClass().getName().equals("ReflectionGetEnclosingClass1$GetEnclosingClassTest1")) { + System.out.println(0); + } + } + public static class GetEnclosingClassTest1 { + public Object test1() { + class classA { + } + return new classA(); + } + Object test2() { + class classB { + } + return new classB(); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/expected.txt b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/maple.prof b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7f1f172700bdf2f2ae5d979823633fd8d1139acd Binary files /dev/null and b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/test.cfg b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bb34cbfdf0ef9c91116160f24581d5ff3171038b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0045-rt-compact-ReflectiongetEnclosingClass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnclosingClass1) +run(ReflectionGetEnclosingClass1) diff --git a/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java new file mode 100755 index 0000000000000000000000000000000000000000..1a2db0a6c4063de4a22ec2cbf3770ab488748fad --- /dev/null +++ b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetEnclosingClassTest2 { + public Object test1() { + class classA { + } + return new classA(); + } + Object test2() { + class classB { + } + return new classB(); + } +} +public class ReflectionGetEnclosingClass2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetEnclosingClassTest2"); + Class clazz2 = (new GetEnclosingClassTest2()).test2().getClass(); + if (clazz1.getEnclosingClass() == null + && clazz2.getEnclosingClass().getName().equals("GetEnclosingClassTest2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/expected.txt b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/maple.prof b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..bbf8c9bce3c8f9fc091755d7893cf4b2326b1dd0 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/test.cfg b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..877748ddb590e3034702e6501a118f0e22a1b32f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0046-rt-compact-ReflectiongetEnclosingClass2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnclosingClass2) +run(ReflectionGetEnclosingClass2) diff --git a/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java new file mode 100755 index 0000000000000000000000000000000000000000..7370ff82691b8b2e9cbfc91562ec1ad67adf3254 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +enum Weekday { + MONDAY { + Object test1() { + class classA { + } + return new classA(); + } + }, + TUESDAY { + Object test2() { + class classB { + } + return new classB(); + } + }, + WEDNESDAY { + Object test3() { + class classC { + } + return new classC(); + } + }, + THURSDAY { + Object test4() { + class classD { + } + return new classD(); + } + }, + FRIDAY { + Object test5() { + class classE { + } + return new classE(); + } + }, + SATURDAY { + Object test6() { + class classF { + } + return new classF(); + } + }, + SUNDAY { + Object test7() { + class classG { + } + return new classG(); + } + } +} +class GetEnumConstants { +} +public class ReflectionGetEnumConstants { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("Weekday"); + Class clazz2 = Class.forName("GetEnumConstants"); + Object[] objects1 = clazz1.getEnumConstants(); + Object[] objects2 = clazz2.getEnumConstants(); + if (objects1.length == 7) { + if (objects2 == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/expected.txt b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/maple.prof b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3366b41f63b00ec1213f219a2395cf13bcf13322 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/test.cfg b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9080ec9b239805e9061b72b3b3947a14e2770488 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0047-rt-compact-ReflectiongetEnumConstants/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnumConstants) +run(ReflectionGetEnumConstants) diff --git a/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/ReflectionGetField1.java b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/ReflectionGetField1.java new file mode 100755 index 0000000000000000000000000000000000000000..16a4e1644438fee3292e944e64cd97f26e59c6e0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/ReflectionGetField1.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetField1_a { + int num2 = 5; + public String str = "bbb"; +} +class GetField1 extends GetField1_a { + public int num = 1; + String string = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +public class ReflectionGetField1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetField1"); + Field field1 = clazz.getField("num"); + Field field2 = clazz.getField("str"); + if (field1.getName().equals("num") && field2.getName().equals("str")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/expected.txt b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/maple.prof b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f8ad2b084a49c2bb99383d619ca416efaf002e5b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/test.cfg b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3b9e427aed0bffe105dc9807ec1527b68896145b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0048-rt-compact-ReflectiongetField1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetField1) +run(ReflectionGetField1) diff --git a/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/ReflectionGetField2.java b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/ReflectionGetField2.java new file mode 100755 index 0000000000000000000000000000000000000000..5fdf07a82212aa2ae962fd667b25303f481791e2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/ReflectionGetField2.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetField2_a { + int num = 5; + public String str = "bbb"; +} +class GetField2 extends GetField2_a { + public int num = 1; + String str2 = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +public class ReflectionGetField2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetField2"); + Field field1 = clazz1.getField("str2"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + try { + Class clazz2 = Class.forName("GetField2"); + Field field2 = clazz2.getField(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchFieldException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/expected.txt b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/maple.prof b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..82cefe9e6ea38e288ee692295d923993848eceaf Binary files /dev/null and b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/test.cfg b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5a58ad12c58aafabc785a7bd0f68fe17c7429c3f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0049-rt-compact-ReflectiongetField2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetField2) +run(ReflectionGetField2) diff --git a/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/ReflectionGetFields.java b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/ReflectionGetFields.java new file mode 100755 index 0000000000000000000000000000000000000000..d87fc863cfbfff7b7e1005bd23223e3aa4fe54cd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/ReflectionGetFields.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetFields_a { + public int num = 5; + String str = "bbb"; +} +class GetFields extends GetFields_a { + public int num = 1; + String str = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +interface GetFields_b { + public int num = 2; + String str = "ccc"; +} +class GetFields_c { +} +public class ReflectionGetFields { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetFields"); + Class clazz2 = Class.forName("GetFields_b"); + Class clazz3 = Class.forName("GetFields_c"); + Field[] fields1 = clazz1.getFields(); + Field[] fields2 = clazz2.getFields(); + Field[] fields3 = clazz3.getFields(); + if (fields1.length == 2 && fields2.length == 2 && fields3.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/expected.txt b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/maple.prof b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..2069b3be4b7c02667f18af02f60d0863bf1334fd Binary files /dev/null and b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/test.cfg b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7b5ec262ddabf8f98214c275f6aacadd7cf21ab8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0050-rt-compact-ReflectiongetFields/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetFields) +run(ReflectionGetFields) diff --git a/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/ReflectionGetMethod1.java b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/ReflectionGetMethod1.java new file mode 100755 index 0000000000000000000000000000000000000000..37930216dcf8aa0590f63d40055214fe2bd57c07 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/ReflectionGetMethod1.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetMethod1_a { + public int setName(String name) { + return 10; + } + public String getStr() { + return "getDda"; + } +} +class GetMethod1 extends GetMethod1_a { + public void empty() { + } + void emptyB() { + } + int getNum() { + return 0; + } + private String getDd() { + return "getDd"; + } + public void empty(int number) { + } + int getNum(String name) { + return 2; + } +} +public class ReflectionGetMethod1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetMethod1"); + Method method1 = clazz.getMethod("empty"); + Method method2 = clazz.getMethod("empty", int.class); + Method method3 = clazz.getMethod("setName", String.class); + Method method4 = clazz.getMethod("getStr"); + if (method1.toString().equals("public void GetMethod1.empty()") + && method2.toString().equals("public void GetMethod1.empty(int)") + && method3.toString().equals("public int GetMethod1_a.setName(java.lang.String)") + && method4.toString().equals("public java.lang.String GetMethod1_a.getStr()")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/expected.txt b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/maple.prof b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8e563240fcda693b0b781e3197697968b29e0c64 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/test.cfg b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d65eb03f27915f644927faf9c0b4e7478480050 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0051-rt-compact-ReflectiongetMethod1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetMethod1) +run(ReflectionGetMethod1) diff --git a/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/ReflectionGetMethod2.java b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/ReflectionGetMethod2.java new file mode 100755 index 0000000000000000000000000000000000000000..869034cd4ec387c502fdb85b9bdc750a7bf00483 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/ReflectionGetMethod2.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetMethod2_a { + public int getName(String name) { + return 10; + } + public String getString() { + return "dda"; + } +} +class GetMethod2 extends GetMethod2_a { + public void getVoid() { + } + void empty() { + } + int getZero() { + return 0; + } + private String getStr() { + return "dd"; + } + public void setNum(int number) { + } + int getSecondNum(String name) { + return 2; + } +} +public class ReflectionGetMethod2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetMethod2"); + Method method1 = clazz1.getMethod("empty"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + // NoSuchMethodException is thrown when method not exist. + try { + Class clazz2 = Class.forName("GetMethod2"); + Method method2 = clazz2.getMethod(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchMethodException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + // Expected result: NullPointerException is thrown when method is null. + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/expected.txt b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/maple.prof b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..216df7fe3a2d1dddfe7bb497d0dea09c2048b576 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/test.cfg b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b516e0937280e94ae808668709eaf335e66edd9f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0052-rt-compact-ReflectiongetMethod2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetMethod2) +run(ReflectionGetMethod2) diff --git a/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/ReflectionGetSigners.java b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/ReflectionGetSigners.java new file mode 100755 index 0000000000000000000000000000000000000000..67f397c3c1e61d1ccb4b9a59cf4e3652103ad70b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/ReflectionGetSigners.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetSigners { +} +public class ReflectionGetSigners { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetSigners"); + Object[] objects = clazz.getSigners(); + if (objects == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/expected.txt b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/maple.prof b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..b78cbd88ed14c1e2600ee16a1bcd3cf838409afb Binary files /dev/null and b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/test.cfg b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8de86972a06dab4814c8757452be072351fd9461 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0053-rt-compact-ReflectiongetSigners/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetSigners) +run(ReflectionGetSigners) diff --git a/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/ReflectionGetSimpleName.java b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/ReflectionGetSimpleName.java new file mode 100755 index 0000000000000000000000000000000000000000..f3cab4f35f567237c0a3b8e4b7754c97d337e7db --- /dev/null +++ b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/ReflectionGetSimpleName.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetSimpleName { +} +public class ReflectionGetSimpleName { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetSimpleName"); + String string = clazz.getSimpleName(); + if (string.equals("GetSimpleName")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/expected.txt b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/maple.prof b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ee6f87bed03254968dec69ab0d1fbc36dbdfb2c2 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/test.cfg b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9c8074f5131573b9b7bc377560b7a6de36351c30 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0054-rt-compact-ReflectiongetSimpleName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetSimpleName) +run(ReflectionGetSimpleName) diff --git a/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..724c8c4c4d9492a33b449fcf9adb560f0adc831a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.TypeVariable; +class GetTypeParameters { +} +public class ReflectionGetTypeParameters { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetTypeParameters"); + TypeVariable[] typeParameters = clazz.getTypeParameters(); + if (typeParameters.length == 2 && typeParameters[0].getName().equals("s") + && typeParameters[1].getName().equals("T")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7ed49b978a42a81c95b399ea5ddc16c6fdf44375 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..858039960aaeb8b062feffae197e0e97548e4725 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0055-rt-compact-ReflectiongetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetTypeParameters) +run(ReflectionGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/ReflectionIsArray.java b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/ReflectionIsArray.java new file mode 100755 index 0000000000000000000000000000000000000000..167d9047c6fc4b0b352209ef961a5aa3a00f9cd3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/ReflectionIsArray.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class IsArray { + public int num; + String str; + float fNum; +} +public class ReflectionIsArray { + public static void main(String[] args) { + try { + Class clazz = Class.forName("IsArray"); + Field[] fields = clazz.getDeclaredFields(); + Class clazz1 = fields.getClass(); + if (clazz1.isArray()) { + if (!clazz.isArray()) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/expected.txt b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/maple.prof b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..dca8326dbf9335fc7e989919795a8ae8a9fa3c63 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/test.cfg b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ed00eadf4f7792e8b2cbe11c9edfc3a062c05cf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0056-rt-compact-ReflectionisArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsArray) +run(ReflectionIsArray) diff --git a/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java new file mode 100755 index 0000000000000000000000000000000000000000..f628c5e0035525d5ce84608e70f90e538cf08110 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class AssignableFrom1 { +} +class AssignableFrom1_a extends AssignableFrom1 { +} +interface AssignableFromTest1 { +} +interface AssignableFromTest1_a extends AssignableFromTest1 { +} +public class ReflectionIsAssignableFrom1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("AssignableFrom1"); + Class clazz2 = Class.forName("AssignableFrom1_a"); + Class clazz3 = Class.forName("AssignableFromTest1"); + Class clazz4 = Class.forName("AssignableFromTest1_a"); + if (clazz1.isAssignableFrom(clazz2) && !clazz2.isAssignableFrom(clazz1) && clazz3.isAssignableFrom(clazz4) + && !clazz4.isAssignableFrom(clazz3)) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/expected.txt b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/maple.prof b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..535eed8bf0d78bfb3a3d5331f990eabd7e55d9f6 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/test.cfg b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a375b936a63f051626b8d8d62903bf6473cd5faa --- /dev/null +++ b/testsuite/java_test/compact_test/RT0057-rt-compact-ReflectionisAssignableFrom1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsAssignableFrom1) +run(ReflectionIsAssignableFrom1) diff --git a/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..1bdbfaf35f523b87f5680184bd639cf8b6206e31 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class AssignableFromNullPointerException { +} +public class ReflectionIsAssignableFromNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("AssignableFromNullPointerException"); + zqp1.isAssignableFrom(null); + result = -1; + } catch (ClassNotFoundException e1) { + result = -1; + } catch (NullPointerException e2) { + result = 0; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/expected.txt b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/maple.prof b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..23b2691ee85c3e0a1aa944080459f47485a2ef5e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/test.cfg b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fe7d43920ddc4778b7d4d886a4ff13438cda3346 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0058-rt-compact-ReflectionisAssignableFrom2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsAssignableFromNullPointerException) +run(ReflectionIsAssignableFromNullPointerException) diff --git a/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/ReflectionIsLocalClass.java b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/ReflectionIsLocalClass.java new file mode 100755 index 0000000000000000000000000000000000000000..13eb67b9e6eaed210f6e6ffb95a7b0b67c8ed2b7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/ReflectionIsLocalClass.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsLocalClass { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + class isLocalClass { + } + try { + Class zqp1 = isLocalClass.class; + Class zqp2 = Class.forName("ReflectionIsLocalClass"); + Class zqp3 = IsLocalClass_a.class; + Class zqp4 = IsLocalClass_b.class; + Class zqp5 = (new isLocalClass() { + }).getClass(); + if (!zqp2.isLocalClass()) { + if (!zqp3.isLocalClass()) { + if (!zqp4.isLocalClass()) { + if (!zqp5.isLocalClass()) { + if (zqp1.isLocalClass()) { + result = 0; + } + } + } + } + } + } catch (ClassNotFoundException e) { + result = 2; + } + System.out.println(result); + } + class IsLocalClass_a { + } + static class IsLocalClass_b { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/expected.txt b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/maple.prof b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..41a6c01f1ca87136d1697eaecb76ede0d9524081 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/test.cfg b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eff558a3dc3eaa3a6dd782c9cea2d90e3eb41d44 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0059-rt-compact-ReflectionisLocalClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsLocalClass) +run(ReflectionIsLocalClass) diff --git a/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/ReflectionIsMemberClass.java b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/ReflectionIsMemberClass.java new file mode 100755 index 0000000000000000000000000000000000000000..5d6e4d624f8f22f2ff8573807824c4c5c1b80a91 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/ReflectionIsMemberClass.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsMemberClass { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + class IsMemberClass_a { + } + try { + Class zqp1 = IsMemberClass.class; + Class zqp2 = Class.forName("ReflectionIsMemberClass"); + Class zqp3 = IsMemberClass_a.class; + Class zqp4 = IsMemberClass_b.class; + Class zqp5 = (new IsMemberClass_b() { + }).getClass(); + if (!zqp2.isMemberClass()) { + if (!zqp3.isMemberClass()) { + if (zqp4.isMemberClass()) { + if (!zqp5.isMemberClass()) { + if (zqp1.isMemberClass()) { + result = 0; + } + } + } + } + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } + class IsMemberClass { + } + static class IsMemberClass_b { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/expected.txt b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/maple.prof b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..12809ece0268319ea295d25fa1fc6328bea249c9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/test.cfg b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1afa27d4577522e7b8895cec74b1ef84828bb16 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0060-rt-compact-ReflectionisMemberClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsMemberClass) +run(ReflectionIsMemberClass) diff --git a/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/ReflectionIsPrimitive.java b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/ReflectionIsPrimitive.java new file mode 100755 index 0000000000000000000000000000000000000000..32a86b762392dfbc44088059d98da13fd8322720 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/ReflectionIsPrimitive.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsPrimitive { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + Class zqp1 = ReflectionIsPrimitive.class; + Class zqp2 = int.class; + Class zqp3 = boolean.class; + Class zqp4 = byte.class; + Class zqp5 = char.class; + Class zqp6 = short.class; + Class zqp7 = long.class; + Class zqp8 = float.class; + Class zqp9 = double.class; + Class zqp10 = void.class; + if (!zqp1.isPrimitive() && zqp2.isPrimitive() && zqp3.isPrimitive() && zqp4.isPrimitive() && zqp5.isPrimitive() + && zqp6.isPrimitive() && zqp7.isPrimitive() && zqp8.isPrimitive() && zqp9.isPrimitive() && + zqp10.isPrimitive()) { + result = 0; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/expected.txt b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/maple.prof b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..aeb056928162bb28c944627eb6262a26232fb797 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/test.cfg b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5105cc43d0ef19063284645ed0920cbda2e5af99 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0061-rt-compact-ReflectionisPrimitive/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsPrimitive) +run(ReflectionIsPrimitive) diff --git a/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/ReflectionIsSynthetic.java b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/ReflectionIsSynthetic.java new file mode 100755 index 0000000000000000000000000000000000000000..fc4a7be61301a7de30a6371abf6fd3fff8453151 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/ReflectionIsSynthetic.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsSynthetic { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + new IsSynthetic(); + try { + Class zqp1 = IsSynthetic.class; + Class zqp2 = int.class; + Class zqp3 = Class.forName("ReflectionIsSynthetic$1"); + if (!zqp2.isSynthetic()) { + if (!zqp1.isSynthetic()) { + if (zqp3.isSynthetic()) { + result = 0; + } + } + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } + private static class IsSynthetic { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/expected.txt b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/maple.prof b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cdc6a5394f96cd4c6b7c513a06c76ba23289c4ef Binary files /dev/null and b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/test.cfg b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b5a9a7363439494f96c58a2bc946887c2adf24b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0062-rt-compact-ReflectionisSynthetic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsSynthetic) +run(ReflectionIsSynthetic) diff --git a/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/ReflectionNewInstance1.java b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/ReflectionNewInstance1.java new file mode 100755 index 0000000000000000000000000000000000000000..528af2f2ee885c7b7de826092f024be5ddfb6278 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/ReflectionNewInstance1.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class NewInstance1 { +} +public class ReflectionNewInstance1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("NewInstance1"); + Object zhu = zqp.newInstance(); + if (zhu.toString().indexOf("NewInstance1@") != -1) { + result = 0; + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (InstantiationException e1) { + System.err.println(e1); + result = -1; + } catch (IllegalAccessException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/expected.txt b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/maple.prof b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c2e4687ce6c44ce8bebc176022352ef814eaecc4 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/test.cfg b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2837ce4278673868101173fe54def9fdb99d89ab --- /dev/null +++ b/testsuite/java_test/compact_test/RT0063-rt-compact-ReflectionnewInstance1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionNewInstance1) +run(ReflectionNewInstance1) diff --git a/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java new file mode 100755 index 0000000000000000000000000000000000000000..e7e9c146866bd8cc17940aac9d63de6ac9e14bab --- /dev/null +++ b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface NewInstance2 { +} +class NewInstance2_a { + private NewInstance2_a() { + } +} +public class ReflectionNewInstanceInstantiationExceptionIllegalAccessException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("NewInstance2"); + Object zhu1 = zqp1.newInstance(); + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (InstantiationException e1) { + try { + Class zqp2 = Class.forName("NewInstance2_a"); + Object zhu2 = zqp2.newInstance(); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + result = -1; + } catch (InstantiationException e4) { + System.err.println(e4); + result = -1; + } catch (IllegalAccessException e5) { + result = 0; + } + } catch (IllegalAccessException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/expected.txt b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/maple.prof b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4b1e607df6243fd7eb05ff639567391f75dac585 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/test.cfg b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bdfe7d616118b97aa6f1d7bac0374acae51f2203 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0064-rt-compact-ReflectionnewInstance2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionNewInstanceInstantiationExceptionIllegalAccessException) +run(ReflectionNewInstanceInstantiationExceptionIllegalAccessException) diff --git a/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/ReflectionToGenericString.java b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/ReflectionToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..8e9ecfc96fa561ec6399a175eca76bfd6cfe83f4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/ReflectionToGenericString.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +@interface Eee { +} +@Eee +abstract class ToGenericString { +} +public class ReflectionToGenericString { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ToGenericString"); + String zhu = zqp.toGenericString(); + if (zhu.equals("abstract class ToGenericString")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/expected.txt b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/maple.prof b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5ef48df1f2a792ce27a625d5db727829ab499add Binary files /dev/null and b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/test.cfg b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dfa6a8fbf435aaf336128c5513878619be9edab7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0065-rt-compact-ReflectiontoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionToGenericString) +run(ReflectionToGenericString) diff --git a/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/ReflectionToString.java b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/ReflectionToString.java new file mode 100755 index 0000000000000000000000000000000000000000..2077f1c8950ddff27b592803c018d83cc6e1f4dc --- /dev/null +++ b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/ReflectionToString.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +@interface Fff { +} +@Fff +abstract class ToString_$ { +} +public class ReflectionToString { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ToString_$"); + String zhu = zqp.toString(); + if (zhu.equals("class ToString_$")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/expected.txt b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/maple.prof b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..1aa2a4719c7d88fed1ff777dcf1a005252146ee0 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/test.cfg b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c76e98d23b8c3d48209a6aa3003887bec4d29737 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0066-rt-compact-ReflectiontoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionToString) +run(ReflectionToString) diff --git a/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..3580eecc5fed26635b40686d1c6667c472f87f92 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Www1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Www1_a { + int c() default 0; + String d() default ""; +} +class ConstructorGetAnnotation1 { + @Www1(i = 333, t = "ConstructorgetAnnotation") + public ConstructorGetAnnotation1() { + } + public ConstructorGetAnnotation1(String name) { + } + @Www1_a(c = 666, d = "Constructor") + ConstructorGetAnnotation1(int number) { + } + ConstructorGetAnnotation1(String name, int number) { + } +} +public class RTConstructorGetAnnotation1 { + public static void main(String[] args) { + try { + Class zqp = Class.forName("ConstructorGetAnnotation1"); + Constructor zhu1 = zqp.getDeclaredConstructor(int.class); + Constructor zhu2 = zqp.getConstructor(); + Constructor zhu3 = zqp.getConstructor(String.class); + if ((zhu1.getAnnotation(Www1_a.class).toString().indexOf("c=666") != -1 && + zhu1.getAnnotation(Www1_a.class).toString().indexOf("d=Constructor") != -1 && + zhu2.getAnnotation(Www1.class).toString().indexOf("i=333") != -1 && + zhu2.getAnnotation(Www1.class).toString().indexOf("t=ConstructorgetAnnotation") != -1)) { + if (zhu3.getAnnotation(Www1.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/expected.txt b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/maple.prof b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8240ad65dc2a7cac3a678d0f253748213042dd16 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/test.cfg b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..614b1890fa3357090810e242b881aa9f0c5cb3ac --- /dev/null +++ b/testsuite/java_test/compact_test/RT0067-rt-compact-RTConstructorgetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetAnnotation1) +run(RTConstructorGetAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..18126ce2ed74ba8e368facb012be5ae48ddd337e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class ConstructorGetAnnotation2 { + @IF2(i = 333, t = "ConstructorGetAnnotation") + public ConstructorGetAnnotation2() { + } + @IF2_a(c = 666, d = "Constructor") + ConstructorGetAnnotation2(int number) { + } +} +class ConstructorGetAnnotation2_a { + ConstructorGetAnnotation2_a(String name, int number) { + } +} +public class RTConstructorGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetAnnotation2"); + Constructor instance1 = cls.getDeclaredConstructor(int.class); + Constructor instance2 = cls.getConstructor(); + if (instance1.getAnnotation(IF2.class) == null && instance2.getAnnotation(IF2_a.class) == null) { + instance1.getAnnotation(IF2.class).toString(); + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(1); + return; + } catch (NoSuchMethodException e2) { + System.out.println(1); + return; + } catch (NullPointerException e3) { + try { + Class cls = Class.forName("ConstructorGetAnnotation2_a"); + Constructor instance3 = cls.getDeclaredConstructor(String.class, int.class); + if (instance3.getAnnotation(IF2.class) == null && instance3.getAnnotation(IF2_a.class) == null) { + instance3.getAnnotation(IF2.class).toString(); + } + System.out.println(1); + return; + } catch (ClassNotFoundException e4) { + System.out.println(2); + return; + } catch (NoSuchMethodException e5) { + System.out.println(3); + return; + } catch (NullPointerException e6) { + System.out.println(0); + return; + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/expected.txt b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/maple.prof b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..585d2445d6471b98daa9abc8a9fc62b94fa0fc70 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/test.cfg b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..edde0d1d4578022b002a54334a879eb8a39ffdec --- /dev/null +++ b/testsuite/java_test/compact_test/RT0068-rt-compact-RTConstructorgetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetAnnotation2) +run(RTConstructorGetAnnotation2) diff --git a/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..5e985b15f35fc7cda0e3c448577990ec5495e4b3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int i_a() default 2; + String t_a() default ""; +} +class ConstructorGetDeclaredAnnotations1 { + public ConstructorGetDeclaredAnnotations1() { + } + @IF1(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations1(String name) { + } + @IF1(i = 333, t = "test1") + ConstructorGetDeclaredAnnotations1(int number) { + } +} +class ConstructorGetDeclaredAnnotations1_a extends ConstructorGetDeclaredAnnotations1 { + @IF1_a(i_a = 666, t_a = "right1") + @IF1(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations1_a(String name) { + } + @IF1_a(i_a = 666, t_a = "right1") + ConstructorGetDeclaredAnnotations1_a(int number) { + } +} +public class RTConstructorGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetDeclaredAnnotations1_a"); + Constructor instance1 = cls.getConstructor(String.class); + if (instance1.getDeclaredAnnotations().length == 2) { + Constructor instance2 = cls.getDeclaredConstructor(int.class); + if (instance2.getDeclaredAnnotations().length == 1) { + Annotation[] j = instance2.getDeclaredAnnotations(); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + System.out.println(0); + return; + } + } + System.out.println(1); + return; + } + System.out.println(2); + return; + } catch (ClassNotFoundException e) { + System.out.println(3); + return; + } catch (NoSuchMethodException e1) { + System.out.println(4); + return; + } catch (NullPointerException e2) { + System.out.println(5); + return; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f7478a072c7f85f4206ff67b3f85301ac353e4c9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b46882406cb70b15fd48440a93cd5e286e8ba956 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0069-rt-compact-RTConstructorgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetDeclaredAnnotations1) +run(RTConstructorGetDeclaredAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..d0d85fefc04351ac49a3b99e2130fc2426bf9a88 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int i_a() default 2; + String t_a() default ""; +} +class ConstructorGetDeclaredAnnotations2 { + public ConstructorGetDeclaredAnnotations2() { + } + @IF2(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations2(String name) { + } + @IF2(i = 333, t = "test1") + ConstructorGetDeclaredAnnotations2(int number) { + } +} +class ConstructorGetDeclaredAnnotations2_a extends ConstructorGetDeclaredAnnotations2 { + public ConstructorGetDeclaredAnnotations2_a(String name) { + } + ConstructorGetDeclaredAnnotations2_a(int number) { + } +} +public class RTConstructorGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetDeclaredAnnotations2_a"); + Constructor instance1 = cls.getConstructor(String.class); + Constructor instance2 = cls.getDeclaredConstructor(int.class); + if (instance1.getDeclaredAnnotations().length == 0 && instance2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } catch (NullPointerException e2) { + System.out.println(4); + return; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/maple.prof b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..62d86fd243bb9e27544d30edb7d5dbd85bcbfa96 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7f358e313b189f52b78f5b09a7853b2c9f3f7f2b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0070-rt-compact-RTConstructorgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetDeclaredAnnotations2) +run(RTConstructorGetDeclaredAnnotations2) diff --git a/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..57c41b0f023491e06d74d47e0eda9fb966cb39b9 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class ConstructorGetExceptionTypes { + ConstructorGetExceptionTypes() throws ExceptionInInitializerError, InstantiationException { + } +} +public class RTConstructorGetExceptionTypes { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetExceptionTypes"); + Constructor cons = cls.getDeclaredConstructor(); + Class[] exClass = cons.getExceptionTypes(); + if (exClass.length == 2) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(2); + return; + } catch (NoSuchMethodException e2) { + System.out.println(3); + return; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/expected.txt b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/maple.prof b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..82973935da1f9853f5f756cf048b11905af32c92 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/test.cfg b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e01023d88afa5491d431d729bab48ae506f76444 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0071-rt-compact-RTConstructorgetExceptionTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetExceptionTypes) +run(RTConstructorGetExceptionTypes) diff --git a/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..6b2e34ecf3186975641bcea0c6867f764ba43bb9 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +import java.lang.reflect.TypeVariable; +class ConstructorGetTypeParameters { + public ConstructorGetTypeParameters(int number) { + } + ConstructorGetTypeParameters() { + } +} +public class RTConstructorGetTypeParameters { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetTypeParameters"); + Constructor instance1 = cls.getConstructor(int.class); + Constructor instance2 = cls.getDeclaredConstructor(); + TypeVariable[] q1 = instance1.getTypeParameters(); + TypeVariable[] q2 = instance2.getTypeParameters(); + if (q1.length == 5 && q2.length == 0) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(2); + return; + } catch (NoSuchMethodException e2) { + System.out.println(3); + return; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ab55b85c4a309b8834d09a527854c728cd9af5d3 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..959b7b2a32cbb8d0816f8e79364f40ed1fffa506 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0072-rt-compact-RTConstructorgetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetTypeParameters) +run(RTConstructorGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/RTConstructorToGenericString1.java b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/RTConstructorToGenericString1.java new file mode 100755 index 0000000000000000000000000000000000000000..bb250a151730358c6bcf90fe51b8ff2268ee67d1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/RTConstructorToGenericString1.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class ConstructorToGenericString1 { + public ConstructorToGenericString1(int number) { + } +} +public class RTConstructorToGenericString1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorToGenericString1"); + Constructor instance1 = cls.getConstructor(int.class); + if (instance1.toGenericString().equals("public ConstructorToGenericString1(int)")) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e1) { + System.out.println(1); + return; + } catch (NoSuchMethodException e2) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/expected.txt b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/maple.prof b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..eca6b0e214429eac376e58ecec276e7a0327ae2c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/test.cfg b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8fe87cfb0453d4664244c4c216839a9606d74b07 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0073-rt-compact-RTConstructortoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorToGenericString1) +run(RTConstructorToGenericString1) diff --git a/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/RTFieldGet1.java b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/RTFieldGet1.java new file mode 100755 index 0000000000000000000000000000000000000000..9986a72d0b37ccacd85d6b65481effe6cd644be7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/RTFieldGet1.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet1_a { + public static String str = "aaa"; + public int num = 2; + public int num1 = 5; + public static boolean aBoolean = false; +} +class FieldGet1 extends FieldGet1_a { + public static String str = "bbb"; + public int number = 1; + public int test = super.num1 + 1; + public static boolean bBoolean = true; + public char aChar = '国'; +} +public class RTFieldGet1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet1"); + Object obj = cls.newInstance(); + Object q1 = cls.getField("str").get(obj); + Object q2 = cls.getField("number").get(obj); + Object q3 = cls.getField("test").get(obj); + Object q4 = cls.getField("bBoolean").get(obj); + Object q5 = cls.getField("aChar").get(obj); + Object q6 = cls.getField("num").get(obj); + Object q7 = cls.getField("aBoolean").get(null); + if (q1.toString().equals("bbb") && (int) q2 == 1 && (int) q3 == 6 && (boolean) q4 && q5.toString(). + equals("国") && (int) q6 == 2) { + Class cls1 = Class.forName("FieldGet1_a"); + Object instance1 = cls1.newInstance(); + Object q8 = cls1.getField("str").get(instance1); + if (q8.toString().equals("aaa")) { + if (!(boolean) q7) { + System.out.println(0); + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/expected.txt b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/maple.prof b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..20ed22c1926d355b971660a7dd5f78adaf8ba25b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/test.cfg b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b3d47ebb39ab743d2ad4a027f743f4b8f315cfae --- /dev/null +++ b/testsuite/java_test/compact_test/RT0074-rt-compact-RTFieldget1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet1) +run(RTFieldGet1) diff --git a/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/RTFieldGet2.java b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/RTFieldGet2.java new file mode 100755 index 0000000000000000000000000000000000000000..8ca4b1a64152cb161c09f0cf761941f8c6f82696 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/RTFieldGet2.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet2_a { + public int num; +} +class FieldGet2 extends FieldGet2_a { + private int number = 1; + public boolean aBoolean = true; + public int number1 = 8; +} +class FieldGet2_b { + public int number1 = 18; +} +public class RTFieldGet2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet2"); + Object obj = cls.newInstance(); + Object q1 = cls.getDeclaredField("number").get(obj); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + try { + Class cls = Class.forName("FieldGet2"); + Class cls1 = Class.forName("FieldGet2_b"); + Object instance1 = cls1.newInstance(); + Object q2 = cls.getDeclaredField("number1").get(instance1); + } catch (ClassNotFoundException e5) { + System.err.println(e5); + System.out.println(2); + } catch (InstantiationException e6) { + System.err.println(e6); + System.out.println(2); + } catch (NoSuchFieldException e7) { + System.err.println(e7); + System.out.println(2); + } catch (IllegalAccessException e8) { + System.err.println(e8); + System.out.println(2); + } catch (IllegalArgumentException e9) { + try { + Class cls = Class.forName("FieldGet2"); + Object q3 = cls.getDeclaredField("aBoolean").get(null); + } catch (ClassNotFoundException e10) { + System.err.println(e10); + System.out.println(2); + } catch (NoSuchFieldException e11) { + System.err.println(e11); + System.out.println(2); + } catch (IllegalAccessException e12) { + System.err.println(e12); + System.out.println(2); + } catch (NullPointerException e13) { + System.out.println(0); + } + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/expected.txt b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/maple.prof b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..651ab54fe4e8d4076afad6d38544afacb887e0b9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/test.cfg b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..51cc0ad256fd577fc24cfdc6a80215aaa5c5367d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0075-rt-compact-RTFieldget2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet2) +run(RTFieldGet2) diff --git a/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/RTFieldGet3.java b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/RTFieldGet3.java new file mode 100755 index 0000000000000000000000000000000000000000..c6e48ee1fbabf99ecd990329748effb16c3ee368 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/RTFieldGet3.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet3_a { + public int num; +} +class FieldGet3 extends FieldGet3_a { + public static String str; +} +public class RTFieldGet3 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet3"); + Object obj = cls.newInstance(); + Object obj1 = cls.getField("str").get(obj); + Object obj2 = cls.getField("num").get(obj); + if (obj1 == null && (int) obj2 == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/expected.txt b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/maple.prof b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c93544089afca2c37a068865dc3b81e2025905e7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/test.cfg b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6b617335cfddf3d0af440a0ec33c230e3f0d9241 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0076-rt-compact-RTFieldget3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet3) +run(RTFieldGet3) diff --git a/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/RTFieldGetAnnotation1.java b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/RTFieldGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..08617b324f7bd4dd592cf19b96c363998f23d48c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/RTFieldGetAnnotation1.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface4 { + int num() default 0; + String str() default ""; +} +@interface interface4_a { + int number() default 0; + String string() default ""; +} +class FieldGetAnnotation1 { + @interface4(num = 333, str = "GetAnnotation") + public int num1; + @interface4_a(number = 555, string = "test") + public String str1; +} +public class RTFieldGetAnnotation1 { + public static void main(String[] args) { + try { + Class cls1 = Class.forName("FieldGetAnnotation1"); + Field instance1 = cls1.getField("num1"); + Field instance2 = cls1.getField("str1"); + if (instance1.getAnnotation(interface4_a.class) == null && instance2.getAnnotation(interface4.class) == null) + { + instance1.getAnnotation(interface4_a.class).number(); + } + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..91a36170d74d89ebd6712d0f352260b00a51ab96 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..70955d8cc1511d67993ef3c4f55e90e60237189d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0077-rt-compact-RTFieldgetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetAnnotation1) +run(RTFieldGetAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..c837033e3e024041c2aeb98b463c73d4d43843f8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface1 { + int num() default 0; + String str() default ""; +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface1_a { + int num_a() default 2; + String str_a() default ""; +} +class FieldGetDeclaredAnnotations1 { + @interface1(num = 333, str = "test1") + public int num; + @interface1(num = 333, str = "test1") + public String str; +} +class FieldGetDeclaredAnnotations1_a extends FieldGetDeclaredAnnotations1 { + @interface1_a(num_a = 666, str_a = "right1") + public int num; + @interface1_a(num_a = 666, str_a = "right1") + public String str; +} +public class RTFieldGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaredAnnotations1_a"); + Field instance1 = cls.getField("num"); + if (instance1.getDeclaredAnnotations().length == 1) { + Annotation[] j = instance1.getDeclaredAnnotations(); + if (j[0].toString().indexOf("num_a=666") != -1 && j[0].toString().indexOf("str_a=right1") != -1) { + Field instance2 = cls.getDeclaredField("str"); + if (instance2.getDeclaredAnnotations().length == 1) { + Annotation[] k = instance2.getDeclaredAnnotations(); + if (k[0].toString().indexOf("num_a=666") != -1 && k[0].toString().indexOf("str_a=right1") != -1) + { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5a4b9e20520f68d232352278aee47894cd9b1e1c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b760c6fa451396a792949830bbe45a910bf7b1c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0078-rt-compact-RTFieldgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaredAnnotations1) +run(RTFieldGetDeclaredAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..69210be25f0c4e4e77676b1a20cf44fe98c0d70e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface2 { + int num() default 0; + String str() default ""; +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface2_a { + int i_a() default 2; + String t_a() default ""; +} +class FieldGetDeclaredAnnotations2 { + @interface2(num = 333, str = "test1") + public int num; + @interface2(num = 333, str = "test1") + public String str; +} +class FieldGetDeclaredAnnotations2_a extends FieldGetDeclaredAnnotations2 { + @interface2_a(i_a = 666, t_a = "right1") + public int num; + public String str; +} +public class RTFieldGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaredAnnotations2_a"); + Field instance1 = cls.getField("str"); + Field instance2 = cls.getDeclaredField("str"); + if (instance1.getDeclaredAnnotations().length == 0 && instance2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/maple.prof b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3823b46a14856a0c26881f675aa8bad1b76c4691 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..727e62ae23b675a7ab5a3c1b7e503e6d4c9730bd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0079-rt-compact-RTFieldgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaredAnnotations2) +run(RTFieldGetDeclaredAnnotations2) diff --git a/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java new file mode 100755 index 0000000000000000000000000000000000000000..79dd428df0a6230af282dc2db660dfa65b9f9574 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetDeclaringClass { + public int num; + char aChar; +} +public class RTFieldGetDeclaringClass { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaringClass"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("aChar"); + Class j = instance1.getDeclaringClass(); + Class k = instance2.getDeclaringClass(); + if (j.getName().equals("FieldGetDeclaringClass") && k.getName().equals("FieldGetDeclaringClass")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/expected.txt b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/maple.prof b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..1a6dde231ebee00de1d0784c7def6feeb1530e8a Binary files /dev/null and b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/test.cfg b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e3ed4c8649c499aac9a1ec9ea6b3822598550d18 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0080-rt-compact-RTFieldgetDeclaringClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaringClass) +run(RTFieldGetDeclaringClass) diff --git a/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/RTFieldGetModifiers.java b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/RTFieldGetModifiers.java new file mode 100755 index 0000000000000000000000000000000000000000..6bd3b08cb2fdeeae08e778195400cabb5fca1775 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/RTFieldGetModifiers.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetModifiers { + public static int num; + final String str = "aaa"; + private String string = "ccc"; + protected static int number; +} +public class RTFieldGetModifiers { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetModifiers"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("str"); + Field instance3 = cls.getDeclaredField("string"); + Field field = cls.getDeclaredField("number"); + if (instance1.getModifiers() == 9 && instance2.getModifiers() == 16 && instance3.getModifiers() == 2 + && field.getModifiers() + == 12) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/expected.txt b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/maple.prof b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ab04abcec4b1f3c9e4cd16d9feb6ce21dd6d57d5 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/test.cfg b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e297b16ce8d1706e240e8beef84cd62e1c7efd3b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0081-rt-compact-RTFieldgetModifiers/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetModifiers) +run(RTFieldGetModifiers) diff --git a/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/RTFieldGetName.java b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/RTFieldGetName.java new file mode 100755 index 0000000000000000000000000000000000000000..d9a174b23e09e9f6c156abaf711ba8f5fd96ccb4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/RTFieldGetName.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetName { + public static int num; + final String str = "aaa"; +} +public class RTFieldGetName { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetName"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("str"); + if (instance1.getName().equals("num") && instance2.getName().equals("str")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/expected.txt b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/maple.prof b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3b177b5b135ed79877a9f8f018b1f6f4e39e795b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/test.cfg b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1bbf40e544099da77a2ddb809f776abc2473d378 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0082-rt-compact-RTFieldgetName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetName) +run(RTFieldGetName) diff --git a/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/RTFieldGetType.java b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/RTFieldGetType.java new file mode 100755 index 0000000000000000000000000000000000000000..7ecb6cf13dc518f459216fb74d3e5f06345b9fa4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/RTFieldGetType.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetType { + public static short sNum; + final char aChar = '什'; + private float fNum; +} +public class RTFieldGetType { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetType"); + Field instance1 = cls.getField("sNum"); + Field instance2 = cls.getDeclaredField("aChar"); + Field instance3 = cls.getDeclaredField("fNum"); + if (instance1.getType().getName().equals("short") && instance2.getType().getName().equals("char") + && instance3.getType().getName().equals("float")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/expected.txt b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/maple.prof b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..46382a3e98b5b74e0b2d4e1795fce9249f18d15f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/test.cfg b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ecfd3fb43c92561ff602cd1c65d9762f844edb4b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0083-rt-compact-RTFieldgetType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetType) +run(RTFieldGetType) diff --git a/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/RTFieldSet1.java b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/RTFieldSet1.java new file mode 100755 index 0000000000000000000000000000000000000000..ed28cef52403d4ec726174b325b1572577acd24c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/RTFieldSet1.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet1_a { + public static String str = "aaa"; + public int num2 = 2; + public int number = 5; + public static int num1; +} +class FieldSet1 extends FieldSet1_a { + public static String str = "bbb"; + public int num = 1; + public int test = super.number + 1; + public static boolean aBoolean = true; + public char aChar; +} +public class RTFieldSet1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet1"); + Object obj = cls.newInstance(); + Field f1 = cls.getField("str"); + Field f2 = cls.getField("num"); + Field f3 = cls.getField("aBoolean"); + Field f4 = cls.getField("aChar"); + Field f5 = cls.getField("num1"); + Field f6 = cls.getField("num2"); + Field f7 = cls.getField("number"); + f1.set(obj, "ccc"); + f2.set(obj, 10); + f3.set(obj, false); + f4.set(obj, '国'); + f5.set(obj, 20); + f6.set(obj, 30); + f7.set(obj, 40); + if (f1.get(obj).toString().equals("ccc") && (int) f2.get(obj) == 10 && !(boolean) f3.get(obj) && (int) + f6.get(obj) == 30) { + if (f4.get(obj).toString().equals("国") && (int) f5.get(obj) == 20) { + if ((int) cls.getField("test").get(obj) == 6) { + Class cls1 = Class.forName("FieldSet1_a"); + Object instance1 = cls1.newInstance(); + Object p = cls1.getDeclaredField("str").get(instance1); + if (p.toString().equals("aaa")) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/expected.txt b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/maple.prof b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8eb03c13f1da10242174ca9365bcc01cce31b494 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/test.cfg b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..54f53bff0e82a4c62f6fd21dc228d86fa2e5c411 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0084-rt-compact-RTFieldset1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet1) +run(RTFieldSet1) diff --git a/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/RTFieldSet2.java b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/RTFieldSet2.java new file mode 100755 index 0000000000000000000000000000000000000000..e2f65c1a1e33cf6b6db150fa5f845c02e32fb349 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/RTFieldSet2.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet2_a { + public static String str = "aaa"; + public int num; +} +class FieldSet2 extends FieldSet2_a { + public static String str; + private int num = 1; + public boolean aBoolean = true; + public int num1 = 8; +} +class FieldSet2_b { + public int num = 18; +} +public class RTFieldSet2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet2"); + Object obj = cls.newInstance(); + Field field = cls.getDeclaredField("num"); + field.set(obj, 10); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + try { + Class cls = Class.forName("FieldSet2"); + Class cls1 = Class.forName("FieldSet2_b"); + Object instance1 = cls1.newInstance(); + Field f1 = cls.getDeclaredField("aBoolean"); + f1.set(instance1, 10); + } catch (ClassNotFoundException e5) { + System.err.println(e5); + System.out.println(2); + } catch (InstantiationException e6) { + System.err.println(e6); + System.out.println(2); + } catch (NoSuchFieldException e7) { + System.err.println(e7); + System.out.println(2); + } catch (IllegalAccessException e8) { + System.err.println(e8); + System.out.println(2); + } catch (IllegalArgumentException e9) { + try { + Class cls = Class.forName("FieldSet2"); + Field f2 = cls.getDeclaredField("aBoolean"); + f2.set(null, false); + } catch (ClassNotFoundException e10) { + System.err.println(e10); + System.out.println(2); + } catch (NoSuchFieldException e11) { + System.err.println(e11); + System.out.println(2); + } catch (IllegalAccessException e12) { + System.err.println(e12); + System.out.println(2); + } catch (NullPointerException e13) { + System.out.println(0); + } + } + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/expected.txt b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/maple.prof b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..30da4d3d87208726ca7c75b5df4d56623dd1e4f7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/test.cfg b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9967e5edd4d941a1995d0fd119629561ab5fb613 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0085-rt-compact-RTFieldset2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet2) +run(RTFieldSet2) diff --git a/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/RTFieldSet3.java b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/RTFieldSet3.java new file mode 100755 index 0000000000000000000000000000000000000000..7e44394ec0c1241858263c9acade58d7a811d3f1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/RTFieldSet3.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet3_a { + public final static String str = "aaa"; + public int num = 2; +} +class FieldSet3 extends FieldSet3_a { + public final int num = 1; +} +public class RTFieldSet3 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet3"); + Object obj = cls.newInstance(); + Field q1 = cls.getField("str"); + Field q2 = cls.getField("num"); + q1.set(obj, "bbb"); + q2.set(obj, 10); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/expected.txt b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/maple.prof b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..882da918103a149a0976ffe03325b4f6337d4410 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/test.cfg b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f1921bf53b99e682f24ec182997617a63aee9c96 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0086-rt-compact-RTFieldset3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet3) +run(RTFieldSet3) diff --git a/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/RTFieldSet4.java b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/RTFieldSet4.java new file mode 100755 index 0000000000000000000000000000000000000000..c631e7691589020bdb5620a90b9d3a37897c441a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/RTFieldSet4.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet4 { + public static String str; + private int num = 1; + public boolean aBoolean = true; + public int num1 = 8; +} +public class RTFieldSet4 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet4"); + Object obj = cls.newInstance(); + Field field = cls.getDeclaredField("str"); + field.set(null, "aaa"); + System.out.println(0); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/expected.txt b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/maple.prof b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8efac0a7218c7394ac2d28f6f5e4ff65ffad18b7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/test.cfg b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9f34e54e4a70ac7a5c4de3a00dd10cbea7cd818 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0087-rt-compact-RTFieldset4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet4) +run(RTFieldSet4) diff --git a/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/RTFieldToGenericString.java b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/RTFieldToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..5edd578b1e2f39139601675eefbcbcc05f8eadbf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/RTFieldToGenericString.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.List; +class FieldToGenericString { + public List list1; + private List list2; +} +public class RTFieldToGenericString { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldToGenericString"); + Field instance1 = cls.getField("list1"); + Field instance2 = cls.getDeclaredField("list2"); + String q1 = instance1.toGenericString(); + String q2 = instance2.toGenericString(); + if (q1.equals("public java.util.List FieldToGenericString.list1") && q2.equals + ("private java.util.List FieldToGenericString.list2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/expected.txt b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/maple.prof b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..775704ba186984986b514a9cbb1696cd4e5d36c7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/test.cfg b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..642120ca45dd8a1c4cfa0ebd809e9eb1dc47f4a5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0088-rt-compact-RTFieldtoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldToGenericString) +run(RTFieldToGenericString) diff --git a/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/RTFieldToString.java b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/RTFieldToString.java new file mode 100755 index 0000000000000000000000000000000000000000..87c9e346b49e32234d3db39d0a98c21911973a31 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/RTFieldToString.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.List; +class FieldToString { + public List list1; + private List list2; +} +public class RTFieldToString { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldToString"); + Field instance1 = cls.getField("list1"); + Field instance2 = cls.getDeclaredField("list2"); + String q1 = instance1.toString(); + String q2 = instance2.toString(); + if (q1.equals("public java.util.List FieldToString.list1") + && q2.equals("private java.util.List FieldToString.list2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/expected.txt b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/maple.prof b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..610b1589292e242ec69ee8d56e89d11de076686e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/test.cfg b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06521d2700b197dc4257d8d79902720a102b8dfe --- /dev/null +++ b/testsuite/java_test/compact_test/RT0089-rt-compact-RTFieldtoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldToString) +run(RTFieldToString) diff --git a/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..7486687061da0505f6b29ac679c5d77ae3872ea5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i_a() default 0; + String t_b() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int c() default 0; + String d() default ""; +} +class MethodGetAnnotation1 { + @IF1(i_a = 333, t_b = "MethodGetAnnotation") + public void test1() { + } + public void test2(String name) { + } + @IF1_a(c = 666, d = "Method") + void test3(int number) { + } + void test4(String name, int number) { + } +} +public class RTMethodGetAnnotation1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetAnnotation1"); + Method method1 = clazz.getDeclaredMethod("test3", int.class); + Method method2 = clazz.getMethod("test1"); + Method method3 = clazz.getMethod("test2", String.class); + if (method1.getAnnotation(IF1_a.class).c() == 666 + && method1.getAnnotation(IF1_a.class).d().equals("Method") + && method2.getAnnotation(IF1.class).i_a() == 333 + && method2.getAnnotation(IF1.class).t_b().equals("MethodGetAnnotation")) { + if (method3.getAnnotation(IF1.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/expected.txt b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/maple.prof b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3ae0da937e85c28a6f76f993b0581e0df120d3c1 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/test.cfg b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ac790d02d80f80fba9dbdeb8a93b9cd282f778c5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0090-rt-compact-RTMethodgetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetAnnotation1) +run(RTMethodGetAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..f5cce1f0045f5994218efbde68d6b5e738928249 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class MethodGetAnnotation2 { + @IF2(i = 333, t = "MethodGetAnnotation") + public void test1() { + } + @IF2_a(c = 666, d = "Method") + void test3(int number) { + } +} +public class RTMethodGetAnnotation2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetAnnotation2"); + Method method1 = clazz.getDeclaredMethod("test3", int.class); + Method method2 = clazz.getMethod("test1"); + if (method1.getAnnotation(IF2_a.class) == null && method2.getAnnotation(IF2.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/expected.txt b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/maple.prof b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fafd0688f8e711cc8a86e53d9172be6709552632 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/test.cfg b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..02a024b2056b2b65b20a78298016f7b289d5f3d5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0091-rt-compact-RTMethodgetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetAnnotation2) +run(RTMethodGetAnnotation2) diff --git a/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..edcf864dcb084ab3234fe97c0ef52d94446cb757 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw1_a { + int i_a() default 2; + String t_a() default ""; +} +class MethodGetDeclaredAnnotations1 { + @IFw1(i = 333, t = "test1") + public static void ii(String name) { + } + @IFw1(i = 333, t = "test1") + void tt(int number) { + } +} +class MethodGetDeclaredAnnotations1_a extends MethodGetDeclaredAnnotations1 { + @IFw1_a(i_a = 666, t_a = "right1") + public static void ii(String name) { + } + @IFw1_a(i_a = 666, t_a = "right1") + void tt(int number) { + } +} +public class RTMethodGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetDeclaredAnnotations1_a"); + Method method1 = clazz.getMethod("ii", String.class); + if (method1.getDeclaredAnnotations().length == 1) { + Annotation[] annotations1 = method1.getDeclaredAnnotations(); + if (annotations1[0].toString().indexOf("i_a=666") != -1 + && annotations1[0].toString().indexOf("t_a=right1") != -1) { + Method method2 = clazz.getDeclaredMethod("tt", int.class); + if (method2.getDeclaredAnnotations().length == 1) { + Annotation[] annotations2 = method2.getDeclaredAnnotations(); + if (annotations2[0].toString().indexOf("i_a=666") != -1 + && annotations2[0].toString().indexOf("t_a=right1") != -1) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ce2c31567b055d1d6cddc07ab9eec9a1f8629071 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ffaf58dd1a949bf122925c4ab9be940fc146d865 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0092-rt-compact-RTMethodgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDeclaredAnnotations1) +run(RTMethodGetDeclaredAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..6c494882f903a7b489284293c571218720480171 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw2_a { + int i_a() default 2; + String t_a() default ""; +} +class MethodGetDeclaredAnnotations2 { + @IFw2(i = 333, t = "test1") + public static void ii(String name) { + } + @IFw2_a(i_a = 666, t_a = "right1") + void tt(int number) { + } +} +class MethodGetDeclaredAnnotations2_a extends MethodGetDeclaredAnnotations2 { + public static void ii(String name) { + } + void tt() { + } +} +public class RTMethodGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetDeclaredAnnotations2_a"); + Method method1 = clazz.getMethod("ii", String.class); + Method method2 = clazz.getDeclaredMethod("tt"); + if (method1.getDeclaredAnnotations().length == 0 && method2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/maple.prof b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5c4c92fdc7a5fd833c9b80e8db711134ace79232 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4058221ea538db4d1fd8387bcd053dfcb6a03993 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0093-rt-compact-RTMethodgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDeclaredAnnotations2) +run(RTMethodGetDeclaredAnnotations2) diff --git a/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java new file mode 100755 index 0000000000000000000000000000000000000000..5b1784f2ab01cb6c0e206b804d14789083072d1b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + public int i_a() default 2; + String t_a() default "string default value"; + String s(); +} +class MethodGetDefaultValue1 { + @IF1(i = 333, t = "test1") + public static void ii(String name) { + } + void tt(int number) { + } +} +public class RTMethodGetDefaultValue1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("IF1_a"); + Class clazz2 = Class.forName("IF1"); + Class clazz3 = Class.forName("MethodGetDefaultValue1"); + Method method1 = clazz1.getDeclaredMethod("i_a"); + Method method2 = clazz1.getMethod("t_a"); + Method method3 = clazz2.getDeclaredMethod("t"); + Method[] methods = clazz3.getMethods(); + Method method5 = clazz3.getDeclaredMethod("tt", int.class); + Method method6 = clazz1.getDeclaredMethod("s"); + if ((int) method1.getDefaultValue() == 2 + && method2.getDefaultValue().toString().equals("string default value")) { + if (method3.getDefaultValue().equals("")) { + if (methods[0].getDefaultValue() == null && method5.getDefaultValue() == null) { + if (method6.getDefaultValue() == null) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/expected.txt b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/maple.prof b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..356f4df261d42140cac769d0de7f41c4bd0542f1 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/test.cfg b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e7d5df4dae778b529e0ea74ff58dd1c3a7b7d97 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0094-rt-compact-RTMethodgetDefaultValue1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDefaultValue1) +run(RTMethodGetDefaultValue1) diff --git a/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/RTMethodGetParameterCount.java b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/RTMethodGetParameterCount.java new file mode 100755 index 0000000000000000000000000000000000000000..ee8614285c236a87f670372a83a4e3e235f56e9c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/RTMethodGetParameterCount.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class MethodGetParameterCount2 { + void test1() { + } + public void test2(String name, int number, char c, short s, float f, double d, long l, boolean b, byte bb) { + } +} +public class RTMethodGetParameterCount { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetParameterCount2"); + Method method = clazz.getDeclaredMethod("test1"); + Method[] methods = clazz.getMethods(); + if (method.getParameterCount() == 0) { + if (methods[0].getParameterCount() == 9) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/expected.txt b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/maple.prof b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..549496029bef957186f6da9ee2c84be4b20a71d0 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/test.cfg b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a28e8173d86a1fe9c35ef523bc468cbc0c852d61 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0095-rt-compact-RTMethodgetParameterCount/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetParameterCount) +run(RTMethodGetParameterCount) diff --git a/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..d7b58159429cc8f99d631d2b7087def4759593c0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.TypeVariable; +class MethodGetTypeParameters2 { + public void ss(int number) { + } + void kk() { + } +} +public class RTMethodGetTypeParameters { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetTypeParameters2"); + Method method1 = clazz.getMethod("ss", int.class); + Method method2 = clazz.getDeclaredMethod("kk"); + TypeVariable[] typeVariables1 = method1.getTypeParameters(); + TypeVariable[] typeVariables2 = method2.getTypeParameters(); + if (typeVariables1.length == 5 && typeVariables2.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..b5061cbebe8eee55f56dd8c6e684e5b1593c19bf Binary files /dev/null and b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9dd6ac5bf1b6e816b812b542218526eba7dd6e8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0096-rt-compact-RTMethodgetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetTypeParameters) +run(RTMethodGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/RTMethodIsDefault.java b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/RTMethodIsDefault.java new file mode 100755 index 0000000000000000000000000000000000000000..96fe28490abea660ec1f4482c76d16d5be01706f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/RTMethodIsDefault.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +interface MethodIsDefault_A { + default public void run() { + String i; + } +} +class MethodIsDefault implements MethodIsDefault_A { + public void run() { + String i = "abc"; + } + void ss(int number) { + } +} +public class RTMethodIsDefault { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("MethodIsDefault_A"); + Class clazz2 = Class.forName("MethodIsDefault"); + Method method1 = clazz1.getMethod("run"); + Method method2 = clazz2.getMethod("run"); + Method method3 = clazz2.getDeclaredMethod("ss", int.class); + if (method1.isDefault()) { + if (!method2.isDefault() && !method3.isDefault()) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e) { + System.err.println(e); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/expected.txt b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/maple.prof b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..6cad59bd6d53c1ba6997afb5780fdcf48ddb09c9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/test.cfg b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ff4c051a6b498eb5fb5c12f1b8b637224e7d4dfa --- /dev/null +++ b/testsuite/java_test/compact_test/RT0097-rt-compact-RTMethonisDefault/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodIsDefault) +run(RTMethodIsDefault) diff --git a/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/RTMethodToGenericString.java b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/RTMethodToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..68a02ceda5c6d0758e3fe98c234f697bc839db52 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/RTMethodToGenericString.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class MethodToGenericString { + public void ss(int number) { + } +} +public class RTMethodToGenericString { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodToGenericString"); + Method method = clazz.getMethod("ss", int.class); + if (method.toGenericString().equals("public void MethodToGenericString.ss(int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/expected.txt b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/maple.prof b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..1ade6876276fefdaab333403ad396add823bb782 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/test.cfg b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..82b5a6b2417a7c96a4d90ef6bbecb40f19e34c79 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0098-rt-compact-RTMethontoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodToGenericString) +run(RTMethodToGenericString) diff --git a/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/RTModifierParameterModifiers.java b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/RTModifierParameterModifiers.java new file mode 100755 index 0000000000000000000000000000000000000000..8000f727351831a442186359e8d7f899047fa64b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/RTModifierParameterModifiers.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class RTModifierParameterModifiers { + public static void main(String[] args) { + if (Modifier.parameterModifiers() == 16) { + System.out.println(0); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/expected.txt b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/maple.prof b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..16e2e1b349d7a962eb26c11a9a353d47b038da6c Binary files /dev/null and b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/test.cfg b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b6ae2b3bb67291151a13af881ac5c4e0ae3fd3d3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0099-rt-compact-RTModifierparameterModifiers/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTModifierParameterModifiers) +run(RTModifierParameterModifiers) diff --git a/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/RTParameterGetAnnotation1.java b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/RTParameterGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..ea539b8bb3ef1a46bdae43ef65be3986d69008d8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/RTParameterGetAnnotation1.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotation1 { + ParameterGetAnnotation1(@IF1(i = 222, t = "Parameter") int number) { + } + public ParameterGetAnnotation1(String name) { + } + public void test1(@IF1_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotation1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotation1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + if (p1[0].getAnnotation(IF1.class).i() == 222 && p1[0].getAnnotation(IF1.class).t().equals("Parameter") + && p3[0].getAnnotation(IF1_a.class).c() == 666 + && p3[0].getAnnotation(IF1_a.class).d().equals("Happy new year")) { + if (p2[0].getAnnotation(IF1.class) == null) { + System.out.println(0); + return; + } + System.out.println(2); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(3); + return; + } catch (NoSuchMethodException e1) { + System.out.println(4); + return; + } + System.out.println(5); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/expected.txt b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/maple.prof b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c8f35acebdb248302aba7037e31f1bfe20264a36 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/test.cfg b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6e7a808567bbe9ef2a1630efb87e8b244de372b7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0100-rt-compact-RTParametergetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotation1) +run(RTParameterGetAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/RTParameterGetAnnotation2.java b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/RTParameterGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..a90a33962a5a490592cf7be0ffca1753f61fcc5f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/RTParameterGetAnnotation2.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotation2 { + ParameterGetAnnotation2(@IF2(i = 222, t = "Parameter") int number) { + } + public void test1(@IF2_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotation2"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getAnnotation(IF2_a.class) == null && p2[0].getAnnotation(IF2.class) == null) { + p1[0].getAnnotation(IF2_a.class).c(); + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } catch (NullPointerException e2) { + try { + Class cls1 = Class.forName("ParameterGetAnnotation2"); + Method method2 = cls1.getMethod("test1", int.class); + Parameter[] p3 = method2.getParameters(); + p3[0].getAnnotation(null); + System.out.println(3); + return; + } catch (ClassNotFoundException e3) { + System.out.println(4); + return; + } catch (NoSuchMethodException e4) { + System.out.println(5); + return; + } catch (NullPointerException e5) { + System.out.println(0); + return; + } + } + System.out.println(6); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/expected.txt b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/maple.prof b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..21f583c5e75e25752fef3a4e61ca52a99741db69 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/test.cfg b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..699fa3167c9c04f3fb71c5cab1499c52da48bf2d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0101-rt-compact-RTParametergetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotation2) +run(RTParameterGetAnnotation2) diff --git a/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/RTParameterGetAnnotations1.java b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/RTParameterGetAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..0e9965732244df5d9686548c56f010f545bbec63 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/RTParameterGetAnnotations1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF3 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF3_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotations1 { + ParameterGetAnnotations1(@IF3(i = 222, t = "Parameter") @IF3_a(c = 666, d = "Happy new year") int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotations1"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getAnnotations().length == 2 && p2[0].getAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c04d5330c0f1a1f7dab3ff57aa37203e654760cb Binary files /dev/null and b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..caeda24b3aa66a7b3aa41367ed6b08b9203e0288 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0102-rt-compact-RTParametergetAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotations1) +run(RTParameterGetAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..3517bb0c03ff66261526274e1f10d4c4007ca5a6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF7 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF7_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotationsByType1 { + ParameterGetAnnotationsByType1(@IF7(i = 222, t = "Parameter") int number) { + } + public ParameterGetAnnotationsByType1(String name) { + } + public void test1(@IF7_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotationsByType1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotationsByType1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + Annotation[] q1 = p1[0].getAnnotationsByType(IF7.class); + Annotation[] q3 = p3[0].getAnnotationsByType(IF7_a.class); + if (p2[0].getAnnotationsByType(IF7.class).length == 0) { + if (q1[0].toString().indexOf("i=222") != -1 && q1[0].toString().indexOf("t=Parameter") != -1 + && q3[0].toString().indexOf("c=666") != -1 + && q3[0].toString().indexOf("d=Happy new year") != -1) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/expected.txt b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/maple.prof b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..54010ded1a2aa137fb1c26e2200db62370064fd4 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/test.cfg b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..208bd40d189764331ca51d39f42b6d7caf97cb61 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0103-rt-compact-RTParametergetAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotationsByType1) +run(RTParameterGetAnnotationsByType1) diff --git a/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java new file mode 100755 index 0000000000000000000000000000000000000000..e0e1dd66eddf414d8d847b25823c04b43ff57118 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF8 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF8_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotationsByType2 { + ParameterGetAnnotationsByType2(@IF8(i = 222, t = "Parameter") int number) { + } + public void test1(@IF8_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotationsByType2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotationsByType2"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + Annotation[] q1 = p1[0].getAnnotationsByType(IF8_a.class); + Annotation[] q2 = p2[0].getAnnotationsByType(IF8.class); + q1[0].toString(); + q2[0].toString(); + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } catch (ArrayIndexOutOfBoundsException e2) { + try { + Class cls1 = Class.forName("ParameterGetAnnotationsByType2"); + Constructor cons1 = cls1.getDeclaredConstructor(int.class); + Parameter[] p3 = cons1.getParameters(); + Annotation[] q3 = p3[0].getAnnotationsByType(null); + System.out.println(3); + return; + } catch (ClassNotFoundException e3) { + System.out.println(4); + return; + } catch (NoSuchMethodException e4) { + System.out.println(5); + return; + } catch (NullPointerException e5) { + System.out.println(0); + return; + } + } + System.out.println(6); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/expected.txt b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/maple.prof b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..773fd5f0662b3bf45ff217942250818c733ba05f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/test.cfg b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9c3f557c9e3dd343fd832f763a949f6cbec863c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0104-rt-compact-RTParametergetAnnotationsByType2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotationsByType2) +run(RTParameterGetAnnotationsByType2) diff --git a/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..9d396087885fe2bdac360b2dc1afd37b07e6b4a5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF6 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF6_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotation1 { + ParameterGetDeclaredAnnotation1(@IF6(i = 222, t = "Parameter") int number) { + } + public ParameterGetDeclaredAnnotation1(String name) { + } + public void test1(@IF6_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetDeclaredAnnotation1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotation1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + if (p1[0].getDeclaredAnnotation(IF6.class).i() == 222 && p1[0].getDeclaredAnnotation(IF6.class).t() + .equals("Parameter") && p3[0].getDeclaredAnnotation(IF6_a.class).c() == 666 + && p3[0].getDeclaredAnnotation(IF6_a.class).d().equals("Happy new year")) { + if (p2[0].getDeclaredAnnotation(IF6.class) == null) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/expected.txt b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/maple.prof b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cb2f0aeb56accc017f81f1af4571996beb0c3c71 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/test.cfg b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d176726d61857df4a6e81e90050dd0e2b02765ef --- /dev/null +++ b/testsuite/java_test/compact_test/RT0105-rt-compact-RTParametergetDeclaredAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotation1) +run(RTParameterGetDeclaredAnnotation1) diff --git a/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..97badfbc064bed9111c93fbb391ac52f326f0aba --- /dev/null +++ b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF5 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF5_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotations1 { + ParameterGetDeclaredAnnotations1(@IF5(i = 222, t = "Parameter") @IF5_a(c = 666, d = "Happy new year") int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotations1"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getDeclaredAnnotations().length == 2 && p2[0].getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/expected.txt b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/maple.prof b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..bd9d05c16271d80ad4b4c6183778e22881204433 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/test.cfg b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d568dbd412030588a7424ef1f2558e8ab300d57b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0106-rt-compact-RTParametergetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotations1) +run(RTParameterGetDeclaredAnnotations1) diff --git a/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..78f4b2c8f0222b16e5de47bd1671049c10037a88 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF4 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF4_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotations2 { + ParameterGetDeclaredAnnotations2() { + } + ParameterGetDeclaredAnnotations2(@IF4(i = 222, t = "Parameter") int number) { + } + public void test1(@IF4(i = 222, t = "Parameter") String name) { + } +} +class ParameterGetDeclaredAnnotations2_a extends ParameterGetDeclaredAnnotations2 { + ParameterGetDeclaredAnnotations2_a() { + } + ParameterGetDeclaredAnnotations2_a(@IF4_a(c = 666, d = "Happy new year") int number) { + } + public void test1(@IF4_a(c = 666, d = "Happy new year") String name) { + } +} +class ParameterGetDeclaredAnnotations2_b extends ParameterGetDeclaredAnnotations2_a { + ParameterGetDeclaredAnnotations2_b(int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotations2_b"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getDeclaredAnnotations().length == 0 && p2[0].getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/expected.txt b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/maple.prof b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..04130830137180955fd5095da7e4c49bcaa23298 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/test.cfg b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5e5907a08d1f6341842e5f3c88c0876d06128ce4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0107-rt-compact-RTParametergetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotations2) +run(RTParameterGetDeclaredAnnotations2) diff --git a/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..d8c9b01962d8a50dd53c666c818a675491b29752 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF9 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF9_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotationsByType1 { + ParameterGetDeclaredAnnotationsByType1(@IF9(i = 222, t = "Parameter") int number) { + } + public ParameterGetDeclaredAnnotationsByType1(String name) { + } + public void test1(@IF9_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetDeclaredAnnotationsByType1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotationsByType1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + Annotation[] q1 = p1[0].getDeclaredAnnotationsByType(IF9.class); + Annotation[] q3 = p3[0].getDeclaredAnnotationsByType(IF9_a.class); + if (p2[0].getDeclaredAnnotationsByType(IF9.class).length == 0) { + if (q1[0].toString().indexOf("i=222") != -1 && q1[0].toString().indexOf("t=Parameter") != -1 + && q3[0].toString().indexOf("c=666") != -1 + && q3[0].toString().indexOf("d=Happy new year") != -1) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/expected.txt b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/maple.prof b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..d4b976ea5d6283654c1e8beba65135a8f2e3448b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/test.cfg b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..07a732bed1e56ada793a51ea39d07c6faffee95e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0108-rt-compact-RTParametergetDeclaredAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotationsByType1) +run(RTParameterGetDeclaredAnnotationsByType1) diff --git a/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/RTProxyGetProxyClass1.java b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/RTProxyGetProxyClass1.java new file mode 100755 index 0000000000000000000000000000000000000000..61a977101f645a3a67be93c6b96bb2e97232c865 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/RTProxyGetProxyClass1.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +interface ProxyGetProxyClass1_1 { + default void test1() { + } + default void test2() { + } + default void test3() { + } + default void test4() { + } + default void test5() { + } + default void test6() { + } + default void test7() { + } + default void test8() { + } + default void test9() { + } + default void test10() { + } + default void test11() { + } + default void test12() { + } + default void test13() { + } + default void test14() { + } + default void test15() { + } + default void test16() { + } + default void test17() { + } + default void test18() { + } + default void test19() { + } + default void test20() { + } + default void test21() { + } + default void test22() { + } + default void test23() { + } + default void test24() { + } + default void test25() { + } + default void test26() { + } + default void test27() { + } + default void test28() { + } + default void test29() { + } + default void test30() { + } +} +interface ProxyGetProxyClass1_2 extends ProxyGetProxyClass1_1 { + default void test30() { + } +} +interface ProxyGetProxyClass1_3 { + default void test31() { + } +} +public class RTProxyGetProxyClass1 { + public static void main(String[] args) { + try { + Proxy.getProxyClass(ProxyGetProxyClass1_1.class.getClassLoader(), new Class[] {ProxyGetProxyClass1_1.class, + ProxyGetProxyClass1_2.class}); + Proxy.getProxyClass(ProxyGetProxyClass1_1.class.getClassLoader(), new Class[] {ProxyGetProxyClass1_1.class, + ProxyGetProxyClass1_3.class}); + } catch (IllegalArgumentException e) { + System.err.println(e); + } + System.out.println(0); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/expected.txt b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/maple.prof b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..978ae6792f4b933956d601734d05588f7d571850 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/test.cfg b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6e32644ab3be3e9531261720f23b8b5992a92de1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0109-rt-compact-RTProxygetProxyClass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTProxyGetProxyClass1) +run(RTProxyGetProxyClass1) diff --git a/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java new file mode 100755 index 0000000000000000000000000000000000000000..9579b393258b936b9ed2c6e3cbc7c02b43b5ed90 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +public class ClassGetDeclaredAnnotationNPE { + public static void main(String argv[]) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = ClassGetDeclaredAnnotationNPE_1(); + } catch (Exception e) { + result = 3; + } + System.out.println(result); + } + public static int ClassGetDeclaredAnnotationNPE_1() { + try { + Annotation a = MyClass.class.getDeclaredAnnotation(Deprecated.class); + a = MyClass.class.getDeclaredAnnotation(null); + } catch (NullPointerException e) { + return 0; + } + return 4; + } + @Deprecated + class MyClass extends MySuperClass { + } + @MyAnnotation + class MySuperClass { + } + @interface MyAnnotation { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/expected.txt b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/maple.prof b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..70f33fce889dd21876465414e5b55982931a9dec Binary files /dev/null and b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/test.cfg b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2f7328498c299e69341ca049f1b7f4cbbc0c1211 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0110-rt-compact-ClassgetDeclaredAnnotationNPE/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetDeclaredAnnotationNPE) +run(ClassGetDeclaredAnnotationNPE) diff --git a/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java new file mode 100755 index 0000000000000000000000000000000000000000..3931497f0afa366dc8cd1e4c3ceb0313e7bfaeac --- /dev/null +++ b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ClassIsAssignableFromNPE { + public static void main(String argv[]) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = ClassIsAssignableFromNPE_1(); + } catch (Exception e) { + System.out.println(e); + result = 3; + } + System.out.println(result); + } + public static int ClassIsAssignableFromNPE_1() { + int result1 = 4; /* STATUS_FAILED*/ + + int intArray[] = {1, 2, 3, 4, 5}; + Class cl = null; + try { + intArray.getClass().isAssignableFrom(cl); + } catch (SecurityException e) { + return 1; + } catch (NullPointerException e) { + return 0; + } + return result1; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/expected.txt b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/maple.prof b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fd0125d67407e7186c537778c20813f8be62c814 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/test.cfg b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..78d5881a8c677b70ffaa8cca9ae537876fa442d1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0111-rt-compact-reflectClasssetisAssignableFrom/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassIsAssignableFromNPE) +run(ClassIsAssignableFromNPE) diff --git a/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..101b52baf82057b2146bff925fec7adf7f393f6e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetAnnotationsByType1() { + Class m; + try { + m = MyTargetTest0.class; + MyTarget[] Target = m.getAnnotationsByType(MyTarget.class); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest0 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest0(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/expected.txt b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/maple.prof b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5d9e65e13ae35e9fa7a5da77b5b90356aed8d3e3 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/test.cfg b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..957ebdd0ba202041797ebb31a39343ced64b4989 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0112-rt-compact-ClassGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetAnnotationsByType) +run(ClassGetAnnotationsByType) diff --git a/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/ClassGetCanonicalName.java b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/ClassGetCanonicalName.java new file mode 100755 index 0000000000000000000000000000000000000000..ebb4a3e2e5a564f1c029576a2dd8c1d13818be62 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/ClassGetCanonicalName.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetCanonicalName { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetCanonicalName1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetCanonicalName1() { + Class m; + try { + m = MyTargetTest1.class; + String str = m.getCanonicalName(); + if ("ClassGetCanonicalName.MyTargetTest1".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest1 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest1(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/expected.txt b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/maple.prof b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cb437a51df801fbf9322a55284e859cd126808b7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/test.cfg b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73150467b2c31c277fb9414ace43e49cd8349ad0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0113-rt-compact-ClassGetCanonicalName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetCanonicalName) +run(ClassGetCanonicalName) diff --git a/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/ClassGetEnclosingClass.java b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/ClassGetEnclosingClass.java new file mode 100755 index 0000000000000000000000000000000000000000..37cbfb439ea53d1b34a79e960dfdf675fc39ebf0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/ClassGetEnclosingClass.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetEnclosingClass { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetEnclosingClass1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetEnclosingClass1() { + Class m; + try { + m = MyTargetTest2.class; + Class cl = m.getEnclosingClass(); + if (cl != null) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest2 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest2(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/expected.txt b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/maple.prof b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f35335a17ec9d3ebe7911ca4f3f5cb804b8fdcaa Binary files /dev/null and b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/test.cfg b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06636719e419b137b9d7fd62e7fd88cda439472e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0114-rt-compact-ClassGetEnclosingClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetEnclosingClass) +run(ClassGetEnclosingClass) diff --git a/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/ClassGetEnumConstants.java b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/ClassGetEnumConstants.java new file mode 100755 index 0000000000000000000000000000000000000000..7dc673343c1313e73e606cef11a932701e78199e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/ClassGetEnumConstants.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetEnumConstants { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetEnumConstants1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetEnumConstants1() { + Class m; + try { + m = MyTargetTest3.class; + MyTargetTest3[] target = m.getEnumConstants(); + if (target == null) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest3 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest3(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/expected.txt b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/maple.prof b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..761c64b4d9bb7e88feecd1964cb06f9d2d00e3ad Binary files /dev/null and b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/test.cfg b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9237eebdc450d54f879bc6fc75c6fbfe38d7b41 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0115-rt-compact-ClassGetEnumConstants/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetEnumConstants) +run(ClassGetEnumConstants) diff --git a/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/ClassGetSimpleName.java b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/ClassGetSimpleName.java new file mode 100755 index 0000000000000000000000000000000000000000..afa45ec540d7e92849f0cc18a55c2d8a8d482c8c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/ClassGetSimpleName.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetSimpleName { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetSimpleName1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetSimpleName1() { + Class m; + try { + m = MyTargetTest4.class; + String str = m.getSimpleName(); + if ("MyTargetTest4".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest4 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest4(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/expected.txt b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/maple.prof b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4fc1161f0a4a82597f5107c8b98b819e3d86ec39 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/test.cfg b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bf5aa4609cfa14fa57d58ededbcc82722f09066a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0116-rt-compact-ClassGetSimpleName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetSimpleName) +run(ClassGetSimpleName) diff --git a/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/ClassGetTypeParameters.java b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/ClassGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..fdb333816dd1d0e3348bde827a4cd6614aff77d2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/ClassGetTypeParameters.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.TypeVariable; +public class ClassGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetTypeParameters1() { + Class m; + try { + m = MyTargetTest5.class; + TypeVariable>[] target = m.getTypeParameters(); + if (target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest5 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest5(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4b93c9a18629de8a83a039631ab33bf0502b4541 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..115c64aee04d84fd5f802dc7504a4a16f706cb2c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0117-rt-compact-ClassGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetTypeParameters) +run(ClassGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/ClassToGenericString.java b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/ClassToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..4592b809ec96e4af44e1b3a91b548b690fcad66a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/ClassToGenericString.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassToGenericString1() { + Class m; + try { + m = MyTargetTest6.class; + String str = m.toGenericString(); + if ("class ClassToGenericString$MyTargetTest6".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest6 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest6(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/expected.txt b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/maple.prof b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..075bb095b3f93659382527c0c4dda9765a8ee4bd Binary files /dev/null and b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/test.cfg b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc8a8e725e788bdac8b934fe106b8527be46700e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0118-rt-compact-ClassToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassToGenericString) +run(ClassToGenericString) diff --git a/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/ConstructorGetAnnotation.java b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/ConstructorGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..5181be859c0a409aa3f651d8315db0f5c861ed26 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/ConstructorGetAnnotation.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorAnnotation1() { + Constructor m; + try { + m = MyTargetTest00.class.getConstructor(new Class[] {ConstructorGetAnnotation.class, String.class}); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@ConstructorGetAnnotation$MyTarget(name=cons, value=constructor)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest00 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest00(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..552bd12563181c74778a9f099ce0dce8882288d7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3ba012bd183940a6f3bf22b0361910f92a98f348 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0119-rt-compact-ConstructorGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetAnnotation) +run(ConstructorGetAnnotation) diff --git a/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..3dd363fa0e2b73d101a473921a76ecddf7628d3a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetDeclaredAnnotations1() { + Constructor m; + try { + m = MyTargetTest01.class.getConstructor(new Class[] {ConstructorGetDeclaredAnnotations.class, String.class}); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@ConstructorGetDeclaredAnnotations$MyTarget(name=cons, value=constructor)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest01 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest01(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/expected.txt b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/maple.prof b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..085302dfb984c5728f8343b4cc10a2eaf37b1db5 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/test.cfg b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b6ee06c13b4edfb418952cd317ed3e15db7ba085 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0120-rt-compact-ConstructorGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetDeclaredAnnotations) +run(ConstructorGetDeclaredAnnotations) diff --git a/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..3d0c5a3622a3604e543f32e337441d23c96fdf76 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetExceptionTypes { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetExceptionTypes1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetExceptionTypes1() { + Constructor m; + try { + m = MyTargetTest02.class.getConstructor(new Class[] {ConstructorGetExceptionTypes.class, String.class}); + Class[] Target = m.getExceptionTypes(); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest02 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest02(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/expected.txt b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/maple.prof b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..b2cd3e02120f2091eed13ffd4572474a73608c7e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/test.cfg b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..950ac88e9d47d3f9c1ec505f47d17dc4caf4f6f5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0121-rt-compact-ConstructorGetExceptionTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetExceptionTypes) +run(ConstructorGetExceptionTypes) diff --git a/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..f61edcd64be3fbdf325bdc964962822e4d302115 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +import java.lang.reflect.TypeVariable; +public class ConstructorGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetTypeParameters1() { + Constructor m; + try { + m = MyTargetTest03.class.getConstructor(new Class[] {ConstructorGetTypeParameters.class, String.class}); + TypeVariable>[] Target = m.getTypeParameters(); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest03 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest03(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..2dd0b0c04118abb2b7a1ad89b352edf24868cf2f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..119a121e625beaa90fd3160f8ecab46587993479 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0122-rt-compact-ConstructorGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetTypeParameters) +run(ConstructorGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/ConstructorToGenericString.java b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/ConstructorToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..dec909bdeb32054b261933cc908dc8dbda39b98b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/ConstructorToGenericString.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorToGenericString1() { + Constructor m; + try { + m = MyTargetTest04.class.getConstructor(new Class[] {ConstructorToGenericString.class, String.class}); + String str = m.toGenericString(); + if ("public ConstructorToGenericString$MyTargetTest04(ConstructorToGenericString,java.lang.String)" + .equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest04 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest04(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/expected.txt b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/maple.prof b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ab5f0dd2c754e92e7bc61ed2f5f25927f0d8e0b0 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/test.cfg b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..525f2927186f00a14a8bc2480f7379080246cabd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0123-rt-compact-ConstructorToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorToGenericString) +run(ConstructorToGenericString) diff --git a/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/FieldGetAnnotation.java b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/FieldGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..e0b85f5d354c1cfc24d8d9125fbd93113901ea2a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/FieldGetAnnotation.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldGetAnnotation1() { + Field m; + try { + m = MyTargetTest06.class.getField("home"); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@FieldGetAnnotation$MyTarget(name=newName, value=newValue)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest06 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..9bfd759ddad0362b885976ebba367b70e10ca791 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4c59ff9c0b25afa608dae0c99b817b9830fbbfc9 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0124-rt-compact-FieldGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetAnnotation) +run(FieldGetAnnotation) diff --git a/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..b1f004b7f4ec48251fb7002a40d3fbc3abefdc4d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldGetAnnotationsByType1() { + Field m; + try { + m = MyTargetTest07.class.getField("home"); + MyTarget[] Target = m.getAnnotationsByType(MyTarget.class); + if (Target.length > 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest07 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest07(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/expected.txt b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/maple.prof b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..799833896d1ce75d683727bf2de076f1c727cdd4 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/test.cfg b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..89df1af8a900edd4e3e0197a414851de1f18ca74 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0125-rt-compact-FieldGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetAnnotationsByType) +run(FieldGetAnnotationsByType) diff --git a/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..290d16ec7c6ea26f34fbd05907aeb53ae2c9d9af --- /dev/null +++ b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetDeclaredAnnotations1() { + Field m; + try { + m = MyTargetTest08.class.getField("home"); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@FieldGetDeclaredAnnotations$MyTarget(name=newName, value=newValue)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest08 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest08(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/expected.txt b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/maple.prof b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a09ce87613b3ae4245f25f02d85f724254df535f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/test.cfg b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..99d700750a69b23b15586235fd5aee551b9119e6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0126-rt-compact-FieldGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetDeclaredAnnotations) +run(FieldGetDeclaredAnnotations) diff --git a/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java new file mode 100755 index 0000000000000000000000000000000000000000..455f873a5dab30fbd6e0bae68f075bf725329303 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldIsAnnotationPresent { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodIsAnnotationPresent1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodIsAnnotationPresent1() { + Field m; + try { + m = MyTargetTest09.class.getField("home"); + boolean flag = m.isAnnotationPresent(MyTarget.class); + if (flag) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest09 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest09(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/expected.txt b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/maple.prof b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..234705e7f08d1d416aec05346b6835dd6596775b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/test.cfg b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0493d725c24622bcad24bb7e657d49d633da7795 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0127-rt-compact-FieldIsAnnotationPresent/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldIsAnnotationPresent) +run(FieldIsAnnotationPresent) diff --git a/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/FieldToGenericString.java b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/FieldToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..3e6e3973ce063a18b2f5f55dc7d05f8a03ed3da1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/FieldToGenericString.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldToGenericString1() { + Field m; + try { + m = MyTargetTest10.class.getField("home"); + String str = m.toGenericString(); + if ("public java.lang.String FieldToGenericString$MyTargetTest10.home".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest10 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest10(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/expected.txt b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/maple.prof b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..53af6823df70d282298f82af51f7c4540ccf6132 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/test.cfg b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..beffa74901ff38d380f441df8ae1233749f934f1 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0128-rt-compact-FieldToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldToGenericString) +run(FieldToGenericString) diff --git a/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/MethodGetAnnotation.java b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/MethodGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..5bb4751d5326dce5d3bf063f27f7dd9cb06048f2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/MethodGetAnnotation.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetAnnotation1() { + Method m; + try { + m = MyTargetTest11.class.getMethod("MyTargetTest_1"); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@MethodGetAnnotation$MyTarget(name=name, value=value)".equals(Target.toString())) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest11 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ea9534cce1933d5db20ce9e3949aa705721e0b64 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ecf9b41606c6b690b3299951bec10ff8da1c9bc2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0129-rt-compact-MethodGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetAnnotation) +run(MethodGetAnnotation) diff --git a/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..0861a328eb1ac79f6cb2a4e2fc03b104bed4bc03 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetDeclaredAnnotations1() { + Method m; + try { + m = MyTargetTest12.class.getMethod("MyTargetTest_1"); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@MethodGetDeclaredAnnotations$MyTarget(name=name, value=value)".equals(Target.toString())) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest12 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest12(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/expected.txt b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/maple.prof b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..0d438ba0c4ab5b96885b70da5c9d58221461e056 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/test.cfg b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f48e752c0fd8b0e7f063ecabe5a62e51c342846f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0130-rt-compact-MethodGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetDeclaredAnnotations) +run(MethodGetDeclaredAnnotations) diff --git a/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/MethodGetDefaultValue.java b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/MethodGetDefaultValue.java new file mode 100755 index 0000000000000000000000000000000000000000..2ecbb22ea12d3c54d3144f786fc315a1e7de119c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/MethodGetDefaultValue.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +public class MethodGetDefaultValue { + public static void main(String[] argv) { + int result = 2/* STATUS_FAILED*/ +; + try { + result = MethodGetDefaultValueTypeNotPresent_1(); + } catch (Exception e) { + result = 3; + } + System.out.println(result); + } + public static int MethodGetDefaultValueTypeNotPresent_1() { + try { + Method m = MyTargetTest13.class.getMethod("MyTargetTest_1"); + Object a = m.getDefaultValue(); + } catch (TypeNotPresentException e) { + return 3; + } catch (NoSuchMethodException e) { + return 4; + } + return 0; + } + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + Class style() default String.class; + } + @MyTarget() + class MyTargetTest13 { + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/expected.txt b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/maple.prof b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4ee12d1e19e081e9266dda5d027d9d9b23885347 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/test.cfg b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7045d53146539174e5a753eb5afa0353285d6102 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0131-rt-compact-MethodgetDefaultValue/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetDefaultValue) +run(MethodGetDefaultValue) diff --git a/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/MethodGetParameterCount.java b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/MethodGetParameterCount.java new file mode 100755 index 0000000000000000000000000000000000000000..1c3095665c90f65735e8eb14880192a4b3e13de6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/MethodGetParameterCount.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetParameterCount { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetParameterCount1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetParameterCount1() { + Method m; + try { + m = MyTargetTest14.class.getMethod("MyTargetTest_1"); + int num = m.getParameterCount(); + if (num == 0) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest14 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest14(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/expected.txt b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/maple.prof b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..d3390d6203f6a2260aee46f637752014f1606cf9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/test.cfg b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e468c2db25175e81ace9c828e5e903a05257da64 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0132-rt-compact-MethodGetParameterCount/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetParameterCount) +run(MethodGetParameterCount) diff --git a/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/MethodGetTypeParameters.java b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/MethodGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..d3eae3bbf994db2e0e6a578f01c817b7f7538112 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/MethodGetTypeParameters.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.TypeVariable; +public class MethodGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetTypeParameters1() { + Method m; + try { + m = MyTargetTest15.class.getMethod("MyTargetTest_1"); + TypeVariable[] Target = m.getTypeParameters(); + if (Target.length == 0) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest15 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest15(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/expected.txt b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/maple.prof b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..7528ffafc33f2528f456ba445c9753d02e44f281 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/test.cfg b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7f6854e1c265986b12fa7e38f4187512768c9b8a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0133-rt-compact-MethodGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetTypeParameters) +run(MethodGetTypeParameters) diff --git a/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/MethodIsDefault.java b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/MethodIsDefault.java new file mode 100755 index 0000000000000000000000000000000000000000..2d8d68adf456aa661980aff9a587b91fce760817 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/MethodIsDefault.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodIsDefault { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodIsDefault1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodIsDefault1() { + Method m; + try { + m = MyTargetTest16.class.getMethod("MyTargetTest_1"); + boolean flag = m.isDefault(); + if (!flag) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest16 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest16(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/expected.txt b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/maple.prof b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..55e20e6391474898464df9bc788db90cdec82861 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/test.cfg b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ece76672147016a46a0aac4ae8c3b1b8c049dfa8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0134-rt-compact-MethodIsDefault/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodIsDefault) +run(MethodIsDefault) diff --git a/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/MethodToGenericString.java b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/MethodToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..75deeb8479aae561216fbd2358b8bd11fd5c3960 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/MethodToGenericString.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodToGenericString1() { + Method m; + try { + m = MyTargetTest17.class.getMethod("MyTargetTest_1"); + String str = m.toGenericString(); + if ("public void MethodToGenericString$MyTargetTest17.MyTargetTest_1()".equals(str)) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest17 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest17(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/expected.txt b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/maple.prof b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cd4d742fd63120f90ff1ba811721a71b3fb0bcf8 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/test.cfg b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b76f84edd04516622cb4129c8b287273912c4674 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0135-rt-compact-MethodToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodToGenericString) +run(MethodToGenericString) diff --git a/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/ParameterGetAnnotation.java b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/ParameterGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..d29e8dd576f404696f0cbbc7660ab13be3e1d9d6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/ParameterGetAnnotation.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotation { + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotation1() { + Method m; + try { + m = MyTargetTest18.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget Target = parameters[0].getAnnotation(MyTarget.class); + if ("@ParameterGetAnnotation$MyTarget(name=name1, value=value1)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest18 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + } + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cdd76b025b89fb793a953f8f6fa59be3e9ca35e1 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c83b597de80ca9092cb898e9960d6d19481c1870 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0136-rt-compact-ParameterGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotation) +run(ParameterGetAnnotation) diff --git a/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/ParameterGetAnnotations.java b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/ParameterGetAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..15be545dcfe324fa51b18c33c804c0e98fe9bc20 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/ParameterGetAnnotations.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ParameterGetAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotations1() { + Method m; + try { + m = MyTargetTest19.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + Annotation[] Target = parameters[0].getAnnotations(); + if ("@ParameterGetAnnotations$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest19 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest19(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/expected.txt b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/maple.prof b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..4cfecfef66425467dad382ffe1619c265b68d09d Binary files /dev/null and b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/test.cfg b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..298a5d2e3f7f1722919c8ea157778c4197f361fa --- /dev/null +++ b/testsuite/java_test/compact_test/RT0137-rt-compact-ParameterGetAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotations) +run(ParameterGetAnnotations) diff --git a/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..43feb6a2af6f7a878a6558d6de7162dc2100b8a2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotationsByType1() { + Method m; + try { + m = MyTargetTest20.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget[] Target = parameters[0].getAnnotationsByType(MyTarget.class); + if ("@ParameterGetAnnotationsByType$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest20 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest20(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/expected.txt b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/maple.prof b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..03ade2daa7ca1be15f65931a5d286d7510c28825 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/test.cfg b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09d64a77841372f53826a71c09c50d94b98eaa9a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0138-rt-compact-ParameterGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotationsByType) +run(ParameterGetAnnotationsByType) diff --git a/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..7d4624f9dcb22b7432ac705f183b78ef252b268b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotation1() { + Method m; + try { + m = MyTargetTest21.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget Target = parameters[0].getDeclaredAnnotation(MyTarget.class); + if ("@ParameterGetDeclaredAnnotation$MyTarget(name=name1, value=value1)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest21 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest21(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/expected.txt b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/maple.prof b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..b6980d2f4d0174ac95abb718b68878b985e5441a Binary files /dev/null and b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/test.cfg b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09fc082610eac6a59bb483425fa1b59c987b3667 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0139-rt-compact-ParameterGetDeclaredAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotation) +run(ParameterGetDeclaredAnnotation) diff --git a/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..01e226346d667fa0e3292e860f33e725dccafa9b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotations1() { + Method m; + try { + m = MyTargetTest22.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + Annotation[] Target = parameters[0].getDeclaredAnnotations(); + if ("@ParameterGetDeclaredAnnotations$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest22 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest22(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/expected.txt b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/maple.prof b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..659d53fed6bbda4cc7f28e1340a96ebf6e1879e1 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/test.cfg b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..db342d3e79ce78004110ded8f92885b22d90d0d7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0140-rt-compact-ParameterGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotations) +run(ParameterGetDeclaredAnnotations) diff --git a/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..c9f930e1117158a4981754bad7f31b49be9f51f0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotationsByType1() { + Method m; + try { + m = MyTargetTest23.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget[] Target = parameters[0].getDeclaredAnnotationsByType(MyTarget.class); + if ("@ParameterGetDeclaredAnnotationsByType$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest23 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest23(String home) { + this.home = home; + } + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/expected.txt b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/maple.prof b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..cc7520ea0ee4cdb1007e2fccdd7db8ce7c92e064 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/test.cfg b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c33d69b4bb5e5e6f002e1e2bb0b5a27a6689bc6c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0141-rt-compact-ParameterGetDeclaredAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotationsByType) +run(ParameterGetDeclaredAnnotationsByType) diff --git a/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..4717e4dd38aaeb92c595d8b7caa51fddb47ca654 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.util.Arrays; +public class ReflectionAnnotationGetClass { + public static void main(String[] args) { + int result = 2; + try{ + // Check point 1 : only 1 annotation in user-defined Class Two. + Annotation[] annotations1 = Class.forName("Two").getAnnotations(); + if (annotations1.length == 1){ + if (annotations1[0].getClass().toString().startsWith("class $Proxy")) { + result --; + } + } + // Check point 2 : 3 annotations in Class java.lang.annotation.Documented. + Annotation[] annotations2 = Class.forName("java.lang.annotation.Documented").getAnnotations(); + String [] annoClazz = new String[annotations2.length]; + for (int i = 0; i < annoClazz.length; i++) { + annoClazz[i] = annotations2[i].getClass().toString(); + } + Arrays.sort(annoClazz); + if (annotations2.length == 3) { + if (annoClazz[0].startsWith("class $Proxy") && annoClazz[1] + .startsWith("class $Proxy") + && annoClazz[2].startsWith("class $Proxy")) { + result --; + } + } + }catch (Exception e) { + result = 3; + } + System.out.println(result); + } +} +@A0 +class Two{} +@Retention(RetentionPolicy.RUNTIME) @interface A0 {} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/expected.txt b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/maple.prof b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..31693821f867d12610d3aa266aba45a4344d8307 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/test.cfg b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..91f31237f23bac38c7f677da670be9660720c4ab --- /dev/null +++ b/testsuite/java_test/compact_test/RT0142-rt-compact-ReflectionAnnotationGetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAnnotationGetClass) +run(ReflectionAnnotationGetClass) diff --git a/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/ClassInitClassNewInstance.java b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/ClassInitClassNewInstance.java new file mode 100755 index 0000000000000000000000000000000000000000..0cebf64695a4a76c80ce88f4f7daf58fec23bb26 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/ClassInitClassNewInstance.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +public class ClassInitClassNewInstance { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try{ + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + /* Check point 1: no class initialization when calling following methods of Class + * not test clazz.cast(Object obj) because it success only when obj is an instance of One or Two, + * and need to call new One(), which result in Class initialization.*/ + + clazz.asSubclass(clazz); + clazz.desiredAssertionStatus(); + clazz.getAnnotation(A.class); + clazz.getAnnotations(); + clazz.getAnnotationsByType(A.class); + clazz.getCanonicalName(); + clazz.getClasses(); + clazz.getClassLoader(); + clazz.getComponentType(); + clazz.getConstructor(String.class); + clazz.getConstructors(); + clazz.getDeclaredAnnotation(A.class); + clazz.getDeclaredAnnotations(); + clazz.getDeclaredAnnotationsByType(A.class); + clazz.getDeclaredClasses(); + clazz.getDeclaredConstructor(String.class); + clazz.getDeclaredConstructors(); + clazz.getDeclaredField("what"); + clazz.getDeclaredFields(); + clazz.getDeclaredMethod("testOne", String.class); + clazz.getDeclaredMethods(); + clazz.getDeclaringClass(); + clazz.getEnclosingClass(); + clazz.getEnclosingConstructor(); + clazz.getEnclosingMethod(); + clazz.getEnumConstants(); + clazz.getField("hi"); + clazz.getFields(); + clazz.getGenericInterfaces(); + clazz.getGenericSuperclass(); + clazz.getInterfaces(); + clazz.getMethod("testOne",String.class); + clazz.getMethods(); + clazz.getModifiers(); + clazz.getName(); + clazz.getPackage(); + clazz.getProtectionDomain(); + clazz.getSigners(); + clazz.getSimpleName(); + clazz.getSuperclass(); + clazz.getTypeName(); + clazz.getTypeParameters(); + clazz.isAnnotation(); + clazz.isAnnotationPresent(A.class); + clazz.isAnonymousClass(); + clazz.isArray(); + clazz.isAssignableFrom(clazz); + clazz.isEnum(); + clazz.isInstance(new Object()); + clazz.isInterface(); + clazz.isLocalClass(); + clazz.isMemberClass(); + clazz.isPrimitive(); + clazz.isSynthetic(); + clazz.toString(); + clazz.toGenericString(); + clazz.getResource("hi"); + clazz.getResourceAsStream("hi"); + // Check point 2: when call newInstance, start class initialization + if (result.toString().compareTo("") == 0) { + clazz.newInstance(); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitClassNewInstance.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitClassNewInstance.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitClassNewInstance.result.append("One"); + } + String what = "lala"; + public String hi = ""; + One(){} + public One(String s){ + what = s; + System.out.println(s); + } + public int testOne(String a){ + System.out.println(a); + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitClassNewInstance.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitClassNewInstance.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/expected.txt b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/maple.prof b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ab74fad4735046e305e394d5486aa7424f4daddd Binary files /dev/null and b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/test.cfg b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1974ad87773ecfe146c71bf0377301c6a3974b0d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0143-rt-compact-ClinitClassNewInstance/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitClassNewInstance) +run(ClassInitClassNewInstance) diff --git a/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java new file mode 100755 index 0000000000000000000000000000000000000000..43188d985c6ab58e0c37ded17d66cd57a577817e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +public class ClassInitConstructorNewInstance { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Constructor constructor = clazz.getConstructor(String.class); + //check point 1: calling following methods, class not initialized + constructor.equals(constructor); + constructor.getAnnotation(A.class); + constructor.getDeclaredAnnotations(); + constructor.getDeclaringClass(); + constructor.getExceptionTypes(); + constructor.getGenericExceptionTypes(); + constructor.getGenericParameterTypes(); + constructor.getModifiers(); + constructor.getName(); + constructor.getParameterAnnotations(); + constructor.getParameterCount(); + constructor.getParameterTypes(); + constructor.hashCode(); + constructor.isSynthetic(); + constructor.isVarArgs(); + constructor.toString(); + constructor.toGenericString(); + //check point 2: after call newInstance(), class initialized + if (result.toString().compareTo("") == 0) { + constructor.newInstance("newInstance"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitConstructorNewInstance.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitConstructorNewInstance.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitConstructorNewInstance.result.append("One"); + } + String what = "lala"; + One(){} + public One(String s){ + what = s; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitConstructorNewInstance.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitConstructorNewInstance.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/expected.txt b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/maple.prof b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a2b01f6b43dbaa564b55e6a619e5bb954e2116cc Binary files /dev/null and b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/test.cfg b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..25a361f0733633a7600320725e5240ddee4649c0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0144-rt-compact-ClinitConstructorNewInstance/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitConstructorNewInstance) +run(ClassInitConstructorNewInstance) diff --git a/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..22859f3cb37183fc8555fe2c7eb686ca7b7a917c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetBooleanStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.getBoolean(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetBooleanStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetBooleanStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetBooleanStatic.result.append("One"); + } + public static boolean hiBoolean = false; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetBooleanStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetBooleanStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/expected.txt b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/maple.prof b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..bdf0dcb8b451dc9bc954905a2ece47ce52bb59c5 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/test.cfg b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2099f29be693892bcb9ec921a7cca301e1f49f0f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0145-rt-compact-ClinitFieldGetBooleanStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetBooleanStatic) +run(ClassInitFieldGetBooleanStatic) diff --git a/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..ee32596a5ad26e3d3c7ebde22ab652397226f83b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetByteStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.getByte(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetByteStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetByteStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetByteStatic.result.append("One"); + } + public static byte hiByte = (byte)0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetByteStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetByteStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/expected.txt b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/maple.prof b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..52104d1b2988a8b077a8dd87275b30774e0feb5b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/test.cfg b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f0bcec95178ff2c19752941b1ba34fcf411d4074 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0146-rt-compact-ClinitFieldGetByteStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetByteStatic) +run(ClassInitFieldGetByteStatic) diff --git a/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..773e6fb668cc67dacda74bc6d8acf13c7845aaf2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetCharStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.getChar(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetCharStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetCharStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetCharStatic.result.append("One"); + } + public static char hiChar = (char)45; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetCharStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetCharStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/expected.txt b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/maple.prof b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..8d507e96a53e0e8ca3f60d57039e6e501c7c7c9a Binary files /dev/null and b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/test.cfg b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..607f0c6737cd6ac740ada174adc712637dffcb62 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0147-rt-compact-ClinitFieldGetCharStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetCharStatic) +run(ClassInitFieldGetCharStatic) diff --git a/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..7c3fd33b685d1c44bb5695db839ddf38cb5d94b0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetDoubleStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.getDouble(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetDoubleStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetDoubleStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetDoubleStatic.result.append("One"); + } + public static double hiDouble = 4.5; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetDoubleStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetDoubleStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/expected.txt b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/maple.prof b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..84e88ad6756d015aea91f08ed92edd7e50763df9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/test.cfg b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc534102a0c50cc0e6ca714d9ce35566f6aafe04 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0148-rt-compact-ClinitFieldGetDoubleStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetDoubleStatic) +run(ClassInitFieldGetDoubleStatic) diff --git a/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..bf25f361c715e3796989955d071653bfde338c8c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetFloatStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.getFloat(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetFloatStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetFloatStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetFloatStatic.result.append("One"); + } + public static float hiFloat = 0.25f; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetFloatStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetFloatStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/expected.txt b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/maple.prof b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5457e15323328a2af64349508f3256544f2311af Binary files /dev/null and b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/test.cfg b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f5e98566242a11ee81668c3536656515aaf775b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0149-rt-compact-ClinitFieldGetFloatStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetFloatStatic) +run(ClassInitFieldGetFloatStatic) diff --git a/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..235d4b1fbc3a38e2227301d715716b3ce227dfbd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetIntStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.getInt(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetIntStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetIntStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetIntStatic.result.append("One"); + } + public static int hiInt = 0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetIntStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetIntStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/expected.txt b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/maple.prof b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..22d956ee7716377cf6402e6702ae679596be87c6 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/test.cfg b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46499c2a920987329489fdf526c3e14d4a7a211b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0150-rt-compact-ClinitFieldGetIntStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetIntStatic) +run(ClassInitFieldGetIntStatic) diff --git a/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..cd0d9514caebd6bf678120db2db2d7db4394624d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetLongStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.getLong(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetLongStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetLongStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetLongStatic.result.append("One"); + } + public static long hiLong = 4859l; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetLongStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetLongStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/expected.txt b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/maple.prof b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a5e845268fd172dca84696fc6605b3f12bb3e0f9 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/test.cfg b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..afe14aec272391c4c16841b7e1b59bee48e1f1f8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0151-rt-compact-ClinitFieldGetLongStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetLongStatic) +run(ClassInitFieldGetLongStatic) diff --git a/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..5329320a1f5ebd3f0049d6a6fc591ad22d917f58 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetShortStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.getShort(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetShortStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetShortStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetShortStatic.result.append("One"); + } + public static short hiShort = 48; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetShortStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetShortStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/expected.txt b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/maple.prof b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f181b24c76180624382eb30c3e5a0503cfe3f1be Binary files /dev/null and b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/test.cfg b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..11a217d81fcd445412385c7463a64939adc01311 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0152-rt-compact-ClinitFieldGetShortStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetShortStatic) +run(ClassInitFieldGetShortStatic) diff --git a/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/ClassInitFieldGetStatic.java b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/ClassInitFieldGetStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..819bfa169e26808d81670b8095020680e91af300 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/ClassInitFieldGetStatic.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +public class ClassInitFieldGetStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + String fValue = ""; + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + fValue = (String)f.get(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0 && fValue.compareTo("hi") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetStatic.result.append("One"); + } + public static String hi = "hi"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/expected.txt b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/maple.prof b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..76a3877ba7a4348fb05dec49aa1384c1c4f5cc99 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/test.cfg b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e51cb828f8e89d7fe47c5659aeda253c43a9a2df --- /dev/null +++ b/testsuite/java_test/compact_test/RT0153-rt-compact-ClinitFieldGetStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetStatic) +run(ClassInitFieldGetStatic) diff --git a/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java new file mode 100755 index 0000000000000000000000000000000000000000..df55352820b73d755401811d1e2e38a99def6707 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldOtherMethod { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + f.equals(f); + f.getAnnotation(B.class); + f.getAnnotationsByType(B.class); + f.getDeclaredAnnotations(); + f.getDeclaringClass(); + f.getGenericType(); + f.getModifiers(); + f.getName(); + f.getType(); + f.hashCode(); + f.isEnumConstant(); + f.isSynthetic(); + f.toGenericString(); + f.toString(); + } catch (Exception e) { + System.out.println(e); + } + if(result.toString().compareTo("") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldOtherMethod.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldOtherMethod.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldOtherMethod.result.append("One"); + } + @B("hello") + public static String hi = "value"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldOtherMethod.result.append("|InterfaceA|").toString(); +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@interface B{ + String value() default "hi"; +} +class Two extends One { + static { + ClassInitFieldOtherMethod.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/expected.txt b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/maple.prof b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..0d2d2d2980e4b97da46bd914447ac0202156498d Binary files /dev/null and b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/test.cfg b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e732c328c09f173dee225a6f5da848150e715507 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0154-rt-compact-ClinitFieldOtherMethod/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldOtherMethod) +run(ClassInitFieldOtherMethod) diff --git a/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..508e9f0f0c51568b11576b47510274442c2e9def --- /dev/null +++ b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetBooleanStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.setBoolean(null, false); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetBooleanStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetBooleanStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetBooleanStatic.result.append("One"); + } + String what = "lala"; + public static boolean hiBoolean = false; + One(){} + public One(String s){ + what = s; + System.out.println(s); + } + public int testOne(String a){ + System.out.println(a); + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetBooleanStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetBooleanStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/expected.txt b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/maple.prof b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..594cdfa2d24d54413aaf55cb05cd3f98aa8d8318 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/test.cfg b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06efaf3974a352b8f6a571a4fd82a232005fd619 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0155-rt-compact-ClinitFieldSetBooleanStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetBooleanStatic) +run(ClassInitFieldSetBooleanStatic) diff --git a/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..1223281b7d096e167515c4c496e67496e8ba9820 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetByteStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.setByte(null, (byte)1); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetByteStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetByteStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetByteStatic.result.append("One"); + } + public static byte hiByte = (byte)0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetByteStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetByteStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/expected.txt b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/maple.prof b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..0ee2cabb73e9105032568e4eaa46e989f23a484f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/test.cfg b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f13f3770322e8216edb0dcc9cf7d913f3826ae46 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0156-rt-compact-ClinitFieldSetByteStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetByteStatic) +run(ClassInitFieldSetByteStatic) diff --git a/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..2063f11bad479e8ecc775f03d83221973a713d5b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetCharStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.setChar(null, (char)1); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetCharStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetCharStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetCharStatic.result.append("One"); + } + public static char hiChar = (char)45; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetCharStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetCharStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/expected.txt b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/maple.prof b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..1aeb275c3e1af5b2ea02f59e4c7caf8629fec7b5 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/test.cfg b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2fa8ac2248e976ba9330a76c955b7914393e9e73 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0157-rt-compact-ClinitFieldSetCharStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetCharStatic) +run(ClassInitFieldSetCharStatic) diff --git a/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..a41a577099b6269475a56dcdede923ced70bc629 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetDoubleStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.setDouble(null, 0.2589); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetDoubleStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetDoubleStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetDoubleStatic.result.append("One"); + } + public static double hiDouble = 4.5; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetDoubleStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetDoubleStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/expected.txt b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/maple.prof b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..f29a113b91fbacb7fd26ea0a050f21a6527bb5bf Binary files /dev/null and b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/test.cfg b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60060498b3dd722f45d5320c8307a4a631a2c8c3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0158-rt-compact-ClinitFieldSetDoubleStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetDoubleStatic) +run(ClassInitFieldSetDoubleStatic) diff --git a/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..89101036bc7eae5998d05bcedd0311bea7c20940 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetFloatStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.setFloat(null, 0.2589f); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetFloatStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetFloatStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetFloatStatic.result.append("One"); + } + public static float hiFloat = 0.25f; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetFloatStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetFloatStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/expected.txt b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/maple.prof b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fc1c2cdf27c79eb0843f7c1bca82f6c60a4d7a1b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/test.cfg b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..613dd74deb12ef27a97c26a0b23c27020112ec19 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0159-rt-compact-ClinitFieldSetFloatStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetFloatStatic) +run(ClassInitFieldSetFloatStatic) diff --git a/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..28c8dce2017371a6f9aecb71e16de89be751dc0c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetIntStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.setInt(null, 25); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetIntStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetIntStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetIntStatic.result.append("One"); + } + public static int hiInt = 0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetIntStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetIntStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/expected.txt b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/maple.prof b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..54b270055f4f6024697914b92445c2a19e4cc331 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/test.cfg b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c2d4510413fcd37d0839f4c5fb591bf85abc4ad3 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0160-rt-compact-ClinitFieldSetIntStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetIntStatic) +run(ClassInitFieldSetIntStatic) diff --git a/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..b91898581c835c128011fbf980030c6290865583 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetLongStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.setLong(null, 25l); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetLongStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetLongStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetLongStatic.result.append("One"); + } + public static long hiLong = 4859l; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetLongStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetLongStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/expected.txt b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/maple.prof b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c3aca0e10b09ed707d697d9f33c85dd14dd51c83 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/test.cfg b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..445b38a8eed543cdc19d7d361b934f0788a361d7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0161-rt-compact-ClinitFieldSetLongStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetLongStatic) +run(ClassInitFieldSetLongStatic) diff --git a/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..6f90973512f88927a2b20647c3efd360583afbfb --- /dev/null +++ b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetShortStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.setShort(null, (short)25); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetShortStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetShortStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetShortStatic.result.append("One"); + } + public static short hiShort = 48; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetShortStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetShortStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/expected.txt b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/maple.prof b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..451e795c411f2cf01bc0f60fb105251a0d4969cc Binary files /dev/null and b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/test.cfg b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6547b397f9e7d3d651c50e0628d6231c2b27df13 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0162-rt-compact-ClinitFieldSetShortStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetShortStatic) +run(ClassInitFieldSetShortStatic) diff --git a/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/ClassInitFieldSetStatic.java b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/ClassInitFieldSetStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..11407e69bb17c706dc416fbf491c67a570777e7e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/ClassInitFieldSetStatic.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.set(null, "what"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetStatic.result.append("One"); + } + public static String hi = "hi"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/expected.txt b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/maple.prof b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..2b27332d72e603c2f9be28270b7fdfdc15f698fa Binary files /dev/null and b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/test.cfg b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8fbc5aa95cfeea763b6239afab5b9aa7ca1cf946 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0163-rt-compact-ClinitFieldSetStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetStatic) +run(ClassInitFieldSetStatic) diff --git a/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..56b013962bce7e95bc27d59e9ab171310095fb54 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +public class ClassInitMethodInvokeStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Method m = clazz.getDeclaredMethod("testOne", String.class); + // Check point 1: calling following methods, class not initialized. + m.equals(m); + m.getAnnotation(A.class); + m.getDeclaredAnnotations(); + m.getDeclaringClass(); + m.getDefaultValue(); + m.getExceptionTypes(); + m.getGenericExceptionTypes(); + m.getGenericParameterTypes(); + m.getGenericReturnType(); + m.getModifiers(); + m.getName(); + m.getParameterAnnotations(); + m.getParameterCount(); + m.getParameterTypes(); + m.getReturnType(); + m.getTypeParameters(); + m.hashCode(); + m.isBridge(); + m.isDefault(); + m.isSynthetic(); + m.isVarArgs(); + m.toString(); + m.toGenericString(); + // Check point 2: after newInstance, class initialized. + if (result.toString().compareTo("") == 0) { + m.invoke(null, "hi"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitMethodInvokeStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitMethodInvokeStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitMethodInvokeStatic.result.append("One"); + } + public static int testOne(String a){ + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitMethodInvokeStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitMethodInvokeStatic.result.append("Two"); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/expected.txt b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/maple.prof b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..e7f2a82b283dc49a43f0c044e1615de79a0b2451 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/test.cfg b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e3f46cd636e5232a3bf5863a2c20dfd7dd998450 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0164-rt-compact-ClinitMethodInvokeStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitMethodInvokeStatic) +run(ClassInitMethodInvokeStatic) diff --git a/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..52bb177ed5fe44f1ed48d1d4788e6bf149547abd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetBooleanInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.getBoolean(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetBooleanInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetBooleanInterface.result.append("One").toString(); + boolean hiBoolean = false; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetBooleanInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetBooleanInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/expected.txt b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/maple.prof b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..738d92b88054332b9f2dc9b19fe365611b801128 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/test.cfg b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..124c9cff27d3f489653b77f8612abd1245b144be --- /dev/null +++ b/testsuite/java_test/compact_test/RT0165-rt-compact-ClinitFieldGetBooleanInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetBooleanInterface) +run(ClassInitFieldGetBooleanInterface) diff --git a/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..ab9a8fb4e4935d77ea4f7b72d5ed2e0da0688f22 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetByteInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.getByte(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetByteInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetByteInterface.result.append("One").toString(); + byte hiByte = (byte)1; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetByteInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetByteInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/expected.txt b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/maple.prof b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..e811b56ac8e431cb446f4f34e85e5effd9885a05 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/test.cfg b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3a8eb14296f74ec9d6795760985abafef4f11ea7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0166-rt-compact-ClinitFieldGetByteInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetByteInterface) +run(ClassInitFieldGetByteInterface) diff --git a/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..e676411c9569942bf28312214c2fb9d5aef8cb13 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetCharInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.getChar(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetCharInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetCharInterface.result.append("One").toString(); + char hiChar = (char)45; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetCharInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetCharInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/expected.txt b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/maple.prof b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fe354ed637d305aad97babd1fba141fd317eade6 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/test.cfg b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4812994d404ec302f3840e09dfd4027590337074 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0167-rt-compact-ClinitFieldGetCharInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetCharInterface) +run(ClassInitFieldGetCharInterface) diff --git a/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..d4e17c4d41882052b243008baef8a25bf764e13f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetDoubleInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.getDouble(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetDoubleInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetDoubleInterface.result.append("One").toString(); + double hiDouble = 0.1532; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetDoubleInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetDoubleInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/expected.txt b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/maple.prof b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c9fa68a8c7617a1d8b94e653a856c9d4570610e3 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/test.cfg b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cfb69664aeddd9f74586b319c204cd5ac6e93090 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0168-rt-compact-ClinitFieldGetDoubleInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetDoubleInterface) +run(ClassInitFieldGetDoubleInterface) diff --git a/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..9822ef1d728aac8efcd0166b6104e614ca8ee778 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetFloatInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.getFloat(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetFloatInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetFloatInterface.result.append("One").toString(); + float hiFloat = 0.25f; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetFloatInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetFloatInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/expected.txt b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/maple.prof b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..086fbf8f9ba15b096712a448ff6f2cc5e79bd59f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/test.cfg b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c46b7b457ed0baf8108d7a2286c05d226cc62073 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0169-rt-compact-ClinitFieldGetFloatInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetFloatInterface) +run(ClassInitFieldGetFloatInterface) diff --git a/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/ClassInitFieldGetInterface.java b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/ClassInitFieldGetInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..03b692a3bf91ffcf6a68597e616c35000dbcb2fd --- /dev/null +++ b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/ClassInitFieldGetInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.get(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetInterface.result.append("One").toString(); + String hi = "hiField"; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/expected.txt b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/maple.prof b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..5f03bddbb01e3a4d32c366670c46f31e4dadb8f7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/test.cfg b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dc1fee4b22cd92f9295a3cb24a96f48d9258ea20 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0170-rt-compact-ClinitFieldGetInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetInterface) +run(ClassInitFieldGetInterface) diff --git a/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..b62d582a229462110083228bf6eeb35899515acf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetIntInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.getInt(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetIntInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetIntInterface.result.append("One").toString(); + int hiInt = 125; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetIntInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetIntInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/expected.txt b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/maple.prof b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..115e270885d6d455632c9e54714dac61fd373aea Binary files /dev/null and b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/test.cfg b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e0af09c702d64eec6799483e866bebaad36accf0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0171-rt-compact-ClinitFieldGetIntInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetIntInterface) +run(ClassInitFieldGetIntInterface) diff --git a/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..10374aff55406ae75bc661de436da26d51996539 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetLongInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.getLong(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetLongInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetLongInterface.result.append("One").toString(); + long hiLong = 4859l; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetLongInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetLongInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/expected.txt b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/maple.prof b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..e80a274ac9770849cc1a09960c328a79af6cf307 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/test.cfg b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c4a59df5021deb0ccef8a2d419cf7b8ad336347 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0172-rt-compact-ClinitFieldGetLongInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetLongInterface) +run(ClassInitFieldGetLongInterface) diff --git a/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..e781980e191f96ac66edc44b2bbc9eb77a636ffb --- /dev/null +++ b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetShortInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.getShort(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetShortInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetShortInterface.result.append("One").toString(); + short hiShort = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetShortInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetShortInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/expected.txt b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/maple.prof b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..d777cbda119bdda66d74df796b285348711a52f2 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/test.cfg b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f8d73542adb7dde372dadddbe0074e3b99ea28e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0173-rt-compact-ClinitFieldGetShortInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetShortInterface) +run(ClassInitFieldGetShortInterface) diff --git a/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..fa3d881a8df0db4a9fac96824d56733775ea1ae2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldOtherMethodInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + f.equals(f); + f.getAnnotation(A.class); + f.getAnnotationsByType(A.class); + f.getDeclaredAnnotations(); + f.getDeclaringClass(); + f.getGenericType(); + f.getModifiers(); + f.getName(); + f.getType(); + f.hashCode(); + f.isEnumConstant(); + f.isSynthetic(); + f.toGenericString(); + f.toString(); + } catch (Exception e) { + System.out.println(e); + } + if(result.toString().compareTo("") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldOtherMethodInterface.result.append("Super").toString(); +} +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldOtherMethodInterface.result.append("One").toString(); + @A + short hi = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldOtherMethodInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldOtherMethodInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/expected.txt b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/maple.prof b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..fa247c97c257a0391181aac3bc05dcc3da73350e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/test.cfg b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1febba627f87de8fc07e5025a7c22b2636c41ca8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0174-rt-compact-ClinitFieldOtherMethodInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldOtherMethodInterface) +run(ClassInitFieldOtherMethodInterface) diff --git a/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..75c21a2cb5f60ae9d9848c267c0406612a8cf03e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetBooleanInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.setBoolean(null, true); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetBooleanInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetBooleanInterface.result.append("One").toString(); + boolean hiBoolean = false; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetBooleanInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetBooleanInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/expected.txt b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/maple.prof b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..6eedb8817e29294e89f45a5b13b32c172bff1830 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/test.cfg b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eccb561d025f20868cfba9e7870fd5aa2fdc3d8b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0175-rt-compact-ClinitFieldSetBooleanInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetBooleanInterface) +run(ClassInitFieldSetBooleanInterface) diff --git a/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..d79a20b195087acdaca4d67bcfe692dca857228b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetByteInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.setByte(null, (byte)0); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetByteInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetByteInterface.result.append("One").toString(); + byte hiByte = (byte)1; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetByteInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetByteInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/expected.txt b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/maple.prof b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..36824c084dd45fe4c73433aed279daaff554dd2e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/test.cfg b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..87b2d92832883e427078bc33eb113f6d91165ee0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0176-rt-compact-ClinitFieldSetByteInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetByteInterface) +run(ClassInitFieldSetByteInterface) diff --git a/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..24dd6cf65ca4cd138ad1c7ff180985f69395192b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetFloatInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.setFloat(null, 0.654f); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetFloatInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetFloatInterface.result.append("One").toString(); + float hiFloat = 0.25f; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetFloatInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetFloatInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/expected.txt b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/maple.prof b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..e0738f89b3fc6c3e240f12e908c40f8446d12506 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/test.cfg b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..286cb316d0ba00e807e834c56a39fd6c3b634084 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0177-rt-compact-ClinitFieldSetFloatInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetFloatInterface) +run(ClassInitFieldSetFloatInterface) diff --git a/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/ClassInitFieldSetInterface.java b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/ClassInitFieldSetInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..d3a2c2d5cf6633b6ed4ba3ae5a3f0d879a1caf61 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/ClassInitFieldSetInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.set(null, "newString"); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetInterface.result.append("One").toString(); + String hi = "hiField"; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/expected.txt b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/maple.prof b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ca7ab9c5d6bfe28709f89b4e6b1f394ccc39736b Binary files /dev/null and b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/test.cfg b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e962f1c79619a14be9fcdf201830489624173a4a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0178-rt-compact-ClinitFieldSetInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetInterface) +run(ClassInitFieldSetInterface) diff --git a/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..3d41dbdaa7ca9452431ad025ffe20a5c92ba5bf5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetIntInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.setInt(null, 98); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetIntInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetIntInterface.result.append("One").toString(); + int hiInt = 125; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetIntInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetIntInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/expected.txt b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/maple.prof b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a7784e399729d698bdd8965d1a3b7f603df958bf Binary files /dev/null and b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/test.cfg b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b98d7f9f68ebdea47b18abff533a8be416dfeef8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0179-rt-compact-ClinitFieldSetIntInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetIntInterface) +run(ClassInitFieldSetIntInterface) diff --git a/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..62ca4b007746cc226dccbeabea43f4912bdc0dc5 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetLongInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.setLong(null, 7456l); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetLongInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetLongInterface.result.append("One").toString(); + long hiLong = 4859l; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetLongInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetLongInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/expected.txt b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/maple.prof b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..b377bffc689254d4b104c6faec7e059397d023e7 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/test.cfg b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b800b479fa19149ce402c021d916f008c210ad82 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0180-rt-compact-ClinitFieldSetLongInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetLongInterface) +run(ClassInitFieldSetLongInterface) diff --git a/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..7a2949b124f3ae6bd325a92116bd2cbd42082051 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetShortInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.setShort(null, (short)124); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetShortInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetShortInterface.result.append("One").toString(); + short hiShort = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetShortInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetShortInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/expected.txt b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/maple.prof b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..6d8d8dd0fb5300d392f0eab1a5f4f2cdd0b68fdf Binary files /dev/null and b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/test.cfg b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6153336cd572a7c6e066044b7634c659d01f6a9e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0181-rt-compact-ClinitFieldSetShortInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetShortInterface) +run(ClassInitFieldSetShortInterface) diff --git a/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..95f3596dcee61fa113912d76b0f779f050187df7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class ClassInitMethodInvokeInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Method m = clazz.getDeclaredMethod("runInterface", String.class); + //check point 1: calling following methods, class not initialized + m.equals(m); + m.getAnnotation(A.class); + m.getDeclaredAnnotations(); + m.getDeclaringClass(); + m.getDefaultValue(); + m.getExceptionTypes(); + m.getGenericExceptionTypes(); + m.getGenericParameterTypes(); + m.getGenericReturnType(); + m.getModifiers(); + m.getName(); + m.getParameterAnnotations(); + m.getParameterCount(); + m.getParameterTypes(); + m.getReturnType(); + m.getTypeParameters(); + m.hashCode(); + m.isBridge(); + m.isDefault(); + m.isSynthetic(); + m.isVarArgs(); + m.toString(); + m.toGenericString(); + //check point 2: after newInstance, class initialized + if (result.toString().compareTo("") == 0) { + m.invoke(null, "hi"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneRunInterface") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitMethodInvokeInterface.result.append("Super").toString(); +} +interface OneInterface extends SuperInterface{ + String aOne = ClassInitMethodInvokeInterface.result.append("One").toString(); + @A + static void runInterface(String a){ + ClassInitMethodInvokeInterface.result.append("RunInterface"); + } +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitMethodInvokeInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitMethodInvokeInterface.result.append("Annotation").toString(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/expected.txt b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/maple.prof b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a481097f6a8e96a40b120bbbc50dd13b6b84bb99 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/test.cfg b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2ba74e2e84412e33fd5cccfbc39f200617492db7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0182-rt-compact-ClinitMethodInvokeInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitMethodInvokeInterface) +run(ClassInitMethodInvokeInterface) diff --git a/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/FieldMultiThreadTest.java b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/FieldMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..1c4a71bf0cfcfcbca79061503ed90dcf5184d837 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/FieldMultiThreadTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + fieldMultithread(); + System.out.println(passCnt/executeCnt - 10); + } catch (Exception e) { + System.out.println(e); + } + } + private static int fieldMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThread"); + String[] allFields = new String[] {"charPub", "fieldIntPri", "fieldIntPro", "fieldString"}; + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (String s : allFields) { + Field field = clazz.getDeclaredField(s); + field.setAccessible(true); + } + for (Field f: clazz.getDeclaredFields()) { + f.setAccessible(true); + } + Field field = clazz.getField("charPub"); + field.setAccessible(true); + for (Field f: clazz.getFields()) { + f.setAccessible(true); + } + } + } catch (Exception e) { + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (String s : allFields) { + Field field = clazz.getDeclaredField(s); + passCnt += field.isAccessible()== false ? 1 : 0; + } + for (Field f: clazz.getDeclaredFields()) { + passCnt += f.isAccessible()== false ? 1 : 0; + } + Field field = clazz.getField("charPub"); + passCnt += field.isAccessible()== false ? 1 : 0; + for (Field f: clazz.getFields()) { + passCnt += f.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThread { + public char charPub = 'a'; + private int fieldIntPri = 416; + protected int[] fieldIntPro = {123}; + String fieldString = "hey, hello"; +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/expected.txt b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/maple.prof b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..aaefced92d2cbc274ef79ffc3f30c40b59c512cd Binary files /dev/null and b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/test.cfg b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..878d22ef234f866e229469c49414d7d72d877cc8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0183-rt-compact-FieldMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldMultiThreadTest) +run(FieldMultiThreadTest) diff --git a/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/MethodTest.java b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/MethodTest.java new file mode 100755 index 0000000000000000000000000000000000000000..020bf5dac705259bd9b01e82fa157e35c6dcfc4f --- /dev/null +++ b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/MethodTest.java @@ -0,0 +1,346 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +public class MethodTest { + /** + * Verify that for the same method, different Method object is return when call following API twice: + * - Class.getMethods(), + * - Class.getEnclosingMethod(), + * - Class.getDeclaredMethods(), + * - Class.getMethod(String name, Class... parameterTypes), + * - Class.getDeclaredMethod(String name, Class... parameterTypes), + * if any Method failed the check, will print error message including testcase and method name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllMethodTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getMethods() + Method[] methods1 = clazz.getMethods(); + Method[] methods2 = clazz.getMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 2. Class.getMethod(String name) + Method m1 = clazz.getMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed"); + } + } + // checkpoint 3. Class.getDeclaredMethods() + methods1 = clazz.getDeclaredMethods(); + methods2 = clazz.getDeclaredMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 4. Class.getDeclaredMethod(String name) + Method m1 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for declared method"); + } + } + // checkpoint 5. Class.getEnclosingMethod() + if (clazz.getEnclosingMethod() != null) { + Method m1 = clazz.getEnclosingMethod(); + Method m2 = clazz.getEnclosingMethod(); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for Enclosing method"); + } + } + casesPassed++; + } + private static void checkMethods(Method[] methods1, Method[] methods2) { + for (Method m1: methods1) { + for (Method m2: methods2) { + // only when modifers and class and name is same, two Method object is for same method + if(m1.toString().equals(m2.toString())) { + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(m1.getName()+" failed in checkMethods"); + } + } + } + } + } + private static int singleMethodCheck(Method m1, Method m2) { + int passCnt = 0; + passCnt += m1 == m2 ? 0 : 1; + passCnt += m1.equals(m2) ? 1 : 0; + passCnt += m1.hashCode() == m2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + method01(); + method02(); + method03(); + method04(); + method05(); + method06(); + method07(); + method08(); + method09(); + method10(); + method11(); + System.out.println(casesPassed - 11); + } + + private static void method01() { + try { + classAllMethodTest(Class.forName("java.lang.Thread"), "method01"); + } catch (Exception e) { + System.out.println("Case method01 failed with exception" + e); + } + } + + private static void method02() { + try { + classAllMethodTest(Class.forName("TestMethod02"), "method02"); + } catch (Exception e) { + System.out.println("Case method02 failed with exception" + e); + } + } + + private static void method03() { + try { + classAllMethodTest(Class.forName("TestMethod03"), "method03"); + } catch (Exception e) { + System.out.println("Case method03 failed with exception" + e); + } + } + + private static void method04() { + try { + classAllMethodTest(Class.forName("TestMethod04"), "method04"); + } catch (Exception e) { + System.out.println("Case method04 failed with exception" + e); + } + } + + private static void method05() { + try { + // step 1 + Class clazz = Class.forName("MethodTest"); + MethodTest mainClass = new MethodTest(); + Field method = clazz.getDeclaredField("testMethod05"); + classAllMethodTest(method.get(mainClass).getClass(), "method05"); + } catch (Exception e) { + System.out.println("Case method05 failed with exception" + e); + } + } + private Runnable testMethod05 = new Runnable() { + private final synchronized int intRunnable() { + return 1; + } + @Override + public void run() { + for (int i = 0; i < 10; i++) { + } + } + }; + + private static void method06() { + class TestMethod06 { + private final int intLocalMethod() { + return 9; + } + public synchronized String stringLocal() { + return "a fake behind the fear"; + } + } + try { + classAllMethodTest(Class.forName("MethodTest$1TestMethod06"), "method06"); + } catch (Exception e) { + System.out.println("Case method06 failed with exception" + e); + } + } + + private static void method07() { + try { + classAllMethodTest(Class.forName("MethodTest$TestMethod07"), "method07"); + } catch (Exception e) { + System.out.println("Case method07 failed with exception" + e); + } + } + class TestMethod07 { + private char charInnerMethod(int a, double... b) { + return 'l'; + } + final public double doubleInnerMethod() { + return 1988.0416; + } + } + + private static void method08() { + try { + classAllMethodTest(Class.forName("TestMethod08"), "method08"); + } catch (Exception e) { + System.out.println("Case method08 failed with exception" + e); + } + } + + private static void method09() { + try { + classAllMethodTest(Class.forName("TestMethod09"), "method09"); + } catch (Exception e) { + System.out.println("Case method09 failed with exception" + e); + } + } + + private static void method10() { + try { + classAllMethodTest(Class.forName("TestMethod10"), "method10"); + } catch (Exception e) { + System.out.println("Case method10 failed with exception" + e); + } + } + + private static void method11() { + try { + classAllMethodTest(Class.forName("TestMethod11"), "method11"); + } catch (Exception e) { + System.out.println("Case method11 failed with exception" + e); + } + } +} +class TestMethod02 { + // step1 + void voidMethod() {} + boolean booleanMethod() { + return true; + } + byte byteMethod() { + return (byte)1; + } + short shortMethod() { + return (short)2; + } + int intMethod() { + return 3; + } + long longMethod() { + return 4l; + } + char charMethod() { + return 'a'; + } + float floatMethod() { + return 0.9f; + } + double doubleMethod() { + return 0.416; + } + String stringMethod() { + return "The queerest of the queer"; + } + Runnable[] rArrayMethod() { + return null; + } + boolean[][][][][][][] booleanArray7Method() { + return new boolean[][][][][][][] {{{{{{{true, false}}}}}}}; + } + String[][][] stringArray3Method() { + return new String[][][] {{{"the strangest of the strange"}}}; + } + int parameterMethod(boolean a, byte b, short c, int d, long e, char f, float g, double h, + boolean[] aa, byte[] bb, short[] cc, int[] dd, long[] ee, char[] ff, float[] gg, double[] hh, + String i, String[][][] iii, Runnable j, Byte k, Double l, Thread.State m, int... o) { + return 1; + } + // step2 + public int publicIntMethod(boolean a) { + return 88; + } + protected double protectedDoubleMethod(byte a) { + return 99; + } + private String privateStringMethod(String a) { + return "the coldest of the cool"; + } + // step3 + strictfp double[][] transientDoubleArrayMethod(float[][] a) { + return new double[][] {{1988, 4.16}}; + } + final int finalIntMethod() { + return 9876; + } + synchronized String volatileStringMethod() { + return "the lamest of the lame"; + } + static Character staticCharacterMethod(Thread.State a) { + return 'd'; + } + //step 4 + @Deprecated + String[][] stringsAnnotationMethod() { + return new String[][] {{"the numbest of the dumb"}}; + } +} +interface TestMethod03 { + String stringInterfaceMethod(int[] a); + char[][][] charArrayInterfaceMethod(double... a); +} +abstract class TestMethod04 { + public static final synchronized String[] stringsAbstractArrayMethod() { + return new String[] {"i hate to see you here", "you choke behind a smile"}; + } + abstract Runnable runnableAbstractMethod(); +} +enum TestMethod08 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + private static short shortEnumMethod() { + return (short)6; + } + public final String stringEnumMethod(int... a) { + return "Dry Martini"; + } +} +class TestMethod09 { + public int int09Method() { + return 1; + } + protected boolean boolean09Method() { + return false; + } + char[] chars09Method() { + return new char[] {'a', 'b', 'c'}; + } + private String string09Method() { + return "I'm only happy when it rains"; + } +} +class TestMethod10 extends TestMethod09 implements TestMethod11 { + public boolean boolean09Method() { + return true; + } + public double double10Method() { + return 0.416; + } + public char[] chars09Method() { + return new char[] {'a'}; + } + public String string09Method() { + return "SHALALALA"; + } +} +interface TestMethod11 { + int int09Method(); + boolean boolean09Method(); + char[] chars09Method(); + String string09Method(); +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/expected.txt b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/maple.prof b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..773fd5f0662b3bf45ff217942250818c733ba05f Binary files /dev/null and b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/test.cfg b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b52fd6d6794c91a5ade7d178fd2ec9cab17d13ea --- /dev/null +++ b/testsuite/java_test/compact_test/RT0184-rt-compact-MethodTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodTest) +run(MethodTest) diff --git a/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/MethodMultiThreadTest.java b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/MethodMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..203a6f1510813a0e76ef2c167729bd7351b4d342 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/MethodMultiThreadTest.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + methodMultithread(); + System.out.println(passCnt/executeCnt - 28); + } catch (Exception e) { + System.out.println(e); + } + } + private static int methodMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThreadM"); + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (Method m: clazz.getDeclaredMethods()) { + m.setAccessible(true); + Method method = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + method.setAccessible(true); + } + for (Method m: clazz.getMethods()) { + m.setAccessible(true); + Method method = clazz.getMethod(m.getName(), m.getParameterTypes()); + method.setAccessible(true); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (Method m: clazz.getDeclaredMethods()) { + passCnt += m.isAccessible()== false ? 1 : 0; + Method method = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + passCnt += method.isAccessible()== false ? 1 : 0; + } + for (Method m: clazz.getMethods()) { + passCnt += m.isAccessible()== false ? 1 : 0; + Method method = clazz.getMethod(m.getName(), m.getParameterTypes()); + passCnt += method.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThreadM { + public char charPubMethod(int... a) { + return 'a'; + } + private int intPriMethod() { + return 416; + } + protected int[] intProMethod(Double... b) { + return new int[] {123}; + } + String stringMethod() { + return "hey, hello"; + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/expected.txt b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/maple.prof b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..e41d19f9a11af20f5e2bbf5ef5bbe79c0d209339 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/test.cfg b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..98b348fceadc609093a1bb0cc57cfab58722659c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0185-rt-compact-MethodMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodMultiThreadTest) +run(MethodMultiThreadTest) diff --git a/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/ConstructorTest.java b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/ConstructorTest.java new file mode 100755 index 0000000000000000000000000000000000000000..293d509f55e6573a2ddf40082faae8ad497a5b0a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/ConstructorTest.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Constructor; +public class ConstructorTest { + /** + * Verify that for the same constructor, different Constructor object is return when call following API twice: + * - Class.getConstructors(), + * - Class.getEnclosingConstructor(), + * - Class.getDeclaredConstructors(), + * - Class.getConstructor(String name, Class... parameterTypes), + * - Class.getDeclaredConstructor(String name, Class... parameterTypes), + * if any Constructor failed the check, will print error message including testcase and constructor name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllConstructorTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getConstructors() + Constructor[] constructors1 = clazz.getConstructors(); + Constructor[] constructors2 = clazz.getConstructors(); + checkConstructors(constructors1, constructors2); + for (Constructor c : constructors1) { + // checkpoint 2. Class.getConstructor(String name) + Constructor c1 = clazz.getConstructor(c.getParameterTypes()); + Constructor c2 = clazz.getConstructor(c.getParameterTypes()); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed"); + } + } + // checkpoint 3. Class.getDeclaredConstructors() + constructors1 = clazz.getDeclaredConstructors(); + constructors2 = clazz.getDeclaredConstructors(); + checkConstructors(constructors1, constructors2); + for (Constructor c : constructors1) { + // checkpoint 4. Class.getDeclaredConstructor(String name) + Constructor c1 = clazz.getDeclaredConstructor(c.getParameterTypes()); + Constructor c2 = clazz.getDeclaredConstructor(c.getParameterTypes()); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed for declared constructor"); + } + } + // checkpoint 5. Class.getEnclosingConstructor() + if (clazz.getEnclosingConstructor() != null) { + Constructor c1 = clazz.getEnclosingConstructor(); + Constructor c2 = clazz.getEnclosingConstructor(); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed for Enclosing constructor"); + } + } + casesPassed++; + } + private static void checkConstructors(Constructor[] constructors1, Constructor[] constructors2) { + for (Constructor c1: constructors1) { + for (Constructor c2: constructors2) { + // only when modifers and class and name is same, two Constructor object is for same constructor + if(c1.toString().equals(c2.toString())) { + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(c1.getName()+" failed in checkConstructors"); + } + } + } + } + } + private static int singleConstructorCheck(Constructor c1, Constructor c2) { + int passCnt = 0; + passCnt += c1 == c2 ? 0 : 1; + passCnt += c1.equals(c2) ? 1 : 0; + passCnt += c1.hashCode() == c2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + constructor01(); + constructor02(); + constructor03(); + constructor04(); + constructor05(); + constructor06(); + constructor07(); + constructor08(); + constructor09(); + constructor10(); + constructor11(); + System.out.println(casesPassed - 11); + } + + private static void constructor01() { + try { + classAllConstructorTest(Class.forName("java.lang.Thread"), "constructor01"); + } catch (Exception e) { + System.out.println("Case constructor01 failed with exception" + e); + } + } + + private static void constructor02() { + try { + classAllConstructorTest(Class.forName("TestConstructor02"), "constructor02"); + } catch (Exception e) { + System.out.println("Case constructor02 failed with exception" + e); + } + } + + private static void constructor03() { + try { + classAllConstructorTest(Class.forName("TestConstructor03"), "constructor03"); + } catch (Exception e) { + System.out.println("Case constructor03 failed with exception" + e); + } + } + + private static void constructor04() { + try { + classAllConstructorTest(Class.forName("TestConstructor04"), "constructor04"); + } catch (Exception e) { + System.out.println("Case constructor04 failed with exception" + e); + } + } + + private static void constructor05() { + try { + Class clazz = Class.forName("ConstructorTest"); + ConstructorTest mainClass = new ConstructorTest(); + Field constructor = clazz.getDeclaredField("testConstructor05"); + classAllConstructorTest(constructor.get(mainClass).getClass(), "constructor05"); + } catch (Exception e) { + System.out.println("Case constructor05 failed with exception" + e); + } + } + private Runnable testConstructor05 = new Runnable() { + @Override + public void run() { + for (int i = 0; i < 10; i++) { + } + } + }; + + private static void constructor06() { + class TestConstructor06 { + private TestConstructor06(int a) { + } + public TestConstructor06(String[][][] a) { + } + } + try { + classAllConstructorTest(Class.forName("ConstructorTest$1TestConstructor06"), "constructor06"); + } catch (Exception e) { + System.out.println("Case constructor06 failed with exception" + e); + } + } + + private static void constructor07() { + try { + classAllConstructorTest(Class.forName("ConstructorTest$TestConstructor07"), "constructor07"); + } catch (Exception e) { + System.out.println("Case constructor07 failed with exception" + e); + } + } + class TestConstructor07 { + private TestConstructor07(int a, double... b) { + } + public TestConstructor07() { + } + } + + private static void constructor08() { + try { + classAllConstructorTest(Class.forName("TestConstructor08"), "constructor08"); + } catch (Exception e) { + System.out.println("Case constructor08 failed with exception" + e); + } + } + + private static void constructor09() { + try { + classAllConstructorTest(Class.forName("TestConstructor09"), "constructor09"); + } catch (Exception e) { + System.out.println("Case constructor09 failed with exception" + e); + } + } + + private static void constructor10() { + try { + classAllConstructorTest(Class.forName("TestConstructor10"), "constructor10"); + } catch (Exception e) { + System.out.println("Case constructor10 failed with exception" + e); + } + } + + private static void constructor11() { + try { + Class clazz = (new TestConstructor11()).c.getClass(); + classAllConstructorTest(clazz, "constructor11"); + } catch (Exception e) { + System.out.println("Case constructor11 failed with exception" + e); + } + } +} +class TestConstructor02 { + // step1 + TestConstructor02() { + } + TestConstructor02(boolean a, byte b, short c, int d, long e, char f, float g, double h, + boolean[] aa, byte[] bb, short[] cc, int[] dd, long[] ee, char[] ff, float[] gg, double[] hh, + String i, String[][][] iii, Runnable j, Byte k, Double l, Thread.State m, int... o) { + } + // step2 + public TestConstructor02(int a) {} + TestConstructor02(byte a) {} + protected TestConstructor02(String a) {} + private TestConstructor02(Runnable[] a) {} + // step3 + @Deprecated + TestConstructor02(int... a) {} +} +strictfp class TestConstructor03 { + public TestConstructor03(float... a) { + } + TestConstructor03(float a, double b) { + } +} +abstract class TestConstructor04 { + public TestConstructor04() { + } + TestConstructor04(int a) { + } +} +enum TestConstructor08 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + TestConstructor08() { + } + TestConstructor08(String a) { + } +} +class TestConstructor09 { + public TestConstructor09() { + } + TestConstructor09(int... a) { + } + protected TestConstructor09(double[] a) { + } + private TestConstructor09(int a) { + } +} +class TestConstructor10 extends TestConstructor09 { + public TestConstructor10() { + } + TestConstructor10(int... a) { + } + protected TestConstructor10(double[] a) { + } + private TestConstructor10(int a) { + } +} +class TestConstructor11 { + public Object c; + public TestConstructor11( ) { + class ClassA { } + c = new ClassA( ); + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/expected.txt b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/maple.prof b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..33a2e3fb511aaba51692f5742a294bed45354382 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/test.cfg b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ccfa3945dcfed7451b625e074f0d76c8aab24c9a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0186-rt-compact-ConstructorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorTest) +run(ConstructorTest) diff --git a/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..6f69eac02fc39b9ee86d759095f9f9d1cb5d94ac --- /dev/null +++ b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +public class ConstructorMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + constructorMultithread(); + System.out.println(passCnt/executeCnt - 10); + } catch (Exception e) { + System.out.println(e); + } + } + private static int constructorMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThreadC"); + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (Constructor c: clazz.getDeclaredConstructors()) { + c.setAccessible(true); + Constructor constructor = clazz.getDeclaredConstructor(c.getParameterTypes()); + constructor.setAccessible(true); + } + for (Constructor c: clazz.getConstructors()) { + c.setAccessible(true); + Constructor constructor = clazz.getConstructor(c.getParameterTypes()); + constructor.setAccessible(true); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (Constructor c: clazz.getDeclaredConstructors()) { + passCnt += c.isAccessible()== false ? 1 : 0; + Constructor constructor = clazz.getDeclaredConstructor(c.getParameterTypes()); + passCnt += constructor.isAccessible()== false ? 1 : 0; + } + for (Constructor c: clazz.getConstructors()) { + passCnt += c.isAccessible()== false ? 1 : 0; + Constructor constructor = clazz.getConstructor(c.getParameterTypes()); + passCnt += constructor.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThreadC { + public TestMultiThreadC(int... a) { + } + private TestMultiThreadC(String a) { + } + protected TestMultiThreadC(Double... a) { + } + TestMultiThreadC() { + } +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/expected.txt b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/maple.prof b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..3000b900c1d80fcf013bec4b66e48ffa06409cfc Binary files /dev/null and b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/test.cfg b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3df0352b8d4255745b1b5821da20b3ec1e930816 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0187-rt-compact-ConstructorMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorMultiThreadTest) +run(ConstructorMultiThreadTest) diff --git a/testsuite/java_test/compact_test/RT0188-rt-compact-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java b/testsuite/java_test/compact_test/RT0188-rt-compact-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c01d422c908c56ac948702c6981bd9e3e5c52755 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0188-rt-compact-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import static java.lang.invoke.MethodHandles.lookup; +import static java.lang.invoke.MethodHandles.reflectAs; +import static java.lang.invoke.MethodType.methodType; +public class MethodHandleReflectCombineTest { + static int passCnt = 0; + private static int singleMethodCheck(T m1, T m2) { + int passCnt = 0; + passCnt += m1 == m2 ? 0 : 1; + passCnt += m1.equals(m2) ? 1 : 0; + passCnt += m1.hashCode() == m2.hashCode() ? 1 : 0; + return passCnt; + } + public static void main(String[] args) { + try { + System.out.println(run()); + } catch (Throwable e) { + e.printStackTrace(); + } + } + private static int run() throws Throwable { + Object[][] testData = new Object[][] { + {Member.class, lookup().findVirtual(String.class, "concat", methodType(String.class, String.class))}, + {Member.class, lookup().findStatic(String.class, "copyValueOf", methodType(String.class, char[].class))}, + {Member.class, RATest.LOOKUP().findSpecial(RATest.class, "mhVar", methodType(int.class, Object[].class), RATest.class)}, + {Constructor.class, lookup().findConstructor(RATest.class, methodType(void.class, int.class))}, + {Constructor.class, lookup().findConstructor(RATest.class, methodType(void.class, double[].class))}, + {Field.class, lookup().findStaticGetter(RATest.class, "svi", int.class)}, + {Field.class, lookup().findStaticSetter(RATest.class, "svi", int.class)}, + {Field.class, RATest.LOOKUP().findGetter(RATest.class, "vd", double.class)}, + {Field.class, lookup().findGetter(RATest.class, "vs", String[].class)}, + {Field.class, lookup().findSetter(RATest.class, "vs", String[].class)} + }; + for (int i = 0; i{ + private T obj; + public void setObj(T obj) { + this.obj = obj; + } + public void say(){ + System.out.println("hello "+obj); + } +} +interface PackageInfoInterface { + void test(); +} +class PackageInfoConst { + public static final String MESSAGE="Annotation Study"; +} diff --git a/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/expected.txt b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/maple.prof b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..36e3cbf01de54ee248146595c824dc35ae92cfed Binary files /dev/null and b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/test.cfg b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a45b78761165f417dc2d535f52e690899c6b5bf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0199-rt-compact-AnnotationPackageSetTest/test.cfg @@ -0,0 +1,6 @@ +clean() +javac com/huawei/*.java +jar -cvf com.huawei.AnnotationPackageSetTest.jar com/ +${OUT_ROOT}/target/product/public/bin/jar2dex -p ${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/core-oj_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/core-libart_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/framework_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/services_intermediates/classes.jar -i com.huawei.AnnotationPackageSetTest.jar +compile(com.huawei.AnnotationPackageSetTest) +run(com.huawei.AnnotationPackageSetTest) diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoA.java b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..5f06bbbee2c53d37e325643d7aad8d49273e72e7 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE_PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoB.java b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java new file mode 100755 index 0000000000000000000000000000000000000000..2b56b10bf3c4d823730b99c7eb7e864c84ea8066 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +public class AnnotationTypeParameterSetTest { + static int[] passCnt; + public static void main(String[] args) { + System.out.println(Test.class.getAnnotations().length); +// TypeVeriable.getAnnotation not supported in ART +/* AnnoA anno = Test.class.getTypeParameters()[0].getAnnotation(AnnoA.class); + passCnt = new int[24]; + // 基本数据类型 + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + //enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + //基本类型数组 + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"));*/ + } +} +class Test<@AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) T> { +} +// DEPENDENCE: AnnoA.java AnnoB.java +// EXEC:%maple %f AnnoA.java AnnoB.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/expected.txt b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/maple.prof b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..2f268376b5074906587a000d126c46dbdd735a68 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/test.cfg b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9be48f11000f5c42aabd320ed592c2821679881d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0200-rt-compact-AnnotationTypeParameterSetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeParameterSetTest) +run(AnnotationTypeParameterSetTest) diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoA.java b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..2104c625abbc58059295356101ddb20286205228 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE_USE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoB.java b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d22082df949761952d83b6beaac2cabd77d5d808 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeUseSetTest { + static int[] passCnt; + public static void main(String[] args) { + System.out.println(Test.class.getAnnotations().length); +/* AnnoA anno = Test.class.getTypeParameters()[0].getAnnotation(AnnoA.class); + passCnt = new int[24]; + // 基本数据类型 + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + //enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + //基本类型数组 + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"));*/ + } +} +class Test<@AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) T> { +} +// DEPENDENCE: AnnoA.java AnnoB.java +// EXEC:%maple %f AnnoA.java AnnoB.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/expected.txt b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/maple.prof b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ba3e4d6d6ed34252e61d2116b43de86470b95565 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/test.cfg b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..de633afd110d594010008fcc3e9c107993737fd6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0201-rt-compact-AnnotationTypeUseSetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeUseSetTest) +run(AnnotationTypeUseSetTest) diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoA.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..bd35de2ef9e511bcbbe9ee4c21c20725314de948 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoA.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA() default Integer.MAX_VALUE; + double doubleA() default Double.MIN_VALUE; + String stringA() default ""; + AnnoB annoBA(); + ENUMA enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoB.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoC.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoC.java new file mode 100755 index 0000000000000000000000000000000000000000..cbf9e24cbbebe37e60dd66f776a237c46fded798 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoC.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoC { + int[] intA() default Integer.MAX_VALUE; + double[] doubleA() default Double.MIN_VALUE; + String[] stringA() default ""; + AnnoB[] annoBA() default @AnnoB; + ENUMA[] enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoD.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoD.java new file mode 100755 index 0000000000000000000000000000000000000000..e15b5d4c2881118deef1cd9bef9303abc3959410 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnoD.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoD { + int intA() default Integer.MAX_VALUE; + double doubleA() default Double.MIN_VALUE; + String stringA() default ""; + AnnoB annoBA(); + ENUMA enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnotationMultiThread.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnotationMultiThread.java new file mode 100755 index 0000000000000000000000000000000000000000..a7fb8eb6ae4e1d5de6ebfe32a4c0a7e06bb486ec --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/AnnotationMultiThread.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; +public class AnnotationMultiThread { + static AtomicInteger passCnt = new AtomicInteger(); + public static void main(String[] args) throws ClassNotFoundException { + ThreadGroup threadGroup = new ThreadGroup("myGroup"); + String[][] expectedGF = new String[][]{ + {"@AnnoA", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + {"@AnnoB(intB=999)"}, + {"@AnnoC", "annoBA=[@AnnoB(intB=999)]", "intA=[2147483647]", "enumA=[A]", "stringA=[]", "doubleA=[4.9E-324]"} + }; + String[][] expectedF = new String[][]{ + {"@AnnoA", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + {"@AnnoB(intB=999)"}, + {"@AnnoC", "annoBA=[@AnnoB(intB=999)]", "intA=[2147483647]", "enumA=[A]", "stringA=[]", "doubleA=[4.9E-324]"}, + {"@AnnoD", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + }; + new AnnotationGetter("GrandFather", expectedGF, expectedGF, threadGroup, "threadGF").start(); + new AnnotationGetter("Father", expectedF, expectedF, threadGroup, "threadF").start(); + new AnnotationGetter("Interface", expectedF, expectedF, threadGroup, "threadI").start(); + new AnnotationGetter("Son", expectedF, new String[][]{}, threadGroup, "threadS").start(); + new AnnotationGetter("Son2", expectedF, new String[][]{}, threadGroup, "threadS2").start(); + new AnnotationGetter("GrandFather", expectedGF, expectedGF, threadGroup, "threadGF").start(); + new AnnotationGetter("Father", expectedF, expectedF, threadGroup, "threadF").start(); + new AnnotationGetter("Interface", expectedF, expectedF, threadGroup, "threadI").start(); + new AnnotationGetter("Son", expectedF, new String[][]{}, threadGroup, "threadI").start(); + new AnnotationGetter("Son2", expectedF, new String[][]{}, threadGroup, "threadI").start(); + int i = 0; + while (threadGroup.activeCount() > 0){ + i++; + try { + Thread.sleep(100); + }catch (InterruptedException e){ + System.out.println(e); + } + if(i > 1000){ + break; + } + } + System.out.println(passCnt.get() - 200); + } + public static boolean checkAllAnnotations(Annotation[] annotations, String[][] expected){ + String[] actual = new String[annotations.length]; + for (int i = 0; i < annotations.length; i++){ + actual[i] = annotations[i].toString(); + } + Arrays.sort(actual); + if (actual.length != expected.length){ + return false; + } +// System.out.println(Arrays.toString(actual)); + for (int i = 0; i < annotations.length; i++){ + if (expected[i].length == 1){ + if (actual[i].compareTo(expected[i][0])!=0){ + System.out.println(actual[i]); + System.out.println(expected[i][0]); + return false; + } + }else { + for (int j = 0; j < expected[i].length; j++){ + if (!actual[i].contains(expected[i][j])){ + System.out.println(actual[i]); + System.out.println(expected[i][j]); + return false; + } + } + } + } + return true; + } +} +class AnnotationGetter extends Thread{ + String name; + String[][] expected; + String[][] expectedD; + AnnotationGetter(String nameI, String[][] expectedI, String[][] expectedDI, ThreadGroup threadGroup, String thread_name){ + super(threadGroup, thread_name); + name = nameI; + expected = expectedI; + expectedD = expectedDI; + } + @Override + public void run() { + try { + for (int i = 0; i < 10; i++) { + if (AnnotationMultiThread.checkAllAnnotations(Class.forName(this.name).getAnnotations(), this.expected)){ + AnnotationMultiThread.passCnt.incrementAndGet(); + } + if (AnnotationMultiThread.checkAllAnnotations(Class.forName(this.name).getDeclaredAnnotations(), this.expectedD)){ + AnnotationMultiThread.passCnt.incrementAndGet(); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } +} +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +class GrandFather{ + public void method1(int a, double b, Object... objects){ + } +} +@SuppressWarnings("all") +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +@AnnoD(annoBA = @AnnoB) +class Father extends GrandFather implements Interface{ + @Override + public void method1(int a, double b, Object... objects) { + } + @Deprecated + public void method2(){ + } +} +class Son extends Father{ + @Override + @Deprecated + public void method2(){ + } +} +class Son2 extends Father{ + @Override + @Deprecated + public void method2(){ + } +} +@SuppressWarnings("all") +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +@AnnoD(annoBA = @AnnoB) +interface Interface{ +} +// DEPENDENCE: AnnoA.java AnnoB.java AnnoC.java AnnoD.java ENUMA.java +// EXEC:%maple %f AnnoA.java AnnoB.java AnnoC.java AnnoD.java ENUMA.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/ENUMA.java b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/ENUMA.java new file mode 100755 index 0000000000000000000000000000000000000000..bb9cee8770af2ae1fdcc7206c31bd5062d02d38c --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/ENUMA.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +public enum ENUMA { + A, + B, + C +} diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/expected.txt b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/maple.prof b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..a131d387bcc52c7f48ddeaf85eba27f24f6e136a Binary files /dev/null and b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/test.cfg b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..548dbbdeb4d504827dd63b0c3b99ca11152e6ec8 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0202-rt-compact-AnnotationMultiThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationMultiThread) +run(AnnotationMultiThread) diff --git a/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/ReflectClassNameTest.java b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/ReflectClassNameTest.java new file mode 100755 index 0000000000000000000000000000000000000000..33e46b4ff5e4e4f38e7b8d3ea60d4e4cabdd133a --- /dev/null +++ b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/ReflectClassNameTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; +public class ReflectClassNameTest { + static int[] passCnt = new int[6]; + public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException { + int i = 0; + Class clazz = Class.forName("一"); + passCnt[i++] = clazz.getName().compareTo("一") == 0 ? 1 : 0; + Method method = clazz.getDeclaredMethod("дракон"); + passCnt[i++] = method.getName().compareTo("дракон") == 0 ? 1 : 0; + Field field = clazz.getDeclaredField("Rồng"); + passCnt[i++] = field.getName().compareTo("Rồng") == 0 ? 1 : 0; + Class clazz2 = Class.forName("二"); + passCnt[i++] = clazz2.getName().compareTo("二") == 0 ? 1 : 0; + class 三{ + } + Class clazz3 = Class.forName("ReflectClassNameTest$1三"); + passCnt[i++] = clazz3.getName().compareTo("ReflectClassNameTest$1三") == 0 ? 1 : 0; + Class clazz4 = Class.forName("ReflectClassNameTest$二"); + passCnt[i++] = clazz4.getName().compareTo("ReflectClassNameTest$二") == 0 ? 1 : 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1]")); + } + class 二{ + } +} +class 一{ + int Rồng; + public void дракон(){ + } +} +interface 二{ +} +// EXEC:%maple %f %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/expected.txt b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/maple.prof b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..c3d0d48e9349ab0ccf72d38e1ac0f903b340bf5e Binary files /dev/null and b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/test.cfg b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0dc062bd43fdc1400b8d99a4783c2690427199dc --- /dev/null +++ b/testsuite/java_test/compact_test/RT0203-rt-compact-ReflectSpecialClassNameTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectClassNameTest) +run(ReflectClassNameTest) diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoA.java b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..157d9b9509e006c87c49782ccf9f20b56e3716f4 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int 整型(); + byte 字节(); + char 字符(); + double 双精度浮点(); + boolean 布尔(); + long 长整(); + float 浮点(); + short 短整型(); + int[] あ(); + byte[] い(); + char[] う(); + double[] え(); + boolean[] お(); + long[] か(); + float[] き(); + short[] く(); + String 长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长(); + String[] 神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马(); + Class 类(); + Class[] 类类(); + Thread.State 类类类(); + Thread.State[] 类类类类(); + AnnoB 类类类类类(); + AnnoB[] 类类类类类类(); +} diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoB.java b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnotationNotAscii.java b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnotationNotAscii.java new file mode 100755 index 0000000000000000000000000000000000000000..9b4528b0d432a3ea25efb7591e49193bbc77e8cf --- /dev/null +++ b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/AnnotationNotAscii.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationNotAscii { + static int[] passCnt = new int[24]; + public static void main(String[] args) { + AnnoA anno = Test.class.getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.整型() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.字节() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.字符() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.双精度浮点()) ? 1: 0; + passCnt[i++] += anno.布尔() ? 1: 0; + passCnt[i++] += anno.长整() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.浮点())? 1: 0; + passCnt[i++] += anno.短整型() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.类类类() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.类() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.あ()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.い().length == 1 && anno.い()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.う().length == 1 && anno.う()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.え().length == 3 && Double.isNaN(anno.え()[0]) && Double.isInfinite(anno.え()[1]) && Double.isInfinite(anno.え()[2]))? 1: 0; + passCnt[i++] += (anno.お().length == 1 && anno.お()[0]) ? 1: 0; + passCnt[i++] += (anno.か().length == 1 && anno.か()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.き().length == 3 && Float.isNaN(anno.き()[0]) && Float.isInfinite(anno.き()[1]) && Float.isInfinite(anno.き()[2])) ? 1: 0; + passCnt[i++] += (anno.く().length == 1 && anno.く()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马().length == 1 && anno.神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.类类().length == 1 && anno.类类()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.类类类类().length == 1 && anno.类类类类()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.类类类类类().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.类类类类类类()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } +} +@AnnoA(整型 = Integer.MAX_VALUE, 字节 = Byte.MAX_VALUE, 字符 = Character.MAX_VALUE, 双精度浮点 = Double.NaN, + 布尔 = true, 长整 = Long.MAX_VALUE, 浮点 = Float.NaN, 短整型 = Short.MAX_VALUE, + あ = {1,2}, い = {0}, う = {' '}, え = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + お = {true}, か = {Long.MAX_VALUE}, き = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, く = {0}, + 长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长 = "", 神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马 = "", 类 = Thread.class, 类类 = Thread.class, 类类类 = Thread.State.BLOCKED, + 类类类类 = Thread.State.NEW, 类类类类类 = @AnnoB, 类类类类类类 = {@AnnoB, @AnnoB}) +class Test{ +} +// DEPENDENCE: AnnoA.java AnnoB.java +// EXEC:%maple %f AnnoA.java AnnoB.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/expected.txt b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/maple.prof b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..0b55ee358c790d9322c4bd73635eda9ceb81beea Binary files /dev/null and b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/test.cfg b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..be5afadc7c68bf8f256931092618480f1ca0009d --- /dev/null +++ b/testsuite/java_test/compact_test/RT0204-rt-compact-AnnotationSpecialCharacter/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationNotAscii) +run(AnnotationNotAscii) diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoA.java b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..a11eacb37f45e1ebb430d60436afaf8f42ab27dc --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoA.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Repeatable(Test.class) +@AnnoB(intB = 1) +@AnnoB(intB = 2) +@AnnoB(intB = 3) +@AnnoB(intB = 4) +@AnnoB(intB = 5) +@AnnoB(intB = 6) +@AnnoB(intB = 7) +@AnnoB(intB = 8) +@AnnoB(intB = 9) +@AnnoB(intB = 10) +@AnnoB(intB = 11) +@AnnoB(intB = 12) +@AnnoB(intB = 13) +@AnnoB(intB = 14) +@AnnoB(intB = 15) +@AnnoB(intB = 16) +@AnnoB(intB = 17) +@AnnoB(intB = 18) +public @interface AnnoA { + int intA() default 0; + byte byteA() default 0; + char charA() default 0; + double doubleA() default 0; + boolean booleanA() default true; + long longA() default 0; + float floatA() default 0; + short shortA() default 0; + int[] intAA() default 0; + byte[] byteAA() default 0; + char[] charAA() default 0; + double[] doubleAA() default 0; + boolean[] booleanAA() default true; + long[] longAA() default 0; + float[] floatAA() default 0; + short[] shortAA() default 0; + String stringA() default ""; + String[] stringAA() default ""; + Class classA() default Thread.class; + Class[] classAA() default Thread.class; + Thread.State stateA() default Thread.State.BLOCKED; + Thread.State[] stateAA() default Thread.State.BLOCKED; + AnnoB annoBA() default @AnnoB; + AnnoB[] annoBAA() default @AnnoB; + AnnoB[] value(); +} diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoB.java b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..6d15656d5f53fd8dcd0d941b293cf4f9a6ba6d30 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnoB.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Repeatable(AnnoA.class) +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnotationRepeatable.java b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnotationRepeatable.java new file mode 100755 index 0000000000000000000000000000000000000000..7c5942b0ae4a25c21d22479cf61bd5b6628b99a2 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/AnnotationRepeatable.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationRepeatable { + static int[] passCnt = new int[25]; + public static void main(String[] args) { + checkAnnoA(Test.class.getAnnotation(Test.class).value()[0], "[@AnnoB(intB=-1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[1], "[@AnnoB(intB=-2), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[2], "[@AnnoB(intB=-3), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[3], "[@AnnoB(intB=-4), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[4], "[@AnnoB(intB=-5), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[5], "[@AnnoB(intB=-6), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[6], "[@AnnoB(intB=-7), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[7], "[@AnnoB(intB=-8), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[8], "[@AnnoB(intB=-9), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[9], "[@AnnoB(intB=-10), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + boolean checkAnnoA = Arrays.toString(passCnt).compareTo("[1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]") == 0; + boolean checkAnnoB = Arrays.toString(AnnoA.class.getAnnotation(AnnoA.class).value()).compareTo("[@AnnoB(intB=1), @AnnoB(intB=2), @AnnoB(intB=3), @AnnoB(intB=4), @AnnoB(intB=5), @AnnoB(intB=6), @AnnoB(intB=7), @AnnoB(intB=8), @AnnoB(intB=9), @AnnoB(intB=10), @AnnoB(intB=11), @AnnoB(intB=12), @AnnoB(intB=13), @AnnoB(intB=14), @AnnoB(intB=15), @AnnoB(intB=16), @AnnoB(intB=17), @AnnoB(intB=18)]") == 0; + if (checkAnnoA && checkAnnoB){ + System.out.println(0); + } else { + System.out.println(2); + } + } + private static void checkAnnoA(AnnoA anno, String value){ + int i = 0; + passCnt[i++] = anno.intA() == 0 ? 1: 0; + passCnt[i++] += anno.byteA() == 0 ? 1: 0; + passCnt[i++] += anno.charA() == 0 ? 1: 0; + passCnt[i++] += anno.doubleA() == 0 ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == 0 ? 1: 0; + passCnt[i++] += anno.floatA() == 0? 1: 0; + passCnt[i++] += anno.shortA() == 0 ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + // array + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[0]") == 0 ? 1: 0; + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 1 && anno.doubleAA()[0] == 0)? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 1 && anno.floatAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.BLOCKED) ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999)]") == 0 ? 1: 0; + // value + passCnt[i++] += Arrays.toString(anno.value()).compareTo(value) == 0 ? 1: 0; + } +} +// DEPENDENCE: AnnoA.java AnnoB.java Test.java +// EXEC:%maple %f AnnoA.java AnnoB.java Test.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/Test.java b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/Test.java new file mode 100755 index 0000000000000000000000000000000000000000..cb55e7627fe78db39c9395e773c54f456969b2d6 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@AnnoA( value = @AnnoB(intB = -1)) +@AnnoA( value = {@AnnoB(intB = -2), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -3), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -4), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -5), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -6), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -7), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -8), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -9), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -10), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +public @interface Test{ + AnnoA[] value(); +} diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/expected.txt b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/maple.prof b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..90f7fe583ae4ce2553da679343d7c93814d4402d Binary files /dev/null and b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/test.cfg b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ece5cb4379e0abb8b4caa86e7d103af945663e73 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0205-rt-compact-AnnotationRepeatable/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationRepeatable) +run(AnnotationRepeatable) diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoA.java b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..cd152bebfc5b736c3b1bdda44dec59c6e482e58b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoB.java b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java new file mode 100755 index 0000000000000000000000000000000000000000..fd2f62941f47823a3f3689d5d2b37dc7846c2254 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeInnerClassSet { + static int[] passCnt = new int[24]; + public static void main(String[] args) throws ClassNotFoundException { + AnnoA anno = Class.forName("AnnotationTypeInnerClassSet$Test").getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && + Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && + Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt) + .compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } + @AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY}, booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, + Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) + class Test{ + } +} +// DEPENDENCE: AnnoA.java AnnoB.java +// EXEC:%maple %f AnnoA.java AnnoB.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/expected.txt b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/maple.prof b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..227d3f2f979dc82aef2a45250c6bd33e1211a1fa Binary files /dev/null and b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/test.cfg b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e028fcbf9c6616c499512f0b608a56f1cdc10bb0 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0206-rt-compact-AnnotationTypeInnerClassSet/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeInnerClassSet) +run(AnnotationTypeInnerClassSet) diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoA.java b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..cd152bebfc5b736c3b1bdda44dec59c6e482e58b --- /dev/null +++ b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoB.java b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java new file mode 100755 index 0000000000000000000000000000000000000000..3f9c0891e493e966729490d11a430a834915576e --- /dev/null +++ b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeLocalClassSet { + static int[] passCnt = new int[24]; + public static void main(String[] args) throws ClassNotFoundException { + @AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) + class Test{ + } + AnnoA anno = Class.forName("AnnotationTypeLocalClassSet$1Test").getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } +} +// DEPENDENCE: AnnoA.java AnnoB.java +// EXEC:%maple %f AnnoA.java AnnoB.java %build_option -o %n.so +// EXEC:%run %n.so %n %run_option | compare %f +// ASSERT: scan-full 0\n diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/expected.txt b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/maple.prof b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/maple.prof new file mode 100644 index 0000000000000000000000000000000000000000..ca77c458b56482b1fc3e441d1957313f3eb72b94 Binary files /dev/null and b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/maple.prof differ diff --git a/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/test.cfg b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4a88f4936275d290e54ec20f25148f2ab3605eee --- /dev/null +++ b/testsuite/java_test/compact_test/RT0207-rt-compact-AnnotationTypeLocalClassSet/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeLocalClassSet) +run(AnnotationTypeLocalClassSet) diff --git a/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/ReflectionForName2.java b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/ReflectionForName2.java new file mode 100755 index 0000000000000000000000000000000000000000..b43cf87b0fa99734a20dff514f3dfe1a83751f88 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/ReflectionForName2.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.File; +import java.io.IOException; +class ForName2 { + static { + File cls2 = new File("/data/local/tmp/ReflectionForName2.txt"); + try { + cls2.createNewFile(); + } catch (IOException e) { + System.err.println(e); + } + } +} +public class ReflectionForName2 { + public static void main(String[] args) throws ClassNotFoundException { + File cls1 = new File("/data/local/tmp/ReflectionForName2.txt"); + File theDir = new File(cls1.getParentFile().getAbsolutePath()); + if (!theDir.exists()) { + theDir.mkdirs(); + } + if (cls1.exists()) { + cls1.delete(); + } + Class cls = Class.forName("ForName2", true, ForName2.class.getClassLoader()); + if (cls1.exists()) { + System.out.println(0); + }else{ + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/expected.txt b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/test.cfg b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5baba823ff8bd1f47830893d6593c16ea9e9d162 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-0000-rt-compact-ReflectionforName2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName2) +run(ReflectionForName2) diff --git a/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/ReflectionForName3.java b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/ReflectionForName3.java new file mode 100755 index 0000000000000000000000000000000000000000..54b63aa920a1dd79ef6599801ad3b6fceddcf3c6 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/ReflectionForName3.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.File; +import java.io.IOException; +class ForName3 { + static { + File cls2 = new File("/data/local/tmp/ReflectionForName3.txt"); + try { + cls2.createNewFile(); + } catch (IOException e) { + System.err.println(e); + } + } +} +public class ReflectionForName3 { + public static void main(String[] args) throws ClassNotFoundException { + File cls1 = new File("/data/local/tmp/ReflectionForName3.txt"); + if (cls1.exists()) { + cls1.delete(); + } + Class cls = Class.forName("ForName3", false, ForName3.class.getClassLoader()); + if (!cls1.exists()) { + System.out.println(0); + return; + } + System.out.println(2); + return; + } +} diff --git a/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/expected.txt b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/test.cfg b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..53970e2e16fe06bdeefe11453b7dbdf91aa9c6bb --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0096-rt-compact-ReflectionforName3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName3) +run(ReflectionForName3) diff --git a/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..ac953606f1e5ca1c81d589ccde2d38a61e51855a --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetCharInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.setChar(null, (char)46); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetCharInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetCharInterface.result.append("One").toString(); + char hiChar = (char)45; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetCharInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetCharInterface.result.append("Annotation").toString(); +} diff --git a/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/expected.txt b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/test.cfg b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d2311cd9cb889cda5f4c30c5ef0457db7412d6f5 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0893-rt-compact-ClinitFieldSetCharInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetCharInterface) +run(ClassInitFieldSetCharInterface) diff --git a/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..8393ae0c666e7455f424cef1e1b589ca8318051d --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetDoubleInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.setDouble(null, 0.265874); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + return; + } else { + System.out.println(2); + return; + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetDoubleInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetDoubleInterface.result.append("One").toString(); + double hiDouble = 0.1532; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetDoubleInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetDoubleInterface.result.append("Annotation").toString(); +} diff --git a/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/expected.txt b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/test.cfg b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..16f5d899c026f7f0ff4da48152a8ebf83740be20 --- /dev/null +++ b/testsuite/java_test/compact_test/issue-RT0894-rt-compact-ClinitFieldSetDoubleInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetDoubleInterface) +run(ClassInitFieldSetDoubleInterface) diff --git a/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/TryFinallyExceptionTest.java b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/TryFinallyExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9d60b7f507da12f18fcd22860e5ff208bd766950 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/TryFinallyExceptionTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryFinallyExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; + try { + tryFinallyExceptionTest(); + } catch (NumberFormatException e) { + processResult -= 3; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try-finally mode: try{exception}-finally-->caller. + */ + + public static void tryFinallyExceptionTest() { + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } finally { + processResult--; + } + } +} diff --git a/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e2d73c21a03b0f73bfa20ad540f7e3e095baf484 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0032-rt-eh-TryFinallyExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryFinallyExceptionTest) +run(TryFinallyExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/TryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/TryCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..495f2d2b912a0c01f14a81ba250e8585b599e34c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/TryCatchExceptionTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; + try { + tryCatchExceptionTest1(); + tryCatchExceptionTest2(); + tryCatchExceptionTest3(); + tryCatchExceptionTest4(); + } catch (Exception e) { + processResult -= 10; + result = 3; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Check NumberFormatException + */ + + public static void tryCatchExceptionTest1() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } + } + /** + * Check IllegalArgumentException + */ + + public static void tryCatchExceptionTest2() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + } + } + /** + * Check RuntimeException + */ + + public static void tryCatchExceptionTest3() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (RuntimeException e) { + processResult--; + } + } + /** + * Check Exception + */ + + public static void tryCatchExceptionTest4() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (Exception e) { + processResult--; + } + } +} diff --git a/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b491478891c7f79fa84999475ddd1564de2c96e3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0033-rt-eh-TryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchExceptionTest) +run(TryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/TryMultiCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/TryMultiCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bebe9cc4fae74a717de5a5b1b3f11bd4da9059cd --- /dev/null +++ b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/TryMultiCatchExceptionTest.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class TryMultiCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; + try { + tryMultiCatchExceptionTest1(); + tryMultiCatchExceptionTest2(); + tryMultiCatchExceptionTest3(); + tryMultiCatchExceptionTest4(); + tryMultiCatchExceptionTest5(); + } catch (Exception e) { + processResult -= 10; + result = 3; + } + if (result == 2 && processResult == 94) { + result = 0; + } + return result; + } + /** + * Use try-catch/catch/...(multi-catch) test static int parseInt(String s), NumberFormatException is in first catch. + */ + + public static void tryMultiCatchExceptionTest1() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } catch (ClassCastException e) { + processResult -= 10; + } catch (InvalidPathException e) { + processResult -= 10; + } catch (IllegalStateException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult -= 10; + } + } + /** + * Use try-catch/catch/...(multi-catch) test static int parseInt(String s), NumberFormatException is in second catch. + */ + + public static void tryMultiCatchExceptionTest2() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException e) { + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } catch (InvalidPathException e) { + processResult -= 10; + } catch (IllegalStateException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult -= 10; + } + } + /** + * Use try-catch/catch/...(multi-catch) test static int parseInt(String s), NumberFormatException is in third catch. + */ + + public static void tryMultiCatchExceptionTest3() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException e) { + processResult -= 10; + } catch (InvalidPathException e) { + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } catch (IllegalStateException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult -= 10; + } + } + /** + * Use try-catch/catch/...(multi-catch) test static int parseInt(String s), NumberFormatException is in forth catch. + */ + + public static void tryMultiCatchExceptionTest4() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException e) { + processResult -= 10; + } catch (InvalidPathException e) { + processResult -= 10; + } catch (IllegalStateException e) { + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } catch (IllegalArgumentException e) { + processResult -= 10; + } + } + /** + * Use try-catch/catch/...(multi-catch) test static int parseInt(String s), NumberFormatException is in fifth catch. + */ + + public static void tryMultiCatchExceptionTest5() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException e) { + processResult -= 10; + } catch (InvalidPathException e) { + processResult -= 10; + } catch (IllegalStateException e) { + processResult -= 10; + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (NumberFormatException e) { + processResult--; + } + } +} diff --git a/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d5291dfe84ac591b7ee9f2d1b8d42fe21ba07f0 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0034-rt-eh-TryMultiCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryMultiCatchExceptionTest) +run(TryMultiCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/TryMultiCatchMatchFirstExceptionTest.java b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/TryMultiCatchMatchFirstExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..57bbbd38b8689e19d278dcaf1137ce1fce8db068 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/TryMultiCatchMatchFirstExceptionTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryMultiCatchMatchFirstExceptionTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + result = tryMultiCatchMatchFirstExceptionTest1(); + if (result != 0) { + return 2; + } + return result; + } + /** + * Test try-catch/catch/...(multi-catch) mode. + * @return status code + */ + + public static int tryMultiCatchMatchFirstExceptionTest1() { + int result1 = 2; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + result1 = 0; + } catch (IllegalArgumentException e) { + result1 = 2; + } catch (RuntimeException e) { + result1 = 2; + } catch (Exception e) { + result1 = 2; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6fd8fb02df5730f32b79552302f536e931804f2e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0035-rt-eh-TryMultiCatchMatchFirstExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryMultiCatchMatchFirstExceptionTest) +run(TryMultiCatchMatchFirstExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/TryCatchPipelineExceptionTest.java b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/TryCatchPipelineExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5ea482d7a61b1ae9f93ced15db0b700fc07ff853 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/TryCatchPipelineExceptionTest.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class TryCatchPipelineExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; + try { + tryCatchPipelineExceptionTest1(); + tryCatchPipelineExceptionTest2(); + tryCatchPipelineExceptionTest3(); + tryCatchPipelineExceptionTest4(); + tryCatchPipelineExceptionTest5(); + } catch (Exception e) { + processResult -= 10; + result = 3; + } + if (result == 2 && processResult == 94) { + result = 0; + } + return result; + } + /** + * Use try-catch(type1 | type 2 | ...) to test static int parseInt(String s), NumberFormatException is in first type. + */ + + public static void tryCatchPipelineExceptionTest1() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (NumberFormatException + | ClassCastException + | InvalidPathException + | IllegalStateException + | IndexOutOfBoundsException e) { + processResult--; + } + } + /** + * Use try-catch(type1 | type 2 | ...) to test static int parseInt(String s), NumberFormatException is in second type. + */ + + public static void tryCatchPipelineExceptionTest2() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException + | NumberFormatException + | InvalidPathException + | IllegalStateException + | IndexOutOfBoundsException e) { + processResult--; + } + } + /** + * Use try-catch(type1 | type 2 | ...) to test static int parseInt(String s), NumberFormatException is in third type. + */ + + public static void tryCatchPipelineExceptionTest3() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException + | InvalidPathException + | NumberFormatException + | IllegalStateException + | IndexOutOfBoundsException e) { + processResult--; + } + } + /** + * Use try-catch(type1 | type 2 | ...) to test static int parseInt(String s), NumberFormatException is in fourth type. + */ + + public static void tryCatchPipelineExceptionTest4() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException + | InvalidPathException + | IllegalStateException + | NumberFormatException + | IndexOutOfBoundsException e) { + processResult--; + } + } + /** + * Use try-catch(type1 | type 2 | ...) to test static int parseInt(String s), NumberFormatException is in fifth+ type. + */ + + public static void tryCatchPipelineExceptionTest5() { + String str = "123#456"; + try { + Integer.parseInt(str); + processResult -= 10; + } catch (ClassCastException + | InvalidPathException + | IllegalStateException + | IndexOutOfBoundsException + | NumberFormatException e) { + processResult--; + } + } +} diff --git a/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eb5e0f8d2fff9b9f7329ff6edd21841edc9668c1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0036-rt-eh-TryCatchPipelineExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchPipelineExceptionTest) +run(TryCatchPipelineExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/TryMultiCatchFinallyExceptionTest.java b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/TryMultiCatchFinallyExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..934607ce30fba84584b5a81be746493cac93e4fd --- /dev/null +++ b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/TryMultiCatchFinallyExceptionTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryMultiCatchFinallyExceptionTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; + result = tryMultiCatchFinallyExceptionTest(); + if (result != 0) { + return 2; + } + try { + result = tryMultiCatchFinallyExceptionTest2(); + } catch (NumberFormatException e) { + if (result != 0) { + return 2; + } + } + return result; + } + /** + * Use try-catch/catch…-finally to test static int parseInt(String s), NumberFormatException is in catch. + * @return status code + */ + + public static int tryMultiCatchFinallyExceptionTest() { + int result1 = 2; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + result1--; + } catch (IllegalArgumentException e) { + result1 = 2; + } catch (RuntimeException e) { + result1 = 2; + } catch (Exception e) { + result1 = 2; + } finally { + result1--; + } + return result1; + } + /** + * Use try-catch/catch…-finally to test static int parseInt(String s), NumberFormatException is not in catch. + * @return status code + * @throws NumberFormatException + */ + + public static int tryMultiCatchFinallyExceptionTest2() throws NumberFormatException { + int result2 = 2; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + result2 = 2; + } finally { + result2 = 0; + } + return result2; + } +} diff --git a/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..35ab357616c6231db004f48e01c333a7d9bbf706 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0037-rt-eh-TryMultiCatchFinallyExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryMultiCatchFinallyExceptionTest) +run(TryMultiCatchFinallyExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/TryCatchResourceExceptionTest.java b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/TryCatchResourceExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9a666e3bd94c342952dfb61f90a5df5f249d96c4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/TryCatchResourceExceptionTest.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryCatchResourceExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 4; /* STATUS_FAILED*/ + + try { + // No Exception occur: conn.start->conn.close->finally. + result = result - tryCatchResourceExceptionTest1(); + // Exception in try: conn.start->conn.close->catch(catch e in try,ignore e in close)->finally. + result = result - tryCatchResourceExceptionTest2(); + // Exception in try: conn.start->conn.close->catch(catch e in start,ignore e in try & close)->finally. + result = result - tryCatchResourceExceptionTest3(); + } catch (Exception e) { + processResult += 10; + } + if (result == 1 && processResult == 90) { + result = 0; + } + return result; + } + /** + * No Exception occur: conn.start->conn.close->finally. + * @return status code + */ + + public static int tryCatchResourceExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResourceA conn = new MyResourceA()) { + conn.start(); + result1 = 1; + processResult--; + } catch (Exception e) { + System.out.println("catch ......"); + processResult -= 10; + result1++; + } finally { + processResult--; + } + processResult--; + return result1; + } + /** + * Exception in try: conn.start->conn.close->catch(catch e in try,ignore e in close)->finally. + * @return status code + */ + + public static int tryCatchResourceExceptionTest2() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResourceB conn = new MyResourceB()) { + conn.start(); + int num = 1 / (result1 - 4); + processResult -= 10; + } catch (Exception e) { + processResult--; + result1 = 1; + } finally { + processResult--; + } + processResult--; + return result1; + } + /** + * Exception in try: conn.start->conn.close->catch(catch e in start,ignore e in try & close)->finally. + * @return status code + */ + + public static int tryCatchResourceExceptionTest3() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResourceC conn = new MyResourceC()) { + conn.start(); + int num = 1 / (result1 - 4); + processResult -= 10; + } catch (Exception e) { + processResult--; + result1 = 1; + } finally { + processResult--; + } + processResult--; + return result1; + } + public static class MyResourceA implements AutoCloseable { + /** + * start fun + */ + + public void start() { + processResult = processResult * 2; + } + @Override + public void close() { + processResult = processResult / 2; + } + } + public static class MyResourceB implements AutoCloseable { + /** + * start fun + */ + + public void start() { + processResult = processResult * 2; + } + @Override + public void close() throws Exception { + processResult = processResult / 2; + throw new NoSuchFieldException("ee"); + } + } + public static class MyResourceC implements AutoCloseable { + /** + * start fun + */ + + public void start() throws Exception { + processResult = processResult * 2; + throw new NoSuchMethodException("mm"); + } + @Override + public void close() throws Exception { + processResult = processResult / 2; + throw new NoSuchFieldException("ee"); + } + } +} diff --git a/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b43d2144ccf124da0e2710de2206ac3a73bae248 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0038-rt-eh-TryCatchResourceExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchResourceExceptionTest) +run(TryCatchResourceExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/TryCatchThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/TryCatchThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e08cf6287571f18058ce958860853e943cd15d6b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/TryCatchThrowExceptionTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryCatchThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchThrowExceptionTest1(); + } catch (NumberFormatException e) { + processResult--; + } + if (processResult == 97) { + result--; + } + try { + tryCatchThrowExceptionTest3(); + } catch (Exception3 e) { + processResult--; + } + if (processResult == 95) { + result--; + } + return result; + } + /** + * Test static int parseInt(String s), NumberFormatException is caught by catch + * @return status code + * @throws NumberFormatException + */ + + public static int tryCatchThrowExceptionTest1() throws NumberFormatException { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + processResult--; + throw e; + } + processResult -= 10; // Compiled successfully, but cannot execute. + return result1; + } + /** + * Create a new Exception extends from Exception. + * @return status code + * @throws Exception3 + */ + + public static int tryCatchThrowExceptionTest3() throws Exception3 { + int result3 = 3; /* STATUS_FAILED*/ + + if (result3 != 4) { + processResult--; + throw new Exception3(); + } + processResult -= 10; // Compiled successfully, but cannot execute. + return result3; + } + static class Exception3 extends Exception { + Exception3() { + super("yes"); + } + } +} diff --git a/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d77119955978c953db4cbcf9c653fa8379ea4ba --- /dev/null +++ b/testsuite/java_test/eh_test/RT0039-rt-eh-TryCatchThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchThrowExceptionTest) +run(TryCatchThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/TryExceptionFinallyExceptionTest.java b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/TryExceptionFinallyExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..5f16e574677d6e1c3aa60be9f631468a3c7d6b6a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/TryExceptionFinallyExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryExceptionFinallyExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryExceptionFinallyExceptionTest1(); + } catch (NumberFormatException e) { + if (processResult == 97) { + processResult -= 2; + } + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{exception}-finally:handler is caller. + * @return status code + */ + + public static int tryExceptionFinallyExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } finally { + if (processResult == 99) { + processResult--; + } + } + processResult -= 10; + } finally { + if (processResult == 98) { + processResult--; + } + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a5722a328a4fb11a8590ea1b6e235830dec16c2e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0040-rt-eh-TryExceptionFinallyExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryExceptionFinallyExceptionTest) +run(TryExceptionFinallyExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/TryTryThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/TryTryThrowExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..f615e61a89ce1605e07cb2cc38d4f2ebd56b3e07 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/TryTryThrowExceptionTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryTryThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryTryThrowExceptionTest1(); + } catch (NumberFormatException e) { + if (processResult == 97) { + processResult -= 2; + } + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{exception}-catch(x)-finally:handler is caller. + * @return status code + */ + + public static int tryTryThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } finally { + if (processResult == 99) { + processResult --; + } + } + processResult -= 10; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + if (processResult == 98) { + processResult --; + } + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..186bf1a397db6b25900d32b2ed1082b40e687304 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0041-rt-eh-TryTryThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryTryThrowExceptionTest) +run(TryTryThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/TryTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/TryTryCatchExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..9bc42c62e4bf4ddda6895ddfcaa9afb72cb9aeae --- /dev/null +++ b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/TryTryCatchExceptionTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +/** + * Testcase for EH module +*/ + +public class TryTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryTryCatchExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{exception}-catch(e)-finally. + * @return status code + */ + + public static int tryTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } finally { + if (processResult == 99) { + processResult--; + } + } + processResult -= 10; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IllegalArgumentException e) { + if (processResult == 98) { + processResult--; + result1 = 1; + } + } finally { + if (processResult == 97) { + processResult--; + } + } + if (processResult == 96) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4e8a97272687130126a7b4e97122ce0e96d3c042 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0042-rt-eh-TryTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryTryCatchExceptionTest) +run(TryTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/TryCatchTryExceptionTest.java b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/TryCatchTryExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..7c0d441f6a5d7dc55e92058bbeb646c5a0ac9791 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/TryCatchTryExceptionTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +/** + * Testcase for EH module +*/ + +public class TryCatchTryExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchTryExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{exception} catch(e)}-catch-finally. + * @return status code + */ + + public static int tryCatchTryExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + result1 = 1; + if (processResult == 99) { + processResult--; + } + } + if (processResult == 98) { + processResult--; + } + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + if (processResult == 97) { + processResult--; + } + } + if (processResult == 96) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2ebd5af09f5c266a10fbfb5f9da17bd6c2005035 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0043-rt-eh-TryCatchTryExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchTryExceptionTest) +run(TryCatchTryExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/DoubleTryCatchFinallyExceptionTest.java b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/DoubleTryCatchFinallyExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..ad390b3bf3e82d705c6658cf75438effcf06105a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/DoubleTryCatchFinallyExceptionTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +/** + * Testcase for EH module +*/ + +public class DoubleTryCatchFinallyExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = doubleTryCatchFinallyExceptionTest1(); + } catch (IllegalArgumentException e) { + processResult -= 2; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{exception} catch(x)}-finally -->caller. + * @return status code + */ + + public static int doubleTryCatchFinallyExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } catch (ClassCastException e) { + result1 = 3; + processResult -= 10; + } finally { + if (processResult == 99) { + processResult--; + } + } + processResult -= 10; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + if (processResult == 98) { + processResult--; + } + } + processResult -= 10; + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..da330814bf76394e925e78b8619a4852c89a768c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0044-rt-eh-DoubleTryCatchFinallyExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(DoubleTryCatchFinallyExceptionTest) +run(DoubleTryCatchFinallyExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/TryCatchTryCatchFinallyExceptionTest.java b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/TryCatchTryCatchFinallyExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..12dae4b090e90ba91ff78a299b0681ccab161a13 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/TryCatchTryCatchFinallyExceptionTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.FormatterClosedException; +public class TryCatchTryCatchFinallyExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchTryCatchFinallyExceptionTest1(); + } catch (NumberFormatException e) { + processResult--; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{exception} catch(x)}-catch()-finally --> caller. + * @return status code + */ + + public static int tryCatchTryCatchFinallyExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } catch (IllegalStateException e113) { + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + } + processResult -= 10; + } catch (FormatterClosedException e1132) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 3; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6423e60710ae892bc1f4978ff021a60006023237 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0045-rt-eh-TryCatchTryCatchFinallyExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchTryCatchFinallyExceptionTest) +run(TryCatchTryCatchFinallyExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/TryCatchTryCatchExceptionFinallyTest.java b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/TryCatchTryCatchExceptionFinallyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1de441e628be1806fbc0cede791b3064036dd1b3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/TryCatchTryCatchExceptionFinallyTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.FormatterClosedException; +public class TryCatchTryCatchExceptionFinallyTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchTryCatchExceptionFinallyTest1(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{exception} catch(x)}-catch(e)-finally. + * @return status code + */ + + public static int tryCatchTryCatchExceptionFinallyTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + try { + Integer.parseInt(str); + } catch (IllegalStateException e113) { + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + } + processResult -= 10; + } catch (FormatterClosedException e1132) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (IllegalArgumentException e111) { + result1 = 1; + } catch (IndexOutOfBoundsException e112) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 1; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/expected.txt b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/test.cfg b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..54cd65da84b82079a5a209e58c65aff1e01b9718 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0046-rt-eh-TryCatchTryCatchExceptionFinallyTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchTryCatchExceptionFinallyTest) +run(TryCatchTryCatchExceptionFinallyTest) diff --git a/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/CatchThrowNewExceptionTest.java b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/CatchThrowNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..098db9c9b6feb8f335d0fb7d82bfe21aff7a39de --- /dev/null +++ b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/CatchThrowNewExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CatchThrowNewExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = catchThrowNewExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + if (result == 2 && processResult == 95) { + return 0; + } + } + return result; + } + /** + * Test catch(){exception}, handler is caller. + * @return status code + */ + + public static int catchThrowNewExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + processResult -= 2; + System.out.println(str.substring(-5)); + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 2; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..00bc273932b5705b30e96aad3e7acb2cd029b131 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0047-rt-eh-CatchThrowNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CatchThrowNewExceptionTest) +run(CatchThrowNewExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/CatchTryCatchNewExceptionTest.java b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/CatchTryCatchNewExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..f5d8d18c88ef4ac180fc76b11ed4f77fbee8b120 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/CatchTryCatchNewExceptionTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CatchTryCatchNewExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = catchTryCatchNewExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try-catch(){try{exception},catch(e)}-finally. + * @return status code + */ + + public static int catchTryCatchNewExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + try { + System.out.println(str.substring(-5)); + } catch (StringIndexOutOfBoundsException e2) { + if (processResult == 99) { + processResult--; + } + } + result1 = 1; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + if (processResult == 98) { + processResult--; + } + } + if (processResult == 97) { + processResult -= 2; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cd48ee56c2d7f42023e01aa7a4c0a045d26aa05e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0048-rt-eh-CatchTryCatchNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CatchTryCatchNewExceptionTest) +run(CatchTryCatchNewExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/CatchTryThrowNewExceptionTest.java b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/CatchTryThrowNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ee4315ef18d683343cf9fa6901b513c22bbd2369 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/CatchTryThrowNewExceptionTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CatchTryThrowNewExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = catchTryThrowNewExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult--; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try-catch(){try{exception},catch(x)}-finally --> caller. + * @return status code + */ + + public static int catchTryThrowNewExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + result1 = 1; + try { + System.out.println(str.substring(-5)); + } catch (NumberFormatException e2) { + processResult -= 10; + } + processResult -= 10; + } catch (StringIndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 3; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60414ae2b4adc2d50db039a2e843278efa3ba52c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0049-rt-eh-CatchTryThrowNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CatchTryThrowNewExceptionTest) +run(CatchTryThrowNewExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/FinallyThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/FinallyThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2f4434ea12052121dfec42762825205225ec9c69 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/FinallyThrowExceptionTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class FinallyThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = finallyThrowExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + if (result == 2 && processResult == 95) { + return 0; + } + } + return result; + } + /** + * Test finally{exception}, handler is caller. + * @return status code + */ + + public static int finallyThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + result1 = 1; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 4; + System.out.println(str.substring(-5)); + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + } + System.out.println("=====See:ERROR!!!"); + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b6c18fad0e546e5aba1bb2c50f080b802b1eda80 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0050-rt-eh-FinallyThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinallyThrowExceptionTest) +run(FinallyThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/FinallyTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/FinallyTryCatchExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..38dde8c369ac907e839003080c115e435acffd31 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/FinallyTryCatchExceptionTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class FinallyTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = finallyTryCatchExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try-catch-finally{try{exception},catch(e)}. + * @return status code + */ + + public static int finallyTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + result1 = 1; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult--; + try { + System.out.println(str.substring(-5)); + } catch (StringIndexOutOfBoundsException e) { + processResult--; + } + } + processResult -= 2; + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..29344b65daf44c378491721c76e7afc781be6e50 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0051-rt-eh-FinallyTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinallyTryCatchExceptionTest) +run(FinallyTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/FinallyTryThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/FinallyTryThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..01477e93320accbe719f3fb6dea58bd00166203f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/FinallyTryThrowExceptionTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class FinallyTryThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = finallyTryThrowExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 3; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try-catch-finally{try{exception},catch(x)}--> caller. + * @return status code + */ + + public static int finallyTryThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + System.out.println("=====See:ERROR!!!"); + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + result1 = 1; + } catch (IllegalArgumentException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult--; + try { + System.out.println(str.substring(-5)); + } catch (NumberFormatException e) { + processResult -= 10; + } + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fe9789ddfcffa8a107567807348d264cfd923fb6 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0052-rt-eh-FinallyTryThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinallyTryThrowExceptionTest) +run(FinallyTryThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/TryResourceStartThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/TryResourceStartThrowExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..69143bec85d87396041ffc95ce020017f09233a0 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/TryResourceStartThrowExceptionTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryResourceStartThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryResourceStartThrowExceptionTest1(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 1 && processResult == 94) { + result = 0; + } + return result; + } + public static class MyResource implements AutoCloseable { + /** + * start fun + * @throws NumberFormatException + */ + + public void start() throws NumberFormatException { + if (processResult == 99) { + processResult--; + } + throw new NumberFormatException("start:exception!!!"); + } + @Override + public void close() throws StringIndexOutOfBoundsException { + if (processResult == 98) { + processResult--; + } + } + } + /** + * Test try(exception){}-catch(e){}-close()-finally. + * @return status code + */ + + public static int tryResourceStartThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResource conn = new MyResource()) { + conn.start(); + } catch (NumberFormatException e) { + if (processResult == 97) { + processResult--; + } + result1 = 1; + } catch (StringIndexOutOfBoundsException e) { + processResult -= 10; + result1 = 3; + } finally { + if (processResult == 96) { + processResult--; + } + } + if (processResult == 95) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e28516100401b367480114437c3de86fddedbac1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0053-rt-eh-TryResourceStartThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryResourceStartThrowExceptionTest) +run(TryResourceStartThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/TryResourceCloseThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/TryResourceCloseThrowExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..f26c43e7a091035a2f1ea5bfa52e85dff47837eb --- /dev/null +++ b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/TryResourceCloseThrowExceptionTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryResourceCloseThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryResourceCloseThrowExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 94) { + result = 0; + } + return result; + } + public static class MyResource implements AutoCloseable { + /** + * start fun + * @throws NumberFormatException + */ + + public void start() throws NumberFormatException { + if (processResult == 99) { + processResult--; + } + } + @Override + public void close() throws StringIndexOutOfBoundsException { + if (processResult == 98) { + processResult--; + } + throw new StringIndexOutOfBoundsException("end:exception!!!"); + } + } + /** + * Test try(){}-catch(e){}-close(exception)-finally. + * @return status code + */ + + public static int tryResourceCloseThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResource conn = new MyResource()) { + conn.start(); + } catch (NumberFormatException e) { + processResult -= 10; + e.printStackTrace(); + result1 = 3; + } catch (StringIndexOutOfBoundsException e) { + if (processResult == 97) { + processResult--; + } + result1 = 1; + } finally { + if (processResult == 96) { + processResult--; + } + } + if (processResult == 95) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f8e8a7add7f6ff632233007ad5c2a8484cdcc7e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0054-rt-eh-TryResourceCloseThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryResourceCloseThrowExceptionTest) +run(TryResourceCloseThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/TryResourceStartAndCloseExceptionTest.java b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/TryResourceStartAndCloseExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..68972eee71df0598a59c74fb10049770c8ff7be6 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/TryResourceStartAndCloseExceptionTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; +public class TryResourceStartAndCloseExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryResourceStartAndCloseExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 94) { + result = 0; + } + return result; + } + public static class MyResource implements AutoCloseable { + /** + * start fun + * @throws NumberFormatException + */ + + public void start() throws NumberFormatException { + if (processResult == 99) { + processResult--; + } + throw new NumberFormatException("start:exception!!!"); + } + @Override + public void close() throws StringIndexOutOfBoundsException { + if (processResult == 98) { + processResult--; + } + throw new StringIndexOutOfBoundsException("end:exception!!!"); + } + } + /** + * Test try(exception1){}-catch(e1){}-close(exception2)-finally. + * @return status code + */ + + public static int tryResourceStartAndCloseExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + try (MyResource conn = new MyResource()) { + conn.start(); + } catch (NumberFormatException e) { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + String msg=sw.toString(); +// System.out.println(msg); + if (processResult == 97 && msg.contains("start:exception!!!") && msg.contains("end:exception!!!")) { + processResult--; + } + result1 = 1; + } catch (StringIndexOutOfBoundsException e) { + processResult -= 10; + result1 = 3; + } finally { + if (processResult == 96) { + processResult--; + } + } + if (processResult == 95) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..563e63057cc170199a8b0a7c89fae214f94479af --- /dev/null +++ b/testsuite/java_test/eh_test/RT0055-rt-eh-TryResourceStartAndCloseExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryResourceStartAndCloseExceptionTest) +run(TryResourceStartAndCloseExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/MultiTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/MultiTryCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f852159e8d3b113e2603a55052c56dffd505758d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/MultiTryCatchExceptionTest.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class MultiTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = multiTryCatchExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{try{try{try{exception}catch()}catch()}catch()}catch()},catch(e). + * @return status code + */ + + public static int multiTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + Integer.parseInt(str); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + processResult -= 10; + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + result1 = 1; + } finally { + processResult -= 100; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f5a5e9f75d71bba2f9ccbfb15c9c54966b54b42 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0056-rt-eh-MultiTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MultiTryCatchExceptionTest) +run(MultiTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/MultiTryCatchThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/MultiTryCatchThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..80706d50c1d5555a725d9a554db8f68fe721d32a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/MultiTryCatchThrowExceptionTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class MultiTryCatchThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = multiTryCatchThrowExceptionTest1(); + } catch (Exception e) { + processResult -= 4; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{try{try{try{try{exception}catch()}catch()}catch()}catch()},catch(x):-->caller. + * @return status code + */ + + public static int multiTryCatchThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + Integer.parseInt(str); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + processResult -= 10; + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalStateException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9183fa7bb0590b2bbfb62ea83a0403b2198fd6d1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0057-rt-eh-MultiTryCatchThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MultiTryCatchThrowExceptionTest) +run(MultiTryCatchThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/FunctionNestMultiTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/FunctionNestMultiTryCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e39e05e429645dbb43b454227401a11616c4f61 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/FunctionNestMultiTryCatchExceptionTest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.charset.IllegalCharsetNameException; +import java.util.IllegalFormatException; +public class FunctionNestMultiTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 0 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run1 fun + * @return status code + */ + + public static int run1() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run2(); + } catch (IllegalArgumentException e) { + processResult -= 1; + } + if (processResult == 98) { + result = 0; + processResult -= 3; + } + return result; + } + /** + * Nested run2 fun + * @return status code + */ + + public static int run2() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run3(); + } catch (ClassCastException e) { + processResult -= 2; + } + if (processResult == 97) { + result = 0; + } + return result; + } + /** + * Nested run3 fun + * @return status code + */ + + public static int run3() { + int result = 3; /* STATUS_FAILED*/ + + try { + result = run4(); + } catch (IllegalStateException e) { + processResult -= 3; + } + if (processResult == 96) { + result = 0; + } + return result; + } + /** + * Nested run4 fun + * @return status code + */ + + public static int run4() { + int result = 4; /* STATUS_FAILED*/ + + try { + result = run5(); + } catch (IllegalFormatException e) { + processResult -= 4; + } + if (processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run5 fun + * @return status code + */ + + public static int run5() { + int result = 5; /* STATUS_FAILED*/ + + try { + result = functionNestMultiTryCatchExceptionTest1(); + } catch (IllegalCharsetNameException e) { + processResult -= 5; + } + if (processResult == 94) { + result = 0; + } + return result; + } + /** + * Test try{try{try{try{try{exception}catch()}catch()}catch()}catch()}, -->caller.caller.caller + * @return status code + */ + + public static int functionNestMultiTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + Integer.parseInt(str); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + processResult -= 10; + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalCharsetNameException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8aaf7ee1be5cceb92d43337774c0fc59a9438c9c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0058-rt-eh-FunctionNestMultiTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FunctionNestMultiTryCatchExceptionTest) +run(FunctionNestMultiTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/CatchMultiTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/CatchMultiTryCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1e8fbf3120abf25a363ef6dbf56ad113ad2e963f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/CatchMultiTryCatchExceptionTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CatchMultiTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = catchMultiTryCatchExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try -catch(){try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch(e)}. + * @return status code + */ + + public static int catchMultiTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (StringIndexOutOfBoundsException e4) { + processResult--; + result1 = 1; + } finally { + processResult -= 100; + } + } finally { + processResult--; + } + processResult--; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60bff4bb50468fa0b6abb72a8185dbfca0582b7c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0059-rt-eh-CatchMultiTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CatchMultiTryCatchExceptionTest) +run(CatchMultiTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/CatchMultiTryCatchThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/CatchMultiTryCatchThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..793ca45da6315d9c6e46db9561531229e9003dc9 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/CatchMultiTryCatchThrowExceptionTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CatchMultiTryCatchThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = catchMultiTryCatchThrowExceptionTest1(); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 2; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Try -catch(){try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch()}: -->caller. + * @return status code + */ + + public static int catchMultiTryCatchThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e4) { + processResult -= 10; + } finally { + processResult -= 100; + } + } finally { + processResult--; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fba1be4db611ab20e91bc21013814dd18e001985 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0060-rt-eh-CatchMultiTryCatchThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CatchMultiTryCatchThrowExceptionTest) +run(CatchMultiTryCatchThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/FunctionNestCatchMultiTryExceptionTest.java b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/FunctionNestCatchMultiTryExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..058b0668ceadc262f563020865034aaf3438600e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/FunctionNestCatchMultiTryExceptionTest.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.charset.IllegalCharsetNameException; +import java.util.IllegalFormatException; +public class FunctionNestCatchMultiTryExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 0 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run1 fun + * @return status code + */ + + public static int run1() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run2(); + } catch (StringIndexOutOfBoundsException e) { + processResult--; + } + if (processResult == 96) { + result = 0; + processResult--; + } + return result; + } + /** + * Nested run2 fun + * @return status code + */ + + public static int run2() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run3(); + } catch (ClassCastException e) { + processResult -= 2; + } + if (processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run3 fun + * @return status code + */ + + public static int run3() { + int result = 3; /* STATUS_FAILED*/ + + try { + result = run4(); + } catch (IllegalStateException e) { + processResult -= 3; + } + if (processResult == 94) { + result = 0; + } + return result; + } + /** + * Nested run4 fun + * @return status code + */ + + public static int run4() { + int result = 4; /* STATUS_FAILED*/ + + try { + result = run5(); + } catch (IllegalFormatException e) { + processResult -= 4; + } + if (processResult == 93) { + result = 0; + } + return result; + } + /** + * Nested run5 fun + * @return status code + */ + + public static int run5() { + int result = 5; /* STATUS_FAILED*/ + + try { + result = functionNestCatchMultiTryExceptionTest1(); + } catch (IllegalCharsetNameException e) { + processResult -= 5; + } + if (processResult == 92) { + result = 0; + } + return result; + } + /** + * Test try-catch(){try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch()}: + * @return status code + */ + + public static int functionNestCatchMultiTryExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e4) { + processResult -= 10; + } finally { + processResult -= 100; + } + } finally { + processResult--; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d8c290ed887ba6a7474978b4196c05a79cbdbf36 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0061-rt-eh-FunctionNestCatchMultiTryExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FunctionNestCatchMultiTryExceptionTest) +run(FunctionNestCatchMultiTryExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/FinallyMultiTryCatchExceptionTest.java b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/FinallyMultiTryCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9e07e8c270a00aebc948e885eb233e26ed4e4789 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/FinallyMultiTryCatchExceptionTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class FinallyMultiTryCatchExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = finallyMultiTryCatchExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Try-catch()-finally{try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch(e)}. + * @return status code + */ + + public static int finallyMultiTryCatchExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + } finally { + processResult--; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (StringIndexOutOfBoundsException e4) { + processResult -= 100; + result1 = 1; + } finally { + processResult--; + } + } + processResult--; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..13c0d3e3a66e77d60d8787f4813d9f0c6ee0eebb --- /dev/null +++ b/testsuite/java_test/eh_test/RT0062-rt-eh-FinallyMultiTryCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinallyMultiTryCatchExceptionTest) +run(FinallyMultiTryCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/FinallyMultiTryThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/FinallyMultiTryThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..80bd83de0cc9da993f6352b260d3f63d54200f0f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/FinallyMultiTryThrowExceptionTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class FinallyMultiTryThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = finallyMultiTryThrowExceptionTest1(); + } catch (Exception e) { + processResult -= 2; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Try-catch()-finally{try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch()}: + * @return status code + */ + + public static int finallyMultiTryThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + } finally { + processResult -= 1; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalArgumentException e4) { + processResult -= 10; + } finally { + processResult -= 100; + } + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1acf4999d2b7c70847e9f768501177e392e69ddc --- /dev/null +++ b/testsuite/java_test/eh_test/RT0063-rt-eh-FinallyMultiTryThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinallyMultiTryThrowExceptionTest) +run(FinallyMultiTryThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/MultiTryRecursiveThrowExceptionTest.java b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/MultiTryRecursiveThrowExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..53c08786dfe2677c0cd73768b43df1887643d8e5 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/MultiTryRecursiveThrowExceptionTest.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.charset.IllegalCharsetNameException; +import java.util.IllegalFormatException; +public class MultiTryRecursiveThrowExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 0 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run1 fun + * @return status code + */ + + public static int run1() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run2(); + } catch (StringIndexOutOfBoundsException e) { + processResult--; + } + if (processResult == 96) { + result = 0; + processResult--; + } + return result; + } + /** + * Nested run2 fun + * @return status code + */ + + public static int run2() { + int result = 2; /* STATUS_FAILED*/ + + try { + result = run3(); + } catch (ClassCastException e) { + processResult -= 2; + } + if (processResult == 95) { + result = 0; + } + return result; + } + /** + * Nested run3 fun + * @return status code + */ + + public static int run3() { + int result = 3; /* STATUS_FAILED*/ + + try { + result = run4(); + } catch (IllegalStateException e) { + processResult -= 3; + } + if (processResult == 94) { + result = 0; + } + return result; + } + /** + * Nested run4 fun + * @return status code + */ + + public static int run4() { + int result = 4; /* STATUS_FAILED*/ + + try { + result = run5(); + } catch (IllegalFormatException e) { + processResult -= 4; + } + if (processResult == 93) { + result = 0; + } + return result; + } + /** + * Nested run5 fun + * @return status code + */ + + public static int run5() { + int result = 5; /* STATUS_FAILED*/ + + try { + result = multiTryRecursiveThrowExceptionTest1(); + } catch (IllegalCharsetNameException e) { + processResult -= 5; + } + if (processResult == 92) { + result = 0; + } + return result; + } + /** + * Try-catch()-finally{try{try{try{try{try{exception}catch()}catch()}catch()}catch()}catch()}: + * @return status code + */ + + public static int multiTryRecursiveThrowExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + } catch (IndexOutOfBoundsException e) { + processResult -= 10; + } catch (IllegalArgumentException e) { + processResult--; + } finally { + processResult--; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + try { + processResult += 100; + System.out.println(str.substring(-5)); + } catch (ClassCastException e) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e1) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (ClassCastException e3) { + processResult -= 10; + } finally { + processResult -= 100; + } + } catch (IllegalArgumentException e4) { + processResult -= 10; + } finally { + processResult -= 100; + } + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b4b21ef284ca9fc53da2da770275ca546725984 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0064-rt-eh-MultiTryRecursiveThrowExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MultiTryRecursiveThrowExceptionTest) +run(MultiTryRecursiveThrowExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/JvmArrayIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/JvmArrayIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..63607389a6b7ef93a8d656fd46b1327c46d11681 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/JvmArrayIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class JvmArrayIndexOutOfBoundsExceptionTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + static final int len = 10; + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + Object[] objs = new Object[len]; + try { + Object obj1 = objs[len]; + } catch (ArrayIndexOutOfBoundsException e) { + return 0; // STATUS_PASSED + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d5a187aadf6f76489c4da94b490afa357fdc188f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0066-rt-eh-JvmArrayIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(JvmArrayIndexOutOfBoundsExceptionTest) +run(JvmArrayIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/JvmStaticExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/JvmStaticExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5f1b88ae47fa643fcc0d0b08ba2b300491153109 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/JvmStaticExceptionInInitializerErrorTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class JvmStaticExceptionInInitializerErrorTesta { + static int other_class_test_field = 21; + static int local_field = 5 / 0; + static int testFail() { + int aNum = 1; + return aNum; + } +} +public class JvmStaticExceptionInInitializerErrorTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + try { + int tmp = JvmStaticExceptionInInitializerErrorTesta.testFail(); + } catch (ExceptionInInitializerError e1) { + try { + int tmp = JvmStaticExceptionInInitializerErrorTesta.testFail(); + } catch (NoClassDefFoundError e2) { + return 0; // STATUS_PASSED + } + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fd1a39a766fc8d812a715520faed13a33ac43b74 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0067-rt-eh-JvmStaticExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(JvmStaticExceptionInInitializerErrorTest) +run(JvmStaticExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/MultiTryNoExceptionTest.java b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/MultiTryNoExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..30d157533f6a41a47012cce7e4fd788c7a317aaa --- /dev/null +++ b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/MultiTryNoExceptionTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class MultiTryNoExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = multiTryNoExceptionTest1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test no Exception in try-multi catch-finally. + * @return status code + */ + + public static int multiTryNoExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123456"; + try { + try { + Integer.parseInt(str); + } catch (ClassCastException e) { + result1 = 3; + } catch (IllegalStateException e) { + result1 = 3; + } catch (IndexOutOfBoundsException e) { + result1 = 3; + } finally { + processResult--; + } + processResult--; + } catch (ClassCastException e) { + result1 = 3; + } catch (IllegalStateException e) { + result1 = 3; + } catch (IndexOutOfBoundsException e) { + result1 = 3; + } finally { + processResult--; + result1 = 1; + } + processResult--; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..076f1e950a03beebe27d605f1fbf6470a64a468e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0073-rt-eh-MultiTryNoExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MultiTryNoExceptionTest) +run(MultiTryNoExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/TryCatchReturnExceptionTest.java b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/TryCatchReturnExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8917417782347aebdfb18bb1d6d5fb00cc2c39e3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/TryCatchReturnExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryCatchReturnExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchReturnExceptionTest1(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Test try{exception return_x}-catch(e){return_x}-finally{return_v}. + * @return status code + */ + + public static int tryCatchReturnExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + return processResult; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + processResult -= 1; + result1 = 1; + return result1; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 3; + result1++; + return result1; // Execute return 2 + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dbcc2f0e000f487d029f948f267f569a42f82588 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0074-rt-eh-TryCatchReturnExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchReturnExceptionTest) +run(TryCatchReturnExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/TryReturnValueExceptionTest.java b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/TryReturnValueExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..391eadbd4d559d6659c9324e141edfadaaa95999 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/TryReturnValueExceptionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryReturnValueExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryReturnValueExceptionTest1(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 5 && processResult == 95) { + result = 0; + } + return result; + } + /** + * try{return_v}-catch(x){return_x}-finally{return_x} + * @return status code + */ + + public static int tryReturnValueExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123456"; + try { + Integer.parseInt(str); + return result1; // Execute return result1++. + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return 3; + } catch (NumberFormatException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return 3; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return 3; + } finally { + processResult -= 4; + result1++; + return result1; + } + } +} diff --git a/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ff6b5cdb6cb641893cb40d2c282c22bb49044aa7 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0075-rt-eh-TryReturnValueExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryReturnValueExceptionTest) +run(TryReturnValueExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/TryCatchReturnValueExceptionTest.java b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/TryCatchReturnValueExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0c30bba462022e429dbaea878dbfd8be9d3d13dd --- /dev/null +++ b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/TryCatchReturnValueExceptionTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class TryCatchReturnValueExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = tryCatchReturnValueExceptionTest1(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Try{exception return_x}-catch(e){return_v}-finally{}. + * @return status code + */ + + public static int tryCatchReturnValueExceptionTest1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str = "123#456"; + try { + Integer.parseInt(str); + return processResult; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + processResult--; + result1 = 1; + return result1; // Execute return 1. + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult -= 3; + result1++; + } + processResult -= 10; + return processResult; + } +} diff --git a/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a5e4c3233474a0bab6e463c19427ac3553a8501b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0076-rt-eh-TryCatchReturnValueExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TryCatchReturnValueExceptionTest) +run(TryCatchReturnValueExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/ExcpReturn04140.java b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/ExcpReturn04140.java new file mode 100644 index 0000000000000000000000000000000000000000..c4763e68f016886a0a461dc98c5f8e740c5a90f3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/ExcpReturn04140.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ExcpReturn04140 { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = excpReturn041401(); + } catch (NumberFormatException e) { + processResult -= 10; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * try{exception return_x}-catch(e){}-finally{},return_v + * @return status code + */ + + public static int excpReturn041401() { + int result1 = 4; /*STATUS_FAILED*/ + String str = "123#456"; + try { + Integer.parseInt(str); + return processResult; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (NumberFormatException e) { + processResult--; + result1 = 1; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } finally { + processResult--; + result1++; + } + processResult -= 2; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/expected.txt b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/test.cfg b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d265bb414a843397337e86cf39c2ef42ec751aed --- /dev/null +++ b/testsuite/java_test/eh_test/RT0077-rt-eh-ExcpReturn04140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ExcpReturn04140) +run(ExcpReturn04140) diff --git a/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/ExcpReturn04150.java b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/ExcpReturn04150.java new file mode 100644 index 0000000000000000000000000000000000000000..3962ce01e869ca311a5015ffcb677f80a95db95b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/ExcpReturn04150.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ExcpReturn04150 { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = excpReturn04150(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 5 && processResult == 95) { + result = 0; + } + return result; + } + /** + * try{exception return_x}-catch(x){}-finally{return_v},-->caller(x) + * @return status code + */ + + public static int excpReturn04150() { + int result1 = 4; /*STATUS_FAILED*/ + String str = "123#456"; + try { + Integer.parseInt(str); + return processResult; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return result1; + } catch (StringIndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return result1; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return result1; + } finally { + processResult -= 4; + result1++; + return result1; // execute return 5 + } + } +} diff --git a/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/expected.txt b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/test.cfg b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2617dad2f6fdbbbd1b47a2045ef2861b42522693 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0078-rt-eh-ExcpReturn04150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ExcpReturn04150) +run(ExcpReturn04150) diff --git a/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/ExcpReturn04160.java b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/ExcpReturn04160.java new file mode 100644 index 0000000000000000000000000000000000000000..12c6675df9d9e031b4a5ea75dcd53e111ce58688 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/ExcpReturn04160.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ExcpReturn04160 { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = excpReturn04160(); + } catch (Exception e) { + processResult -= 2; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * try{exception return_x}-catch(x){}-finally{},return_x-->caller(v) + * @return status code + */ + + public static int excpReturn04160() { + int result1 = 4; /*STATUS_FAILED*/ + String str = "123#456"; + try { + Integer.parseInt(str); + return processResult; + } catch (ClassCastException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + } catch (StringIndexOutOfBoundsException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return result1; + } catch (IllegalStateException e) { + System.out.println("=====See:ERROR!!!"); + result1 = 3; + return result1; + } finally { + processResult -= 2; + result1++; + } + processResult -= 10; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/expected.txt b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/test.cfg b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..409e75b04c822c5e490e5884c9317b95ec82f944 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0079-rt-eh-ExcpReturn04160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ExcpReturn04160) +run(ExcpReturn04160) diff --git a/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest.java b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..00b8157c860be84fc9e9db0df4f26559223cc6c4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = accessibleObjectgAnnotationsByTypeNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in addSuppressed:public T[] getAnnotationsByType(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int accessibleObjectgAnnotationsByTypeNullPointerException() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + AccessibleObject accessibleObject = Test013.class.getMethod("getName", new Class[] {}); + try { + Object file1 = accessibleObject.getAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test013 { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b8554851bb45157b75a7307285b30b9c3bf80f0b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0516-rt-eh-AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest) +run(AccessibleObjectGetAnnotationsByTypeNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/AccessibleObjectGetDeclaredAnnotationExceptionTest.java b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/AccessibleObjectGetDeclaredAnnotationExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1cf742a55f5e2b125e0bf62448f52bed664a0803 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/AccessibleObjectGetDeclaredAnnotationExceptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectGetDeclaredAnnotationExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = accessibleObjectgDeclaredAnnotationNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in AccessibleObject: T getDeclaredAnnotation(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int accessibleObjectgDeclaredAnnotationNullPointerException() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /* STATUS_FAILED*/ + + AccessibleObject accessibleObject = Test02aa.class.getMethod("getName", new Class[] {}); + try { + Object file1 = accessibleObject.getDeclaredAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test02aa { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7bbd31340462a49b4897c1b45959da4b0e143498 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0517-rt-eh-AccessibleObjectGetDeclaredAnnotationExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectGetDeclaredAnnotationExceptionTest) +run(AccessibleObjectGetDeclaredAnnotationExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest.java b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f096a781d57657a1c9468b53d47a3148b06b3a6f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = accessibleObjectgDeclaredAnnotationsByTypeNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in AccessibleObject:public T[] getAnnotationsByType(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int accessibleObjectgDeclaredAnnotationsByTypeNullPointerException() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /* STATUS_FAILED*/ + + AccessibleObject mt = Test01a.class.getMethod("getName", new Class[] {}); + try { + Object file1 = mt.getDeclaredAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult -= 1; + } + return result1; + } +} +class Test01a { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9ccb1a3f1e521a713abe0d4fe658be257b3db92d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0518-rt-eh-AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest) +run(AccessibleObjectGetDeclaredAnnotationsByTypeExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/CharacterCodePointCountIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/CharacterCodePointCountIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..dd9789f02b757cf51a8351f0f3aafa13c9acb93b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/CharacterCodePointCountIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CharacterCodePointCountIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = charactercodePointCountIndexOutOfBoundsException1(); + } catch (Exception e) { + processResult -= 20; + } + try { + result = charactercodePointCountIndexOutOfBoundsException2(); + } catch (Exception e) { + processResult -= 40; + } + if (result == 4 && processResult == 97) { + result = 0; + } + return result; + } + /** + * Test method codePointCount(char[] seq, int offset, int count). + * @return status code + */ + + public static int charactercodePointCountIndexOutOfBoundsException1() { + int result1 = 4; /*STATUS_FAILED*/ + char[] chars = new char[] {'a', 'b', 'c', 'd', 'e'}; + int offset = 1; + int count = 10; + try { + int obj = Character.codePointCount(chars, offset, count); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult -= 1; + } + return result1; + } + /** + * Test method codePointCount(CharSequence seq, int beginIndex, int endIndex). + * @return status code + */ + + public static int charactercodePointCountIndexOutOfBoundsException2() { + int result1 = 4; /*STATUS_FAILED*/ + CharSequence seq = "a b c d e"; + int offset = 1; + int count = 10; + try { + int obj = Character.codePointCount(seq, offset, count); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..85fccc008ad11474df3cbd08be91001a58005069 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0519-rt-eh-CharacterCodePointCountIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterCodePointCountIndexOutOfBoundsExceptionTest) +run(CharacterCodePointCountIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/CharactercodePointCountNullPointerException.java b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/CharactercodePointCountNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..f98216c2f8ef155eaf18012b7e46de769e91a068 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/CharactercodePointCountNullPointerException.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CharactercodePointCountNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = charactercodePointCountNullPointerException(); + } catch (Exception e) { + processResult -= 20; + } + try { + result = charactercodePointCountNullPointerException2(); + } catch (Exception e) { + processResult -= 40; + } + if (result == 4 && processResult == 97) { + result = 0; + } + return result; + } + /** + * codePointCount(char[] a, int offset, int count),a is null,catch NullPointerException + * @return status code + */ + + public static int charactercodePointCountNullPointerException() { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if seq is null. + // + // public static int codePointCount(char[] a, int offset, int count) + int offset = 1; + int count = 4; + char[] chars = null; + try { + int obj = Character.codePointCount(chars, offset, count); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } + /** + * codePointCount(CharSequence seq, int beginIndex, int endIndex), seq is null,catch NullPointerException + * @return status code + */ + + public static int charactercodePointCountNullPointerException2() { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if seq is null. + // + // public static int codePointCount(CharSequence seq, int beginIndex, int endIndex) + int offset = 1; + int count = 4; + CharSequence seq = null; + try { + int obj = Character.codePointCount(seq, offset, count); + processResult -= 30; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6fd6a7f062feb78d619e0db5b0c68d00e9b80b7f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0520-rt-eh-CharactercodePointCountNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharactercodePointCountNullPointerException) +run(CharactercodePointCountNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/CharacteroffsetByCodePointsIndexOutOfBoundsException.java b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/CharacteroffsetByCodePointsIndexOutOfBoundsException.java new file mode 100644 index 0000000000000000000000000000000000000000..774ba8e8ddbd5d3961bb6aa5a043e7ba809cdd5d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/CharacteroffsetByCodePointsIndexOutOfBoundsException.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CharacteroffsetByCodePointsIndexOutOfBoundsException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = characteroffsetByCodePointsIndexOutOfBoundsException1(); + } catch (Exception e) { + processResult -= 20; + } + try { + result = characteroffsetByCodePointsIndexOutOfBoundsException2(); + } catch (Exception e) { + processResult -= 40; + } + if (result == 4 && processResult == 97) { + result = 0; + } + return result; + } + /** + * offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset), check IndexOutOfBoundsException + * @return status code + */ + + public static int characteroffsetByCodePointsIndexOutOfBoundsException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IndexOutOfBoundsException -if start or count is negative, or if start + count is larger than the length + // of the given array, or if index is less than start or larger then start + count, or if codePointOffset + // is positive and the text range starting with index and ending with start + count - 1 has fewer than + // codePointOffset code points, or if codePointOffset is negative and the text range starting with start and + // ending with index - 1 has fewer than the absolute value of codePointOffset code points. + // + // public static int offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset) + int offset = 0; + int count = 10; + char[] chars = new char[] {'a', 'b', 'c', 'd', 'e'}; + try { + int obj = Character.offsetByCodePoints(chars, offset, count, 0, 0); + System.out.println(obj); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + /** + * offsetByCodePoints(CharSequence seq, int index, int codePointOffset), catch IndexOutOfBoundsException + * @return status code + */ + + public static int characteroffsetByCodePointsIndexOutOfBoundsException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IndexOutOfBoundsException -if start or count is negative, or if start + count is larger than the length + // of the given array, or if index is less than start or larger then start + count, or if codePointOffset + // is positive and the text range starting with index and ending with start + count - 1 has fewer than + // codePointOffset code points, or if codePointOffset is negative and the text range starting with start and + // ending with index - 1 has fewer than the absolute value of codePointOffset code points. + // + // public static int offsetByCodePoints(CharSequence seq, int index, int codePointOffset) + int offset = 0; + int count = 10; + CharSequence seq = "a b c d e"; + try { + int obj = Character.offsetByCodePoints(seq, offset, count); + System.out.println(obj); + processResult -= 30; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/expected.txt b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/test.cfg b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..394dd1fc2acdb9306b6809debce196b743efa32d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0521-rt-eh-CharacteroffsetByCodePointsIndexOutOfBoundsException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacteroffsetByCodePointsIndexOutOfBoundsException) +run(CharacteroffsetByCodePointsIndexOutOfBoundsException) diff --git a/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/CharacteroffsetByCodePointsNullPointerException.java b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/CharacteroffsetByCodePointsNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..5bbc7e6f87588fb4eb4d0338c7323ec3e3cb8213 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/CharacteroffsetByCodePointsNullPointerException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CharacteroffsetByCodePointsNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + ; + try { + result = characteroffsetByCodePointsNullPointerException1(); + } catch (Exception e) { + processResult -= 20; + } + try { + result = characteroffsetByCodePointsNullPointerException2(); + } catch (Exception e) { + processResult -= 40; + } + if (result == 4 && processResult == 97) { + result = 0; + } + return result; + } + /** + * offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset), catch NullPointerException + * @return status code + */ + + public static int characteroffsetByCodePointsNullPointerException1() { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if seq is null. + // + // public static int offsetByCodePoints(char[] a, int start, int count, int index, int codePointOffset) + int offset = 1; + int count = 4; + char[] chars = null; + try { + int obj = Character.offsetByCodePoints(chars, offset, count, 0, 2); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } + /** + * offsetByCodePoints(CharSequence seq, int index, int codePointOffset), catch NullPointerException + * @return status code + */ + + public static int characteroffsetByCodePointsNullPointerException2() { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if seq is null. + // + // public static int offsetByCodePoints(CharSequence seq, int index, int codePointOffset) + int offset = 1; + int count = 4; + CharSequence seq = null; + try { + int obj = Character.offsetByCodePoints(seq, offset, count); + processResult -= 30; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5a9a8e76890fec60e4ed5cf73440dbe93dec4443 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0522-rt-eh-CharacteroffsetByCodePointsNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacteroffsetByCodePointsNullPointerException) +run(CharacteroffsetByCodePointsNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/ClassasSubclassClassCastException.java b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/ClassasSubclassClassCastException.java new file mode 100644 index 0000000000000000000000000000000000000000..e4e4e3a2f8d67090eff1c2a392fc9c07af7be0fb --- /dev/null +++ b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/ClassasSubclassClassCastException.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.List; +public class ClassasSubclassClassCastException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classAsSubclassClassCastException(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * asSubclass(Class clazz), check ClassCastException + * @return status code + */ + + public static int classAsSubclassClassCastException() { + int result1 = 4; /*STATUS_FAILED*/ + // ClassCastException - if this Class object does not represent a subclass of the specified class + // (here "subclass" includes the class itself). + // + // public Class asSubclass(Class clazz) + La1 la1 = new La1(); + try { + Class strListCast = la1.getClass().asSubclass(List.class); + processResult -= 10; + } catch (ClassCastException e1) { + processResult -= 1; + } + return result1; + } +} +class La1 { + /** + * just for test + */ + + public int field1 = 1; + /** + * just for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * just for test + */ + + public static int field3 = field2[3]; +} diff --git a/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/expected.txt b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/test.cfg b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..66c1224dd1de9d14d3c8047fa0aa9d39b250d5d7 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0523-rt-eh-ClassasSubclassClassCastException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassasSubclassClassCastException) +run(ClassasSubclassClassCastException) diff --git a/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/ClasscastClassCastException.java b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/ClasscastClassCastException.java new file mode 100644 index 0000000000000000000000000000000000000000..b4dd242a80da080e269b0947e2c5ce2074d4fef5 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/ClasscastClassCastException.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClasscastClassCastException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classCastClassCastException(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class:public T cast(Object obj) + * @return status code + */ + + public static int classCastClassCastException() { + int result1 = 4; /*STATUS_FAILED*/ + // ClassCastException - if this Class object does not represent a subclass of the specified class + // (here "subclass" includes the class itself). + // + // public T cast(Object obj) + Object obj1 = new Cast1(); + Cast2 cast22 = new Cast2(); + try { + Object type1 = Cast1.class.cast(cast22); + System.out.println(type1.getClass()); + processResult -= 10; + } catch (ClassCastException e1) { + processResult -= 1; + } + return result1; + } +} +class Cast1 { + String str1 = "str1"; + /** + * set String method1 + */ + + public static void setStr() { + String method1 = "1"; + } +} +class Cast2 { + String str2 = "str2"; + /** + * set String method2 + */ + + public static void setInt() { + int method2 = 2; + } +} diff --git a/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/expected.txt b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/test.cfg b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..da5b00bec00d3d3f1f5524b1e185a8792b8abcc9 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0524-rt-eh-ClasscastClassCastException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClasscastClassCastException) +run(ClasscastClassCastException) diff --git a/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/ClassforName1ParExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/ClassforName1ParExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..bd003dfbc981ebcfbbfcefc00230939e49ab00e8 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/ClassforName1ParExceptionInInitializerError.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClassforName1ParExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classForName1ParExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class :public static Class forName(String name, boolean initialize, ClassLoader loader) + * @return status code + * @throws ClassNotFoundException + */ + + public static int classForName1ParExceptionInInitializerError() throws ClassNotFoundException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError - if the initialization provoked by this method fails + // + // public static Class forName(String className) + Class cls = Class.forName("ClassforName1ParExceptionInInitializerError"); + ClassLoader cLoader = cls.getClassLoader(); + try { + Class cls2 = Class.forName("Cast6"); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class Cast6 { + String str1 = "str1"; + /** + * set String method1 + */ + + public static void setStr() { + String method1 = "1"; + } + static { + int num = 1 / 0; + } +} diff --git a/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..421fcd51dd256689e6cab89d343900246ffc083d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0525-rt-eh-ClassforName1ParExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassforName1ParExceptionInInitializerError) +run(ClassforName1ParExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/ClassforNameExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/ClassforNameExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..d91a427b6457123e207e903214384f1599aa7ef3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/ClassforNameExceptionInInitializerError.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClassforNameExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classForNameExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class :public static Class forName(String name, boolean initialize, ClassLoader loader) + * @return status code + * @throws ClassNotFoundException + */ + + public static int classForNameExceptionInInitializerError() throws ClassNotFoundException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError - if the initialization provoked by this method fails + // + // public static Class forName(String name, boolean initialize, ClassLoader loader) + Class cls = Class.forName("ClassforNameExceptionInInitializerError"); + ClassLoader cLoader = cls.getClassLoader(); + try { + Class cls2 = Class.forName("Cast5", true, cLoader); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class Cast5 { + String str1 = "str1"; + /** + * set String method1 + */ + + public static void setStr() { + String method1 = "1"; + } + static { + int num = 1 / 0; + } +} diff --git a/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e72124af1fb755ac3bfd238e2463f2796ed586c6 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0526-rt-eh-ClassforNameExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassforNameExceptionInInitializerError) +run(ClassforNameExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/ClassgAnnotationsByTypeNullPointerException.java b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/ClassgAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..705de15d40f41524841154f3bdbeb83c96b4a402 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/ClassgAnnotationsByTypeNullPointerException.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClassgAnnotationsByTypeNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classGAnnotationsByTypeNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in AccessibleObject:public A[] getAnnotationsByType(Class annotationClass) + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int classGAnnotationsByTypeNullPointerException() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException- Null pointer exception + // public A[] getAnnotationsByType(Class annotationClass) + Class class1 = Class.class; + try { + Object file1 = class1.getAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test01c { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cb4558b4227ea5c9f3c78f3ebcc48d2d581224ef --- /dev/null +++ b/testsuite/java_test/eh_test/RT0527-rt-eh-ClassgAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassgAnnotationsByTypeNullPointerException) +run(ClassgAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/ClassgetDeclaredAnnotationNullPointerException.java b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/ClassgetDeclaredAnnotationNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..6e7e8f1957edc4c6da8d4a1d343c35a1dca896d3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/ClassgetDeclaredAnnotationNullPointerException.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.annotation.Annotation; +public class ClassgetDeclaredAnnotationNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classGetDeclaredAnnotationNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in AccessibleObject:public A getDeclaredAnnotation + * @return status code + */ + + public static int classGetDeclaredAnnotationNullPointerException() { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException- Null pointer exception + // public A getDeclaredAnnotation(Class annotationClass) + Class class1 = Class.class; + try { + // Object file1 = m. getAnnotationsByType(null); + // getDeclaredAnnotation + Annotation file1 = class1.getDeclaredAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult -= 1; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..81ebf80e7c4af9559e440436a23a61e591284110 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0528-rt-eh-ClassgetDeclaredAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassgetDeclaredAnnotationNullPointerException) +run(ClassgetDeclaredAnnotationNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/ClassgetDeclaredFieldNoSuchFieldException.java b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/ClassgetDeclaredFieldNoSuchFieldException.java new file mode 100644 index 0000000000000000000000000000000000000000..b6a5f6b556e4691b1659c2e4460231c3cbda05a1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/ClassgetDeclaredFieldNoSuchFieldException.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class ClassgetDeclaredFieldNoSuchFieldException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classGetDeclaredFieldNoSuchFieldException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class constructor:public Field getDeclaredField(String name) + * @return status code + */ + + public static int classGetDeclaredFieldNoSuchFieldException() { + int result1 = 4; /*STATUS_FAILED*/ + // NoSuchFieldException - if a field with the specified name is not found. + // + // public Field getDeclaredField(String name) + Class class1 = Class.class; + try { + Field file1 = class1.getDeclaredField("abc123"); + processResult -= 10; + } catch (NoSuchFieldException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/expected.txt b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/test.cfg b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0487fe15a30bdafcd2ef55e68040acb06fb0fe6f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0529-rt-eh-ClassgetDeclaredFieldNoSuchFieldException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassgetDeclaredFieldNoSuchFieldException) +run(ClassgetDeclaredFieldNoSuchFieldException) diff --git a/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/ClassgetDeclaredFieldNullPointerException.java b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/ClassgetDeclaredFieldNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..c3254b58d0efb785c0590826d07c3919ac1e16d9 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/ClassgetDeclaredFieldNullPointerException.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class ClassgetDeclaredFieldNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = classGetDeclaredFieldNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class constructor:public Field getDeclaredField(String name) + * @return status code + * @throws NoSuchFieldException + */ + + public static int classGetDeclaredFieldNullPointerException() throws NoSuchFieldException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if name is null. + // + // public Field getDeclaredField(String name) + String string = null; + Class class1 = Class.class; + try { + Field file1 = class1.getDeclaredField(string); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f6ef15598c715004ccb42144bda212b731aaf31 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0530-rt-eh-ClassgetDeclaredFieldNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassgetDeclaredFieldNullPointerException) +run(ClassgetDeclaredFieldNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/ConstructorgAnnotationNullPointerException.java b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/ConstructorgAnnotationNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..1d9c17946beda4f2ea97ed24a2b85bc4ec05b274 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/ConstructorgAnnotationNullPointerException.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Constructor; +public class ConstructorgAnnotationNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = constructorGAnnotationNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Constructor:public T getAnnotation + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int constructorGAnnotationNullPointerException() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - Null pointer exception + // public T getAnnotation(Class annotationClass) + Class class1 = Test01b.class; + Constructor c1 = class1.getConstructor(new Class[] {String.class}); + // Constructor m = Class.class.getMethod("getName", new Class[] {}); + try { + Object file1 = c1.getAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult -= 1; + } + return result1; + } +} +class Test01b { + /** + * just for test + */ + + public String name = "default"; + public String getName() { + return name; + } + public Test01b(String hh) { + this.name = hh; + } +} diff --git a/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a553804499f13a62e62616f67c0c70a4b074bf4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0531-rt-eh-ConstructorgAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorgAnnotationNullPointerException) +run(ConstructorgAnnotationNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/ConstructornewInstanceExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/ConstructornewInstanceExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..adb4389c95eea3700991bad113b7d2abe05201d1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/ConstructornewInstanceExceptionInInitializerError.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +public class ConstructornewInstanceExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = constructorNewInstanceExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + // System.out.println("result: " + result); + // System.out.println("ConstructornewInstanceExceptionInInitializerError.res: " + + // ConstructornewInstanceExceptionInInitializerError.res); + return result; + } + /** + * In a static variable initialization exception occurs + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + * @throws InstantiationException + * @throws IllegalAccessException + * @throws IllegalArgumentException + * @throws InvocationTargetException + */ + + public static int constructorNewInstanceExceptionInInitializerError() + throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, + IllegalArgumentException, InvocationTargetException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError - In a static variable initialization exception occurs + // public T newInstance(Object... initargs) + Class class1 = Test01n.class; + Constructor c1 = class1.getConstructor(new Class[] {}); + try { + Object file1 = c1.newInstance(); + // System.out.println(file1); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult -= 1; + } + return result1; + } +} +class Test01n { + /** + * test a String val + */ + + public String name = "default"; + public String getName() { + return name; + } + public Test01n() { + this.name = "init"; + } + static { + int num = 1 / 0; + } +} diff --git a/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..83616c8d7c3dbd985aecacb0cd447cd51d91e191 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0532-rt-eh-ConstructornewInstanceExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructornewInstanceExceptionInInitializerError) +run(ConstructornewInstanceExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/FieldgetAnnotationNullPointerException.java b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/FieldgetAnnotationNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..f70d44a75555ace8e3c268d2547e9d4dce68f328 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/FieldgetAnnotationNullPointerException.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetAnnotationNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetAnnotationNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Class reflect Field:public T getAnnotation(Class annotationClass) + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + */ + + public static int fieldGetAnnotationNullPointerException() throws NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if the specified object is null and the field is an instance field. + // public T getAnnotation(Class annotationClass) + Field field = Test01a.class.getDeclaredField("field1"); + try { + Object value = field.getAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } + class Test01a { + /** + * a field for test + */ + + public int field1 = 1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..032e4414417da472004e39462088a1e895f7004d --- /dev/null +++ b/testsuite/java_test/eh_test/RT0533-rt-eh-FieldgetAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetAnnotationNullPointerException) +run(FieldgetAnnotationNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/FieldgetAnnotationsByTypeNullPointerException.java b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/FieldgetAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..fb672728b0ecec5429999553ac5398b9117a8de9 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/FieldgetAnnotationsByTypeNullPointerException.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetAnnotationsByTypeNullPointerException { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetAnnotationsByTypeNullPointerException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect Field:public T[] getAnnotationsByType(Class annotationClass) + * @return status code + * @throws IllegalArgumentException + * @throws IllegalAccessException + * @throws NoSuchFieldException + * @throws SecurityException + */ + + public static int fieldGetAnnotationsByTypeNullPointerException() + throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - if the specified object is null and the field is an instance field. + // public T[] getAnnotationsByType(Class annotationClass) + Field field = Test01a.class.getDeclaredField("field1"); + try { + Object value = field.getAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult -= 1; + } + return result1; + } + class Test01a { + /** + * a field for test + */ + + public int field1 = 1; + } +} diff --git a/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..672c21b93e1691dfd1c432aa9a62313d2683b976 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0534-rt-eh-FieldgetAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetAnnotationsByTypeNullPointerException) +run(FieldgetAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/FieldgetByteExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/FieldgetByteExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..7f746628c75cc1e30ddb53ce6ea9d02cb171435f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/FieldgetByteExceptionInInitializerError.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetByteExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetByteExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public byte getByte(Object obj) + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetByteExceptionInInitializerError() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError -if the initialization provoked by this method fails. + // + // public byte getByte(Object obj) + Field field = Test03aa.class.getDeclaredField("field6"); + try { + byte obj = field.getByte(new Test03aa()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class Test03aa { + /** + * define a byte for test + */ + + public static byte field6 = selfByte(); + /** + * define a int[] filed for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set bValue and return + * @return bValue + */ + + public static byte selfByte() { + int self1 = field2[2]; + byte bValue = 11; + return bValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6717d400fbb8b28d71ba63c347bf2d92bdb0cada --- /dev/null +++ b/testsuite/java_test/eh_test/RT0535-rt-eh-FieldgetByteExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetByteExceptionInInitializerError) +run(FieldgetByteExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/FieldgetCharExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/FieldgetCharExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..2fd89613d82cb3f5610edec08bb2f6b19e175c36 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/FieldgetCharExceptionInInitializerError.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetCharExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetCharExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public byte getByte(Object obj) + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetCharExceptionInInitializerError() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError -if the initialization provoked by this method fails. + // + // public char getChar(Object obj) + Field field = TestChar.class.getDeclaredField("field6"); + try { + char obj = field.getChar(new TestChar()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestChar { + /** + * a char field for test + */ + + public static char field6 = selfChar(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set cValue and return + */ + + public static char selfChar() { + int self1 = field2[2]; + char cValue = 11; + return cValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3c9493036d49299861127e7fbff76a8ad8f23e1b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0536-rt-eh-FieldgetCharExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetCharExceptionInInitializerError) +run(FieldgetCharExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/FieldgetDoubleExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/FieldgetDoubleExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..8e10ec96ff279e9b47961b5a6709f2cc3f42015a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/FieldgetDoubleExceptionInInitializerError.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetDoubleExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetDoubleExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public double getDouble(Object obj) + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetDoubleExceptionInInitializerError() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError -if the initialization provoked by this method fails. + // + // public double getDouble(Object obj) + Field field = TestDouble.class.getDeclaredField("field6"); + try { + double obj = field.getDouble(new TestDouble()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestDouble { + /** + * a double field for test + */ + + public static double field6 = selfDouble(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set dValue and return + */ + + public static double selfDouble() { + int self1 = field2[2]; + double dValue = 11; + return dValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c524171949ffe627dd2be7b122787eaaf5b71bcf --- /dev/null +++ b/testsuite/java_test/eh_test/RT0537-rt-eh-FieldgetDoubleExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetDoubleExceptionInInitializerError) +run(FieldgetDoubleExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/FieldgetExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/FieldgetExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..9addf445cb1084c072091b66faf85d718fd9a423 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/FieldgetExceptionInInitializerError.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect field:public Object get(Object obj) + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetExceptionInInitializerError() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError -if the initialization provoked by this method fails. + // + // public Object get(Object obj) + // Test01aa class1 = new Test01aa(); + Field field = Test01aa.class.getDeclaredField("field1"); + try { + Object obj = field.get(new Test01aa()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class Test01aa { + /** + * a int field for test + */ + + public int field1 = 1; + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * a int field for test + */ + + public static int field3 = field2[3]; + static { + int field4 = 1 / 0; + } +} diff --git a/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..439eba26e34b0e04a13705b6e3bd2917edb2ce9b --- /dev/null +++ b/testsuite/java_test/eh_test/RT0538-rt-eh-FieldgetExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetExceptionInInitializerError) +run(FieldgetExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/FieldgetFloatExceptionInInitializerError.java b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/FieldgetFloatExceptionInInitializerError.java new file mode 100644 index 0000000000000000000000000000000000000000..0cbda1c5bda2ea8db4a263376316bef4f75fae96 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/FieldgetFloatExceptionInInitializerError.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldgetFloatExceptionInInitializerError { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetFloatExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public float getFloat(Object obj) + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetFloatExceptionInInitializerError() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + // ExceptionInInitializerError -if the initialization provoked by this method fails. + // + // public float getFloat(Object obj) + Field field = TestFloat.class.getDeclaredField("field6"); + try { + float obj = field.getFloat(new TestFloat()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestFloat { + /** + * a float field for test + */ + + public static float field6 = selfDouble(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set fValue and return + * @return fValue + */ + + public static float selfDouble() { + int self1 = field2[2]; + float fValue = 11; + return fValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/expected.txt b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/test.cfg b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a417851ab9816094f390139d60e426c8d4063611 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0539-rt-eh-FieldgetFloatExceptionInInitializerError/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldgetFloatExceptionInInitializerError) +run(FieldgetFloatExceptionInInitializerError) diff --git a/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/FieldGetIntExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/FieldGetIntExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..033c9613f83b5cc67eb1a3002a27673ce2d9dbd8 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/FieldGetIntExceptionInInitializerErrorTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldGetIntExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldGetIntExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public int getInt(Object obj). + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetIntExceptionInInitializerErrorTest() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestInt.class.getDeclaredField("field6"); + try { + int obj = field.getInt(new TestInt()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestInt { + /** + * a int field for test + */ + + public static int field6 = selfDouble(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set iValue and return + * @return iValue + */ + + public static int selfDouble() { + int self1 = field2[2]; + int iValue = 11; + return iValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..492635c1f77e04646bd5141aafff9b274076cbd2 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0541-rt-eh-FieldGetIntExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetIntExceptionInInitializerErrorTest) +run(FieldGetIntExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/FieldGetLongExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/FieldGetLongExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..465c9063106f0369106163a097c3060568b6f1ce --- /dev/null +++ b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/FieldGetLongExceptionInInitializerErrorTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldGetLongExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldGetLongExceptionInInitializerErrorTes1(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public double getLong(Object obj). + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetLongExceptionInInitializerErrorTes1() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field fe = TestLong.class.getDeclaredField("field6"); + try { + long obj = fe.getLong(new TestLong()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestLong { + /** + * a long field for test + */ + + public static long field6 = selfDouble(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set lValue and return + * @return lValue + */ + + public static long selfDouble() { + int self1 = field2[2]; + long lValue = 11; + return lValue; + } +} diff --git a/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ac7b00c273e96dfd857dd8c513a11f3f70f52547 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0542-rt-eh-FieldGetLongExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetLongExceptionInInitializerErrorTest) +run(FieldGetLongExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/FieldGetShortExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/FieldGetShortExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6df9f34b16494757b127d1378410fb844f547ab8 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/FieldGetShortExceptionInInitializerErrorTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldGetShortExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldGetShortExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public short getShort(Object obj). + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldGetShortExceptionInInitializerErrorTest() + throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestShort.class.getDeclaredField("field6"); + try { + short obj = field.getShort(new TestShort()); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestShort { + /** + * a short field for test + */ + + public static short field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static short selfShort() { + int self1 = field2[2]; + short value = 11; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a96dc57d1a7ff5149e5e0f54115e8977ba3cc049 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0543-rt-eh-FieldGetShortExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetShortExceptionInInitializerErrorTest) +run(FieldGetShortExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/FieldSetBooleanExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/FieldSetBooleanExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..53656510a0213c7b00c7bbc4ceae372d578e584a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/FieldSetBooleanExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetBooleanExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetBooleanExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setBoolean(Object obj, boolean z). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetBooleanExceptionInInitializerErrorTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSetBoolean.class.getDeclaredField("field6"); + try { + field.setBoolean(new TestSetBoolean(), false); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetBoolean { + /** + * a boolean field for test + */ + + public static boolean field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static boolean selfShort() { + int self1 = field2[2]; + boolean value = true; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..18a542b7f3b9c20738a5f94d6a3d9fbf4a53e2a4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0544-rt-eh-FieldSetBooleanExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,4 @@ +clean() +compile(FieldSetBooleanExceptionInInitializerErrorTest) +run(FieldSetBooleanExceptionInInitializerErrorTest) + diff --git a/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/FieldSetByteExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/FieldSetByteExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..06dcea300d93ec7560d145c76227754884de01a1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/FieldSetByteExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetByteExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetByteExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setByte(Object obj, byte b). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetByteExceptionInInitializerErrorTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSetByte.class.getDeclaredField("field6"); + try { + field.setByte(new TestSetByte(), (byte) 1); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetByte { + /** + * a byte field for test + */ + + public static byte field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static byte selfShort() { + int self1 = field2[2]; + byte value = (byte) 2; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f7d2187cf0969842cbc61d673964c903d4578db --- /dev/null +++ b/testsuite/java_test/eh_test/RT0545-rt-eh-FieldSetByteExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetByteExceptionInInitializerErrorTest) +run(FieldSetByteExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/FieldSetCharExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/FieldSetCharExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..6f58ac91fb4e0c380f8e00641b2b03e90ea0b328 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/FieldSetCharExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetCharExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetCharExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public void setChar(Object obj, char c). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetCharExceptionInInitializerErrorTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSetChar.class.getDeclaredField("field6"); + try { + field.setChar(new TestSetChar(), 'c'); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetChar { + /** + * a char field for test + */ + + public static char field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static char selfShort() { + int self1 = field2[2]; + char value = 'a'; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5f4a4113ec9308cdfec17c9542377c82fc9f5818 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0546-rt-eh-FieldSetCharExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetCharExceptionInInitializerErrorTest) +run(FieldSetCharExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/FieldSetDoubleExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/FieldSetDoubleExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c951841d828f350a191d2830c39aa43b91cfdd65 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/FieldSetDoubleExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetDoubleExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetDoubleExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed:public void setDouble(Object obj, double d). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetDoubleExceptionInInitializerErrorTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSetDouble.class.getDeclaredField("field6"); + try { + field.setDouble(new TestSetDouble(), 23); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetDouble { + /** + * a double field for test + */ + + public static double field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static double selfShort() { + int self1 = field2[2]; + double value = 12; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dae417d167dc104faf4dacfd06007aefd35da03f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0547-rt-eh-FieldSetDoubleExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetDoubleExceptionInInitializerErrorTest) +run(FieldSetDoubleExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/FieldSetExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/FieldSetExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..571c1db7cddbb959952ba504e56136df667bc24c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/FieldSetExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void set(Object obj, Object value). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetExceptionInInitializerError() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSet.class.getDeclaredField("field6"); + try { + field.set(new TestSet(), 123); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSet { + /** + * a int field for test + */ + + public static int field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static int selfShort() { + int self1 = field2[2]; + int value = 11; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..15c34fbead447549216fe0c823635c661e800838 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0548-rt-eh-FieldsetExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetExceptionInInitializerErrorTest) +run(FieldSetExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/FieldSetFloatExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/FieldSetFloatExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5a56824f92f102665e95913de42e85224b1f154c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/FieldSetFloatExceptionInInitializerErrorTest.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetFloatExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = fieldSetFloatExceptionInInitializerErrorTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setFloat(Object obj, float f). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetFloatExceptionInInitializerErrorTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /* STATUS_FAILED*/ + + Field field = TestSetFloat.class.getDeclaredField("field6"); + try { + field.setFloat(new TestSetFloat(), (float) 0.12); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetFloat { + /** + * a float field for test + */ + + public static float field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static float selfShort() { + int self1 = field2[2]; + float value = (float) 12.54; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3d17ce1990e3697000c1ee9389c1b503a47fbe74 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0549-rt-eh-FieldSetFloatExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetFloatExceptionInInitializerErrorTest) +run(FieldSetFloatExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/FieldSetIntExceptionTest.java b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/FieldSetIntExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e36710b6ba8253c810616c656c7c8a3f44000dc1 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/FieldSetIntExceptionTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetIntExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldSetIntExceptionTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setInt(Object obj, int i). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetIntExceptionTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + Field field = TestSetInt.class.getDeclaredField("field6"); + try { + field.setInt(new TestSetInt(), 123); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetInt { + /** + * a int field for test + */ + + public static int field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static int selfShort() { + int self1 = field2[2]; + int value = 11; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a8e2343876429238bf2c1f18b635320f163e4e5f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0550-rt-eh-FieldSetIntExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetIntExceptionTest) +run(FieldSetIntExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/FieldSetLongExceptionTest.java b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/FieldSetLongExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4f08ac5b01ba6f37093124da4d34546cfdc5f7f4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/FieldSetLongExceptionTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetLongExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldSetLongExceptionTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setLong(Object obj, long l). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetLongExceptionTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + Field field = TestSetLong.class.getDeclaredField("field6"); + try { + field.setLong(new TestSetLong(), 123); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetLong { + /** + * a long field for test + */ + + public static long field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static long selfShort() { + int self1 = field2[2]; + long value = 11; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cf5b8fb6ee843742414efe925133e5e83dd4a5b2 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0551-rt-eh-FieldSetLongExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetLongExceptionTest) +run(FieldSetLongExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/FieldSetShortExceptionTest.java b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/FieldSetShortExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ec78633b4e2103f87d744f756e230463261f464c --- /dev/null +++ b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/FieldSetShortExceptionTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Field; +public class FieldSetShortExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldSetShortExceptionTest(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect filed: public void setShort(Object obj, short s). + * @return status code + * @throws ClassNotFoundException + * @throws NoSuchFieldException + * @throws SecurityException + * @throws IllegalArgumentException + * @throws IllegalAccessException + */ + + public static int fieldSetShortExceptionTest() + throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, + IllegalAccessException { + int result1 = 4; /*STATUS_FAILED*/ + Field field = TestSetShort.class.getDeclaredField("field6"); + try { + field.setShort(new TestSetShort(), (short) 12); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestSetShort { + /** + * a short field for test + */ + + public static short field6 = selfShort(); + /** + * a int[] field for test + */ + + public static int[] field2 = {1, 2, 3, 4}; + /** + * set value and return + * @return value + */ + + public static short selfShort() { + int self1 = field2[2]; + short value = 11; + return value; + } +} diff --git a/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e6c99006280890f0aa3c193dc86785ba74469588 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0552-rt-eh-FieldSetShortExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldSetShortExceptionTest) +run(FieldSetShortExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/MethodGetAnnotationExceptionTest.java b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/MethodGetAnnotationExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..eb024e62c5b9100004a5daaf2667685794113131 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/MethodGetAnnotationExceptionTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +public class MethodGetAnnotationExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = methodGetAnnotationExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect Method: public T getAnnotation(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int methodGetAnnotationExceptionTest() throws NoSuchMethodException, SecurityException { + int result1 = 4; /* STATUS_FAILED*/ + + Method method = Test02a.class.getMethod("getName", new Class[] {}); + try { + Object value = method.getAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test02a { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ff3a5cc8cf00c911e6b54f32ccf621821545e75a --- /dev/null +++ b/testsuite/java_test/eh_test/RT0553-rt-eh-MethodGetAnnotationExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetAnnotationExceptionTest) +run(MethodGetAnnotationExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/MethodInvokeExceptionInInitializerErrorTest.java b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/MethodInvokeExceptionInInitializerErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..61e2e17f1278da0f24f18ae0d4ce0d021f9c55a4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/MethodInvokeExceptionInInitializerErrorTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +public class MethodInvokeExceptionInInitializerErrorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodInvokeExceptionInInitializerError(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect method : public Object invoke(Object obj, Object... args). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + * @throws IllegalAccessException + * @throws IllegalArgumentException + * @throws InvocationTargetException + */ + + public static int methodInvokeExceptionInInitializerError() + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException { + int result1 = 4; /*STATUS_FAILED*/ + Class class1 = TestExceptionInInitializerError.class; + Method method = class1.getMethod("setInt", new Class[] {int.class}); + try { + method.invoke(new TestExceptionInInitializerError(10), new Object[] {20}); + processResult -= 10; + } catch (ExceptionInInitializerError e1) { + processResult--; + } + return result1; + } +} +class TestExceptionInInitializerError { + int nu; + /** + * set num + * @param num for test + */ + + public static void setInt(int num) { + int num1 = num; + } + public TestExceptionInInitializerError(int num) { + this.nu = num; + } + static { + int num = 1 / 0; + } +} diff --git a/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/expected.txt b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/test.cfg b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..31e0b54dda8ef2b6e2b9244c0a81591025143c6f --- /dev/null +++ b/testsuite/java_test/eh_test/RT0555-rt-eh-MethodInvokeExceptionInInitializerErrorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodInvokeExceptionInInitializerErrorTest) +run(MethodInvokeExceptionInInitializerErrorTest) diff --git a/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/ParameterGetAnnotationNullPointerExceptionTest.java b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/ParameterGetAnnotationNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..694f4245b3ee0a5493a70225e0a5202426f18dce --- /dev/null +++ b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/ParameterGetAnnotationNullPointerExceptionTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotationNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterGetAnnotationNullPointerException(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect.Parameter: public T getAnnotation(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int parameterGetAnnotationNullPointerException() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + Method method = Test03a.class.getMethod("getName", new Class[] {String.class}); + Parameter[] parameters = method.getParameters(); + try { + Object value = parameters[0].getAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test03a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} diff --git a/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..40b47f2516981de2266f1495437c3c9b0d770667 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0556-rt-eh-ParameterGetAnnotationNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotationNullPointerExceptionTest) +run(ParameterGetAnnotationNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/ParameterGetAnnotationsByTypeNullPointerExceptionTest.java b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/ParameterGetAnnotationsByTypeNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b9ad9c0db19ccc07c92bc2778bf604246892e186 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/ParameterGetAnnotationsByTypeNullPointerExceptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotationsByTypeNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterGetAnnotationsByTypeNullPointerException(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect.Parameter: public T[] getAnnotationsByType(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int parameterGetAnnotationsByTypeNullPointerException() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + Method method = Test04a.class.getMethod("getName", new Class[] {String.class}); + Parameter[] parameters = method.getParameters(); + try { + Object value = parameters[0].getAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test04a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} diff --git a/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f56286db24f8541452347640eddda6cbc733250e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0557-rt-eh-ParameterGetAnnotationsByTypeNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotationsByTypeNullPointerExceptionTest) +run(ParameterGetAnnotationsByTypeNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/ParameterGetDeclaredAnnotationNullPointerExceptionTest.java b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/ParameterGetDeclaredAnnotationNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4633497a949cec24b72846cd924441455c990419 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/ParameterGetDeclaredAnnotationNullPointerExceptionTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotationNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterGetDeclaredAnnotationNullPointerException1(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in reflect.Parameter: public T getDeclaredAnnotation(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int parameterGetDeclaredAnnotationNullPointerException1() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + Method method = Test05a.class.getMethod("getName", new Class[] {String.class}); + Parameter[] parameters = method.getParameters(); + try { + Object value = parameters[0].getDeclaredAnnotation(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test05a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} diff --git a/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d3a200b0dae99e6c62bda9b463cf4a91c0e6ace3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0558-rt-eh-ParameterGetDeclaredAnnotationNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotationNullPointerExceptionTest) +run(ParameterGetDeclaredAnnotationNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/ParameterGetDeclaredAnnotationsByTypeExceptionTest.java b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/ParameterGetDeclaredAnnotationsByTypeExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c5683caa626f8e5e771c5d78ed71af006cc7ba8e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/ParameterGetDeclaredAnnotationsByTypeExceptionTest.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotationsByTypeExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = parameterGetDeclaredAnnotationsByTypeException(); + } catch (Exception e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Parameter: public T[] getDeclaredAnnotationsByType(Class annotationClass). + * @return status code + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int parameterGetDeclaredAnnotationsByTypeException() + throws NoSuchMethodException, SecurityException { + int result1 = 4; /* STATUS_FAILED*/ + + Method method = Test06a.class.getMethod("getName", new Class[] {String.class}); + Parameter[] parameters = method.getParameters(); + try { + Object value = parameters[0].getDeclaredAnnotationsByType(null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test06a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} diff --git a/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d29fa1c9ae4a143d7fffd0d8a9493b9ddf01d2a3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0559-rt-eh-ParameterGetDeclaredAnnotationsByTypeExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotationsByTypeExceptionTest) +run(ParameterGetDeclaredAnnotationsByTypeExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/ThrowableAddSuppressedExceptionTest.java b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/ThrowableAddSuppressedExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fbd0c8592be76f1ca1e6b6f9d09b8b99af0fe456 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/ThrowableAddSuppressedExceptionTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ThrowableAddSuppressedExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = throwableAddSuppressedException(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Throwable: public final void addSuppressed(Throwable exception). + * @return status code + */ + + public static int throwableAddSuppressedException() { + int result1 = 4; /* STATUS_FAILED*/ + + Throwable cause = new Throwable(); + try { + cause.addSuppressed(cause); + processResult -= 10; + } catch (IllegalArgumentException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3d7495b8b5516c354c24b488646ff97e0e03bc30 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0560-rt-eh-ThrowableAddSuppressedExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableAddSuppressedExceptionTest) +run(ThrowableAddSuppressedExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/ThrowableAddSuppressedNullPointerExceptionTest.java b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/ThrowableAddSuppressedNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9654a87cb3e6de405f9ae52d3897e3c0089ea1fa --- /dev/null +++ b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/ThrowableAddSuppressedNullPointerExceptionTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ThrowableAddSuppressedNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = throwableAddSuppressedNullPointerException1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * Exception in Throwable: public final void addSuppressed(Throwable exception). + * @return status code + */ + + public static int throwableAddSuppressedNullPointerException1() { + int result1 = 4; /*STATUS_FAILED*/ + Throwable cause = new Throwable(); + try { + cause.addSuppressed((Throwable) null); + processResult -= 10; + } catch (NullPointerException e1) { + processResult--; + } + return result1; + } +} +class Test02ga { + private String name = "default"; + public String getName() { + return name; + } +} diff --git a/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4a8631ba27fad90222de755e3e1038e7b9e2eab3 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0561-rt-eh-ThrowableAddSuppressedNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableAddSuppressedNullPointerExceptionTest) +run(ThrowableAddSuppressedNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/MethodInvokeExceptionTest.java b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/MethodInvokeExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0465a0d8377c5ea57a14059fe906f5b13e5bbcad --- /dev/null +++ b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/MethodInvokeExceptionTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +public class MethodInvokeExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + private static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + invokeMethod(); + } catch (Exception e) { + processResult--; + System.out.println(3); + } + try { + invokeMethodTest(); + } catch (Exception e) { + processResult--; + System.out.println(6); + } + if (result == 2 && processResult == 97) { + result = 0; + } + return result; + } + static void invokeMethod() throws Exception { + Method method = Class.forName("java.lang.Class").getDeclaredMethod("getConstructor", Class[].class); + Object instance = Class.forName("java.security.CodeSigner"); + Object[] parameters = new Object[1]; + parameters[0] = + new Class[] { + java.security.CodeSigner.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.LinkedHashMap.class, + java.nio.channels.AsynchronousFileChannel.class, + java.sql.Time.class, + java.util.EnumMap.class, + java.nio.channels.FileLock.class, + java.util.WeakHashMap.class + }; + System.out.println(1); + method.invoke(instance, parameters); + System.out.println(2); + } + static void invokeMethodTest() throws Exception { + Method method = + Class.forName("java.lang.Character").getDeclaredMethod("CharConversionException", Class[].class); + Object instance = Class.forName("java.security.CodeSigner"); + Object[] parameters = new Object[1]; + parameters[0] = + new Class[] { + java.security.CodeSigner.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.LinkedHashMap.class, + java.nio.channels.AsynchronousFileChannel.class, + java.sql.Time.class, + java.util.EnumMap.class, + java.nio.channels.FileLock.class, + java.util.WeakHashMap.class + }; + System.out.println(4); + method.invoke(instance, parameters); + System.out.println(5); + } +} diff --git a/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..71991f9527b9147d7c993ab4aaa599d49b38b405 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/expected.txt @@ -0,0 +1,4 @@ +1 +3 +6 +0 diff --git a/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/old_result_figo.log b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/old_result_figo.log new file mode 100644 index 0000000000000000000000000000000000000000..2bdf79d1340d622634a928845f9dd9084ce5e1f9 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/old_result_figo.log @@ -0,0 +1,2 @@ +/home/chenliliu/emui/maple/cll/important/RT0817-runtime-mrtUT-MethodInvokeExceptionTest/ +MethodInvokeException.java Failed 0 run check unexpected output diff --git a/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c199ac103ccc6b4175888895f6ea124dbd45d6e --- /dev/null +++ b/testsuite/java_test/eh_test/RT0817-rt-mrtUT-MethodInvokeExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodInvokeExceptionTest) +run(MethodInvokeExceptionTest) diff --git a/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/MethodInvokeObjectObjectsTest.java b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/MethodInvokeObjectObjectsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cc5042d1eb2ec31d9fe18506368477ff99090acb --- /dev/null +++ b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/MethodInvokeObjectObjectsTest.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.*; +import java.nio.charset.Charset; +import java.util.*; +public class MethodInvokeObjectObjectsTest { + /** + * test class + */ + + public static Class clazz; + public static void main(String[] args) { + try { + System.out.println(run()); + } catch (Exception e) { + System.out.println(e); + } + } + /** + * main test fun + * @return status code + */ + + public static int run() { + try { + clazz = Class.forName("java.lang.reflect.Method"); + Method method = clazz.getMethod("invoke", Object.class, Object[].class); + String fcn2 = "java.util.concurrent.ConcurrentHashMap"; + int mIndex6 = 1; + Method[] methods2 = Class.forName(fcn2).getDeclaredMethods(); + Arrays.sort(methods2, new ConstructorComparator()); + Object instance = methods2[mIndex6]; + Constructor con = java.lang.StringBuffer.class.getDeclaredConstructor(); + Object param1 = con.newInstance(); + Object[] param2 = new Object[4]; + Constructor con0 = java.lang.StringBuffer.class.getDeclaredConstructor(); + param2[0] = con0.newInstance(); + Constructor con1 = + java.security.spec.MGF1ParameterSpec.class.getDeclaredConstructor(java.lang.String.class); + param2[1] = con1.newInstance("abcdefghijklmnopqrstuvwxxzABCDEFGHIJKLMNOPQRSTUVWXYZ-9223372036854775551"); + Constructor con2 = java.util.Stack.class.getDeclaredConstructor(); + param2[2] = con2.newInstance(); + Constructor con3 = + java.security.spec.ECGenParameterSpec.class.getDeclaredConstructor(java.lang.String.class); + param2[3] = con3.newInstance("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + Object result = method.invoke(instance, param1, param2); + System.out.println(result); + } catch (Exception e) { + if (e.toString().equals("java.lang.reflect.InvocationTargetException") + && e.getCause().getClass().getName().toString().equals("java.lang.IllegalArgumentException")) { + return 0; + } + } + return -1; + } +} +class ConstructorComparator implements Comparator { + @Override + public int compare(Object c1, Object c2) { + byte[] b1 = c1.toString().getBytes(Charset.defaultCharset()); + byte[] b2 = c2.toString().getBytes(Charset.defaultCharset()); + int len = (b1.length < b2.length ? b1.length : b2.length); + for (int i = 0; i < len; i++) { + if (b1[i] < b2[i]) { + return 1; + } else if (b1[i] > b2[i]) { + return -1; + } + } + if (b1.length > b2.length) { + return -1; + } else if (b1.length < b2.length) { + return 1; + } + return 1; + } +} diff --git a/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/expected.txt b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/test.cfg b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6db0c4c7f1cfdd76806c2881a8fa544355d30dd4 --- /dev/null +++ b/testsuite/java_test/eh_test/RT0904-rt-fuzzapi-MethodInvokeObjectObjectsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodInvokeObjectObjectsTest) +run(MethodInvokeObjectObjectsTest) diff --git a/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/MethodInvokeInvocationTargetExceptionTest.java b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/MethodInvokeInvocationTargetExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..33e3cd4989c542e1e7438abc15de6cd8221f9743 --- /dev/null +++ b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/MethodInvokeInvocationTargetExceptionTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +public class MethodInvokeInvocationTargetExceptionTest { + public static void main(String[] args) { + try { + invokeMethod(); + } catch (InvocationTargetException e) { + System.out.println(0); + } catch (Exception e) { + System.out.println(3); + } + } + static void invokeMethod() + throws NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException { + Method method = Class.forName("java.lang.Class").getDeclaredMethod("getConstructor", Class[].class); + Object instance = Class.forName("java.security.CodeSigner"); + Object[] parameters = new Object[1]; + parameters[0] = + new Class[] { + java.security.CodeSigner.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.concurrent.locks.AbstractOwnableSynchronizer.class, + java.util.LinkedHashMap.class, + java.nio.channels.AsynchronousFileChannel.class, + java.sql.Time.class, + java.util.EnumMap.class, + java.nio.channels.FileLock.class, + java.util.WeakHashMap.class + }; + method.invoke(instance, parameters); + System.out.println(2); + } +} diff --git a/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/expected.txt b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/test.cfg b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..29522f83a7489c9a142895f53a9aaaf396c43dbf --- /dev/null +++ b/testsuite/java_test/eh_test/RT1075-rt-EH-MethodInvokeInvocationTargetExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodInvokeInvocationTargetExceptionTest) +run(MethodInvokeInvocationTargetExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/JvmDefaultUnsatisfiedLinkErrorTest.java b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/JvmDefaultUnsatisfiedLinkErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..26f9bbfed2be7257ef985551fe2432e46bf776d9 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/JvmDefaultUnsatisfiedLinkErrorTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class JvmDefaultUnsatisfiedLinkErrorTesta { + native int testFail(); +} +public class JvmDefaultUnsatisfiedLinkErrorTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + JvmDefaultUnsatisfiedLinkErrorTesta test = new JvmDefaultUnsatisfiedLinkErrorTesta(); + try { + int tmp = test.testFail(); + } catch (UnsatisfiedLinkError e1) { + return 0; // STATUS_PASSED + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4120af72bfa5c905e6adb574408e9e8de2421f23 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmDefaultUnsatisfiedLinkErrorTest/test.cfg @@ -0,0 +1,2 @@ +compile(JvmDefaultUnsatisfiedLinkErrorTest.java) +run(JvmDefaultUnsatisfiedLinkErrorTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/JvmInterfaceUnsatisfiedLinkErrorTest.java b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/JvmInterfaceUnsatisfiedLinkErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9537c6e61c5377f3fbb13082a3e1b6b533b51b7c --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/JvmInterfaceUnsatisfiedLinkErrorTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +interface JvmInterfaceUnsatisfiedLinkErrorTesti { + /** + * just a simple method for test + * @return null + */ + + int testFail(); +} +class JvmInterfaceUnsatisfiedLinkErrorTesta implements JvmInterfaceUnsatisfiedLinkErrorTesti { + /** + * just a simple native method for test + * @return null + */ + + public native int testFail(); +} +public class JvmInterfaceUnsatisfiedLinkErrorTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + JvmInterfaceUnsatisfiedLinkErrorTesta test = new JvmInterfaceUnsatisfiedLinkErrorTesta(); + try { + int tmp = test.testFail(); + } catch (UnsatisfiedLinkError e1) { + return 0; // STATUS_PASSED + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..302421efeb83caa90b450b84bb08fdd9057554b5 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmInterfaceUnsatisfiedLinkErrorTest/test.cfg @@ -0,0 +1,2 @@ +compile(JvmInterfaceUnsatisfiedLinkErrorTest.java) +run(JvmInterfaceUnsatisfiedLinkErrorTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/JvmStaticUnsatisfiedLinkErrorTest.java b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/JvmStaticUnsatisfiedLinkErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1f23dac7b550d5433f4fb5fb5a20ab00bbf8c756 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/JvmStaticUnsatisfiedLinkErrorTest.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class JvmStaticUnsatisfiedLinkErrorTesta { + static native int testFail(); +} +public class JvmStaticUnsatisfiedLinkErrorTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + try { + int tmp = JvmStaticUnsatisfiedLinkErrorTesta.testFail(); + } catch (UnsatisfiedLinkError e1) { + return 0; // STATUS_PASSED + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1c800401d6fe2fffbbb2fed81e856bfa89012c72 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmStaticUnsatisfiedLinkErrorTest/test.cfg @@ -0,0 +1,2 @@ +compile(JvmStaticUnsatisfiedLinkErrorTest.java) +run(JvmStaticUnsatisfiedLinkErrorTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/JvmUnsatisfiedLinkErrorTest.java b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/JvmUnsatisfiedLinkErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1f8fc99024e872a36df692043b213daea2111c5b --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/JvmUnsatisfiedLinkErrorTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class JvmUnsatisfiedLinkErrorTest { + private native int testFail2(); + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + JvmUnsatisfiedLinkErrorTest test = new JvmUnsatisfiedLinkErrorTest(); + try { + int tmp = test.testFail2(); + } catch (UnsatisfiedLinkError e1) { + return 0; // STATUS_PASSED + } + return 2; // STATUS_FAILED + } +} diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7e2b00c681dfc1e452c4cbbc32e733be30635adc --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-eh-JvmUnsatisfiedLinkErrorTest/test.cfg @@ -0,0 +1,2 @@ +compile(JvmUnsatisfiedLinkErrorTest.java) +run(JvmUnsatisfiedLinkErrorTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.jar b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.jar new file mode 100644 index 0000000000000000000000000000000000000000..0aa33147d740835bf821aa293669de95f7547fe8 Binary files /dev/null and b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.jar differ diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.java b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..11c868f0f60d0ca0aaa2b2de9113bd5d069353ee --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/MethodGetDefaultValueExceptionTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.annotation.AnnotationFormatError; +import java.lang.reflect.Method; +public class MethodGetDefaultValueExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = methodGetDefaultValueExceptionTest(); + } catch (NoSuchMethodException | SecurityException e) { + processResult -= 20; + } + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * main test fun + * @return return STATUS + * @throws NoSuchMethodException + * @throws SecurityException + */ + + public static int methodGetDefaultValueExceptionTest() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // TypeNotPresentException - if the annotation is of type Class and no definition can be found for the default + // class value. + // Test public Object getDefaultValue(). + Method method = RequestForEnhancementDefault.class.getMethod("cTest"); + Object value = new Object(); + try { + value = method.getDefaultValue(); + processResult -= 10; + } catch (AnnotationFormatError e1) { + processResult--; + } catch (TypeNotPresentException e1) { + processResult--; + } + return result1; + } +} +@interface RequestForEnhancementDefault { + int id(); + String synopsis(); + String engineer() default "[assigned]"; + String date() default "[unassigned]"; + Class cTest() default Tt01.class; +} +/* + * interface RequestForEnhancementDefault { + * int id(); + * String synopsis(); + * // String engineer() default "[assigned]"; + * // String date() default "[unassigned]"; + * // default Class cTest(){return Tt01.class;} + * default Tt01 cTest(){return new Tt01();} + * } +*/ + diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a3777ba7fd9d059bdb23486653ea1bab4e66734f --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-MethodGetDefaultValueExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(MethodGetDefaultValueExceptionTest.java) +run(MethodGetDefaultValueExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/Readme b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/Readme new file mode 100644 index 0000000000000000000000000000000000000000..34e40461fd2353da3786633c4a1bcee6b2a34209 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/Readme @@ -0,0 +1,3 @@ +maybe + +expected.txt will changed along with runtime diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/StringMethodsNullPointExceptionTest.java b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/StringMethodsNullPointExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3693f6d855598dd7a9cc593ba0c716acce0ba2cb --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/StringMethodsNullPointExceptionTest.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringMethodsNullPointExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2 /* STATUS_FAILED*/ +; + try { + stringMethodsNullPointExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 83) { + result = 0; + } + return result; + } + /** + * main test fun + */ + + public static void stringMethodsNullPointExceptionTest() { + String str1 = "abc123"; + String str2 = null; + test0(str1); + test1(str2); + test2(str2); + test3(str2); + test4(str2); + test5(str2); + test6(str2); + test7(str2); + } + private static void test0(String str) { + try { + char t0 = str.charAt(-2); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 2; + } + } + private static void test1(String str) { + try { + char t1 = str.charAt(0); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test2(String str) { + char[] t2 = null; + try { + t2 = str.toCharArray(); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test3(String str) { + String t3 = null; + try { + t3 = str.substring(1); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test4(String str) { + try { + int t4 = str.compareTo("aaa"); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test5(String str) { + try { + String t5 = str.intern(); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test6(String str) { + try { + String t6 = str.replace("a", "b"); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } + private static void test7(String str) { + try { + String t7 = str.concat("aaa"); + } catch (NullPointerException e) { + System.out.println("======Please check below information as manual======"); + System.out.println(e); + processResult -= 2; + } + } +} diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..322fc475908a25b683b6c84a3deeb8ab1d1d82d9 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/expected.txt @@ -0,0 +1,15 @@ +======Please check below information as manual====== +java.lang.NullPointerException: unknown reason +======Please check below information as manual====== +java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference +======Please check below information as manual====== +java.lang.NullPointerException: unknown reason +======Please check below information as manual====== +java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference +======Please check below information as manual====== +java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference +======Please check below information as manual====== +java.lang.NullPointerException: unknown reason +======Please check below information as manual====== +java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference +0 diff --git a/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e3105d210630a5a75befc52ce04d656c5adfeaf4 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-0000-rt-runtime-eh-StringMethodsNullPointExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(StringMethodsNullPointExceptionTest.java) +run(StringMethodsNullPointExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.c b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..d46708b9079735a36a48f4c4ef2ac7a95f9260dc --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeExNumberFormatExceptionTest (JNIEnv *env, jobject obj) { + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); // NumberFormatException:"Java_Method_throw_xxx" + + jboolean chk = (*env)->ExceptionCheck(env); + + if(chk){ + (*env)->ExceptionDescribe(env); + } + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeExNumberFormatExceptionTest", "()V", (void*)&native_nativeNativeExNumberFormatExceptionTest }, + }; + + jclass cls = (*env)->FindClass(env, "NativeExNumberFormatExceptionTest"); // if package is test:"test/ExcpAsync06110" + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.java b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..76f794c704ed774ab4517871119c4134ce2f4fb6 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/NativeExNumberFormatExceptionTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class NativeExNumberFormatExceptionTest extends Exception { + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out) + 95); /* STATUS_TEMP*/ + + } + private native void nativeNativeExNumberFormatExceptionTest() throws InvalidPathException; // e2 + private void callback() throws NumberFormatException { // e1 + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeExNumberFormatExceptionTest1(); + } catch (Exception e) { + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 10; + } + if (result == 3 && NativeExNumberFormatExceptionTest.processResult == 95) { + result = 0; + } + return result; + } + /** + * main test fun Entrance + * @return status code + */ + + public static int nativeExNumberFormatExceptionTest1() { + int result1 = 4; /*STATUS_FAILED*/ + NativeExNumberFormatExceptionTest cTest = new NativeExNumberFormatExceptionTest(); + try { + cTest.nativeNativeExNumberFormatExceptionTest(); + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 10; + } catch (NumberFormatException e1) { + result1 = 3; + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 1; + } catch (InvalidPathException e2) { + result1 = 3; + System.out.println("======>" + e2.getMessage()); + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 3; + System.out.println("======>" + e3.getMessage()); + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 10; + } + NativeExNumberFormatExceptionTest.processResult = NativeExNumberFormatExceptionTest.processResult - 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/jniNativeExNumberFormatExceptionTest.cpp b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/jniNativeExNumberFormatExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..95d765997867df48a14972368601a52ad3803383 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/jniNativeExNumberFormatExceptionTest.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeExNumberFormatExceptionTest_nativeNativeExNumberFormatExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jboolean chk = env->ExceptionCheck(); + if (chk){ + env->ExceptionDescribe(); + } + + printf("------>CheckPoint:CcanContinue\n"); + +} +} diff --git a/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c9d9d61fb92eb0e043356832550a79b8146b6b23 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0031-rt-eh-NativeExNumberFormatExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(NativeExNumberFormatExceptionTest.java) +run(NativeExNumberFormatExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/UninitializedExNullPointerExceptionTest.java b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/UninitializedExNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f2d44e0d964c869550a3aa859c3225075ca5097d --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/UninitializedExNullPointerExceptionTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class UninitializedExNullPointerExceptionTest { + static int processResult = 2; + static UninitializedExNullPointerExceptionTest iv; + private void proc2() {} + /** + * Test Jvm instr: invoke special throw NullPointException. + */ + + public static void proc1() { + try { + iv.proc2(); // the invoke special instruction is used here + } catch (NullPointerException e) { + processResult = 0; // STATUS_PASSED + } + } + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + proc1(); + return processResult; + } +} diff --git a/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..156f036e91bf7629926889fb5938859c3469a89c --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0065-rt-eh-UninitializedExNullPointerExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(UninitializedExNullPointerExceptionTest.java) +run(UninitializedExNullPointerExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/JvmInitializeOutOfMemoryErrorTest.java b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/JvmInitializeOutOfMemoryErrorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a58593623f30657b733187e70a1619036dbb4006 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/JvmInitializeOutOfMemoryErrorTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class JvmInitializeOutOfMemoryErrorTest { + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + JvmInitializeOutOfMemoryErrorTest tTest = new JvmInitializeOutOfMemoryErrorTest(); + return tTest.test(); + } + /** + * Test jvm instr: invoke virtual thrown Exception InInitializerError. + * @return status code + */ + + public static int test() { + try { + int[] num; + num = new int[1024 * 1024 * 1280]; // 1024*1024*4B = 4M, *128=512M + num[0] = 1; // If no this, y = new int[] will be optimizated and deleted. + } catch (OutOfMemoryError e2) { + return 0; + } + return 2; + } +} diff --git a/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ebc9f6983e7f54bbd69bbb1beadfc50f6f803b99 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0068-rt-eh-JvmInitializeOutOfMemoryErrorTest/test.cfg @@ -0,0 +1,2 @@ +compile(JvmInitializeOutOfMemoryErrorTest.java) +run(JvmInitializeOutOfMemoryErrorTest) diff --git a/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.jar b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.jar new file mode 100644 index 0000000000000000000000000000000000000000..ae23171bde804360e3bc59ab48e7768b951652c1 Binary files /dev/null and b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.jar differ diff --git a/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.java b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..01616a688fdc99e747caf7cbeeb10ae093596576 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/FieldGetGenericTypeExceptionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.PrintStream; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.util.List; +public class FieldGetGenericTypeExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldGetGenericTypeExceptionTest(); + } catch (Exception e) { + e.printStackTrace(); + processResult -= 20; + } + // System.out.println("============================"+result); + // System.out.println("============================"+processResult); + if (result == 4 && processResult == 98) { + result = 0; + } + return result; + } + /** + * TypeNotPresentException in reflect Field: public Type getGenericType(). + * @return status code + * @throws NoSuchFieldException + * @throws SecurityException + */ + + public static int fieldGetGenericTypeExceptionTest() throws NoSuchFieldException, SecurityException { + int result1 = 4; /* STATUS_FAILED*/ + + // TypeNotPresentException - if the generic type signature of the underlying field refers to a non-existent type + // declaration. + // Test public Type getGenericType(). + Field field = Wrapper.class.getDeclaredField("people"); + Type value = new Type() {}; + try { + value = field.getGenericType(); + processResult -= 10; + } catch (TypeNotPresentException e1) { + processResult--; + } + return result1; + } +} +class Wrapper { + List people; +} diff --git a/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/Person.java b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/Person.java new file mode 100644 index 0000000000000000000000000000000000000000..19cb1a6296c68ee00c4c07e5acf85b389fbe0939 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/Person.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +public class Person { + int num = 1; +} diff --git a/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73bd1e1cca0efaca0b03633ac0406de105fabb37 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0540-rt-eh-FieldGetGenericTypeExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(FieldGetGenericTypeExceptionTest.java) +run(FieldGetGenericTypeExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.c b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..9f82e058af23119815ab9e3f5e7e944786b5bceb --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include +#include + +JNIEXPORT void JNICALL Java_StaticNativeNumberFormatExceptionTest_nativeStaticNativeNumberFormatExceptionTest(JNIEnv *env, jobject obj) { + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + + (*env)->CallVoidMethod(env, obj, mid); + printf("------>CheckPoint:CcanContinue\n"); +} diff --git a/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.java b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2adacf5093bc86127dda0cf2e2a91e6862e229f4 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/StaticNativeNumberFormatExceptionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StaticNativeNumberFormatExceptionTest extends Exception { + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out) + 95); /* STATUS_TEMP*/ + + } + private native void nativeStaticNativeNumberFormatExceptionTest() throws IllegalStateException; // e2 + private void callback() throws NumberFormatException { // e1 + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = staticNativeNumberFormatExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Static Binding: Native(exception at callback from Java), catch by Java. + * @return status code + */ + + public static int staticNativeNumberFormatExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + StaticNativeNumberFormatExceptionTest cTest = new StaticNativeNumberFormatExceptionTest(); + try { + cTest.nativeStaticNativeNumberFormatExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 1; + processResult--; + } catch (IllegalStateException e2) { + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + processResult -= 10; + } + processResult -= 3; + return result1; + } + static { + try { + System.loadLibrary("JniStaticNativeNumberFormatExceptionTest"); + } catch (UnsatisfiedLinkError e) { + System.out.println("======>load:UnsatisfiedLinkError"); // Export LD_LIBRARY_PATH=/data/local/tmp. + } + } +} diff --git a/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1bd3d23f5fb126a9d4f72999f519e0731466822c --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0595-rt-eh-StaticNativeNumberFormatExceptionTest/test.cfg @@ -0,0 +1,2 @@ +compile(StaticNativeNumberFormatExceptionTest.java) +run(StaticNativeNumberFormatExceptionTest) diff --git a/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/ResourceExNumberFormatExceptionTest.java b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/ResourceExNumberFormatExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..342bdf7ccdfeff5b43395e734d9b346e97674b59 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/ResourceExNumberFormatExceptionTest.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.*; +public class ResourceExNumberFormatExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = resourceExNumberFormatExceptionTest(); + } catch (IOException e) { + e.printStackTrace(); + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + public static class MyResource implements AutoCloseable { + /** + * start fun + * @throws NumberFormatException + */ + + public void start() throws NumberFormatException { + if (processResult == 99) { + processResult--; + } + throw new NumberFormatException("start:exception!!!"); + } + @Override + public void close() {} + } + /** + * Test 1 try with resource. + * @return status code + */ + + public static int resourceExNumberFormatExceptionTest() throws IOException { + int result1 = 4; /* STATUS_FAILED*/ + + String exception = ""; + try (MyResource conn = new MyResource()) { + conn.start(); + } catch (NumberFormatException e) { + // e.printStackTrace(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); // 将e的调用栈信息输出到ByteArrayOutputStream + InputStream ins = new ByteArrayInputStream(baos.toByteArray()); // 将信息放到InputStream + BufferedReader buffer = new BufferedReader(new InputStreamReader(ins, "UTF-8")); + int checkFlag = 0; + String line = null; + while ((line = buffer.readLine()) != null) { +// System.out.println(line); + if (line.contains("java.lang.NumberFormatException")) { + // System.out.println(checkFlag); + checkFlag++; + } + if (line.contains("ResourceExNumberFormatExceptionTest.java") && line.contains("60")) { + if (checkFlag == 1) { + // System.out.println(checkFlag); + checkFlag++; + } + } + if (line.contains("ResourceExNumberFormatExceptionTest.java") && line.contains("75")) { + if (checkFlag == 2) { + // System.out.println(checkFlag); + checkFlag++; + } + } + if (line.contains("ResourceExNumberFormatExceptionTest.java") && line.contains("40")) { + if (checkFlag == 3) { + checkFlag++; + } + } + if (line.contains("ResourceExNumberFormatExceptionTest.java") && line.contains("30")) { + if (checkFlag == 4) { + checkFlag++; + } + } + } + if (processResult == 98) { + if (checkFlag == 5) { + processResult--; + } + } + result1 = 1; + } finally { + if (processResult == 97) { + processResult--; + } + } + if (processResult == 96) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/expected.txt b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/test.cfg b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..15598bb52956a42cc70f1c4a5bdb97f1cf3d21e9 --- /dev/null +++ b/testsuite/java_test/eh_test/issue-RT0638-rt-eh-ResourceExNumberFormatExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ResourceExNumberFormatExceptionTest) +run(ResourceExNumberFormatExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..3fc1c78f7b9ee15f5c4fad22a1b2f2f18f170e67 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include +#include + +void native_nativeNativeCatchExceptionTest(JNIEnv *env, jobject obj){ + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + + (*env)->CallVoidMethod(env, obj, mid); + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeCatchExceptionTest", "()V", (void*)&native_nativeNativeCatchExceptionTest }, + }; + + jclass cls = (*env)->FindClass(env, "NativeCatchExceptionTest"); //if package is test:"test/NativeCatchExceptionTest" + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} diff --git a/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1117a45723a7ba9c811482834e02a29000621887 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/NativeCatchExceptionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class NativeCatchExceptionTest extends Exception { + private static int processResult = 99; + static { + System.loadLibrary("jniNativeCatchExceptionTest"); + } + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeCatchExceptionTest() throws IllegalStateException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeCatchExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java), captured by Java. + * @return status code + */ + + public static int nativeCatchExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeCatchExceptionTest cTest = new NativeCatchExceptionTest(); + try { + cTest.nativeNativeCatchExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 1; + processResult--; + } catch (IllegalStateException e2) { + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + processResult -= 10; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/jniNativeCatchExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/jniNativeCatchExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5c46fb461228929110b35683a67e26dd9b921174 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/jniNativeCatchExceptionTest.cpp @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeCatchExceptionTest_nativeNativeCatchExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if ( cls == NULL ) { + return; + } + + mid = env->GetMethodID(cls, "callback", "()V"); + if ( mid == NULL ) { + return; + } + + env->CallVoidMethod(j_obj, mid); + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeCatchExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeCatchExceptionTest", "()V", reinterpret_cast(Java_NativeCatchExceptionTest_nativeNativeCatchExceptionTest__)}, + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bdb8a2aab89404a872d9750685871d2560f1b019 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0023-rt-eh-NativeCatchExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeCatchExceptionTest,NATIVE_SRC=jniNativeCatchExceptionTest) +run(NativeCatchExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..bd2a45bea5206036c3f43bf3fd8caf4eff3f3a1b --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeCodeCheckExceptionTest (JNIEnv *env, jobject obj){ + + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); + + jthrowable exc = (*env)->ExceptionOccurred(env); // catch + if(exc){ + (*env)->Throw(env, exc); + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeCodeCheckExceptionTest", "()V", (void*)&native_nativeNativeCodeCheckExceptionTest }, + }; + + // if package is test: "test/NativeCodeCheckExceptionTest" + jclass cls = (*env)->FindClass(env, "NativeCodeCheckExceptionTest"); + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0a90719c0cfc86d40d67ca1796a609aeb3a11c52 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/NativeCodeCheckExceptionTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class NativeCodeCheckExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeCodeCheckExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeCodeCheckExceptionTest() throws IllegalStateException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeCodeCheckExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 3 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java, then throw),captured by Java. + * @return status code + */ + + public static int nativeCodeCheckExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeCodeCheckExceptionTest cTest = new NativeCodeCheckExceptionTest(); + try { + cTest.nativeNativeCodeCheckExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 3; + processResult -= 1; + } catch (IllegalStateException e2) { + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + processResult -= 10; + } finally { + processResult -= 3; + return result1; + } + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/jniNativeCodeCheckExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/jniNativeCodeCheckExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b1649dcfe1e536ac2234e1910c2a1644b5e31d76 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/jniNativeCodeCheckExceptionTest.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeCodeCheckExceptionTest_nativeNativeCodeCheckExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jthrowable j_exc = NULL; + j_exc = env->ExceptionOccurred(); + + if(j_exc){ + env->Throw(j_exc); + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeCodeCheckExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeCodeCheckExceptionTest", "()V", reinterpret_cast(Java_NativeCodeCheckExceptionTest_nativeNativeCodeCheckExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..964bd48c20723d273bce18278b27a2d663b732ed --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0024-rt-eh-NativeCodeCheckExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeCodeCheckExceptionTest,NATIVE_SRC=jniNativeCodeCheckExceptionTest) +run(NativeCodeCheckExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..959e6b574e3dc048d60b388323ee6217319e410d --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeNewExceptionTest (JNIEnv *env, jobject obj){ + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); + jclass newExcCls = (*env)->FindClass(env,"java/lang/StringIndexOutOfBoundsException"); + (*env)->ThrowNew(env,newExcCls,"NativeThrowNew"); // throw new exception + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeNewExceptionTest", "()V", (void*)&native_nativeNativeNewExceptionTest }, + }; + + // if package is test:"test/NativeNewExceptionTest" + jclass cls = (*env)->FindClass(env, "NativeNewExceptionTest"); + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + return result; +} + diff --git a/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..984884190f54545572f7eb437c8cae28070148f0 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/NativeNewExceptionTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class NativeNewExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeNewExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeNewExceptionTest() throws IllegalStateException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeNewExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 3 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception-throw new), captured by Java. + * @return status code + */ + + public static int nativeNewExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeNewExceptionTest cTest = new NativeNewExceptionTest(); + try { + cTest.nativeNativeNewExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + processResult -= 10; + } catch (IllegalStateException e2) { + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 3; + processResult--; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/jniNativeNewExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/jniNativeNewExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13882d3e4895c35ea30e9f3d14e45c343870b961 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/jniNativeNewExceptionTest.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeNewExceptionTest_nativeNativeNewExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + jclass newExcCls = NULL; + newExcCls = env->FindClass("java/lang/StringIndexOutOfBoundsException"); + if (newExcCls == NULL){ + return; + } + + env->ThrowNew(newExcCls,"NativeThrowNew"); + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeNewExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeNewExceptionTest", "()V", reinterpret_cast(Java_NativeNewExceptionTest_nativeNativeNewExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d4b28958ade8ec5ed2d782b8820fb85df5ea8916 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0025-rt-eh-NativeNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeNewExceptionTest,NATIVE_SRC=jniNativeNewExceptionTest) +run(NativeNewExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..f95e9650d50e8d03d4d1c5448c377d1f60299df8 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeTryCatchNewExceptionTest (JNIEnv *env, jobject obj){ + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); + jclass newExcCls = (*env)->FindClass(env,"java/lang/StringIndexOutOfBoundsException"); + (*env)->ThrowNew(env,newExcCls,"NativeThrowNew"); + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeTryCatchNewExceptionTest", "()V", (void*)&native_nativeNativeTryCatchNewExceptionTest }, + }; + // if package is test:"test/NativeTryCatchNewExceptionTest" + jclass cls = (*env)->FindClass(env, "NativeTryCatchNewExceptionTest"); + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} + diff --git a/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7f480f29e3f2767d8e7043229401b180c50b2d06 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/NativeTryCatchNewExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class NativeTryCatchNewExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeTryCatchNewExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeTryCatchNewExceptionTest() throws IllegalArgumentException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeTryCatchNewExceptionTest(); + } catch (Exception e) { + processResult--; + } + if (result == 2 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java-throw new), captured by Java(try-catch). + * @return status code + */ + + public static int nativeTryCatchNewExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeTryCatchNewExceptionTest cTest = new NativeTryCatchNewExceptionTest(); + try { + cTest.nativeNativeTryCatchNewExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + processResult -= 10; + } catch (IllegalStateException e2) { + processResult -= 10; + } finally { + processResult -= 3; + } + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/jniNativeTryCatchNewExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/jniNativeTryCatchNewExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a6e37a34ecf5af3c2bf0e2035f13b12e959125d0 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/jniNativeTryCatchNewExceptionTest.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeTryCatchNewExceptionTest_nativeNativeTryCatchNewExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jclass newExcCls = NULL; + newExcCls = env->FindClass("java/lang/StringIndexOutOfBoundsException"); + if (newExcCls == NULL){ + return; + } + + env->ThrowNew(newExcCls,"NativeThrowNew"); + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeTryCatchNewExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeTryCatchNewExceptionTest", "()V", reinterpret_cast(Java_NativeTryCatchNewExceptionTest_nativeNativeTryCatchNewExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..939d1e78ebffce5673575273b00101da3dff7f8a --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0026-rt-eh-NativeTryCatchNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeTryCatchNewExceptionTest,NATIVE_SRC=jniNativeTryCatchNewExceptionTest) +run(NativeTryCatchNewExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..a63e9f8839c28f6f86f2796691fbd578a954b84d --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + + +#include +#include +#include +#include + +void native_NativeExcpAsync06150 (JNIEnv *env, jobject obj){ + + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); // NumberFormatException:"Java_Method_throw_xxx" + + jthrowable exc = (*env)->ExceptionOccurred(env); // catch + if(exc){ + jclass newExcCls = (*env)->FindClass(env,"java/lang/StringIndexOutOfBoundsException"); + (*env)->ThrowNew(env,newExcCls,"NativeThrowNew"); // throw new exception + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"NativeExcpAsync06150", "()V", (void*)&native_NativeExcpAsync06150 }, + }; + + jclass cls = (*env)->FindClass(env, "ExcpAsync06150"); //if package is test:"test/ExcpAsync06110" + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} + + diff --git a/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d1e647e4182f586a3f1c06fd9fd9f0aaff156bfb --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/NativeCodeCheckNewExceptionTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class NativeCodeCheckNewExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeCodeCheckNewExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeCodeCheckNewExceptionTest() throws InvalidPathException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeCodeCheckNewExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java, then Occurred-throw new), catch by Java. + * @return status code + */ + + public static int nativeCodeCheckNewExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeCodeCheckNewExceptionTest cTest = new NativeCodeCheckNewExceptionTest(); + try { + cTest.nativeNativeCodeCheckNewExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 3; + System.out.println("======>" + e1.getMessage()); + processResult -= 10; + } catch (InvalidPathException e2) { + result1 = 3; + System.out.println("======>" + e2.getMessage()); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 1; + processResult--; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/jniNativeCodeCheckNewExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/jniNativeCodeCheckNewExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..537e069736cd545826d83afa67c8249c98e24021 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/jniNativeCodeCheckNewExceptionTest.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeCodeCheckNewExceptionTest_nativeNativeCodeCheckNewExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jthrowable j_exc =NULL; + j_exc=env->ExceptionOccurred(); + if (j_exc == NULL){ + return; + } + + if (j_exc){ + jclass newExcCls = NULL; + newExcCls = env->FindClass("java/lang/StringIndexOutOfBoundsException"); + if (newExcCls == NULL){ + return; + } + env->ThrowNew(newExcCls,"NativeThrowNew"); + } + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeCodeCheckNewExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeCodeCheckNewExceptionTest", "()V", reinterpret_cast(Java_NativeCodeCheckNewExceptionTest_nativeNativeCodeCheckNewExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5c07d483048c75c0001d650c87f040ead3003f57 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0027-rt-eh-NativeCodeCheckNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeCodeCheckNewExceptionTest,NATIVE_SRC=jniNativeCodeCheckNewExceptionTest) +run(NativeCodeCheckNewExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..0ff1015e8941d25e1314798fd56e9c0aaa57dedb --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeClearExceptionTest (JNIEnv *env, jobject obj){ + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); // NumberFormatException:"Java_Method_throw_xxx" + + jthrowable exc = (*env)->ExceptionOccurred(env); // catch + if(exc){ + jclass newExcCls = (*env)->FindClass(env,"java/lang/StringIndexOutOfBoundsException"); + (*env)->ThrowNew(env,newExcCls,"NativeThrowNew"); // throw new exception + (*env)->ExceptionClear(env); + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeClearExceptionTest", "()V", (void*)&native_nativeNativeClearExceptionTest }, + }; + + //if package is test:"test/NativeClearExceptionTest" + jclass cls = (*env)->FindClass(env, "NativeClearExceptionTest"); + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..baf9d7c31aea0a6ef35a17525bef9cb0bda15da9 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/NativeClearExceptionTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class NativeClearExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeClearExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeClearExceptionTest() throws InvalidPathException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeClearExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java, then Occurred-throw new-clear). + * @return status code + */ + + public static int nativeClearExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeClearExceptionTest cTest = new NativeClearExceptionTest(); + try { + cTest.nativeNativeClearExceptionTest(); + processResult -= 1; + } catch (NumberFormatException e1) { + result1 = 3; + System.out.println("======>" + e1.getMessage()); + processResult -= 10; + } catch (InvalidPathException e2) { + result1 = 3; + System.out.println("======>" + e2.getMessage()); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 3; + System.out.println("======>" + e3.getMessage()); + processResult -= 10; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/jniNativeClearExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/jniNativeClearExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dc111d3d5804ea4e5d8eb4a7b1efc1957784de4a --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/jniNativeClearExceptionTest.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeClearExceptionTest_nativeNativeClearExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jthrowable j_exc =NULL; + j_exc=env->ExceptionOccurred(); + if (j_exc == NULL){ + return; + } + + if (j_exc){ + jclass newExcCls = NULL; + newExcCls = env->FindClass("java/lang/StringIndexOutOfBoundsException"); + if (newExcCls == NULL){ + return; + } + env->ThrowNew(newExcCls,"NativeThrowNew"); + env->ExceptionClear(); + } + + printf("------>CheckPoint:CcanContinue\n"); + +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeClearExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeClearExceptionTest", "()V", reinterpret_cast(Java_NativeClearExceptionTest_nativeNativeClearExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0c12b6ad91f1f18cd280a14dd0402de7afa60bbb --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0028-rt-eh-NativeClearExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeClearExceptionTest,NATIVE_SRC=jniNativeClearExceptionTest) +run(NativeClearExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.c b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.c new file mode 100644 index 0000000000000000000000000000000000000000..89934cb53d3c37d105416927394091f6b08a624b --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeCodeCatchThrowNewExceptionTest (JNIEnv *env, jobject obj){ + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); // NumberFormatException:"Java_Method_throw_xxx" + + jboolean chk = (*env)->ExceptionCheck(env); + + if(chk){ + jclass newExcCls = (*env)->FindClass(env,"java/lang/StringIndexOutOfBoundsException"); + (*env)->ThrowNew(env,newExcCls,"NativeThrowNew"); // Throw new exception + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeCodeCatchThrowNewExceptionTest", "()V", (void*)&native_nativeNativeCodeCatchThrowNewExceptionTest }, + }; + + //if package is test:"test/NativeCodeCatchThrowNewExceptionTest" + jclass cls = (*env)->FindClass(env, "NativeCodeCatchThrowNewExceptionTest"); + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} + + diff --git a/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8748620cda49260c47d20e2c65c7266efe7d8b84 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/NativeCodeCatchThrowNewExceptionTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class NativeCodeCatchThrowNewExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeCodeCatchThrowNewExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeCodeCatchThrowNewExceptionTest() throws InvalidPathException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeCodeCatchThrowNewExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java, then check-throw new), captured by Java. + * @return status code + */ + + public static int nativeCodeCatchThrowNewExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeCodeCatchThrowNewExceptionTest cTest = new NativeCodeCatchThrowNewExceptionTest(); + try { + cTest.nativeNativeCodeCatchThrowNewExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 3; + System.out.println("======>" + e1.getMessage()); + processResult -= 10; + } catch (InvalidPathException e2) { + result1 = 3; + System.out.println("======>" + e2.getMessage()); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 1; + processResult--; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..50ecd3e2edcbd78fc15ac3c591ff3fb9a06f1bee --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/expected.txt @@ -0,0 +1 @@ +------>CheckPoint:CcanContinue diff --git a/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/jniNativeCodeCatchThrowNewExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/jniNativeCodeCatchThrowNewExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..38b53f3a76b6f6f4a379bbdc93ad3ed80ad2c2cd --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/jniNativeCodeCatchThrowNewExceptionTest.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeCodeCatchThrowNewExceptionTest_nativeNativeCodeCatchThrowNewExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + + jboolean chk = '\0'; + chk = env->ExceptionCheck(); + if (chk == '\0'){ + return; + } + + if (chk){ + jclass newExcCls = NULL; + newExcCls = env->FindClass("java/lang/StringIndexOutOfBoundsException"); + if (newExcCls == NULL){ + return; + } + env->ThrowNew(newExcCls,"NativeThrowNew"); + } + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeCodeCatchThrowNewExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeCodeCatchThrowNewExceptionTest", "()V", reinterpret_cast(Java_NativeCodeCatchThrowNewExceptionTest_nativeNativeCodeCatchThrowNewExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3d5c30a6527af547f98d9840fa5948c11c43e5ac --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0029-rt-eh-NativeCodeCatchThrowNewExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeCodeCatchThrowNewExceptionTest,NATIVE_SRC=jniNativeCodeCatchThrowNewExceptionTest) +run(NativeCodeCatchThrowNewExceptionTest) diff --git a/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorExceptionTest.java b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8740e0f5b52aee74702d2ecf7fce33a1896df4df --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorExceptionTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.file.InvalidPathException; +public class NativeCheckFatalErrorExceptionTest extends Exception { + static { + System.loadLibrary("jniNativeCheckFatalErrorExceptionTest"); + } + private static int processResult = 99; + public static void main(String[] argv) { + System.exit(run(argv, System.out)); + } + private native void nativeNativeCheckFatalErrorExceptionTest() throws InvalidPathException; + private void callback() throws NumberFormatException { + throw new NumberFormatException("JavaMethodThrows"); + } + /** + * main test fun + * @return status code + */ + + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = nativeCheckFatalErrorExceptionTest(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 1 && processResult == 95) { + result = 0; + } + return result; + } + /** + * Asynchronous: Native(exception at callback from Java, then FatalError), catch by Java. + * @return status code + */ + + public static int nativeCheckFatalErrorExceptionTest() { + int result1 = 4; /* STATUS_FAILED*/ + + NativeCheckFatalErrorExceptionTest cTest = new NativeCheckFatalErrorExceptionTest(); + try { + cTest.nativeNativeCheckFatalErrorExceptionTest(); + processResult -= 10; + } catch (NumberFormatException e1) { + result1 = 1; + System.out.println("======>" + e1.getMessage()); + processResult--; + } catch (InvalidPathException e2) { + result1 = 3; + System.out.println("======>" + e2.getMessage()); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e3) { + result1 = 3; + processResult -= 10; + } + processResult -= 3; + return result1; + } +} diff --git a/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorTest.c b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorTest.c new file mode 100644 index 0000000000000000000000000000000000000000..5b7123bfe6910dc8c7c6a14fa82df0a217bb60af --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/NativeCheckFatalErrorTest.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +void native_nativeNativeCheckFatalErrorExceptionTest (JNIEnv *env, jobject obj){ + + jclass cls = (*env)->GetObjectClass(env, obj); + jmethodID mid = (*env)->GetMethodID(env, cls, "callback", "()V"); + if (mid == NULL){ + return; + } + (*env)->CallVoidMethod(env, obj, mid); // NumberFormatException:"Java_Method_throw_xxx" + + (*env)->FatalError(env,"------>CheckPoint:FatalError"); + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) +{ + JNIEnv* env = NULL; + jint result = -1; + + if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) { + return -1; + } + assert(env != NULL); + + JNINativeMethod gMethods [] = + { + {"nativeNativeCheckFatalErrorExceptionTest", "()V", (void*)&native_nativeNativeCheckFatalErrorExceptionTest}, + }; + + jclass cls = (*env)->FindClass(env, "NativeCheckFatalErrorExceptionTest"); // if package is test:"test/ExcpAsync06110" + (*env)->RegisterNatives(env, cls, gMethods, 1); + + /* success -- return valid version number */ + result = JNI_VERSION_1_4; + + return result; +} \ No newline at end of file diff --git a/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/expected.txt b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b2be12b8908ac503d84094b43385256ebcfb311b --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/expected.txt @@ -0,0 +1,2 @@ +------>CheckPoint:CcanContinue +======>JavaMethodThrows diff --git a/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/jniNativeCheckFatalErrorExceptionTest.cpp b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/jniNativeCheckFatalErrorExceptionTest.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4cfc6a93c444fe869f984a5e568d874c03b4aac --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/jniNativeCheckFatalErrorExceptionTest.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT void JNICALL Java_NativeCheckFatalErrorExceptionTest_nativeNativeCheckFatalErrorExceptionTest__ +(JNIEnv *env, jobject j_obj) +{ + jclass cls = NULL; + jmethodID mid = NULL; + + cls = env->GetObjectClass(j_obj); + if (cls == NULL){ + return; + } + mid = env->GetMethodID(cls,"callback", "()V"); + if (mid == NULL){ + return; + } + + env->CallVoidMethod(j_obj, mid); + env->FatalError("------>CheckPoint:FatalError"); + + printf("------>CheckPoint:CcanContinue\n"); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("NativeCheckFatalErrorExceptionTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"nativeNativeCheckFatalErrorExceptionTest", "()V", reinterpret_cast(Java_NativeCheckFatalErrorExceptionTest_nativeNativeCheckFatalErrorExceptionTest__)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} + +} diff --git a/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/test.cfg b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dda65ebc08c8af46b739097c7fa60d0a1ab0cbe5 --- /dev/null +++ b/testsuite/java_test/eh_test/native_test/RT0030-rt-eh-NativeCheckFatalErrorExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NativeCheckFatalErrorExceptionTest,NATIVE_SRC=jniNativeCheckFatalErrorExceptionTest) +run(NativeCheckFatalErrorExceptionTest) diff --git a/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/Message125004.java b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/Message125004.java new file mode 100755 index 0000000000000000000000000000000000000000..7e4df93cc832d3f4bc34f51a70e9ed87f5440c6b --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/Message125004.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +public class Message125004 { + private static int RES = 99; + private static Class clazz; + public static void main(String[] args){ + int result; + try{ + result = message125004(); + if(result == 4 && Message125004.RES == 89){ + result = 0; + } + System.out.println(result); + }catch(Exception e){ + e.printStackTrace(); + } + } + /**测试实例:[{NeedRandomClass=java.io.PipedReader}] 测试入参:abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ257 测试api信息:java.lang.Class + * 测试api信息:getField + 测试api信息:String + */ + + public static int message125004() { + try { + clazz = Class.forName("java.lang.Class"); + Method method = clazz.getMethod("getField",java.lang.String.class); + String parameters1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ257"; + Class instance = Class.forName("java.io.PipedReader") ; + Object result1 = method.invoke(instance, parameters1); + Message125004.RES -= 10; + return 4; + } catch (InvocationTargetException e) { + // 只打印类型 由Agent端接受进行对比 + // 打印全错误信息 +// e.printStackTrace(); + Message125004.RES -= 10; + return 4; + } catch (Exception e) { + // 只打印类型 由Agent端接受进行对比 + // 打印全错误信息 +// e.printStackTrace(); + Message125004.RES -= 10; + return 4; + } + } +} diff --git a/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/expected.txt b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/test.cfg b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a36b0b6470e72a308abf5e38b21961aa0d1a9b2e --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0001-rt-fuzzapi-PipedReaderEH/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Message125004) +run(Message125004) diff --git a/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/Message011706.java b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/Message011706.java new file mode 100755 index 0000000000000000000000000000000000000000..5d37a3b97aca3ccf3b11ef9aaaf0fa68aabbbb5b --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/Message011706.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.*; +import java.util.*; +public class Message011706 { + public static Class clazz; + private static List resultlist = new LinkedList<>(); + public static void main(String[] args) { + try { + System.out.println(messageCommonUse()); + } catch (Exception e) { + System.out.println(e); + } + } + public static int messageCommonUse() { + try { + clazz = Class.forName("java.lang.reflect.Method"); + Method method = clazz.getMethod("invoke",Object.class,Object[].class); + String fcn2 = "java.util.concurrent.ConcurrentHashMap"; + int mIndex6 = 1; + Method[] methods2 = Class.forName(fcn2).getDeclaredMethods(); + Arrays.sort(methods2, new ConstructorComparator()); + Object instance = methods2[mIndex6]; + Constructor con = java.lang.StringBuffer.class.getDeclaredConstructor(); + Object param1 = con.newInstance(); + Object param2[] = new Object[4]; + Constructor con0 = java.lang.StringBuffer.class.getDeclaredConstructor(); + param2[0] = con0.newInstance(); + Constructor con1 = java.security.spec.MGF1ParameterSpec.class.getDeclaredConstructor(java.lang.String.class); + param2[1] = con1.newInstance("abcdefghijklmnopqrstuvwxxzABCDEFGHIJKLMNOPQRSTUVWXYZ-9223372036854775551"); + Constructor con2 = java.util.Stack.class.getDeclaredConstructor(); + param2[2] = con2.newInstance(); + Constructor con3 = java.security.spec.ECGenParameterSpec.class.getDeclaredConstructor(java.lang.String.class); + param2[3] = con3.newInstance("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); + Object Result = method.invoke(instance,param1,param2); + System.out.println(Result); + } catch (Exception e) { + if (e.toString().equals("java.lang.reflect.InvocationTargetException") && + e.getCause().getClass().getName().toString().equals("java.lang.IllegalArgumentException")) + { + return 0; + } + } + return -1; + } +} +class ConstructorComparator implements Comparator{ + @Override + public int compare(Object c1, Object c2){ + byte[] b1 = c1.toString().getBytes(); + byte[] b2 = c2.toString().getBytes(); + int len = (b1.lengthb2[i]){ + return -1; + } + } + if(b1.length > b2.length){ + return -1; + }else if(b1.length < b2.length){ + return 1; + } + return 1; + } +} diff --git a/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/expected.txt b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/test.cfg b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..45ac6ed1283c111173c4ed9cf437e719b92d0b15 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0002-rt-fuzzapi-EHOrder/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Message011706) +run(Message011706) diff --git a/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/ThreadcountStackFramesTest.java b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/ThreadcountStackFramesTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8c3091a955931954ce0633bb64e55b01f4ef534b --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/ThreadcountStackFramesTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ThreadcountStackFramesTest { + static int RES = 99; + public static void main(String[] args) { + System.out.println(run()); + } + private static int run() { + int result; + result = countStackFramesTest(); + if(result == 4 && ThreadcountStackFramesTest.RES == 89) { + result = 0; + } + return result; + } + private static int countStackFramesTest() { + Runnable ra = new MyThread1(); + String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ4294967295"; + Thread t = new Thread(ra, str); + @SuppressWarnings("deprecation") + int i = t.countStackFrames(); + if(i == 0) { + ThreadcountStackFramesTest.RES -= 10; + } + return 4; + } +} +class MyThread1 implements Runnable { + private int ticket = 10; + @SuppressWarnings("unused") + private String name; + public void run() { + for (int i = 0; i < 500; i++) { + if (this.ticket > 0) { + System.out.println(Thread.currentThread().getName() + "---->" + (this.ticket--)); + } + } + } + public Object handler() { + Thread thread = new Thread(new MyThread1()); + thread.setUncaughtExceptionHandler(new MyExceptionHandler()); + thread.start(); + return thread.getUncaughtExceptionHandler(); + } + class MyExceptionHandler implements Thread.UncaughtExceptionHandler { + public void uncaughtException(Thread t, Throwable e) { + System.out.printf("An exception has been captured\n"); + System.out.printf("Thread:%s\n", t.getName()); + System.out.printf("Exception: %s: %s:\n", e.getClass().getName(), e.getMessage()); + System.out.printf("Stack Trace:\n"); + e.printStackTrace(); + System.out.printf("Thread status:%s\n", t.getState()); + } + } +} diff --git a/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/expected.txt b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/test.cfg b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..376daf69908bfcafa06d94480b582da72e16384c --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0003-rt-fuzzapi-noStartThreadInfo/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadcountStackFramesTest) +run(ThreadcountStackFramesTest) diff --git a/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/Message021404.java b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/Message021404.java new file mode 100644 index 0000000000000000000000000000000000000000..ab4dd2a44492c2566c4f76855bcfed84e5383812 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/Message021404.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +public class Message021404 { + private static int res = 99; + public static void main(String[] args){ + try{ + System.out.println(run()); + }catch (Exception e){ + e.printStackTrace(); + } + } + private static int run() throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + int result; + result = message021404(); + if(result == 4 && Message021404.res == 89){ + result = 0; + } + return result; + } + private static int message021404() throws NoSuchFieldException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { + Field f = Unsafe.class.getDeclaredField("theUnsafe"); + f.setAccessible(true); + Unsafe s = (Unsafe)f.get(null); + Method m = Unsafe.class.getDeclaredMethod("getUnsafe"); + m.invoke(s); + Message021404.res -= 10; + return 4; + } +} diff --git a/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/expected.txt b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/test.cfg b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f7bd528e0957f26805f0b98deaf99d3389adefda --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/RT0004-rt-fuzzapi-stackframeless/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Message021404) +run(Message021404) diff --git a/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/Message61004.java b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/Message61004.java new file mode 100755 index 0000000000000000000000000000000000000000..6da2b56fc56e39eb7d1b8733a5f9440a884c1bd4 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/Message61004.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class Message61004 { + private static int RES = 99; + private static Class clazz; + public static void main(String[] args) { +//message61104(); + int result = 2; + try { + result = message61004(); + if(result == 4 && Message61004.RES == 89){ + result = 0; + } + } catch (Exception e) { + e.printStackTrace(); + } + System.out.println(result); + } + /* 测试实例:测试入参:1389308892测试入参:-1727641912测试api信息:java.lang.String测试api信息:substring测试api信息:int测试api信息:int + */ + + private static int message61004() { + String str = null; + try { + clazz = Class.forName("java.lang.String"); +// Method[] met = clazz.getMethods(); +// Method method = clazz.getMethod("substring", int.class, int.class); + int parameters1 = 1389308892; + int parameters2 = -1727641912; + String instance = new String(); + instance.substring(parameters1, parameters2); +// Object result1 = method.invoke(instance, parameters1, parameters2); + } catch (Error e) { + str = e.getClass().toString(); + //System.out.println(str); + //e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + if(str != null && str.equals("class java.lang.OutOfMemoryError")){ + Message61004.RES -= 10; + } + return 4; + } +} diff --git a/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/expected.txt b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/test.cfg b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fb9b2879be9cfde7e19cfdb1375d3a47304d8d2b --- /dev/null +++ b/testsuite/java_test/fuzzapi_test/issue-RT0901-rt-fuzzapi-Message61004-subStringOOM/test.cfg @@ -0,0 +1,2 @@ +compile(Message61004.java) +run(Message61004) diff --git a/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/CharacterNativeUncover.java b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/CharacterNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..325b9019684fbbcda0b4b16a8ce26ef8921a3da1 --- /dev/null +++ b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/CharacterNativeUncover.java @@ -0,0 +1,515 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class CharacterNativeUncover { + private static int res = 99; + public static void main(String[] args) { + int result = 2; + CharacterDemo1(); + if(result == 2&&res == 53) { + res = 0; + } + System.out.println(res); + } + public static void CharacterDemo1() { + Character character = new Character('a'); + test1(character); + test2(character); + test3(character); + test4(character); + test5(character); + test6(character); + test7(character); + test8(character); + test9(character); + test10(character); + test11(character); + test12(character); + test13(character); + test14(character); + test15(character); + test16(character); + test17(character); + test18(character); + test19(character); + test20(character); + test21(character); + test22(character); + test23(character); + } + /** + * static native boolean isLowerCaseImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test1(Character character) { + try { + boolean flag = Character.isLowerCase(97);//isLowerCaseImpl() called by isLowerCase(); + // System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isUpperCaseImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test2(Character character) { + try { + boolean flag = Character.isUpperCase(65);//isUpperCaseImpl() called by isUpperCase(); + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isTitleCaseImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test3(Character character) { + try { + boolean flag = Character.isTitleCase(0x01c8);//isTitleCaseImpl() called by isTitleCase(); + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isDigitImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test4(Character character) { + try { + boolean flag = Character.isDigit(0x06f8);//isDigitImpl() called by isDigit();judge if it`s number; + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isDefinedImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test5(Character character) { + try { + boolean flag = Character.isDefined(0x012345);//isDefinedImpl() called by isDefined(); + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isLetterImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test6(Character character) { + try { + boolean flag = Character.isLetter(0x0065);//isLetterImpl() called by isLetter();tell if it`s char type; + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isLetterOrDigitImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test7(Character character) { + try { + boolean flag = Character.isLetterOrDigit(0x0033);//isLetterOrDigitImpl() called by isLetterOrDigit();tell if it`s char type; + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isAlphabeticImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test8(Character character) { + try { + boolean flag = Character.isAlphabetic(0x0065);//isAlphabeticImpl() called by isAlphabetic(); tell if it`s char type; + //System.out.println(flag); + if (flag) { + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isIdeographicImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test9(Character character) { + try { + boolean flag = Character.isIdeographic(0x0065);//isIdeographicImpl() called by isIdeographic(); + if (!flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isUnicodeIdentifierStartImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test10(Character character) { + try { + boolean flag = Character.isUnicodeIdentifierStart(0x0065);//isUnicodeIdentifierStartImpl() called by isUnicodeIdentifierStart(); + if (flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isUnicodeIdentifierPartImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test11(Character character) { + try { + boolean flag = Character.isUnicodeIdentifierPart(0x053e);//isUnicodeIdentifierPartImpl() called by isUnicodeIdentifierPart(); + if (flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * ensure the char should be a ignoreable char in java or unicode identifier + * static native boolean isIdentifierIgnorableImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test12(Character character) { + try { + boolean flag = Character.isIdentifierIgnorable(0x053e);//isIdentifierIgnorableImpl() called by isIdentifierIgnorable(); + if (!flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native int toLowerCaseImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test13(Character character) { + try { + int num = Character.toLowerCase(0x053e);//toLowerCaseImpl() called by toLowerCase(); + if (num == 1390) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native int toUpperCaseImpl(int codePoint) + * @param character + * @return + */ + + public static boolean test14(Character character) { + try { + int num = Character.toUpperCase(0x053e);//toUpperCaseImpl() called by toUpperCase(); + if (num == 1342) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native int toTitleCaseImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test15(Character character) { + try { + int num = Character.toTitleCase(0x053e);//toTitleCaseImpl() called by toTitleCase(); + if (num == 1342) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * native static int digitImpl(int codePoint, int radix); + * @param character + * @return + */ + + public static boolean test16(Character character) { + try { + int num = Character.digit(9,2);//digitImpl() called by digit(); + if (num == -1) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * native static int getNumericValueImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test17(Character character) { + try { + int num = Character.getNumericValue(9);//getNumericValueImpl() called by getNumericValue(); + if (num == -1) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native boolean isSpaceCharImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test18(Character character) { + try { + boolean flag = Character.isSpaceChar(9);//isSpaceCharImpl() called by isSpaceChar(); + if (!flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * native static boolean isWhitespaceImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test19(Character character) { + try { + boolean flag = Character.isWhitespace(9);//isWhitespaceImpl() called by isWhitespace(); + if (flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * static native int getTypeImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test20(Character character) { + try { + int num = Character.getType(9);//getTypeImpl() called by getType(); + if (num == 15) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * native static byte getDirectionalityImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test21(Character character) { + try { + int num = Character.getDirectionality(9);//getDirectionalityImpl() called by getDirectionality(); + if (num == 11) { + //System.out.println(num); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * native static boolean isMirroredImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test22(Character character) { + try { + boolean flag = Character.isMirrored(9);//isMirroredImpl() called by isMirrored(); + if (!flag) { + //System.out.println(flag); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * private static native String getNameImpl(int codePoint); + * @param character + * @return + */ + + public static boolean test23(Character character) { + try { + String string = Character.getName(9);//getNameImpl() called by getName(); + //if (string.equals("CHARACTER TABULATION")) { + if(string.equals("")){ + //System.out.println(string); + CharacterNativeUncover.res = CharacterNativeUncover.res - 2; + }else { + return false; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7df6ae9230203f6e2b206e1e0b190e64a976968a --- /dev/null +++ b/testsuite/java_test/other_test/RT0001-rt-other-CharacterNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterNativeUncover) +run(CharacterNativeUncover) diff --git a/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/ClassNativeUncover.java b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/ClassNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..fbe6c887e88d3a8f6149b5dee724bb8c55f39ad7 --- /dev/null +++ b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/ClassNativeUncover.java @@ -0,0 +1,333 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +public class ClassNativeUncover{ + private static int res = 99; + public String name; + public ClassNativeUncover() { + super(); + } + public ClassNativeUncover(String name) { + super(); + this.name = name; + } + public static void main(String[] args) { + int result = 2; + ClassDemo1(); + if(result ==2 && res == 65) { + res = 0; + } + System.out.println(res); + } + public static void ClassDemo1() { + Class class1 = ClassNativeUncover.class; + test1(class1); + test2(class1); + test3(class1); + test4(class1); + test5(class1); + test6(class1); + test7(class1); + test8(class1); + test9(class1); + test10(class1); + test11(class1); + test12(class1); + test13(class1); + test14(class1); + test15(class1); + test16(class1); + test17(class1); + } + /** + * public native Class getDeclaringClass(); + * @param class1 + */ + + public static void test1(Class class1) { + try { + boolean flag = class1.isMemberClass();//getDeclaringClass() called by isMemberClass(); + if (!flag) { + //System.out.println(flag); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } + /** + * public native Class getEnclosingClass(); + * @param class1 + */ + + public static void test2(Class class1) { + try { + String string = class1.getCanonicalName();//getEnclosingClass() called by getCanonicalName(); + if (string.equals("ClassNativeUncover")) { + //System.out.println(string); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } +} + /** + * public native boolean isAnonymousClass(); + * @param class1 + */ + + public static void test3(Class class1) { + try { + boolean flag = class1.isAnonymousClass(); + if (!flag) { + //System.out.println(flag); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * private native Field getPublicFieldRecursive(String name); + * @param class1 + */ + + public static void test4(Class class1) { + try { + Field field = class1.getField("name");//get the whole attributes which named "public" and inherited from parent class;getPublicFieldRecursive() called by getField(); + if (field.toString().equals("public java.lang.String ClassNativeUncover.name")) { + //System.out.println(field.toString()); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * public native Field[] getDeclaredFields(); + * @param class1 + */ + + public static void test5(Class class1) { + try { + Field[] fields = class1.getDeclaredFields();//get all declarative attributes; + if (fields!=null && fields.length>0) { +// for(Field field:fields ) { +// System.out.println(field); +// } + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * public native Method[] MethodsUnchecked(boolean publicOnly); + * @param class1 + */ + + public static void test6(Class class1) { + try { + Method[] methods = class1.getDeclaredMethods();//get declarative methods;getDeclaredMethodsUnchecked() called by getDeclaredMethods(); + if (methods!=null && methods.length>0) { +// for(Method method:methods ) { +// System.out.println(method); +// } + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } +} + /** + * private native Constructor[] getDeclaredConstructorsInternal(boolean publicOnly); + * @param class1 + */ + + public static void test7(Class class1) { + try { + Constructor[] constructors = class1.getConstructors();//get public constructions and inherited from parent class;getDeclaredConstructorsInternal()called bygetConstructors(); + if (constructors!=null && constructors.length>0) { +// for(Constructor constructor:constructors ) { +// System.out.println(constructor); +// } + ClassNativeUncover.res = ClassNativeUncover.res - 2;} + }catch (Exception e) { + e.printStackTrace(); + } + } + /**dcons + * private native Constructor[] getDeclaredConstructorsInternal(boolean publicOnly); + * @param class1 + */ + + public static void test8(Class class1) { + try { + Constructor[] constructors = class1.getDeclaredConstructors();//get all of declarative construcors;getDeclaredConstructorsInternal() called by getDeclaredConstructors; + if (constructors!=null && constructors.length>0) { +// for(Constructor constructor:constructors ) { +// System.out.println(constructor); +// } + ClassNativeUncover.res = ClassNativeUncover.res - 2;} + }catch (Exception e) { + e.printStackTrace(); + } +} + /** + * public native Field getDeclaredField(String name) throws NoSuchFieldException; + * @param class1 + */ + + public static void test9(Class class1) { + try { + Field field = class1.getDeclaredField("res"); + if(field.toString().equals("private static int ClassNativeUncover.res")) { + //System.out.println(field); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch(NoSuchFieldException e) { + e.printStackTrace(); + } +} + /** + * private native Constructor getDeclaredConstructorInternal(Class[] args); + * @param class1 + */ + + public static void test10(Class class1) { + try { + Constructor constructor = class1.getConstructor(new Class[] {String.class});//getDeclaredConstructorInternal() called by getConstructor; + if(constructor.toString().equals("public ClassNativeUncover(java.lang.String)")) { + //System.out.println(constructor); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch( NoSuchMethodException e) { + e.printStackTrace(); + } +} + /** + * private native Constructor getDeclaredConstructorInternal(Class[] args); + * @param class1 + */ + + public static void test11(Class class1) { + try { + Constructor constructor = class1.getDeclaredConstructor(new Class[] {String.class});//getDeclaredConstructorInternal() called by getDeclaredConstructor(); + if(constructor.toString().equals("public ClassNativeUncover(java.lang.String)")) { + //System.out.println(constructor); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch( NoSuchMethodException e) { + e.printStackTrace(); + } +} + /** + * private native String getInnerClassName(); + * @param class1 + */ + + public static void test12(Class class1) { + try { + String string = class1.getSimpleName();//getInnerClassName() called by getSimpleName(); + if(string.equals("ClassNativeUncover")) { + ClassNativeUncover.res = ClassNativeUncover.res - 2; + //System.out.println(string); + } + }catch(Exception e) { + e.printStackTrace(); + } +} + /** + * private native String[] getSignatureAnnotation(); + * @param class1 + */ + + public static void test13(Class class1) { + try { + TypeVariable[] typeVariables = class1.getTypeParameters();//return a array length 0;getSignatureAnnotation() called by getTypeParameters(); + if(typeVariables.getClass().toString().equals("class [Ljava.lang.reflect.TypeVariable;")&&typeVariables.length==0) { + //System.out.println(typeVariables.length); + //System.out.println(typeVariables.getClass().toString()); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch(Exception e) { + e.printStackTrace(); +} +} + /** + * private native String[] getSignatureAnnotation(); + * @param class1 + */ + + public static void test14(Class class1) { + try { + Type type = class1.getGenericSuperclass();//getSignatureAnnotation()called by getGenericSuperclass; + if(type.toString().equals("class java.lang.Object")) { + //System.out.println(type); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch(Exception e) { + e.printStackTrace(); + } +} + /** + * private native String[] getSignatureAnnotation(); + * @param class1 + */ + + public static void test15(Class class1) { + Type[] type = class1.getGenericInterfaces();//getSignatureAnnotation() called by getGenericInterfaces; + if(type.length == 0 && type.getClass().toString().equals("class [Ljava.lang.Class;")) { + //System.out.println(type.length); + //System.out.println(type.getClass().toString()); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } +} + /** private native Method getDeclaredMethodInternal(String name, Class[] args); + * @param class1 + */ + + public static void test16(Class class1) { + try { + Method method = class1.getMethod("ClassDemo1");//getDeclaredMethodInternal() called by getMethod() + if(method.toString().equals("public static void ClassNativeUncover.ClassDemo1()")) { + //System.out.println(method); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch( NoSuchMethodException e) { + e.printStackTrace(); + } + } + public static void test17(Class class1) { + try { + Annotation[] a = class1.getAnnotations(); //getDeclaredAnnotations() called by getAnnotations() + if (a.length == 0 && a.getClass().toString().equals("class [Ljava.lang.annotation.Annotation;")) { + //System.out.println(a.length); + //System.out.println(a.getClass().toString()); + ClassNativeUncover.res = ClassNativeUncover.res - 2; + } + }catch( Exception e) { + e.printStackTrace(); + } + } +} diff --git a/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ab3e69e013c306f194c8c67ee61675701f29b203 --- /dev/null +++ b/testsuite/java_test/other_test/RT0002-rt-other-ClassNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassNativeUncover) +run(ClassNativeUncover) diff --git a/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/ConstructorNativeUncover.java b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/ConstructorNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..bd84a1fe042d618e74c6843219ff32ee1ce6929c --- /dev/null +++ b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/ConstructorNativeUncover.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Constructor; +import java.util.Arrays; +public class ConstructorNativeUncover { + private static int res = 99; + public ConstructorNativeUncover() { + super(); + // TODO Auto-generated constructor stub + } + public static void main(String[] args) { + int result = 2; + ConstructorDemo1(); + if(result == 2 && res == 97) { + res = 0; + } + System.out.println(res); + } + public static void ConstructorDemo1() { + ConstructorNativeUncover constructorNativeUncover = new ConstructorNativeUncover(); + test(constructorNativeUncover); + } + /** + * public native Class[] getExceptionTypes(); + * @param constructorNativeUncover + * @return + */ + + public static boolean test(ConstructorNativeUncover constructorNativeUncover) { + try { + Class class1 = constructorNativeUncover.getClass(); + Constructor constructor = class1.getConstructor(new Class[] {}); + Class[] classes = constructor.getExceptionTypes(); + if(classes.length == 0 && classes.getClass().toString().equals("class [Ljava.lang.Class;")) { +// System.out.println(classes.getClass().toString()); +// System.out.println(classes.length); + ConstructorNativeUncover.res = ConstructorNativeUncover.res - 2; + } + }catch(NoSuchMethodException e) { + e.printStackTrace(); + return false; + } + return true; + } +} diff --git a/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..63f12b50f1f6a7f103dc767b2aae0760b2ae8131 --- /dev/null +++ b/testsuite/java_test/other_test/RT0003-rt-other-ConstructorNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorNativeUncover) +run(ConstructorNativeUncover) diff --git a/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/FieldNativeUncover.java b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/FieldNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..5b00a6b3178b11fcde40357183dc10bc619a4ff8 --- /dev/null +++ b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/FieldNativeUncover.java @@ -0,0 +1,359 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +public class FieldNativeUncover { + private static int res = 99; + public String userName; + public boolean flag; + public byte newByte; + public char chars; + public short shorts; + public int num; + public long longs; + public float floats; + @newAnnotation(name = "double1", value = "double2") + public double doubles; + @Retention(RetentionPolicy.RUNTIME) + public @interface newAnnotation{ + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + FieldDmeo1(); + if(result == 2 && res == 71) { + res = 0; + } + System.out.println(res); + } + public static void FieldDmeo1() { + FieldNativeUncover fieldNativeUncover = new FieldNativeUncover(); + test1(fieldNativeUncover); + test2(fieldNativeUncover); + test3(fieldNativeUncover); + test4(fieldNativeUncover); + test5(fieldNativeUncover); + test6(fieldNativeUncover); + test7(fieldNativeUncover); + test8(fieldNativeUncover); + test9(fieldNativeUncover); + test10(fieldNativeUncover); + test11(fieldNativeUncover); + test12(fieldNativeUncover); + test13(fieldNativeUncover); + test14(fieldNativeUncover); + } + /** + * private native String getNameInternal(); + * @param fieldNativeUncover + * @return + */ + + public static boolean test1(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("userName"); + String name = field.getName();//getNameInternal() called by getName(); + if(name.equals("userName")) { + //System.out.println(name); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + }catch( NoSuchFieldException e) { + e.printStackTrace(); + } + return true; + } + /** + * private native String[] getSignatureAnnotation(); + * @param fieldNativeUncover + * @return + */ + + public static boolean test2(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("userName"); + Type type = field.getGenericType();//getSignatureAttribute() called by getGenericType(),getSignatureAnnotation() called by getSignatureAttribute(); + if(type.toString().equals("class java.lang.String")) { + //System.out.println(type.toString()); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + }catch( NoSuchFieldException e) { + e.printStackTrace(); + } + return true; + } + /** + * public native Object get(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test3(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("userName"); + field.set(fieldNativeUncover, "Tom");// set the attribute "userName" as "Tom"; + Object object = field.get(fieldNativeUncover); + if(object.toString().equals("Tom")) { + //System.out.println(object); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native boolean getBoolean(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test4(FieldNativeUncover fieldNativeUncover){ + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("flag"); + field.setBoolean(fieldNativeUncover, true); + boolean flags = field.getBoolean(fieldNativeUncover); + if(flags) { + //System.out.println(flags); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native byte getByte(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test5(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("newByte"); + field.setByte(fieldNativeUncover, (byte) 100); + byte flags = field.getByte(fieldNativeUncover); + if(flags == 100) { + //System.out.println(flags); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native char getChar(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test6(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("chars"); + field.setChar(fieldNativeUncover, 'a'); + char chars = field.getChar(fieldNativeUncover); + if ("a".equals(String.valueOf(chars))) { + //System.out.println(chars); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native short getShort(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test7(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("shorts"); + field.setShort(fieldNativeUncover, (short) 20); + short sh = field.getShort(fieldNativeUncover); + if (sh==20) { + //System.out.println(sh); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native int getInt(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test8(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("num"); + field.setInt(fieldNativeUncover, 20); + int number = field.getInt(fieldNativeUncover); + if (number == 20) { + //System.out.println(number); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native long getLong(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test9(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("longs"); + field.setLong(fieldNativeUncover, 20); + long number = field.getLong(fieldNativeUncover); + if (number == 20) { + //System.out.println(number); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native float getFloat(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test10(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("floats"); + field.setFloat(fieldNativeUncover, (float) 1.0); + Float number = field.getFloat(fieldNativeUncover); + if (number==1.0) { + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * public native double getDouble(Object obj)throws IllegalArgumentException, IllegalAccessException; + * @param fieldNativeUncover + * @return + */ + + public static boolean test11(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("doubles"); + field.setDouble(fieldNativeUncover,1.05); + double number = field.getDouble(fieldNativeUncover); + if (number==1.05) { + FieldNativeUncover.res = FieldNativeUncover.res - 2; + return true; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * private native A getAnnotationNative(Class annotationType); + * @param fieldNativeUncover + * @return + */ + + public static boolean test12(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("doubles"); + newAnnotation annotation = field.getAnnotation(newAnnotation.class);//getAnnotationNative() called by getAnnotation() + if(annotation.toString().equals("@FieldNativeUncover$newAnnotation(name=double1, value=double2)")) { + //System.out.println(annotation.toString()); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * private native boolean isAnnotationPresentNative(Class annotationType); + * @param fieldNativeUncover + * @return + */ + + public static boolean test13(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("doubles"); + newAnnotation[] annotations = field.getAnnotationsByType(newAnnotation.class);//isAnnotationPresentNative() called by getAnnotationsByType() + if(annotations.length == 1) { + //System.out.println(annotations.length); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + return true; + } + return true; + } + /** + * public native Annotation[] getDeclaredAnnotations(); + * @param fieldNativeUncover + * @return + */ + + public static boolean test14(FieldNativeUncover fieldNativeUncover) { + try { + Class class1 = fieldNativeUncover.getClass(); + Field field = class1.getField("doubles"); + Annotation[] annotations =field.getDeclaredAnnotations(); + if(annotations.length == 1 && annotations.getClass().toString().equals("class [Ljava.lang.annotation.Annotation;")) { + //System.out.println(annotations.length); + //System.out.println(annotations.getClass().toString()); + FieldNativeUncover.res = FieldNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e6a2992f351e04d2e84f98e98b50b29e9bcf80e0 --- /dev/null +++ b/testsuite/java_test/other_test/RT0004-rt-other-FieldNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldNativeUncover) +run(FieldNativeUncover) diff --git a/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/MethodNativeUncover.java b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/MethodNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..f48b318de344f1330ce7718181cf2150e2e76ba8 --- /dev/null +++ b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/MethodNativeUncover.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Method; +public class MethodNativeUncover { +private static int res = 99; + public static void sayHello() { + String hello = "halo"; + } + public static void main(String[] args) { + int result = 2; + MethodDemo1(); + if(result == 2 && res == 95) { + res = 0; + } + System.out.println(res); + } + public static void MethodDemo1(){ + MethodNativeUncover methodNativeUncover = new MethodNativeUncover(); + test(methodNativeUncover); + test1(methodNativeUncover); + } + /** + * public native Class[] getExceptionTypes(); + * @param methodNativeUncover + */ + + public static void test(MethodNativeUncover methodNativeUncover) { + Class class1 = methodNativeUncover.getClass(); + try { + Method method = class1.getMethod("sayHello"); + Class[] newClass = method.getExceptionTypes(); + if(newClass.length == 0 && newClass.getClass().toString().equals("class [Ljava.lang.Class;")) { + //System.out.println(newClass.length); + //System.out.println(newClass.getClass()); + MethodNativeUncover.res = MethodNativeUncover.res - 2; + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } + /** + * public native Object getDefaultValue(); + * @param methodNativeUncover + */ + + public static void test1(MethodNativeUncover methodNativeUncover) { + Class class1 = methodNativeUncover.getClass(); + try { + Method method = class1.getMethod("sayHello"); + Object object = method.getDefaultValue(); + if(object == null) { + //System.out.println(object); + MethodNativeUncover.res = MethodNativeUncover.res - 2; + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } catch (SecurityException e) { + e.printStackTrace(); + } + } +} diff --git a/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a4de7708930b547acf3c39aed1798cd81bc9be0 --- /dev/null +++ b/testsuite/java_test/other_test/RT0005-rt-other-MethodNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodNativeUncover) +run(MethodNativeUncover) diff --git a/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/ThreadNativeUncover.java b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/ThreadNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..22137ef31d2817f57396941630dd6b5dbec95fb2 --- /dev/null +++ b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/ThreadNativeUncover.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread.State; +public class ThreadNativeUncover { + private static int res = 99; + public static void main(String[] args) { + int result = 2; + ThreadDemo1(); + if (result == 2 && res == 97) { + res = 0; + } + System.out.println(res); + } + public static void ThreadDemo1() { + Thread thread = new Thread(); + test(thread); + } + /** + * private native int nativeGetStatus(boolean hasBeenStarted); + * @param thread + */ + + public static void test(Thread thread) { + try { + State state = thread.getState();//nativeGetStatus() called by getState(); + if (state.toString().equals("NEW")) { + ThreadNativeUncover.res = ThreadNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a26235e542ccb736a16852db922b4f9d96437c9d --- /dev/null +++ b/testsuite/java_test/other_test/RT0006-rt-other-ThreadNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadNativeUncover) +run(ThreadNativeUncover) diff --git a/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/ThrowableNativeUncover.java b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/ThrowableNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..1f9837c92a99f149e2e9990ca87c540861f99ade --- /dev/null +++ b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/ThrowableNativeUncover.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ThrowableNativeUncover { + private static int res = 99; + public static void main(String[] args) { + ThrowableDemo1(); + } + public static void ThrowableDemo1() { + int result = 2; + Throwable throwable = new Throwable(); + test(throwable); + test1(throwable); + if(result == 2 && res == 95) { + res = 0; + } + System.out.println(res); + } + /** + * private static native Object nativeFillInStackTrace(); + * @param throwable + * @return + */ + + public static boolean test(Throwable throwable) { + try { + Throwable throwable2 = throwable.fillInStackTrace();//nativeFillInStackTrace() called by fillInStackTrace(); + if(throwable2.toString().equals("java.lang.Throwable")) { + //System.out.println(throwable2.toString()); + ThrowableNativeUncover.res = ThrowableNativeUncover.res - 2; + } + } catch (Exception e) { + e.printStackTrace(); + } + return true; + } + /** + * private static native StackTraceElement[] nativeGetStackTrace(Object stackState); + * @param throwable + * @return + */ + + public static boolean test1(Throwable throwable) { + try { + StackTraceElement[] stackTraceElements = throwable.getStackTrace();//nativeGetStackTrace() called by getStackTrace(); + if(stackTraceElements.length == 3 && stackTraceElements.getClass().toString().equals("class [Ljava.lang.StackTraceElement;")) { + //System.out.println(stackTraceElements.length); + //System.out.println(stackTraceElements.getClass().toString()); + ThrowableNativeUncover.res = ThrowableNativeUncover.res - 2; + } + }catch (Exception e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/expected.txt b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/test.cfg b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4d53739d9d33bb05a8c33c8fc9ee036f2791026d --- /dev/null +++ b/testsuite/java_test/other_test/RT0007-rt-other-ThrowableNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableNativeUncover) +run(ThrowableNativeUncover) diff --git a/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/TestJniPassingFloat.java b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/TestJniPassingFloat.java new file mode 100644 index 0000000000000000000000000000000000000000..fabe3c6cc05a7b8c82ce36da899c94a42c24afe6 --- /dev/null +++ b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/TestJniPassingFloat.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +class MyCycle { + byte[] bytes; + Object[] refs; + MyCycle() { + bytes = new byte[2500]; + refs = new Object[1]; + refs[0] = this; + } +}; +public class TestJniPassingFloat { + static { + System.loadLibrary("jniFunction"); + } + static volatile boolean running = true; + static native float myNative(float f, double d); + static void run() { + MyCycle obj; + for (int i = 0; i < 30000; ++i) { + obj = new MyCycle(); + } + running = false; + } + public static void main(String[] args) throws Exception { + Thread thread = new Thread(() -> run()); + thread.start(); + while (running) { + float f = myNative(1.0f, 2.0f); + if (Float.compare(f, 1.0f + 2.0f) != 0) { + throw new Exception("test failed f=" + f); + } + } + thread.join(); + System.out.println("pass"); + } +} diff --git a/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/expected.txt b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2ae28399f5fda2dfb1b04405f4a3b4895f5fac1e --- /dev/null +++ b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/expected.txt @@ -0,0 +1 @@ +pass diff --git a/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/jniFunction.cpp b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/jniFunction.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ae0be2ea206ac0be0ff0e7a5364855c108aabf3 --- /dev/null +++ b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/jniFunction.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include + +extern "C" { +JNIEXPORT jfloat JNICALL Java_TestJniPassingFloat_myNative__FD +(JNIEnv *env, jclass cls, jfloat s0, jdouble d1) +{ + return s0 + d1; +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("TestJniPassingFloat"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"myNative", "(FD)F", reinterpret_cast(Java_TestJniPassingFloat_myNative__FD)}, + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} diff --git a/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/test.cfg b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f46e01f95d8a8ff2f1f2b45c7f44c30da9ea2059 --- /dev/null +++ b/testsuite/java_test/other_test/RT0008-rt-other-PassingFloat/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TestJniPassingFloat,NATIVE_SRC=jniFunction) +run(TestJniPassingFloat) diff --git a/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/ArrayNativeUncover.java b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/ArrayNativeUncover.java new file mode 100644 index 0000000000000000000000000000000000000000..57a5181e65497b0eddf6b52df26ac483cf0dc9ce --- /dev/null +++ b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/ArrayNativeUncover.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.reflect.Array; +public class ArrayNativeUncover{ + private static int res = 99; + public static void main(String[] args) { + int result = 2; + ArrayDemo1(); + if(result == 2 && ArrayNativeUncover.res == 97) { + result = 0; + System.out.println(result); + } + } + public static void ArrayDemo1() { + test1(); + } + /** + * private static native Object createObjectArray(Class componentType, int length) throws NegativeArraySizeException; + * @return + */ + + public static boolean test1() { + try { + Object object = Array.newInstance(String.class, 5);//createObjectArray() called by newInstance(); + if(object.getClass().toString().equals("class [Ljava.lang.String;")) { + ArrayNativeUncover.res =ArrayNativeUncover.res - 2; + return true; + } + }catch(Exception e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/expected.txt b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/test.cfg b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2458ca4c20b1cf09255aa59c98d32a15a7be2040 --- /dev/null +++ b/testsuite/java_test/other_test/issue-RT0630-rt-other-ArrayNativeUncover/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayNativeUncover) +run(ArrayNativeUncover) diff --git a/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/AccessibleObjectExObjectequals.java b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/AccessibleObjectExObjectequals.java new file mode 100755 index 0000000000000000000000000000000000000000..31423a4585aa53f864a66b7da61be0cda0e0974e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/AccessibleObjectExObjectequals.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.*; +public class AccessibleObjectExObjectequals { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new AccessibleObjectExObjectequals().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = accessibleObjectExObjectequals1(); + } catch (Exception e) { + AccessibleObjectExObjectequals.res = AccessibleObjectExObjectequals.res - 20; + } + if (result == 4 && AccessibleObjectExObjectequals.res == 89) { + result = 0; + } + return result; + } + private int accessibleObjectExObjectequals1() throws NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // boolean equals(Object obj) + AccessibleObject sampleField2 = AccessibleClass1.class.getDeclaredField("sampleField"); + AccessibleObject sampleField1 = AccessibleClass1.class.getDeclaredField("sampleField"); + if (sampleField2.equals(sampleField1)) { + AccessibleObjectExObjectequals.res = AccessibleObjectExObjectequals.res - 10; + } else { + AccessibleObjectExObjectequals.res = AccessibleObjectExObjectequals.res - 1; + } + return result1; + } +} +@AccessibleAnnotation1(name = "SampleClass", value = "Sample Class Annotation") +class AccessibleClass1 { + private String sampleField; + @AccessibleAnnotation1(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface AccessibleAnnotation1 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/expected.txt b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/test.cfg b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7a7804b0889961834ca14135fa3a38ab86b9bec3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0001-rt-parent-AccessibleObjectExObjectequals/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjectequals) +run(AccessibleObjectExObjectequals) diff --git a/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/AccessibleObjectExObjecthashCode.java b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/AccessibleObjectExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..04e229e264ae60db970d06a1bc23c1366507f2cf --- /dev/null +++ b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/AccessibleObjectExObjecthashCode.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new AccessibleObjectExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = accessibleObjectExObjecthashCode1(); + } catch (Exception e) { + AccessibleObjectExObjecthashCode.res = AccessibleObjectExObjecthashCode.res - 20; + } + if (result == 4 && AccessibleObjectExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int accessibleObjectExObjecthashCode1() throws NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + AccessibleObject sampleField0 = SampleClass.class.getDeclaredField("sampleField0"); + AccessibleObject sampleField1 = SampleClass.class.getDeclaredField("sampleField0"); + AccessibleObject sampleField2 = SampleClass.class.getDeclaredField("sampleField1"); + int px0 = sampleField0.hashCode(); + int px1 = sampleField1.hashCode(); + int px2 = sampleField2.hashCode(); + if (px0 == px1 && px0 != px2) { + AccessibleObjectExObjecthashCode.res = AccessibleObjectExObjecthashCode.res - 10; + } + return result1; + } +} +@CustomAnnotation(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass { + private String sampleField0; + private String sampleField1; + @CustomAnnotation(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + /** + * get sampleField0 + * @return sampleField0 + */ + + public String getSampleField() { + return sampleField0; + } + /** + * set sampleField0 + * @param sampleField just for test + */ + + public void setSampleField(String sampleField) { + this.sampleField0 = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotation { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..75fca79da25f4330c301cdbf53660f963d735b1f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0002-rt-parent-AccessibleObjectExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjecthashCode) +run(AccessibleObjectExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..ab7f0c44b9c2be1c695da1a84e9b37fa3818115e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private static AccessibleObject sampleField1 = null; + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + sampleField1 = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.class.getDeclaredField("res"); + System.out.println(new AccessibleObjectExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = accessibleObjectExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new AccessibleObjectExObjectnotifyAllIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int accessibleObjectExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + sampleField1.notifyAll(); + AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class AccessibleObjectExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + try { + sampleField1.notifyAll(); + AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..42bd1794b3e9ef4f44c5737fe177868051fb16dc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0003-rt-parent-AccessibleObjectExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjectnotifyAllIllegalMonitorStateException) +run(AccessibleObjectExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/AccessibleObjectExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/AccessibleObjectExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..8f09de6032b5dffc0c58a5e1d308d84fdc58e5de --- /dev/null +++ b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/AccessibleObjectExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private static AccessibleObject sampleField1 = null; + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + sampleField1 = AccessibleObjectExObjectnotifyIllegalMonitorStateException.class.getDeclaredField("res"); + System.out.println(new AccessibleObjectExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = acessibleObjectExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + AccessibleObjectExObjectnotifyIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new AccessibleObjectExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && AccessibleObjectExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int acessibleObjectExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + sampleField1.notify(); + AccessibleObjectExObjectnotifyIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectnotifyIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class AccessibleObjectExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + try { + sampleField1.notify(); + AccessibleObjectExObjectnotifyIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectnotifyIllegalMonitorStateException.res = AccessibleObjectExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..29e461da5e4c1f755db12b9812cc15b963f49c2f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0004-rt-parent-AccessibleObjectExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjectnotifyIllegalMonitorStateException) +run(AccessibleObjectExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/AccessibleObjectExObjecttoString.java b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/AccessibleObjectExObjecttoString.java new file mode 100755 index 0000000000000000000000000000000000000000..3947b4c58e353cc65d37c491cc400b8794a94c34 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/AccessibleObjectExObjecttoString.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjecttoString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new AccessibleObjectExObjecttoString().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = accessibleObjectExObjecttoString1(); + } catch (Exception e) { + AccessibleObjectExObjecttoString.res = AccessibleObjectExObjecttoString.res - 20; + } + if (result == 4 && AccessibleObjectExObjecttoString.res == 89) { + result = 0; + } + return result; + } + private int accessibleObjectExObjecttoString1() throws NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ +// String toString() + AccessibleObject sampleField1 = AccessibleObjectExObjecttoString.class.getDeclaredField("res"); + String px1 = sampleField1.toString(); +// System.out.println(px1); + if (px1.equals("static int AccessibleObjectExObjecttoString.res")) { + AccessibleObjectExObjecttoString.res = AccessibleObjectExObjecttoString.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/expected.txt b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/test.cfg b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..08333b18b40fa7002268bd9ac2f4754c700b66d5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0005-rt-parent-AccessibleObjectExObjecttoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjecttoString) +run(AccessibleObjectExObjecttoString) diff --git a/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/AccessibleObjectExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/AccessibleObjectExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..90a69f6a97b1fc01cdc0a27669d75e2937c794bd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/AccessibleObjectExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static AccessibleObject sampleField1 = null; + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + sampleField1 = AccessibleObjectExObjectwaitIllegalMonitorStateException.class.getDeclaredField("res"); + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = accessibleObjectExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = accessibleObjectExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = accessibleObjectExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && AccessibleObjectExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int accessibleObjectExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + sampleField1.wait(); + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int accessibleObjectExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // + // final void wait(long millis) + long millis = 123; + try { + sampleField1.wait(millis); + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int accessibleObjectExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + sampleField1.wait(millis, nanos); + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitIllegalMonitorStateException.res = AccessibleObjectExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..acd2edd0583db66b707d889ff9eabb0facdff2dd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0006-rt-parent-AccessibleObjectExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjectwaitIllegalMonitorStateException) +run(AccessibleObjectExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/ArrayExObjecthashCode.java b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/ArrayExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..4aae54f94491d397bf4a571bdc0544fee1e51975 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/ArrayExObjecthashCode.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ArrayExObjecthashCode().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = arrayExObjecthashCode1(); + } catch (Exception e) { + ArrayExObjecthashCode.res = ArrayExObjecthashCode.res - 20; + } + if (result == 4 && ArrayExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int arrayExObjecthashCode1() throws NoSuchFieldException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + Object ary0 = Array.newInstance(int.class, 10); + Object ary1 = ary0; + Object ary2 = Array.newInstance(int.class, 11); + int px0 = ary0.hashCode(); + int px1 = ary1.hashCode(); + int px2 = ary2.hashCode(); + if (px0 == px1 && px0 != px2) { + ArrayExObjecthashCode.res = ArrayExObjecthashCode.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c8738247845c74286f0fb00d410058e94d0dca13 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0007-rt-parent-ArrayExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjecthashCode) +run(ArrayExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/ArrayExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/ArrayExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..0b9e749b0fef223a308591f7e9f400b4049c2efb --- /dev/null +++ b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/ArrayExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private static Object ary1 = Array.newInstance(int.class, 10); + public static void main(String argv[]) { + System.out.println(new ArrayExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = arrayExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ArrayExObjectnotifyAllIllegalMonitorStateException.res = ArrayExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ArrayExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ArrayExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int arrayExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + ary1.notifyAll(); + ArrayExObjectnotifyAllIllegalMonitorStateException.res = ArrayExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectnotifyAllIllegalMonitorStateException.res = ArrayExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ArrayExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ArrayExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + try { + ary1.notifyAll(); + ArrayExObjectnotifyAllIllegalMonitorStateException.res = ArrayExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectnotifyAllIllegalMonitorStateException.res = ArrayExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f4e3bef4e235a6e5cee7a17bf20b614b00835f35 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0008-rt-parent-ArrayExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjectnotifyAllIllegalMonitorStateException) +run(ArrayExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/ArrayExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/ArrayExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..82cdfb59886e64b04ae3649da203a56a27e13a85 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/ArrayExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private static Object ary1 = Array.newInstance(int.class, 10); + public static void main(String argv[]) { + System.out.println(new ArrayExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = arrayExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ArrayExObjectnotifyIllegalMonitorStateException.res = ArrayExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ArrayExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ArrayExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int arrayExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + ary1.notify(); + ArrayExObjectnotifyIllegalMonitorStateException.res = ArrayExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectnotifyIllegalMonitorStateException.res = ArrayExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ArrayExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ArrayExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + try { + ary1.notify(); + ArrayExObjectnotifyIllegalMonitorStateException.res = ArrayExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectnotifyIllegalMonitorStateException.res = ArrayExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..84ffcedca32dbc0f831b822929e6f9ceff42cb25 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0009-rt-parent-ArrayExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjectnotifyIllegalMonitorStateException) +run(ArrayExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/ArrayExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/ArrayExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..07a7b6b75d316222192bca63113f29b0642d4df8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/ArrayExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjectwaitIllegalMonitorStateException { + static int res = 99; + static Object ary1 = Array.newInstance(int.class, 10); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = arrayExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = arrayExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = arrayExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ArrayExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int arrayExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + ary1.wait(); + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int arrayExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + ary1.wait(millis); + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int arrayExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + ary1.wait(millis, nanos); + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitIllegalMonitorStateException.res = ArrayExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f93ce9e7d7e966f20dcb98f2e152226d637d7c63 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0010-rt-parent-ArrayExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjectwaitIllegalMonitorStateException) +run(ArrayExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/ArrayExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/ArrayExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..cc2b758236823fa488a33ea284c6383d16b665b4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/ArrayExObjectwaitInterruptedException.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjectwaitInterruptedException { + static int res = 99; + private static Object ary1 = Array.newInstance(int.class, 10); + public static void main(String argv[]) { + System.out.println(new ArrayExObjectwaitInterruptedException().run()); + } + private class ArrayExObjectwaitInterruptedException11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(); + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ArrayExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(millis); + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ArrayExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(millis, nanos); + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ArrayExObjectwaitInterruptedException.res = ArrayExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * @param slpNum wait time + */ + + public void sleep(int slpNum) { + try { + Thread.sleep(slpNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ArrayExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new ArrayExObjectwaitInterruptedException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ArrayExObjectwaitInterruptedException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && ArrayExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0d9e9aa2bdda920955dc2121d3f5e7cb0b9bd387 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0011-rt-parent-ArrayExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjectwaitInterruptedException) +run(ArrayExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/ArrayExObjectwait.java b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/ArrayExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..921d746a77f072a2e5f0a9d717d890ec682dee59 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/ArrayExObjectwait.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class ArrayExObjectwait { + static int res = 99; + private static Object ary1 = Array.newInstance(int.class, 10); + public static void main(String argv[]) { + System.out.println(new ArrayExObjectwait().run()); + } + private class ArrayExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(); + ArrayExObjectwait.res = ArrayExObjectwait.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 30; + } + } + } + } + private class ArrayExObjectwait12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(millis); + ArrayExObjectwait.res = ArrayExObjectwait.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 30; + } + } + } + } + private class ArrayExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (ary1) { + ary1.notifyAll(); + try { + ary1.wait(millis, nanos); + ArrayExObjectwait.res = ArrayExObjectwait.res - 10; + } catch (InterruptedException e1) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ArrayExObjectwait.res = ArrayExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ArrayExObjectwait11()); + Thread t2 = new Thread(new ArrayExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new ArrayExObjectwait12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ArrayExObjectwait13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + sleep(1000); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.start(); + sleep(1000); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ArrayExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..32070136a0392400be2558c9a91e3c71153d8156 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0012-rt-parent-ArrayExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayExObjectwait) +run(ArrayExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/CharacterExObjectgetClass.java b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/CharacterExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..7746644f771bdd22df9bfc5caa981475a9e4899a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/CharacterExObjectgetClass.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new CharacterExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterExObjectgetClass1(); + } catch (Exception e) { + CharacterExObjectgetClass.res = CharacterExObjectgetClass.res - 20; + } + if (result == 4 && CharacterExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int characterExObjectgetClass1() { + // final Class getClass() + int result1 = 4; /*STATUS_FAILED*/ + char name = 'A'; + Character char1 = new Character(name); + Class px1 = char1.getClass(); + if (px1.toString().equals("class java.lang.Character")) { + CharacterExObjectgetClass.res = CharacterExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2cb7d90896da49b0c39ba4bd03872614650f0d71 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0013-rt-parent-CharacterExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectgetClass) +run(CharacterExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/CharacterExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/CharacterExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..66e78ab4d4d57b87e04c10d1f62fd13972253cc0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/CharacterExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class CharacterExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private char name = 'A'; + private Character rp = name; + public static void main(String argv[]) { + System.out.println(new CharacterExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterExObjectnotifyIllegalMonitorStateException.res = CharacterExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new CharacterExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && CharacterExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int characterExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp.notify(); + CharacterExObjectnotifyIllegalMonitorStateException.res = CharacterExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectnotifyIllegalMonitorStateException.res = CharacterExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class CharacterExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notify(); + CharacterExObjectnotifyIllegalMonitorStateException.res = CharacterExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectnotifyIllegalMonitorStateException.res = CharacterExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..770024ff8f95a86d8c7750e95e0b5dd576147abd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0014-rt-parent-CharacterExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectnotifyIllegalMonitorStateException) +run(CharacterExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/CharacterExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/CharacterExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..e64eb01a90ba863be1105470a642722025a8bc6e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/CharacterExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterExObjectwaitIllegalMonitorStateException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = characterExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = characterExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = characterExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && CharacterExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int characterExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + char name = 'A'; + Character rp = new Character(name); + try { + rp.wait(); + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int characterExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + char name = 'A'; + long millis = 123; + Character rp = new Character(name); + try { + rp.wait(millis); + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int characterExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + char name = 'A'; + long millis = 123; + int nanos = 10; + Character rp = new Character(name); + try { + rp.wait(millis, nanos); + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitIllegalMonitorStateException.res = CharacterExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2840ba51d165119535c8434d28b488e514a8e88c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0015-rt-parent-CharacterExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectwaitIllegalMonitorStateException) +run(CharacterExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/CharacterExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/CharacterExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..cfddd37a67c20f2e446a48f570fb21c73287ab90 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/CharacterExObjectwaitInterruptedException.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterExObjectwaitInterruptedException { + static int res = 99; + static char name = 'A'; + static Character sampleField1 = new Character(name); + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + System.out.println(new CharacterExObjectwaitInterruptedException().run()); + } + private class CharacterExObjectwaitInterruptedException11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(); + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class CharacterExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis); + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class CharacterExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis, nanos); + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterExObjectwaitInterruptedException.res = CharacterExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * @param slpNum wait time + */ + + public void sleep(int slpNum) { + try { + Thread.sleep(slpNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new CharacterExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new CharacterExObjectwaitInterruptedException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new CharacterExObjectwaitInterruptedException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && CharacterExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..72098144f63f5a3219edb02aab23233d3f9ceac4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0016-rt-parent-CharacterExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectwaitInterruptedException) +run(CharacterExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/CharacterExObjectwait.java b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/CharacterExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..520f8a7ca8a00de909d1d0861fed3c829fba704e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/CharacterExObjectwait.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterExObjectwait { + static int res = 99; + private char name = 'A'; + private String actions = null; + private Character rp = new Character(name); + private Character rp2 = new Character(name); + private Character rp3 = new Character(name); + public static void main(String argv[]) { + System.out.println(new CharacterExObjectwait().run()); + } + private class CharacterExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private CharacterExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + rp.notifyAll(); + try { + rp.wait(); + CharacterExObjectwait.res = CharacterExObjectwait.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 30; + } + } + } + } + private class CharacterExObjectwait12 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private CharacterExObjectwait12(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp2) { + rp2.notifyAll(); + try { + rp2.wait(millis); + CharacterExObjectwait.res = CharacterExObjectwait.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 30; + } + } + } + } + private class CharacterExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private CharacterExObjectwait13(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp3) { + rp3.notifyAll(); + try { + rp3.wait(millis, nanos); + CharacterExObjectwait.res = CharacterExObjectwait.res - 10; + } catch (InterruptedException e1) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectwait.res = CharacterExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new CharacterExObjectwait11(1)); + Thread t2 = new Thread(new CharacterExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new CharacterExObjectwait12(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new CharacterExObjectwait13(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && CharacterExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..27d10546a79e792a2adb3d79c5b34bf07eb3132f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0017-rt-parent-CharacterExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectwait) +run(CharacterExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/CharacterSubsetExObjectgetClass.java b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/CharacterSubsetExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..4f929c7cc37e24ffbf307847a8abbd388ed5b201 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/CharacterSubsetExObjectgetClass.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new CharacterSubsetExObjectgetClass().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterSubsetExObjectgetClass1(); + } catch (Exception e) { + CharacterSubsetExObjectgetClass.res = CharacterSubsetExObjectgetClass.res - 20; + } + if (result == 4 && CharacterSubsetExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int characterSubsetExObjectgetClass1() { +// final Class getClass() + int result1 = 4; /*STATUS_FAILED*/ + MySubset subset = new MySubset("some subset"); + Class px1 = subset.getClass(); + if (px1.toString().equals("class MySubset")) { + CharacterSubsetExObjectgetClass.res = CharacterSubsetExObjectgetClass.res - 10; + } + return result1; + } +} +class MySubset extends Character.Subset { + MySubset(String name) { + super(name); + } +} diff --git a/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cecc294e672f4f959d34125264ef7120ec1bb5dd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0018-rt-parent-CharacterSubsetExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectgetClass) +run(CharacterSubsetExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..a4b9df7e90b590dd4389bf86e555d70fede4b6c6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + MySubset1 mf2 = new MySubset1("some subset"); + public static void main(String argv[]) { + System.out.println(new CharacterSubsetExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterSubsetExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new CharacterSubsetExObjectnotifyAllIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int characterSubsetExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + mf2.notifyAll(); + CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class CharacterSubsetExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notifyAll(); + CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} +class MySubset1 extends Character.Subset { + MySubset1(String name) { + super(name); + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3872c73aa9ce71e65c0582f88a9c68dd63865bf3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0019-rt-parent-CharacterSubsetExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectnotifyAllIllegalMonitorStateException) +run(CharacterSubsetExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/CharacterSubsetExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/CharacterSubsetExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..3230251390dbaac68f93df0b669dc619166b0707 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/CharacterSubsetExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectnotifyIllegalMonitorStateException { + static int res = 99; + MySubset2 mf2 = new MySubset2("some subset"); + public static void main(String argv[]) { + System.out.println(new CharacterSubsetExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterSubsetExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterSubsetExObjectnotifyIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new CharacterSubsetExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && CharacterSubsetExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int characterSubsetExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // + // final void notify() + try { + mf2.notify(); + CharacterSubsetExObjectnotifyIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectnotifyIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class CharacterSubsetExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notify(); + CharacterSubsetExObjectnotifyIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectnotifyIllegalMonitorStateException.res = CharacterSubsetExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} +class MySubset2 extends Character.Subset { + MySubset2(String name) { + super(name); + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..dbc5917aaf19bddb2d92c114b511a852c2bc63a5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0020-rt-parent-CharacterSubsetExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectnotifyIllegalMonitorStateException) +run(CharacterSubsetExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/CharacterSubsetExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/CharacterSubsetExObjectwaitIllegalArgumentException.java new file mode 100644 index 0000000000000000000000000000000000000000..210bd7533f0d4224708aab15d623864dc0ec22fe --- /dev/null +++ b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/CharacterSubsetExObjectwaitIllegalArgumentException.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectwaitIllegalArgumentException { + static int res = 99; + MySubset4 csb1 = new MySubset4("some subset"); + public static void main(String argv[]) { + System.out.println(new CharacterSubsetExObjectwaitIllegalArgumentException().run()); + } + private class CharacterSubsetExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (csb1) { + csb1.notifyAll(); + try { + csb1.wait(millis); + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class CharacterSubsetExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (csb1) { + csb1.notifyAll(); + try { + csb1.wait(millis, nanos); + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterSubsetExObjectwaitIllegalArgumentException.res = CharacterSubsetExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * @param sleepNum wait time + */ + + public void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new CharacterSubsetExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new CharacterSubsetExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && CharacterSubsetExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} +class MySubset4 extends Character.Subset { + MySubset4(String name) { + super(name); + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..978c9bcae95e46ece6a3f62ac5c00f310746eae2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0021-rt-parent-CharacterSubsetExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectwaitIllegalArgumentException) +run(CharacterSubsetExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/CharacterSubsetExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/CharacterSubsetExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..745178e9aea1da90d22da105f73ca58b38242f81 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/CharacterSubsetExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static MySubset5 csb1 = new MySubset5("some subset"); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = characterSubsetExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = characterSubsetExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = characterSubsetExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && CharacterSubsetExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } +// System.out.println("result: " + result); +// System.out.println("CharacterSubsetExObjectwaitIllegalMonitorStateException.res: " + CharacterSubsetExObjectwaitIllegalMonitorStateException.res); + return result; + } + private static int characterSubsetExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor + // final void wait() + try { + csb1.wait(); + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int characterSubsetExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + csb1.wait(millis); + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int characterSubsetExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + csb1.wait(millis, nanos); + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitIllegalMonitorStateException.res = CharacterSubsetExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} +class MySubset5 extends Character.Subset { + MySubset5(String name) { + super(name); + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5c4c937a2f96027e60d93a886f0e09bd6fb9b88c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0022-rt-parent-CharacterSubsetExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectwaitIllegalMonitorStateException) +run(CharacterSubsetExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/CharacterSubsetExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/CharacterSubsetExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..d6ce8927c9289cd9e6ff38a73f4a4f6b58d761b0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/CharacterSubsetExObjectwaitInterruptedException.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterSubsetExObjectwaitInterruptedException { + static int res = 99; + private static MySubset6 csb1 = new MySubset6("some subset"); + public static void main(String argv[]) { + System.out.println(new CharacterSubsetExObjectwaitInterruptedException().run()); + } + private class CharacterSubsetExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (csb1) { + csb1.notifyAll(); + try { + csb1.wait(); + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class CharacterSubsetExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (csb1) { + csb1.notifyAll(); + try { + csb1.wait(millis); + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class CharacterSubsetExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (csb1) { + csb1.notifyAll(); + try { + csb1.wait(millis, nanos); + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + CharacterSubsetExObjectwaitInterruptedException.res = CharacterSubsetExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * @param sleepNum wait time + */ + + public void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new CharacterSubsetExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new CharacterSubsetExObjectwaitInterruptedException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new CharacterSubsetExObjectwaitInterruptedException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && CharacterSubsetExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} +class MySubset6 extends Character.Subset { + MySubset6(String name) { + super(name); + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b02cac6c4812807729ed2f2629d9f0659c3aa53c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0023-rt-parent-CharacterSubsetExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterSubsetExObjectwaitInterruptedException) +run(CharacterSubsetExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/ClassExObjectHashcode.java b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/ClassExObjectHashcode.java new file mode 100755 index 0000000000000000000000000000000000000000..5444361ec2f2677124663fa35459b1c5e54ddf82 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/ClassExObjectHashcode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ClassExObjectHashcode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = classExObjectHashcode(); + } catch (Exception e) { + ClassExObjectHashcode.res = ClassExObjectHashcode.res - 10; + } + if (result == 4 && ClassExObjectHashcode.res == 89) { + result = 0; + } + return result; + } + private static int classExObjectHashcode() { + // int hashCode() + int result1 = 4; /*STATUS_FAILED*/ + Class cal = ClassExObjectHashcode.class.getClass(); + try { + int hashcode = cal.hashCode(); + ClassExObjectHashcode.res = ClassExObjectHashcode.res - 10; + } catch (IllegalArgumentException e1) { + ClassExObjectHashcode.res = ClassExObjectHashcode.res - 1; + } + return result1; + } +} diff --git a/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/expected.txt b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/test.cfg b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b37c5271e42158fa3592a3bbcae52bbd03b91e01 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0024-rt-parent-ClassExObjectHashcode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectHashcode) +run(ClassExObjectHashcode) diff --git a/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/ClassExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/ClassExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..f5c9dee6e4d41ecfd1f94a36e2f37fbdc3e440b2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/ClassExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private Class[] rp = ClassExObjectnotifyAllIllegalMonitorStateException.class.getClasses(); + public static void main(String argv[]) { + System.out.println(new ClassExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = classExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ClassExObjectnotifyAllIllegalMonitorStateException.res = ClassExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ClassExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ClassExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int classExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + rp.notifyAll(); + ClassExObjectnotifyAllIllegalMonitorStateException.res = ClassExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ClassExObjectnotifyAllIllegalMonitorStateException.res = ClassExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ClassExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ClassExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notifyAll(); + ClassExObjectnotifyAllIllegalMonitorStateException.res = ClassExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ClassExObjectnotifyAllIllegalMonitorStateException.res = ClassExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ce508d3da863f97bc0aba02a3366ef94bf63fb89 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0025-rt-parent-ClassExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectnotifyAllIllegalMonitorStateException) +run(ClassExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/ClassExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/ClassExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..b4aa09380eac1ebd1b24089f715ccd221144fedc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/ClassExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private Class[] rp = ClassExObjectnotifyIllegalMonitorStateException.class.getClasses(); + public static void main(String argv[]) { + System.out.println(new ClassExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = classExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ClassExObjectnotifyIllegalMonitorStateException.res = ClassExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ClassExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ClassExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int classExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp.notifyAll(); + ClassExObjectnotifyIllegalMonitorStateException.res = ClassExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ClassExObjectnotifyIllegalMonitorStateException.res = ClassExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ClassExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ClassExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notify(); + ClassExObjectnotifyIllegalMonitorStateException.res = ClassExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ClassExObjectnotifyIllegalMonitorStateException.res = ClassExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..539f6268d9e7acaa94d2b588122bcf3b64d8819d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0026-rt-parent-ClassExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectnotifyIllegalMonitorStateException) +run(ClassExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/ClassExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/ClassExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..794c3a942c71ecf1d63bd5e565046f0238d1a333 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/ClassExObjectwaitIllegalArgumentException.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassExObjectwaitIllegalArgumentException { + static int res = 99; + private Class[] clazz = ClassExObjectwaitIllegalArgumentException.class.getClasses(); + public static void main(String argv[]) { + System.out.println(new ClassExObjectwaitIllegalArgumentException().run()); + } + private class ClassExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (clazz) { + clazz.notifyAll(); + try { + clazz.wait(millis); + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ClassExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (clazz) { + clazz.notifyAll(); + try { + clazz.wait(millis, nanos); + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ClassExObjectwaitIllegalArgumentException.res = ClassExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ClassExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ClassExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ee38531447c62c19995094c82890cda18869fcf6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0027-rt-parent-ClassExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectwaitIllegalArgumentException) +run(ClassExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/ClassExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/ClassExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..f3d94d12ae3ff62c853fcd19aa390b4be4c15244 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/ClassExObjectwaitInterruptedException.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassExObjectwaitInterruptedException { + static int res = 99; + private static Class[] sampleField1 = null; + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + sampleField1 = ClassExObjectwaitInterruptedException.class.getClasses(); + System.out.println(new ClassExObjectwaitInterruptedException().run()); + } + private class ClassExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(); + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class ClassExObjectwaitInterruptedException12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis); + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class ClassExObjectwaitInterruptedException13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis, nanos); + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwaitInterruptedException.res = ClassExObjectwaitInterruptedException.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ClassExObjectwaitInterruptedException11()); + Thread t2 = new Thread(new ClassExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new ClassExObjectwaitInterruptedException12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassExObjectwaitInterruptedException13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ClassExObjectwaitInterruptedException.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9aa504bf1112d574adbf582ede175cec792ee6cf --- /dev/null +++ b/testsuite/java_test/parent_test/RT0028-rt-parent-ClassExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectwaitInterruptedException) +run(ClassExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/ClassExObjectwait.java b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/ClassExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..71517271dfe3c8110f9a8e6cb78e00eaabc23a2f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/ClassExObjectwait.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassExObjectwait { + static int res = 99; + private Class[] cal = ClassExObjectwait.class.getClasses(); + private Class[] cal2 = ClassExObjectwait.class.getClasses(); + private Class[] cal3 = ClassExObjectwait.class.getClasses(); + public static void main(String argv[]) { + System.out.println(new ClassExObjectwait().run()); + } + private class ClassExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ClassExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cal) { + cal.notifyAll(); + try { + cal.wait(); + ClassExObjectwait.res = ClassExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwait.res = ClassExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwait.res = ClassExObjectwait.res - 30; + } + } + } + } + private class ClassExObjectwait12 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ClassExObjectwait12(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cal2) { + cal2.notifyAll(); + try { + cal2.wait(millis); + ClassExObjectwait.res = ClassExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwait.res = ClassExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwait.res = ClassExObjectwait.res - 30; + } + } + } + } + private class ClassExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ClassExObjectwait13(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cal3) { + cal3.notifyAll(); + try { + cal3.wait(millis, nanos); + ClassExObjectwait.res = ClassExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassExObjectwait.res = ClassExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassExObjectwait.res = ClassExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ClassExObjectwait11(1)); + Thread t2 = new Thread(new ClassExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ClassExObjectwait12(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassExObjectwait13(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ClassExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..83f2eb22840fac6cf4d0b69f3e20fa536e85665b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0029-rt-parent-ClassExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassExObjectwait) +run(ClassExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/ClassLoaderExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/ClassLoaderExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..ef60a8cf1e26f7a9174cad8ef2b7550ddb44a7ce --- /dev/null +++ b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/ClassLoaderExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private ClassLoader rp = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.class.getClassLoader(); + public static void main(String argv[]) { + System.out.println(new ClassLoaderExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new MethodExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int methodExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // + // final void notifyAll() + try { + rp.notifyAll(); + ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class MethodExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notifyAll(); + ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res = ClassLoaderExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..934202fe51f15c459a19a7b661be505723f61b44 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0030-rt-parent-ClassLoaderExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectnotifyAllIllegalMonitorStateException) +run(ClassLoaderExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/ClassLoaderExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/ClassLoaderExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..d9e6b2ab3fd82ec25e408bdaf8758c2f6390f722 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/ClassLoaderExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private ClassLoader rp = ClassLoaderExObjectnotifyIllegalMonitorStateException.class.getClassLoader(); + public static void main(String argv[]) { + System.out.println(new ClassLoaderExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = classLoaderExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ClassLoaderExObjectnotifyIllegalMonitorStateException.res = ClassLoaderExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ClassLoaderExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ClassLoaderExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int classLoaderExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp.notify(); + ClassLoaderExObjectnotifyIllegalMonitorStateException.res = ClassLoaderExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectnotifyIllegalMonitorStateException.res = ClassLoaderExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ClassLoaderExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notify(); + ClassLoaderExObjectnotifyIllegalMonitorStateException.res = ClassLoaderExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectnotifyIllegalMonitorStateException.res = ClassLoaderExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..297b376f0fd3c6739df2940234b82de8036321f4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0031-rt-parent-ClassLoaderExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectnotifyIllegalMonitorStateException) +run(ClassLoaderExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/ClassLoaderExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/ClassLoaderExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..4b25e8b8d2b96ddfaa3072f90f5cc5813dd532af --- /dev/null +++ b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/ClassLoaderExObjectwaitIllegalArgumentException.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectwaitIllegalArgumentException { + static int res = 99; + private ClassLoader cl = ClassLoaderExObjectwaitIllegalArgumentException.class.getClassLoader(); + public static void main(String argv[]) { + System.out.println(new ClassLoaderExObjectwaitIllegalArgumentException().run()); + } + private class ClassLoaderExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (cl) { + cl.notifyAll(); + try { + cl.wait(millis); + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ClassLoaderExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cl) { + cl.notifyAll(); + try { + cl.wait(millis, nanos); + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ClassLoaderExObjectwaitIllegalArgumentException.res = ClassLoaderExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ClassLoaderExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassLoaderExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ClassLoaderExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..04da06ba55111a7a43e0cc389c5edf3af6d89677 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0032-rt-parent-ClassLoaderExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectwaitIllegalArgumentException) +run(ClassLoaderExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/ClassLoaderExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/ClassLoaderExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..76c6e817fd5585c396cfb6a414bae6ff770906fd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/ClassLoaderExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static ClassLoader cl = ClassLoaderExObjectwaitIllegalMonitorStateException.class.getClassLoader(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = classLoaderExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = classLoaderExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = classLoaderExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ClassLoaderExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int classLoaderExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + cl.wait(); + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int classLoaderExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + cl.wait(millis); + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int classLoaderExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + cl.wait(millis, nanos); + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitIllegalMonitorStateException.res = ClassLoaderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1a10815a3d395177af0c8e86aca973ce2f78682c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0033-rt-parent-ClassLoaderExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectwaitIllegalMonitorStateException) +run(ClassLoaderExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/ClassLoaderExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/ClassLoaderExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..29b11a3237fce927c1f79e11121a18a8682a8dea --- /dev/null +++ b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/ClassLoaderExObjectwaitInterruptedException.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectwaitInterruptedException { + static int res = 99; + private static ClassLoader sampleField1 = ClassLoaderExObjectwaitInterruptedException.class.getClassLoader(); + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + System.out.println(new ClassLoaderExObjectwaitInterruptedException().run()); + } + private class ClassLoaderExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(); + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class ClassLoaderExObjectwaitInterruptedException12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis); + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class ClassLoaderExObjectwaitInterruptedException13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis, nanos); + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwaitInterruptedException.res = ClassLoaderExObjectwaitInterruptedException.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ClassLoaderExObjectwaitInterruptedException11()); + Thread t2 = new Thread(new ClassLoaderExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new ClassLoaderExObjectwaitInterruptedException12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassLoaderExObjectwaitInterruptedException13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ClassLoaderExObjectwaitInterruptedException.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b8df1dd25e6da8590057971311fa5703a271bfe7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0034-rt-parent-ClassLoaderExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectwaitInterruptedException) +run(ClassLoaderExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/ClassLoaderExObjectwait.java b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/ClassLoaderExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..ab649421ae5e006e09e3011a471ffbff18c9fd3e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/ClassLoaderExObjectwait.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ClassLoaderExObjectwait { + static int res = 99; + private ClassLoader cal = ClassLoaderExObjectwait.class.getClassLoader(); + private ClassLoader cal2 = ClassLoaderExObjectwait.class.getClassLoader(); + private ClassLoader cal3 = ClassLoaderExObjectwait.class.getClassLoader(); + public static void main(String argv[]) { + System.out.println(new ClassLoaderExObjectwait().run()); + } + private class ClassLoaderExObjectwait11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (cal) { + cal.notifyAll(); + try { + cal.wait(); + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 30; + } + } + } + } + private class ClassLoaderExObjectwait12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal2) { + cal2.notifyAll(); + try { + cal2.wait(millis); + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 30; + } + } + } + } + private class ClassLoaderExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal3) { + cal3.notifyAll(); + try { + cal3.wait(millis, nanos); + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 10; + } catch (InterruptedException e1) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ClassLoaderExObjectwait.res = ClassLoaderExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ClassLoaderExObjectwait11()); + Thread t2 = new Thread(new ClassLoaderExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new ClassLoaderExObjectwait12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ClassLoaderExObjectwait13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ClassLoaderExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..acf302e0081637759a0eb0cf2059da5186bc025e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0035-rt-parent-ClassLoaderExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassLoaderExObjectwait) +run(ClassLoaderExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/ConstructorExAccessibleObjectgetAnnotationNullPointerException.java b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/ConstructorExAccessibleObjectgetAnnotationNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..feeb231ef3f955647fefb0bfcd3e0ad983040da0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/ConstructorExAccessibleObjectgetAnnotationNullPointerException.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.AccessibleObject; +import java.lang.Thread; +public class ConstructorExAccessibleObjectgetAnnotationNullPointerException { + static int res = 99; + static String eMsg; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExObjectgetAnnotationNullPointerExceptionTest1(); + constructorExObjectgetAnnotationNullPointerExceptionTest2(); + } catch (Exception e) { + ConstructorExAccessibleObjectgetAnnotationNullPointerException.res = ConstructorExAccessibleObjectgetAnnotationNullPointerException.res - 10; + } + if (result == 4 && ConstructorExAccessibleObjectgetAnnotationNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int constructorExObjectgetAnnotationNullPointerExceptionTest1() { + int result1 = 4; + try { + // T getAnnotation(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass9q.class.getConstructor(String.class); + // System.out.println(sampleconstructor.getClass()); + CustomAnnotations1 annotation = sampleconstructor.getAnnotation(CustomAnnotations1.class); + if (annotation.toString().equals("@CustomAnnotations1(name=sampleConstructor, value=Sample Constructor Annotation)")) { + ConstructorExAccessibleObjectgetAnnotationNullPointerException.res = ConstructorExAccessibleObjectgetAnnotationNullPointerException.res - 2; + } + } catch (NullPointerException e) { + eMsg = e.toString(); + } catch (NoSuchMethodException | SecurityException e1) { + eMsg = e1.toString(); + } + return result1; + } + private static int constructorExObjectgetAnnotationNullPointerExceptionTest2() { + int result1 = 4; + try { + // T getAnnotation(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass9q.class.getConstructor(String.class); + // System.out.println(sampleconstructor.getClass()); + sampleconstructor.getAnnotation(null); + // System.out.println(a.toString()); + } catch (NullPointerException e) { + ConstructorExAccessibleObjectgetAnnotationNullPointerException.res = ConstructorExAccessibleObjectgetAnnotationNullPointerException.res - 2; + } catch (NoSuchMethodException | SecurityException e1) { + eMsg = e1.toString(); + } + return result1; + } +} +@CustomAnnotations1(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass9q { + private String sampleField; + @CustomAnnotations1(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass9q(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations1 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8855bd1f0de08f62594a33f349de420471e93adf --- /dev/null +++ b/testsuite/java_test/parent_test/RT0036-rt-parent-ConstructorExAccessibleObjectgetAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetAnnotationNullPointerException) +run(ConstructorExAccessibleObjectgetAnnotationNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..2722d639f91b11834bdd5c656959f70cc1778507 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerExceptionTest_1(); + ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerExceptionTest_2(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerExceptionTest_1() { + int result = 4; + try { + // T[] getAnnotationsByType(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass2.class.getConstructor(String.class); + CustomAnnotations2[] a = sampleconstructor.getAnnotationsByType(CustomAnnotations2.class); + //System.out.println(a.toString()); + //System.out.println(a[0].toString()); + if (a.length == 1 && a.getClass().toString().equals("class [LCustomAnnotations2;")) { + ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 2; + } + } catch (NullPointerException | SecurityException | NoSuchMethodException e ) { + e.printStackTrace(); + } + return result; + } + private static int ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerExceptionTest_2() { + int result = 4; + try { + // T[] getAnnotationsByType(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass2.class.getConstructor(String.class); + sampleconstructor.getAnnotationsByType(null); + //System.out.println(a.toString()); + //System.out.println(a[0].toString()); + } catch (SecurityException | NoSuchMethodException e) { + //e.printStackTrace(); + } catch (NullPointerException e) { + //e.printStackTrace(); + ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 2; + } + return result; + } +} +@CustomAnnotations2(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass2 { + private String sampleField; + @CustomAnnotations2(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass2(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations2 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9e45b00b6759e1e0211cc8dc6492b3293e9a96ed --- /dev/null +++ b/testsuite/java_test/parent_test/RT0037-rt-parent-ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException) +run(ConstructorExAccessibleObjectgetAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/ConstructorExAccessibleObjectgetAnnotations.java b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/ConstructorExAccessibleObjectgetAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..64f5f61718eeede5735cb5119c59b98c51f2add2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/ConstructorExAccessibleObjectgetAnnotations.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectgetAnnotations { + static int res = 99; + static String eMsg; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExObjectgetAnnotationsTest1(); + } catch (Exception e) { + eMsg = e.toString(); + } + if (result == 4 && ConstructorExAccessibleObjectgetAnnotations.res == 97) { + result = 0; + } + return result; + } + private static int constructorExObjectgetAnnotationsTest1() { + int result1 = 4; + try { + // Annotation[] getAnnotations() + AccessibleObject sampleconstructor = SampleClass0.class.getConstructor(String.class); + Annotation[] annotations = sampleconstructor.getAnnotations(); + if (annotations.length == 1 && annotations.getClass().toString().equals("class [Ljava.lang.annotation.Annotation;")) { + ConstructorExAccessibleObjectgetAnnotations.res = ConstructorExAccessibleObjectgetAnnotations.res - 2; + } + } catch (NoSuchMethodException | SecurityException e1) { + eMsg = e1.toString(); + } + return result1; + } +} +@CustomAnnotations0(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass0 { + private String sampleField; + @CustomAnnotations0(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass0(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations0 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7cab0033acd155a8af33353241c6ed4d272ab35d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0038-rt-parent-ConstructorExAccessibleObjectgetAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetAnnotations) +run(ConstructorExAccessibleObjectgetAnnotations) diff --git a/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.java b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..6bc75eef51ac7041745712337c1647b38a727aa2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = ConstructorExAccessiblegetDeclaredAnnotationNullPointerExceptionTest_1(); + ConstructorExAccessiblegetDeclaredAnnotationNullPointerExceptionTest_2(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int ConstructorExAccessiblegetDeclaredAnnotationNullPointerExceptionTest_2() { + int result1 = 4; + try { + AccessibleObject sampleconstructor = SampleClass3.class.getConstructor(String.class); + sampleconstructor.getDeclaredAnnotation(null); + //System.out.println(a.toString()); + } catch (NullPointerException e) { + //e.printStackTrace(); + ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 2; + } catch (NoSuchMethodException | SecurityException e) { + //e.printStackTrace(); + } + return result1; + } + private static int ConstructorExAccessiblegetDeclaredAnnotationNullPointerExceptionTest_1() { + int result1 = 4; + try { + //T getDeclaredAnnotation(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass3.class.getConstructor(String.class); + CustomAnnotations3 a = sampleconstructor.getDeclaredAnnotation(CustomAnnotations3.class); + //System.out.println(a.toString()); + if (a.toString().equals("@CustomAnnotations3(name=sampleConstructor, value=Sample Constructor Annotation)")) { + ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 2; + } + } catch (NullPointerException | NoSuchMethodException | SecurityException e) { + //e.printStackTrace(); + } + return result1; + } +} +@CustomAnnotations3(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass3 { + private String sampleField; + @CustomAnnotations3(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass3(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations3 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..41f0a85151b9b45176873bdbfd0a364aa37ee765 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0039-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException) +run(ConstructorExAccessibleObjectgetDeclaredAnnotationNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..bbb8ac7e55278ed14cc1234a4e4290b6bbb974a3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerExceptionTest_1(); + ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerExceptionTest_2(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerExceptionTest_1() { + int result1 = 4; + AccessibleObject sampleconstructor; + try { + sampleconstructor = SampleClass5.class.getConstructor(String.class); + CustomAnnotations5[] a = sampleconstructor.getDeclaredAnnotationsByType(CustomAnnotations5.class); + //System.out.println(a.getClass()); + if (a.length == 1 && a.getClass().toString().equals("class [LCustomAnnotations5;")) { + ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 2; + } + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + e.printStackTrace(); + } + return result1; + } + private static int ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerExceptionTest_2() { + int result1 = 4; + AccessibleObject sampleconstructor; + try { + sampleconstructor = SampleClass5.class.getConstructor(String.class); + sampleconstructor.getDeclaredAnnotationsByType(null); + //System.out.println(a.getClass()); + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + //e.printStackTrace(); + ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 2; + } + return result1; + } +} +@CustomAnnotations5(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass5 { + private String sampleField; + @CustomAnnotations5(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass5(String s) { + this.sampleField = s; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations5 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7b214e9244decceffdd6dc5b8eacc29d296f9d95 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0040-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) +run(ConstructorExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/ConstructorExAccessibleObjectgetDeclaredAnnotations.java b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/ConstructorExAccessibleObjectgetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..698240d33a2d55f83a427414f980c8cda7b4f28f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/ConstructorExAccessibleObjectgetDeclaredAnnotations.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectgetDeclaredAnnotations { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExAccessiblegetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExAccessibleObjectgetDeclaredAnnotations.res == 97) { + result = 0; + } + return result; + } + private static int constructorExAccessiblegetDeclaredAnnotations1() { + int result1 = 4; + try { + // T getDeclaredAnnotation(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass4.class.getConstructor(String.class); + // System.out.println(sampleconstructor.getClass()); + Annotation[] annotations = sampleconstructor.getDeclaredAnnotations(); + if (annotations.length == 1 && annotations.getClass().toString().equals("class [Ljava.lang.annotation.Annotation;")) { + ConstructorExAccessibleObjectgetDeclaredAnnotations.res = ConstructorExAccessibleObjectgetDeclaredAnnotations.res - 2; + } + } catch (NoSuchMethodException | SecurityException e1) { + e1.printStackTrace(); + } + return result1; + } +} +@CustomAnnotations4(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass4 { + private String sampleField; + @CustomAnnotations4(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass4(String str) { + this.sampleField = str; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations4 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d93c7a7f5eba5f77be2c4d7513984a986e4545bf --- /dev/null +++ b/testsuite/java_test/parent_test/RT0041-rt-parent-ConstructorExAccessibleObjectgetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectgetDeclaredAnnotations) +run(ConstructorExAccessibleObjectgetDeclaredAnnotations) diff --git a/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/ConstructorExAccessibleObjectisAccessible.java b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/ConstructorExAccessibleObjectisAccessible.java new file mode 100755 index 0000000000000000000000000000000000000000..729cd076acc66a726f75c8c45d40a111825ecf73 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/ConstructorExAccessibleObjectisAccessible.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectisAccessible { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExAccessibleObjectisAccessibleTest(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExAccessibleObjectisAccessible.res == 97) { + result = 0; + } + return result; + } + private static int constructorExAccessibleObjectisAccessibleTest() { + int result = 4; + try { + // boolean isAccessible() + AccessibleObject sampleconstructor = SampleClass6.class.getConstructor(String.class); + boolean value = sampleconstructor.isAccessible(); + // System.out.println(a); + if (!value) { + ConstructorExAccessibleObjectisAccessible.res = ConstructorExAccessibleObjectisAccessible.res - 2; + } + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + String eMsg = e.toString(); + } + return result; + } +} +@CustomAnnotations6(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass6 { + private String sampleField; + @CustomAnnotations6(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass6(String str) { + this.sampleField = str; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations6 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/expected.txt b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/test.cfg b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..acccf06ae033ab2e2cbd16079ec40785922834f3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0042-rt-parent-ConstructorExAccessibleObjectisAccessible/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectisAccessible) +run(ConstructorExAccessibleObjectisAccessible) diff --git a/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.java b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..01b30d28e2af222ba9579efb52117abc8dd411a8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectisAnnotationPresentNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + result = ConstructorExAccessibleObjectisAnnotationPresentNullPointerExceptionTest_1(); + ConstructorExAccessibleObjectisAnnotationPresentNullPointerExceptionTest_2(); + if (result == 4 && ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int ConstructorExAccessibleObjectisAnnotationPresentNullPointerExceptionTest_1() { + int result1 = 4; + try { + // boolean isAnnotationPresent(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass7.class.getConstructor(String.class); + boolean b = sampleconstructor.isAnnotationPresent(CustomAnnotations7.class); + //System.out.println(b); + if (b) { + ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.res = ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.res - 2; + } + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + e.printStackTrace(); + } + return result1; + } + private static int ConstructorExAccessibleObjectisAnnotationPresentNullPointerExceptionTest_2() { + int result1 = 4; + try { + // boolean isAnnotationPresent(Class annotationClass) + AccessibleObject sampleconstructor = SampleClass7.class.getConstructor(String.class); + sampleconstructor.isAnnotationPresent(null); + //System.out.println(b); + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.res = ConstructorExAccessibleObjectisAnnotationPresentNullPointerException.res - 2; + } + return result1; + } +} +@CustomAnnotations7(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass7 { + private String sampleField; + @CustomAnnotations7(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass7(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations7 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a2f111e04eaa8a3fe666a02652e4340eaf47e0d3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0043-rt-parent-ConstructorExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectisAnnotationPresentNullPointerException) +run(ConstructorExAccessibleObjectisAnnotationPresentNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/ConstructorExAccessibleObjectsetAccessibleSecurityException.java b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/ConstructorExAccessibleObjectsetAccessibleSecurityException.java new file mode 100755 index 0000000000000000000000000000000000000000..8b761712c6eae8cfc7943df7072f16e2ed3bdfbe --- /dev/null +++ b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/ConstructorExAccessibleObjectsetAccessibleSecurityException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +public class ConstructorExAccessibleObjectsetAccessibleSecurityException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + result = constructorExAccessibleObjectsetAccessibleSecurityExceptionTest(); + constructorExAccessibleObjectsetAccessibleSecurityExceptionTest2(); + if (result == 4 && ConstructorExAccessibleObjectsetAccessibleSecurityException.res == 95) { + result = 0; + } + return result; + } + private static int constructorExAccessibleObjectsetAccessibleSecurityExceptionTest() { + int result1 = 4; + try { + // void setAccessible(boolean flag) + AccessibleObject sampleconstructor = SampleClass8.class.getConstructor(String.class); + sampleconstructor.setAccessible(true); + boolean value = sampleconstructor.isAccessible(); + if (value) { + // System.out.println(b); + ConstructorExAccessibleObjectsetAccessibleSecurityException.res = ConstructorExAccessibleObjectsetAccessibleSecurityException.res - 2; + } + } catch (NoSuchMethodException | SecurityException e) { + String eMsg = e.toString(); + } + return result1; + } + private static void constructorExAccessibleObjectsetAccessibleSecurityExceptionTest2() { + try { + // static void setAccessible(AccessibleObject[] array, boolean flag) + AccessibleObject[] sampleconstructorlist = SampleClass8.class.getConstructors(); + AccessibleObject.setAccessible(sampleconstructorlist, true); + boolean value = sampleconstructorlist[0].isAccessible(); + if (value) { + ConstructorExAccessibleObjectsetAccessibleSecurityException.res = ConstructorExAccessibleObjectsetAccessibleSecurityException.res - 2; + } + } catch (SecurityException e) { + String eMsg = e.toString(); + } + } +} +@CustomAnnotations8(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass8 { + private String sampleField; + @CustomAnnotations8(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass8(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations8 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/expected.txt b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/test.cfg b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a5946d7d69b2bcfd35abb9ef95b945aa34c9113d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0044-rt-parent-ConstructorExAccessibleObjectsetAccessibleSecurityException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExAccessibleObjectsetAccessibleSecurityException) +run(ConstructorExAccessibleObjectsetAccessibleSecurityException) diff --git a/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/ConstructorExExecutablegetAnnotationNullPointerException.java b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/ConstructorExExecutablegetAnnotationNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..e42363f44ac7a91fbbda22afa153a38c34db8104 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/ConstructorExExecutablegetAnnotationNullPointerException.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Executable; +public class ConstructorExExecutablegetAnnotationNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExExecutablegetAnnotationNullPointerExceptionTest1(); + constructorExExecutablegetAnnotationNullPointerExceptionTest2(); + } catch (Exception e) { + ConstructorExExecutablegetAnnotationNullPointerException.res = ConstructorExExecutablegetAnnotationNullPointerException.res - 10; + } + if (result == 4 && ConstructorExExecutablegetAnnotationNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int constructorExExecutablegetAnnotationNullPointerExceptionTest1() { + int result1 = 4; + try { + // T getAnnotation(Class annotationClass) + Executable sampleexecutable = SampleClass9.class.getConstructor(String.class); + CustomAnnotations9 annotation = sampleexecutable.getAnnotation(CustomAnnotations9.class); + if (annotation.toString().equals("@CustomAnnotations9(name=sampleConstructor, value=Sample Constructor Annotation)")) { + ConstructorExExecutablegetAnnotationNullPointerException.res = ConstructorExExecutablegetAnnotationNullPointerException.res - 2; + } + } catch (NullPointerException | NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return result1; + } + private static int constructorExExecutablegetAnnotationNullPointerExceptionTest2() { + int result1 = 4; + try { + // T getAnnotation(Class annotationClass) + Executable sampleexecutable = SampleClass9.class.getConstructor(String.class); + sampleexecutable.getAnnotation(null); + } catch (NullPointerException e) { + ConstructorExExecutablegetAnnotationNullPointerException.res = ConstructorExExecutablegetAnnotationNullPointerException.res - 2; + } catch (NoSuchMethodException | SecurityException e1) { + String eMsg = e1.toString(); + } + return result1; + } +} +@CustomAnnotations9(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass9 { + private String sampleField; + @CustomAnnotations9(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass9(String str) { + this.sampleField = str; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations9 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5399f237b32aa2014d71609e467456709d447b47 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0045-rt-parent-ConstructorExExecutablegetAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExExecutablegetAnnotationNullPointerException) +run(ConstructorExExecutablegetAnnotationNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/ConstructorExExecutablegetAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/ConstructorExExecutablegetAnnotationsByTypeNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..503add506271f81f1af3cdd9af1ac28ec62fc4f4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/ConstructorExExecutablegetAnnotationsByTypeNullPointerException.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Executable; +public class ConstructorExExecutablegetAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExExecutablegetAnnotationsByTypeNPExceptionTest1(); + constructorExExecutablegetAnnotationsByTypeNPExceptionTest1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExExecutablegetAnnotationsByTypeNullPointerException.res == 95) { + result = 0; + } + return result; + } + private static int constructorExExecutablegetAnnotationsByTypeNPExceptionTest1() { + int result1 = 4; + Executable sampleExecutable; + try { + // T[] getAnnotationsByType(Class annotationClass) + sampleExecutable = SampleClass10.class.getConstructor(String.class); + CustomAnnotations10[] annotations10s = sampleExecutable.getDeclaredAnnotationsByType(CustomAnnotations10.class); + // System.out.println(a.getClass()); + if (annotations10s.length == 1 && annotations10s.getClass().toString().equals("class [LCustomAnnotations10;")) { + ConstructorExExecutablegetAnnotationsByTypeNullPointerException.res = ConstructorExExecutablegetAnnotationsByTypeNullPointerException.res - 2; + } + } catch (NoSuchMethodException | SecurityException | NullPointerException e) { + e.printStackTrace(); + } + return result1; + } +} +@CustomAnnotations10(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass10 { + private String sampleField; + @CustomAnnotations10(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass10(String str) { + this.sampleField = str; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations10 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..59a61ef348fafc6a160d3486bb316568f87212bf --- /dev/null +++ b/testsuite/java_test/parent_test/RT0046-rt-parent-ConstructorExExecutablegetAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExExecutablegetAnnotationsByTypeNullPointerException) +run(ConstructorExExecutablegetAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/ConstructorExExecutablegetDeclaredAnnotations.java b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/ConstructorExExecutablegetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..8afe8aad4606090699fcc99998df60c3048ff410 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/ConstructorExExecutablegetDeclaredAnnotations.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Executable; +public class ConstructorExExecutablegetDeclaredAnnotations { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExExecutablegetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExExecutablegetDeclaredAnnotations.res == 97) { + result = 0; + } + return result; + } + private static int constructorExExecutablegetDeclaredAnnotations1() { + int result1 = 4; + try { + Executable sampleExecutable = SampleClass11.class.getConstructor(String.class); + Annotation[] annotations = sampleExecutable.getDeclaredAnnotations(); + if (annotations.length == 1 && annotations.getClass().toString().equals("class [Ljava.lang.annotation.Annotation;")) { + ConstructorExExecutablegetDeclaredAnnotations.res = ConstructorExExecutablegetDeclaredAnnotations.res - 2; + } + } catch (NoSuchMethodException | SecurityException e1) { + e1.printStackTrace(); + } + return result1; + } +} +@CustomAnnotations11(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass11 { + private String sampleField; + @CustomAnnotations11(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass11(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations11 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..15dc6e0c368b825bc5bc2d52d59efe5162bde4cd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0047-rt-parent-ConstructorExExecutablegetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExExecutablegetDeclaredAnnotations) +run(ConstructorExExecutablegetDeclaredAnnotations) diff --git a/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/ConstructorExExecutablegetExceptionTypes.java b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/ConstructorExExecutablegetExceptionTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..bc9fcd38e7063488622808ac56ba09c6ca06f522 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/ConstructorExExecutablegetExceptionTypes.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Executable; +public class ConstructorExExecutablegetExceptionTypes { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExExecutablegetExceptionTypes1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExExecutablegetExceptionTypes.res == 97) { + result = 0; + } + return result; + } + private static int constructorExExecutablegetExceptionTypes1() { + int result1 = 4; + try { + // abstract Class[] getExceptionTypes() + Executable sampleExecutable = SampleClass12.class.getConstructor(String.class); + Class[] vlClass = sampleExecutable.getExceptionTypes(); + if (vlClass.length == 0 && vlClass.getClass().toString().equals("class [Ljava.lang.Class;")) { + ConstructorExExecutablegetExceptionTypes.res = ConstructorExExecutablegetExceptionTypes.res - 2; + } + } catch (NoSuchMethodException | SecurityException e1) { + String eMsg = e1.toString(); + } + return result1; + } +} +@CustomAnnotations12(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass12 { + private String sampleField; + @CustomAnnotations12(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass12(String str) { + this.sampleField = str; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations12 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/expected.txt b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/test.cfg b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9220b53b0af2e0fa38184ece20090d31966b7fec --- /dev/null +++ b/testsuite/java_test/parent_test/RT0048-rt-parent-ConstructorExExecutablegetExceptionTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExExecutablegetExceptionTypes) +run(ConstructorExExecutablegetExceptionTypes) diff --git a/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/ConstructorExExecutablegetGenericParameterTypes.java b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/ConstructorExExecutablegetGenericParameterTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..8c074f363c307a3cd6d1b70fc89e879b2fe9dda7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/ConstructorExExecutablegetGenericParameterTypes.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Executable; +public class ConstructorExExecutablegetGenericParameterTypes { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + static int run() { + int result = 2; + try { + result = constructorExExecutablegetGenericParameterTypes1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExExecutablegetGenericParameterTypes.res == 97) { + result = 0; + } + return result; + } + private static int constructorExExecutablegetGenericParameterTypes1() { + int result1 = 4; + try { + // Type[] getGenericParameterTypes() + Executable sampleExecutable = SampleClass13.class.getConstructor(String.class); + Class[] classes = sampleExecutable.getParameterTypes(); + if (classes.length == 1 && classes.getClass().toString().equals("class [Ljava.lang.Class;")) { + ConstructorExExecutablegetGenericParameterTypes.res = ConstructorExExecutablegetGenericParameterTypes.res - 2; + } + } catch (NoSuchMethodException | SecurityException e1) { + String eMsg = e1.toString(); + } + return result1; + } +} +@CustomAnnotations13(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass13 { + private String sampleField; + @CustomAnnotations13(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass13(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations13 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/expected.txt b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/test.cfg b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c9ac2100b268eed9ce3b091f8274e434cfb4a8f1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0049-rt-parent-ConstructorExExecutablegetGenericParameterTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExExecutablegetGenericParameterTypes) +run(ConstructorExExecutablegetGenericParameterTypes) diff --git a/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/ConstructorExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/ConstructorExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..801326d44915ff61c355705bf9222e801257b6ca --- /dev/null +++ b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/ConstructorExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +public class ConstructorExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private static Constructor con = null; + public static void main(String argv[]) throws NoSuchMethodException, SecurityException { + con = SampleClass14.class.getConstructor(String.class); + System.out.println(new ConstructorExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; + try { + result = constructorExObjectnotifyAllIllegalMonitorStateExceptionTest1(); + } catch (Exception e) { + ConstructorExObjectnotifyAllIllegalMonitorStateException.res = ConstructorExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ConstructorExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExObjectnotifyAllIllegalMonitorStateException.res == 57) { + result = 0; + } + return result; + } + private int constructorExObjectnotifyAllIllegalMonitorStateExceptionTest1() { + int result1 = 4; + try { + con.notifyAll(); + ConstructorExObjectnotifyAllIllegalMonitorStateException.res = ConstructorExObjectnotifyAllIllegalMonitorStateException.res - 50; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectnotifyAllIllegalMonitorStateException.res = ConstructorExObjectnotifyAllIllegalMonitorStateException.res - 2; + } + return result1; + } + private class ConstructorExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + private int remainder; + // final void notifyAll() + private ConstructorExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + try { + con.notifyAll(); + ConstructorExObjectnotifyAllIllegalMonitorStateException.res = ConstructorExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectnotifyAllIllegalMonitorStateException.res = ConstructorExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} +@CustomAnnotations14(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass14 { + private String sampleField; + @CustomAnnotations14(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass14(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations14 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e4c2c44e6666318aaec54502f484cc08f40c5cd4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0050-rt-parent-ConstructorExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectnotifyAllIllegalMonitorStateException) +run(ConstructorExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/ConstructorExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/ConstructorExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..662854519b90cf1928b80c31dfc30239f3cd58d5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/ConstructorExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +public class ConstructorExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private static Constructor con = null; + public static void main(String argv[]) throws NoSuchMethodException, SecurityException { + con = SampleClass15.class.getConstructor(String.class); + System.out.println(new ConstructorExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; + try { + result = constructorExObjectnotifyIllegalMonitorStateExceptionTest1(); + } catch (Exception e) { + ConstructorExObjectnotifyIllegalMonitorStateException.res = ConstructorExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ConstructorExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ConstructorExObjectnotifyIllegalMonitorStateException.res == 57) { + result = 0; + } + return result; + } + private int constructorExObjectnotifyIllegalMonitorStateExceptionTest1() { + int result1 = 4; + try { + con.notify(); + ConstructorExObjectnotifyIllegalMonitorStateException.res = ConstructorExObjectnotifyIllegalMonitorStateException.res - 50; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectnotifyIllegalMonitorStateException.res = ConstructorExObjectnotifyIllegalMonitorStateException.res - 2; + } + return result1; + } + private class ConstructorExObjectnotifyIllegalMonitorStateException11 implements Runnable { + private int remainder; + // final void notify() + private ConstructorExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + try { + con.notify(); + ConstructorExObjectnotifyIllegalMonitorStateException.res = ConstructorExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectnotifyIllegalMonitorStateException.res = ConstructorExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} +@CustomAnnotations15(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass15 { + private String sampleField; + @CustomAnnotations15(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass15(String s) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations15 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..73959a5eaf03e7283e2b241dd99b9f7a4377428e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0051-rt-parent-ConstructorExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectnotifyIllegalMonitorStateException) +run(ConstructorExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/ConstructorExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/ConstructorExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..036fecaf0bb1e92f8dff3bfe49768c83dde2c5df --- /dev/null +++ b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/ConstructorExObjectwaitIllegalArgumentException.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +public class ConstructorExObjectwaitIllegalArgumentException { + static int res = 99; + private static Constructor con = null; + public static void main(String argv[]) throws SecurityException, NoSuchMethodException { + con = SampleClass16.class.getConstructor(String.class); + System.out.println(new ConstructorExObjectwaitIllegalArgumentException().run()); + } + private class ConstructorExObjectwaitIllegalArgumentException11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(); + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 10; + } + } + } + } + private class ConstructorExObjectwaitIllegalArgumentException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(millis); + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ConstructorExObjectwaitIllegalArgumentException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(millis, nanos); + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ConstructorExObjectwaitIllegalArgumentException.res = ConstructorExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ConstructorExObjectwaitIllegalArgumentException11()); + // final void wait(long millis) + Thread t3 = new Thread(new ConstructorExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ConstructorExObjectwaitIllegalArgumentException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && ConstructorExObjectwaitIllegalArgumentException.res == 96) { + result = 0; + } + return result; + } +} +@CustomAnnotations16(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass16 { + private String sampleField; + @CustomAnnotations16(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass16(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations16 { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8d4246f65cc04bb019259be80644ac86cc0689cc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0052-rt-parent-ConstructorExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectwaitIllegalArgumentException) +run(ConstructorExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/ConstructorExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/ConstructorExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..efdac0f8778e6ec5e7505a0b951a72368d2c5ed1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/ConstructorExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +public class ConstructorExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static Constructor con = null; + public static void main(String argv[]) throws SecurityException, NoSuchMethodException { + con = SampleClass17.class.getConstructor(String.class); + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = constructorExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = constructorExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = constructorExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ConstructorExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int constructorExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + con.wait(); + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int constructorExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + con.wait(millis); + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int constructorExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + con.wait(millis, nanos); + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitIllegalMonitorStateException.res = ConstructorExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} +@CustomAnnotations17(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass17 { + private String sampleField; + @CustomAnnotations17(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass17(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations17 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d6914c12d9211af6af4b6db60c6dadd772344f22 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0053-rt-parent-ConstructorExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectwaitIllegalMonitorStateException) +run(ConstructorExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/ConstructorExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/ConstructorExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..62477ef7d3f5ec1989272f96b9f76679a28f49b8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/ConstructorExObjectwaitInterruptedException.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Constructor; +public class ConstructorExObjectwaitInterruptedException { + static int res = 99; + private static Constructor con = null; + public static void main(String argv[]) throws NoSuchMethodException, SecurityException { + con = SampleClass18.class.getConstructor(String.class); + System.out.println(new ConstructorExObjectwaitInterruptedException().run()); + } + private class ConstructorExObjectwaitInterruptedException11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(); + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ConstructorExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(millis); + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ConstructorExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (con) { + con.notifyAll(); + try { + con.wait(millis, nanos); + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ConstructorExObjectwaitInterruptedException.res = ConstructorExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ConstructorExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new ConstructorExObjectwaitInterruptedException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ConstructorExObjectwaitInterruptedException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && ConstructorExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} +@CustomAnnotations18(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass18 { + private String sampleField; + @CustomAnnotations18(name = "sampleConstructor", value = "Sample Constructor Annotation") + public SampleClass18(String str) { + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +@interface CustomAnnotations18 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c24d9beca472b25bd747d448ad7d2b51a14301a0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0054-rt-parent-ConstructorExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectwaitInterruptedException) +run(ConstructorExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/ConstructorExObjectwait.java b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/ConstructorExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..b3d2a768294d8fe8289b04779eda96f57c41a168 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/ConstructorExObjectwait.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +public class ConstructorExObjectwait { + static int res = 99; + private Constructor[] con1 = ConstructorExObjectwait.class.getConstructors(); + private Constructor[] con2 = ConstructorExObjectwait.class.getConstructors(); + private Constructor[] con3 = ConstructorExObjectwait.class.getConstructors(); + public static void main(String argv[]) { + System.out.println(new ConstructorExObjectwait().run()); + } + private class ConstructorExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (con1) { + con1.notifyAll(); + try { + con1.wait(); + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 30; + } + } + } + } + private class ConstructorExObjectwait12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (con2) { + con2.notifyAll(); + try { + con2.wait(millis); + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private class ConstructorExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (con3) { + con3.notifyAll(); + try { + con3.wait(millis, nanos); + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 10; + } catch (InterruptedException e1) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ConstructorExObjectwait.res = ConstructorExObjectwait.res - 30; + } + } + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ConstructorExObjectwait11()); + Thread t2 = new Thread(new ConstructorExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new ConstructorExObjectwait12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ConstructorExObjectwait13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + t2.interrupt(); + t2.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ConstructorExObjectwait.res == 68) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c8795d1162135de7b599764a7efe0deee9beca5b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0055-rt-parent-ConstructorExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorExObjectwait) +run(ConstructorExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..c27de3abfa306c4940e6b89fca79f726c05ac1ba --- /dev/null +++ b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.java @@ -0,0 +1,96 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Target; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Retention; +import java.lang.annotation.Repeatable; +import java.lang.annotation.ElementType; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectgetAnnotationsByTypeNullPointerException1(); + } catch (Exception e) { + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 20; + } + try { + result = fieldExAccessibleObjectgetAnnotationsByTypeNullPointerException2(); + } catch (Exception e) { + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 20; + } + if (result == 4 && FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectgetAnnotationsByTypeNullPointerException1() throws NoSuchFieldException, SecurityException { + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Field field = SampleClassField2.class.getDeclaredField("id"); + try { + CustomAnnotation2[] tp = field.getAnnotationsByType(CustomAnnotation2.class); + if (tp[0].toString().equals("@CustomAnnotation2(value=id)")) { + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 10; + } else { + System.out.println("Failed not as expect"); + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 15; + } + } catch (NullPointerException e) { + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } + private int fieldExAccessibleObjectgetAnnotationsByTypeNullPointerException2() throws NoSuchFieldException, SecurityException { + // NullPointerException - if the given annotation class is null + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Field field = SampleClassField2.class.getDeclaredField("id"); + try { + CustomAnnotation2[] tp = field.getAnnotationsByType(null); + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 10; + } catch (NullPointerException e) { + FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } +} +@CustomAnnotation2(value = "class") +class SampleClassField2 { + @CustomAnnotation2(value = "id") + String id; + String name; +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Repeatable(CustomAnnotation3.class) +@interface CustomAnnotation2 { + String value(); +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotation3 { + CustomAnnotation2[] value(); +} diff --git a/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..92f43297a66cd5f968a98bf0a5a895cb5f99d7b7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0056-rt-parent-FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException) +run(FieldExAccessibleObjectgetAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/FieldExAccessibleObjectgetAnnotations.java b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/FieldExAccessibleObjectgetAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..24aebd376eb668dd30f6af3d1a8365e7d6642f4a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/FieldExAccessibleObjectgetAnnotations.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.Annotation; +import java.lang.annotation.ElementType; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectgetAnnotations { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new FieldExAccessibleObjectgetAnnotations().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectgetAnnotations(); + } catch (Exception e) { + FieldExAccessibleObjectgetAnnotations.res = FieldExAccessibleObjectgetAnnotations.res - 20; + } + if (result == 4 && FieldExAccessibleObjectgetAnnotations.res == 89) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectgetAnnotations() throws NoSuchFieldException, SecurityException { + // Annotation[] getAnnotations() + int result1 = 4; /*STATUS_FAILED*/ + Field field = SampleClassField4.class.getDeclaredField("id"); + try { + Annotation[] tp = field.getAnnotations(); + if (tp[0].toString().equals("@FieldAnnotations(name=id, value=1)")) { + FieldExAccessibleObjectgetAnnotations.res = FieldExAccessibleObjectgetAnnotations.res - 10; + } else { + System.out.println("Failed not as expect"); + FieldExAccessibleObjectgetAnnotations.res = FieldExAccessibleObjectgetAnnotations.res - 15; + } + } catch (NullPointerException e) { + FieldExAccessibleObjectgetAnnotations.res = FieldExAccessibleObjectgetAnnotations.res - 15; + } + return result1; + } +} +class SampleClassField4 { + @FieldAnnotations(name = "id", value = "1") + String id; + String name; +} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@interface FieldAnnotations { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9ac5d7b03936318b2c46b25af85a9ab468851208 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0057-rt-parent-FieldExAccessibleObjectgetAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectgetAnnotations) +run(FieldExAccessibleObjectgetAnnotations) diff --git a/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/FieldExAccessibleObjectgetDeclaredAnnotation.java b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/FieldExAccessibleObjectgetDeclaredAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..ca9af2ff8529650e95e7f5933251a4368a85224a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/FieldExAccessibleObjectgetDeclaredAnnotation.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Repeatable; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectgetDeclaredAnnotation { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new FieldExAccessibleObjectgetDeclaredAnnotation().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectgetDeclaredAnnotation1(); + } catch (Exception e) { + FieldExAccessibleObjectgetDeclaredAnnotation.res = FieldExAccessibleObjectgetDeclaredAnnotation.res - 20; + } + if (result == 4 && FieldExAccessibleObjectgetDeclaredAnnotation.res == 89) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectgetDeclaredAnnotation1() throws NoSuchFieldException, SecurityException { + // T getDeclaredAnnotation(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Field field = SampleClassField3.class.getDeclaredField("id"); + try { + CustomAnnotation4 tp = field.getDeclaredAnnotation(CustomAnnotation4.class); + if (tp.toString().equals("@CustomAnnotation4(value=id)")) { + FieldExAccessibleObjectgetDeclaredAnnotation.res = FieldExAccessibleObjectgetDeclaredAnnotation.res - 10; + } else { + System.out.println("Failed not as expect"); + FieldExAccessibleObjectgetDeclaredAnnotation.res = FieldExAccessibleObjectgetDeclaredAnnotation.res - 15; + } + } catch (NullPointerException e) { + FieldExAccessibleObjectgetDeclaredAnnotation.res = FieldExAccessibleObjectgetDeclaredAnnotation.res - 15; + } + return result1; + } +} +@CustomAnnotation4(value = "class") +class SampleClassField3 { + @CustomAnnotation4(value = "id") + String id; + String name; +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Repeatable(CustomAnnotation5.class) +@interface CustomAnnotation4 { + String value(); +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotation5 { + CustomAnnotation4[] value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/expected.txt b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/test.cfg b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d7b8350dbd0e15fb467b25cf61d731ed38b57d28 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0058-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectgetDeclaredAnnotation) +run(FieldExAccessibleObjectgetDeclaredAnnotation) diff --git a/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..79b757e90f28f63f4fd36c01008678befd468d86 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String[] argv) { + System.out.println(new FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException().run()); + } + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = FieldExAccessibleObjectgetDeclaredAnnotationsByType_1(); + } catch (Exception e) { + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 20; + } + try { + result = FieldExAccessibleObjectgetDeclaredAnnotationsByType_2(); + } catch (Exception e) { + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 20; + } + if (result == 4 && FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int FieldExAccessibleObjectgetDeclaredAnnotationsByType_1() throws NoSuchFieldException { + // T[] getDeclaredAnnotationsByType(Class annotationClass) + int result1 = 4; + Field f1 = SampleClassField_h1.class.getDeclaredField("id"); + try { + CustomAnnotations_h1[] tp = f1.getDeclaredAnnotationsByType(CustomAnnotations_h1.class); +// System.out.println(tp[0]); + if (tp[0].toString().equals("@CustomAnnotations_h1(name=id)")) { + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 10; + } else { + System.out.println("Failed not as expect"); + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 15; + } + } catch (Exception e) { + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } + private int FieldExAccessibleObjectgetDeclaredAnnotationsByType_2() throws NoSuchFieldException { + // NullPointerException - if the given annotation class is null + // T[] getDeclaredAnnotationsByType(Class annotationClass) + int result2 = 4; + Field f1 = SampleClassField_h1.class.getDeclaredField("id"); + try { + CustomAnnotations_h1[] tp = f1.getDeclaredAnnotationsByType(null); + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 10; + } catch (NullPointerException e) { + FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 15; + } + return result2; + } +} +class SampleClassField_h1 { + @CustomAnnotations_h1(name = "id") + String id; +} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@interface CustomAnnotations_h1 { + String name(); +} diff --git a/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60cea9fd81b2b1b11f12a0c6fa85a877df2024f7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0059-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) +run(FieldExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/FieldExAccessibleObjectgetDeclaredAnnotations.java b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/FieldExAccessibleObjectgetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..0b9fe2553d8557657add95b67609f53d8a2f2424 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/FieldExAccessibleObjectgetDeclaredAnnotations.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.annotation.ElementType; +import java.lang.annotation.Annotation; +import java.lang.annotation.Repeatable; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectgetDeclaredAnnotations { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new FieldExAccessibleObjectgetDeclaredAnnotations().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectgetDeclaredAnnotations1(); + } catch (Exception e) { + FieldExAccessibleObjectgetDeclaredAnnotations.res = FieldExAccessibleObjectgetDeclaredAnnotations.res - 20; + } + if (result == 4 && FieldExAccessibleObjectgetDeclaredAnnotations.res == 89) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectgetDeclaredAnnotations1() throws NoSuchFieldException, SecurityException { + // Annotation[] getDeclaredAnnotations() + int result1 = 4; /*STATUS_FAILED*/ + Field field = SampleClassField5.class.getDeclaredField("id"); + try { + Annotation[] tp = field.getDeclaredAnnotations(); + if (tp[0].toString().equals("@CustomAnnotation6(value=id)")) { + FieldExAccessibleObjectgetDeclaredAnnotations.res = FieldExAccessibleObjectgetDeclaredAnnotations.res - 10; + } else { + System.out.println("Failed not as expect"); + FieldExAccessibleObjectgetDeclaredAnnotations.res = FieldExAccessibleObjectgetDeclaredAnnotations.res - 15; + } + } catch (NullPointerException e) { + FieldExAccessibleObjectgetDeclaredAnnotations.res = FieldExAccessibleObjectgetDeclaredAnnotations.res - 15; + } + return result1; + } +} +@CustomAnnotation6(value = "class") +class SampleClassField5 { + @CustomAnnotation6(value = "id") + String id; + String name; +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Repeatable(CustomAnnotation7.class) +@interface CustomAnnotation6 { + String value(); +} +@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotation7 { + CustomAnnotation6[] value(); +} diff --git a/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..37f2ee38f8e6132457ba7d50fca73f46fdbda31b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0060-rt-parent-FieldExAccessibleObjectgetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectgetDeclaredAnnotations) +run(FieldExAccessibleObjectgetDeclaredAnnotations) diff --git a/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/FieldExAccessibleObjectisAccessible.java b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/FieldExAccessibleObjectisAccessible.java new file mode 100755 index 0000000000000000000000000000000000000000..709b26db66dccce3e6918cf36992a0698b1527d7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/FieldExAccessibleObjectisAccessible.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectisAccessible { + static int res = 99; + public static void main(String[] argv) { + System.out.println(new FieldExAccessibleObjectisAccessible().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectisAccessible1(); + } catch (Exception e) { + FieldExAccessibleObjectisAccessible.res = FieldExAccessibleObjectisAccessible.res - 20; + } + if (result == 4 && FieldExAccessibleObjectisAccessible.res == 89) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectisAccessible1() throws NoSuchFieldException { + // boolean isAccessible() + int result1 = 4; + Field f1 = SampleClassFieldH2.class.getDeclaredField("id"); + try { + if(!f1.isAccessible()){ + FieldExAccessibleObjectisAccessible.res = FieldExAccessibleObjectisAccessible.res - 10; + }else{ + FieldExAccessibleObjectisAccessible.res = FieldExAccessibleObjectisAccessible.res - 15; + } + } catch (Exception e) { + FieldExAccessibleObjectisAccessible.res = FieldExAccessibleObjectisAccessible.res - 15; + } + return result1; + } +} +class SampleClassFieldH2 { + @CustomAnnotationsH2(name = "id") + String id; +} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@interface CustomAnnotationsH2 { + String name(); +} diff --git a/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/expected.txt b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/test.cfg b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..65208225db61fd26bdf02f629a52279b91c01700 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0061-rt-parent-FieldExAccessibleObjectisAccessible/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectisAccessible) +run(FieldExAccessibleObjectisAccessible) diff --git a/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/FieldExAccessibleObjectisAnnotationPresentNullPointerException.java b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/FieldExAccessibleObjectisAnnotationPresentNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..c8b12b30345f0e605029d9c30dbe464960edad33 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/FieldExAccessibleObjectisAnnotationPresentNullPointerException.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectisAnnotationPresentNullPointerException { + static int res = 99; + public static void main(String[] args) { + System.out.println(new FieldExAccessibleObjectisAnnotationPresentNullPointerException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectisAnnotationPresentNullPointerException1(); + } catch (Exception e) { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 20; + } + try { + result = fieldExAccessibleObjectisAnnotationPresentNullPointerException2(); + } catch (Exception e) { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 20; + } + if (result == 4 && FieldExAccessibleObjectisAnnotationPresentNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectisAnnotationPresentNullPointerException1() throws NoSuchFieldException { + // boolean isAnnotationPresent(Class annotationClass) + int result1 = 4; + Field f1 = SampleClassFieldH3.class.getDeclaredField("id"); + try { + if (f1.isAnnotationPresent(CustomAnnotationsH3.class)) { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 10; + } else { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 15; + } + } catch (Exception e) { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 15; + } + return result1; + } + private int fieldExAccessibleObjectisAnnotationPresentNullPointerException2() throws NoSuchFieldException { + int result2 = 4; + // NullPointerException - if the given annotation class is null + // boolean isAnnotationPresent(Class annotationClass) + Field f1 = SampleClassFieldH3.class.getDeclaredField("id"); + try { + boolean tp = f1.isAnnotationPresent(null); + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 10; + } catch (NullPointerException e) { + FieldExAccessibleObjectisAnnotationPresentNullPointerException.res = FieldExAccessibleObjectisAnnotationPresentNullPointerException.res - 15; + } + return result2; + } +} +class SampleClassFieldH3 { + @CustomAnnotationsH3(name = "id") + String id; +} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@interface CustomAnnotationsH3 { + String name(); +} diff --git a/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..378f2f9ce154dc87ea8f45f2679ddaa548313ee2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0062-rt-parent-FieldExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectisAnnotationPresentNullPointerException) +run(FieldExAccessibleObjectisAnnotationPresentNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/FieldExAccessibleObjectsetAccessibleSecurityException.java b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/FieldExAccessibleObjectsetAccessibleSecurityException.java new file mode 100755 index 0000000000000000000000000000000000000000..7e35a5c90d007ef991768a949ba9c6e5cac7e7fa --- /dev/null +++ b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/FieldExAccessibleObjectsetAccessibleSecurityException.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +public class FieldExAccessibleObjectsetAccessibleSecurityException { + static int res = 99; + public static void main(String[] args) { + System.out.println(new FieldExAccessibleObjectsetAccessibleSecurityException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectsetAccessibleSecurityException1(); + } catch (Exception e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 20; + } + try { + result = fieldExAccessibleObjectsetAccessibleSecurityException2(); + } catch (Exception e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 20; + } + if (result == 4 && FieldExAccessibleObjectsetAccessibleSecurityException.res == 59) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectsetAccessibleSecurityException1() throws NoSuchFieldException { + // void setAccessible(boolean flag) + int result1 = 4; + Field f1 = SampleClassFieldH4.class.getDeclaredField("id"); + try { + f1.setAccessible(false); + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 10; + } catch (SecurityException e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 15; + } + try { + f1.setAccessible(true); + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 10; + } catch (SecurityException e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 15; + } + return result1; + } + private int fieldExAccessibleObjectsetAccessibleSecurityException2() throws NoSuchFieldException { + // static void setAccessible(AccessibleObject[] array, boolean flag) + int result2 = 4; + Constructor[] test = AccessibleObject.class.getDeclaredConstructors(); + try { + AccessibleObject.setAccessible(test, false); + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 10; + } catch (SecurityException e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 15; + } + try { + AccessibleObject.setAccessible(test, true); + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 10; + } catch (SecurityException e) { + FieldExAccessibleObjectsetAccessibleSecurityException.res = FieldExAccessibleObjectsetAccessibleSecurityException.res - 15; + } + return result2; + } +} +class SampleClassFieldH4 { + @CustomAnnotationsH4(name = "id") + String id; +} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +@interface CustomAnnotationsH4 { + String name(); +} diff --git a/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/expected.txt b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/test.cfg b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..15dda2d07d1b5c6e04b8419eeb89333596c28b3a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0063-rt-parent-FieldExAccessibleObjectsetAccessibleSecurityException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExAccessibleObjectsetAccessibleSecurityException) +run(FieldExAccessibleObjectsetAccessibleSecurityException) diff --git a/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/FieldExObjectgetClass.java b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/FieldExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..0a22182c962679fe25ea17f5b0ce7a114a774da6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/FieldExObjectgetClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new FieldExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExObjectgetClass1(); + } catch (Exception e) { + FieldExObjectgetClass.res = FieldExObjectgetClass.res - 20; + } + if (result == 4 && FieldExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int fieldExObjectgetClass1() { + // final Class getClass() + int result1 = 4; /*STATUS_FAILED*/ + Field[] f1 = FieldExObjectgetClass.class.getDeclaredFields(); + Class px1 = f1[0].getClass(); + if (px1.toString().equals("class java.lang.reflect.Field")) { + FieldExObjectgetClass.res = FieldExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0e334ddd5afae03606d32570c7be0c39bdbbbb68 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0064-rt-parent-FieldExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectgetClass) +run(FieldExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/FieldExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/FieldExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..e8ad0edbad4f68bd52554002772bf8ad77e32305 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/FieldExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private Field[] rp = FieldExObjectnotifyAllIllegalMonitorStateException.class.getDeclaredFields(); + public static void main(String argv[]) { + System.out.println(new FieldExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + FieldExObjectnotifyAllIllegalMonitorStateException.res = FieldExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new MethodExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && FieldExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int methodExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + rp.notifyAll(); + FieldExObjectnotifyAllIllegalMonitorStateException.res = FieldExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + FieldExObjectnotifyAllIllegalMonitorStateException.res = FieldExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class MethodExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notifyAll(); + FieldExObjectnotifyAllIllegalMonitorStateException.res = FieldExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + FieldExObjectnotifyAllIllegalMonitorStateException.res = FieldExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1ad57c491fcdbdb2fbbc2e5c928d1d7d3030d824 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0065-rt-parent-FieldExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectnotifyAllIllegalMonitorStateException) +run(FieldExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/FieldExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/FieldExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..cd883dc18eed34cc11c29b8b5f0cd7a4e475a3dd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/FieldExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private Field[] rp = FieldExObjectnotifyIllegalMonitorStateException.class.getDeclaredFields(); + public static void main(String argv[]) { + System.out.println(new FieldExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + FieldExObjectnotifyIllegalMonitorStateException.res = FieldExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new MethodExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && FieldExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int methodExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp.notify(); + FieldExObjectnotifyIllegalMonitorStateException.res = FieldExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + FieldExObjectnotifyIllegalMonitorStateException.res = FieldExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class MethodExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notify(); + FieldExObjectnotifyIllegalMonitorStateException.res = FieldExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + FieldExObjectnotifyIllegalMonitorStateException.res = FieldExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..734a13eac0e408dd7bbf1d77d24a57e8e1faf333 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0066-rt-parent-FieldExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectnotifyIllegalMonitorStateException) +run(FieldExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/FieldExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/FieldExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..bc5b544642c4e770cefefa32087644fa3c704d20 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/FieldExObjectwaitIllegalArgumentException.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectwaitIllegalArgumentException { + static int res = 99; + private Field[] fields = FieldExObjectwaitIllegalArgumentException.class.getDeclaredFields(); + public static void main(String argv[]) { + System.out.println(new FieldExObjectwaitIllegalArgumentException().run()); + } + private class FieldExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (fields[0]) { + fields[0].notifyAll(); + try { + fields[0].wait(millis); + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class FieldExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (fields[0]) { + fields[0].notifyAll(); + try { + fields[0].wait(millis, nanos); + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + FieldExObjectwaitIllegalArgumentException.res = FieldExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new FieldExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new FieldExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && FieldExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..798d512c6ecf2bfd50d9f88bdc73565f9604c9ad --- /dev/null +++ b/testsuite/java_test/parent_test/RT0067-rt-parent-FieldExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectwaitIllegalArgumentException) +run(FieldExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/FieldExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/FieldExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..079eb1947a0d51154197402bc0f15ae4fe133092 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/FieldExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static Field[] fields = FieldExObjectwaitIllegalMonitorStateException.class.getDeclaredFields(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = fieldExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = fieldExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = fieldExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && FieldExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int fieldExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + fields[0].wait(); + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int fieldExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + fields[0].wait(millis); + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int fieldExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + fields[0].wait(millis, nanos); + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitIllegalMonitorStateException.res = FieldExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9a6757f844dd19abac9e8905b3e30ea3f0d788a1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0068-rt-parent-FieldExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectwaitIllegalMonitorStateException) +run(FieldExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/FieldExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/FieldExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..07d501dadd53d62d49ef14b0b545e8afbaa98cab --- /dev/null +++ b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/FieldExObjectwaitInterruptedException.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectwaitInterruptedException { + static int res = 99; + private static Field[] fields = FieldExObjectwaitInterruptedException.class.getDeclaredFields(); + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + System.out.println(new FieldExObjectwaitInterruptedException().run()); + } + private class FieldExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (fields[0]) { + fields[0].notifyAll(); + try { + fields[0].wait(); + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class FieldExObjectwaitInterruptedException12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (fields[0]) { + fields[0].notifyAll(); + try { + fields[0].wait(millis); + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class FieldExObjectwaitInterruptedException13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (fields[0]) { + fields[0].notifyAll(); + try { + fields[0].wait(millis, nanos); + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwaitInterruptedException.res = FieldExObjectwaitInterruptedException.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new FieldExObjectwaitInterruptedException11()); + Thread t2 = new Thread(new FieldExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new FieldExObjectwaitInterruptedException12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new FieldExObjectwaitInterruptedException13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && FieldExObjectwaitInterruptedException.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3ee5d5e65d70d1399144d48007bc081bd6f324ab --- /dev/null +++ b/testsuite/java_test/parent_test/RT0069-rt-parent-FieldExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectwaitInterruptedException) +run(FieldExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/FieldExObjectwait.java b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/FieldExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..c127ceaa8dd57d058d49a1f56dacae429354313b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/FieldExObjectwait.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldExObjectwait { + static int res = 99; + private Field[] cal = FieldExObjectwait.class.getDeclaredFields(); + private Field[] cal2 = FieldExObjectwait.class.getDeclaredFields(); + private Field[] cal3 = FieldExObjectwait.class.getDeclaredFields(); + public static void main(String argv[]) { + System.out.println(new FieldExObjectwait().run()); + } + private class FieldExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (cal) { + cal.notifyAll(); + try { + cal.wait(); + FieldExObjectwait.res = FieldExObjectwait.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwait.res = FieldExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwait.res = FieldExObjectwait.res - 30; + } + } + } + } + private class FieldExObjectwait12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal2) { + cal2.notifyAll(); + try { + cal2.wait(millis); + FieldExObjectwait.res = FieldExObjectwait.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwait.res = FieldExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwait.res = FieldExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private class FieldExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal3) { + cal3.notifyAll(); + try { + cal3.wait(millis, nanos); + FieldExObjectwait.res = FieldExObjectwait.res - 10; + } catch (InterruptedException e1) { + FieldExObjectwait.res = FieldExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + FieldExObjectwait.res = FieldExObjectwait.res - 30; + } + } + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new FieldExObjectwait11()); + Thread t2 = new Thread(new FieldExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new FieldExObjectwait12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new FieldExObjectwait13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && FieldExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5344bc50fac9eb545b1f8157cd77a3119d3f4bcd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0070-rt-parent-FieldExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldExObjectwait) +run(FieldExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/MethodExAccessibleObjectgetAnnotationNullPointerException.java b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/MethodExAccessibleObjectgetAnnotationNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..9ebe48ec658042865541ea2ce83b2a5d92fa051a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/MethodExAccessibleObjectgetAnnotationNullPointerException.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectgetAnnotationNullPointerException { + static int res = 100; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExAccessibleObjectgetAnnotationNullPointerException1(); + } catch (Exception e) { + MethodExAccessibleObjectgetAnnotationNullPointerException.res = MethodExAccessibleObjectgetAnnotationNullPointerException.res - 10; + } + try { + result = methodExAccessibleObjectgetAnnotationNullPointerException2(); + } catch (Exception e) { + MethodExAccessibleObjectgetAnnotationNullPointerException.res = MethodExAccessibleObjectgetAnnotationNullPointerException.res - 10; + } + if (result == 4 && MethodExAccessibleObjectgetAnnotationNullPointerException.res == 75) { + result = 0; + } + return result; + } + private static int methodExAccessibleObjectgetAnnotationNullPointerException1() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - If the specified object is empty. + // T getAnnotation(Class annotationClass) + Method sampleMethod = MethodClass9.class.getMethod("sampleMethod"); + try { + sampleMethod.getAnnotation(null); + MethodExAccessibleObjectgetAnnotationNullPointerException.res -= 10; + } catch (NullPointerException e1) { + MethodExAccessibleObjectgetAnnotationNullPointerException.res = MethodExAccessibleObjectgetAnnotationNullPointerException.res - 15; + } + return result1; + } + private static int methodExAccessibleObjectgetAnnotationNullPointerException2() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // T getAnnotation(Class annotationClass) + Method sampleMethod = MethodClass9.class.getMethod("sampleMethod"); + try { + MethodAnnotation get1 = sampleMethod.getAnnotation(MethodAnnotation.class); + if (get1.toString().equals("@MethodAnnotation(name=sampleMethod, value=Sample Method Annotation)")) { + MethodExAccessibleObjectgetAnnotationNullPointerException.res -= 10; + } + } catch (NullPointerException e1) { + MethodExAccessibleObjectgetAnnotationNullPointerException.res = MethodExAccessibleObjectgetAnnotationNullPointerException.res - 15; + } + return result1; + } +} +@MethodAnnotation(name = "SampleClass", value = "Sample Class Annotation") +class MethodClass9 { + private String sampleField; + @MethodAnnotation(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface MethodAnnotation { + String name(); + String value(); +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..99d6f6b5bec403a66ba7aad622b87c4e95d862e6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0071-rt-parent-MethodExAccessibleObjectgetAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectgetAnnotationNullPointerException) +run(MethodExAccessibleObjectgetAnnotationNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/MethodExAccessibleObjectgetAnnotations.java b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/MethodExAccessibleObjectgetAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..d23ce5b2cb0ee069611a1b0fee467fdaf62ed6f3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/MethodExAccessibleObjectgetAnnotations.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectgetAnnotations { + private static int res = 99; + public static void main(String[] args) { + System.out.println(new MethodExAccessibleObjectgetAnnotations().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = fieldExAccessibleObjectsetAccessibleSecurityException1(); + } catch (Exception e) { + e.printStackTrace(); + MethodExAccessibleObjectgetAnnotations.res = MethodExAccessibleObjectgetAnnotations.res - 20; + } + if (result == 4 && MethodExAccessibleObjectgetAnnotations.res == 89) { + result = 0; + } + return result; + } + private int fieldExAccessibleObjectsetAccessibleSecurityException1() throws NoSuchMethodException { + // Annotation[] getAnnotations() + int result1 = 4; + Method method = SampleClassH4.class.getMethod("sampleMethod"); + try { + Annotation[] tp = method.getAnnotations(); + if (tp.length == 1 && + tp[0].toString().equals("@CustomAnnotationsH9(name=sampleMethod, value=Sample Method Annotation)")) { + MethodExAccessibleObjectgetAnnotations.res = MethodExAccessibleObjectgetAnnotations.res - 10; + } + } catch (Exception e) { + MethodExAccessibleObjectgetAnnotations.res = MethodExAccessibleObjectgetAnnotations.res - 15; + } + return result1; + } +} +@CustomAnnotationsH9(name = "SampleClass", value = "Sample Class Annotation") +class SampleClassH4 { + private String sampleField; + @CustomAnnotationsH9(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotationsH9 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..12decd09dae67b858a7da63749b5f09d28e07aee --- /dev/null +++ b/testsuite/java_test/parent_test/RT0072-rt-parent-MethodExAccessibleObjectgetAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectgetAnnotations) +run(MethodExAccessibleObjectgetAnnotations) diff --git a/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.java b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..295d26a0df5991b05d01a5abc9f1843149abbbb5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException { + private static int res = 99; + public static void main(String argv[]) { + System.out.println(new MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException().run()); + } + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException_1(); + } catch (Exception e) { + e.printStackTrace(); + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 20; + } + try { + result = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException_2(); + } catch (Exception e) { + e.printStackTrace(); + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 20; + } + if (result == 4 && MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException_1() throws NoSuchMethodException { + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Method m = SampleClass_h6.class.getMethod("sampleMethod"); + try { + CustomAnnotations_h11[] tp = m.getAnnotationsByType(CustomAnnotations_h11.class); + if (tp.length == 1 && + tp[0].toString().equals("@CustomAnnotations_h11(name=sampleMethod, value=Sample Method Annotation)")) { + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 10; + } + } catch (Exception e) { + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 15; + } + return result1; + } + private int MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException_2() throws NoSuchMethodException { + // NullPointerException - if the given annotation class is null + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Method m = SampleClass_h6.class.getMethod("sampleMethod"); + try { + m.getAnnotationsByType(null); + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 10; + } catch (NullPointerException e) { + MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException.res - 15; + } + return result1; + } +} +@CustomAnnotations_h11(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass_h6 { + private String sampleField; + @CustomAnnotations_h11(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotations_h11 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f101d1e45ef44f98d20f6c8df019bd103446508 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0073-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException) +run(MethodExAccessibleObjectgetDeclaredAnnotationNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..0cf6fde229d9acfacfc81cc05535a82ce7c70c48 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException { + private static int res = 99; + public static void main(String argv[]) { + System.out.println(new MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException().run()); + } + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException_1(); + } catch (Exception e) { + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 20; + } + try { + result = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException_2(); + } catch (Exception e) { + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 20; + } + if (result == 4 && MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException_1() throws NoSuchMethodException { + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Method m = SampleClass_h8.class.getMethod("sampleMethod"); + try { + CustomAnnotations_h13[] tp = m.getAnnotationsByType(CustomAnnotations_h13.class); + if (tp.length == 1 && + tp[0].toString().equals("@CustomAnnotations_h13(name=sampleMethod, value=Sample Method Annotation)")) { + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 10; + } + } catch (Exception e) { + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } + private int MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException_2() throws NoSuchMethodException { + // NullPointerException - if the given annotation class is null + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; /*STATUS_FAILED*/ + Method m = SampleClass_h8.class.getMethod("sampleMethod"); + try { + CustomAnnotations_h13[] tp = m.getAnnotationsByType(null); + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 10; + } catch (NullPointerException e) { + MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res = MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } +} +@CustomAnnotations_h13(name = "SampleClass", value = "Sample Class Annotation") +class SampleClass_h8 { + private String sampleField; + @CustomAnnotations_h13(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotations_h13 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3ecb4992354d1570da0fe1483023673889c713e0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0074-rt-parent-MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) +run(MethodExAccessibleObjectgetDeclaredAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/MethodExAccessibleObjectisAccessible.java b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/MethodExAccessibleObjectisAccessible.java new file mode 100755 index 0000000000000000000000000000000000000000..19d13e4fb31de35562982ddf13f4165ef4be5f49 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/MethodExAccessibleObjectisAccessible.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExAccessibleObjectisAccessible { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExAccessibleObjectisAccessible1(); + } catch (Exception e) { + MethodExAccessibleObjectisAccessible.res = MethodExAccessibleObjectisAccessible.res - 10; + } + if (result == 4 && MethodExAccessibleObjectisAccessible.res == 98) { + result = 0; + } + return result; + } + private static int methodExAccessibleObjectisAccessible1() throws NoSuchMethodException, SecurityException, NoSuchFieldException { + int result1 = 4; /*STATUS_FAILED*/ + // boolean isAccessible() + Method sampleMethod = MethodClass11.class.getMethod("sampleMethod"); + if (sampleMethod.isAccessible()) { + MethodExAccessibleObjectisAccessible.res = MethodExAccessibleObjectisAccessible.res - 10; + } else { + MethodExAccessibleObjectisAccessible.res = MethodExAccessibleObjectisAccessible.res - 1; + } + return result1; + } +} +@CustomAnnotationn(name = "SampleClass", value = "Sample Class Annotation") +class MethodClass11 { + private String sampleField; + @CustomAnnotationn(name = "sampleMethod", value = "Sample Class Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@interface CustomAnnotationn { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/expected.txt b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/test.cfg b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..82163d411ce877a66aa5e092c4932e431f9c927c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0075-rt-parent-MethodExAccessibleObjectisAccessible/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectisAccessible) +run(MethodExAccessibleObjectisAccessible) diff --git a/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/MethodExAccessibleObjectisAnnotationPresentNullPointerException.java b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/MethodExAccessibleObjectisAnnotationPresentNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..0132a3a8db62a85d699936e9e2ae7684b0d52473 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/MethodExAccessibleObjectisAnnotationPresentNullPointerException.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectisAnnotationPresentNullPointerException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExAccessibleObjectisAnnotationPresentNullPointerException1(); + } catch (Exception e) { + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 20; + } + try { + result = methodExAccessibleObjectisAnnotationPresentNullPointerException2(); + } catch (Exception e) { + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 20; + } + if (result == 4 && MethodExAccessibleObjectisAnnotationPresentNullPointerException.res == 68) { + result = 0; + } + return result; + } + private static int methodExAccessibleObjectisAnnotationPresentNullPointerException1() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - If the specified object is empty. + Method sampleMethod = MethodClass8.class.getMethod("sampleMethod"); + try { + sampleMethod.isAnnotationPresent(null); + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 10; + } catch (NullPointerException e1) { + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 1; + } + return result1; + } + private static int methodExAccessibleObjectisAnnotationPresentNullPointerException2() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // NullPointerException - If the specified object is empty. + // boolean isAnnotationPresent(Class annotationClass) + Method sampleMethod = MethodClass8.class.getMethod("sampleMethod"); + try { + sampleMethod.isAnnotationPresent(CustomAnnotationH100.class); + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 30; + } catch (NullPointerException e1) { + MethodExAccessibleObjectisAnnotationPresentNullPointerException.res = MethodExAccessibleObjectisAnnotationPresentNullPointerException.res - 5; + } + return result1; + } +} +@CustomAnnotationH100(name = "SampleClass", value = "Sample Class Annotation") +class MethodClass8 { + private String sampleField; + @CustomAnnotationH100(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotationH100 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7f02da964ac1708d31ef65a84861a504b063edc8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0076-rt-parent-MethodExAccessibleObjectisAnnotationPresentNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectisAnnotationPresentNullPointerException) +run(MethodExAccessibleObjectisAnnotationPresentNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/MethodExAccessibleObjectSetAccessible.java b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/MethodExAccessibleObjectSetAccessible.java new file mode 100755 index 0000000000000000000000000000000000000000..7241491a7ea161e2fc576c3ab6234ba8fdfd0d1d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/MethodExAccessibleObjectSetAccessible.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Method; +public class MethodExAccessibleObjectSetAccessible { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExAccessibleObjectSetAccessible1(); + } catch (Exception e) { + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 10; + } + try { + result = methodExAccessibleObjectSetAccessible2(); + } catch (Exception e) { + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 10; + } + if (result == 4 && MethodExAccessibleObjectSetAccessible.res == 79) { + result = 0; + } + return result; + } + private static int methodExAccessibleObjectSetAccessible1() throws NoSuchFieldException { + int result1 = 4; /*STATUS_FAILED*/ + // SecurityException - Exception safety + // static void setAccessible(AccessibleObject[] array, boolean flag) + Method[] sampleMethod = MethodClass14.class.getMethods(); + try { + AccessibleObject.setAccessible(sampleMethod, false); + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 10; + } catch (SecurityException e1) { + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 1; + } + return result1; + } + private static int methodExAccessibleObjectSetAccessible2() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // SecurityException - Exception safety + // void setAccessible(boolean flag) + Method sampleMethod = MethodClass14.class.getMethod("sampleMethod"); + try { + sampleMethod.setAccessible(false); + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 10; + } catch (SecurityException e1) { + MethodExAccessibleObjectSetAccessible.res = MethodExAccessibleObjectSetAccessible.res - 1; + } + return result1; + } +} +@CustomAnnotationwe(name = "SampleClass", value = "Sample Class Annotation") +class MethodClass14 { + private String sampleField; + @CustomAnnotationwe(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@interface CustomAnnotationwe { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/expected.txt b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/test.cfg b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cd1a9e641d8737caebb69c5fe29d87b6e06ebf61 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0077-rt-parent-MethodExAccessibleObjectSetAccessible/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExAccessibleObjectSetAccessible) +run(MethodExAccessibleObjectSetAccessible) diff --git a/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/MethodExecutablegetDeclaredAnnotations.java b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/MethodExecutablegetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..10cf1fc5323f8fd15145aeed3c699efab75e32c5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/MethodExecutablegetDeclaredAnnotations.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodExecutablegetDeclaredAnnotations { + private static int res = 99; + public static void main(String[] argv) { + System.out.println(new MethodExecutablegetDeclaredAnnotations().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExecutablegetDeclaredAnnotations1(); + } catch (Exception e) { + MethodExecutablegetDeclaredAnnotations.res = MethodExecutablegetDeclaredAnnotations.res - 20; + } + if (result == 4 && MethodExecutablegetDeclaredAnnotations.res == 89) { + result = 0; + } + return result; + } + private int methodExecutablegetDeclaredAnnotations1() throws NoSuchMethodException { + // Annotation[] getDeclaredAnnotations() + int result1 = 4; + Method m1 = SampleClassH2.class.getDeclaredMethod("sampleMethod"); + try { + Annotation[] tp = m1.getDeclaredAnnotations(); + if (tp.length == 1 && + tp[0].toString().equals("@CustomAnnotationsH60(name=sampleMethod, value=Sample Method Annotation)")) { + MethodExecutablegetDeclaredAnnotations.res = MethodExecutablegetDeclaredAnnotations.res - 10; + } + } catch (Exception e) { + MethodExecutablegetDeclaredAnnotations.res = MethodExecutablegetDeclaredAnnotations.res - 15; + } + return result1; + } +} +@CustomAnnotationsH60(name = "SampleClass", value = "Sample Class Annotation") +class SampleClassH2 { + private String sampleField; + @CustomAnnotationsH60(name = "sampleMethod", value = "Sample Method Annotation") + public String sampleMethod() { + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@Retention(RetentionPolicy.RUNTIME) +@interface CustomAnnotationsH60 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/expected.txt b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/test.cfg b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d27947fcecdb96c74d65b9b2837db73c262dd7a6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0078-rt-parent-MethodExecutablegetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExecutablegetDeclaredAnnotations) +run(MethodExecutablegetDeclaredAnnotations) diff --git a/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/MethodExExecutablegetAnnotationsByTypeNullPointerException.java b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/MethodExExecutablegetAnnotationsByTypeNullPointerException.java new file mode 100644 index 0000000000000000000000000000000000000000..eab46124f7a4f30329aa98e900c720933550bf45 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/MethodExExecutablegetAnnotationsByTypeNullPointerException.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExExecutablegetAnnotationsByTypeNullPointerException { + static int res = 99; + public static void main(String[] argv) { + System.out.println(new MethodExExecutablegetAnnotationsByTypeNullPointerException().run()); + } + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = MethodExExecutablegetAnnotationsByTypeNullPointerException_1(); + } catch (Exception e) { + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 20; + } + try { + result = MethodExExecutablegetAnnotationsByTypeNullPointerException_2(); + } catch (Exception e) { + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 20; + } + if (result == 4 && MethodExExecutablegetAnnotationsByTypeNullPointerException.res == 74) { + result = 0; + } + return result; + } + private int MethodExExecutablegetAnnotationsByTypeNullPointerException_1() throws NoSuchMethodException { + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; + Method m1 = SampleClass_h1.class.getDeclaredMethod("sampleMethod"); + try { + CustomAnnotations_h5[] tp = m1.getAnnotationsByType(CustomAnnotations_h5.class); + if(tp.getClass().toString().equals("class [LCustomAnnotations_h5;")){ + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 10; + } + } catch (Exception e) { + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } + private int MethodExExecutablegetAnnotationsByTypeNullPointerException_2() throws NoSuchMethodException { + // NullPointerException - if the given annotation class is null + // T[] getAnnotationsByType(Class annotationClass) + int result1 = 4; + Method m1 = SampleClass_h1.class.getDeclaredMethod("sampleMethod"); + try { + CustomAnnotations_h5[] tp = m1.getAnnotationsByType(null); + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 10; + } catch (NullPointerException e) { + MethodExExecutablegetAnnotationsByTypeNullPointerException.res = MethodExExecutablegetAnnotationsByTypeNullPointerException.res - 15; + } + return result1; + } +} +@CustomAnnotations_h5(name="SampleClass", value = "Sample Class Annotation") +class SampleClass_h1 { + private String sampleField; + @CustomAnnotations_h5(name="sampleMethod", value = "Sample Method Annotation") + public String sampleMethod(){ + return "sample"; + } + public String getSampleField() { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@interface CustomAnnotations_h5 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6fa4f108948d8609a2b8e6cc77a14c84f0db1c3b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0079-rt-parent-MethodExExecutablegetAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExExecutablegetAnnotationsByTypeNullPointerException) +run(MethodExExecutablegetAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/MethodExExecutablegetGenericExceptionTypesExceptions.java b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/MethodExExecutablegetGenericExceptionTypesExceptions.java new file mode 100755 index 0000000000000000000000000000000000000000..7672ff062f701a4e1018a66f9224c447ed3738db --- /dev/null +++ b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/MethodExExecutablegetGenericExceptionTypesExceptions.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.Arrays; +public class MethodExExecutablegetGenericExceptionTypesExceptions { + static int res = 99; + public static void main(String[] argv) { + System.out.println(new MethodExExecutablegetGenericExceptionTypesExceptions().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExExecutablegetGenericExceptionTypesExceptions1(); + } catch (Exception e) { + MethodExExecutablegetGenericExceptionTypesExceptions.res = MethodExExecutablegetGenericExceptionTypesExceptions.res - 20; + } + if (result == 4 && MethodExExecutablegetGenericExceptionTypesExceptions.res == 89) { + result = 0; + } + return result; + } + private int methodExExecutablegetGenericExceptionTypesExceptions1() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + // Type[] getGenericExceptionTypes() + int result1 = 4; + Method m1 = SampleClassH111.class.getDeclaredMethod("getSampleField"); + try { + Type[] tp = m1.getGenericExceptionTypes(); + if (Arrays.toString(tp).equals("[class java.lang.ArrayIndexOutOfBoundsException]")) { + MethodExExecutablegetGenericExceptionTypesExceptions.res = MethodExExecutablegetGenericExceptionTypesExceptions.res - 10; + } + } catch (Exception e) { + MethodExExecutablegetGenericExceptionTypesExceptions.res = MethodExExecutablegetGenericExceptionTypesExceptions.res - 15; + } + return result1; + } +} +@CustomAnnotationsH111(name = "SampleClass", value = "Sample Class Annotation") +class SampleClassH111 { + private String sampleField; + public String getSampleField() throws ArrayIndexOutOfBoundsException { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@interface CustomAnnotationsH111 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/expected.txt b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/test.cfg b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cdea4bcffff496bf0f1af4c7b5629aac8cefd4bd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0080-rt-parent-MethodExExecutablegetGenericExceptionTypesExceptions/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExExecutablegetGenericExceptionTypesExceptions) +run(MethodExExecutablegetGenericExceptionTypesExceptions) diff --git a/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/MethodExExecutablegetGenericParameterTypesExceptions.java b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/MethodExExecutablegetGenericParameterTypesExceptions.java new file mode 100755 index 0000000000000000000000000000000000000000..79033e4889566211077d9e7d80bca8deaece8aa1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/MethodExExecutablegetGenericParameterTypesExceptions.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.Arrays; +public class MethodExExecutablegetGenericParameterTypesExceptions { + static int res = 99; + public static void main(String[] argv) { + System.out.println(new MethodExExecutablegetGenericParameterTypesExceptions().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExExecutablegetGenericParameterTypesExceptions1(); + } catch (Exception e) { + MethodExExecutablegetGenericParameterTypesExceptions.res = MethodExExecutablegetGenericParameterTypesExceptions.res - 20; + } + if (result == 4 && MethodExExecutablegetGenericParameterTypesExceptions.res == 89) { + result = 0; + } + return result; + } + private int methodExExecutablegetGenericParameterTypesExceptions1() throws NoSuchMethodException { + // Type[] getGenericParameterTypes() + int result1 = 4; + Method m1 = SampleClassH3.class.getDeclaredMethod("getSampleField"); + try { + Type[] tp = m1.getGenericParameterTypes(); + if (Arrays.toString(tp).equals("[]")) { + MethodExExecutablegetGenericParameterTypesExceptions.res = MethodExExecutablegetGenericParameterTypesExceptions.res - 10; + } + } catch (Exception e) { + MethodExExecutablegetGenericParameterTypesExceptions.res = MethodExExecutablegetGenericParameterTypesExceptions.res - 15; + } + return result1; + } +} +@CustomAnnotationsH8(name = "SampleClass", value = "Sample Class Annotation") +class SampleClassH3 { + private String sampleField; + public String getSampleField() throws ArrayIndexOutOfBoundsException { + return sampleField; + } + public void setSampleField(String sampleField) { + this.sampleField = sampleField; + } +} +@interface CustomAnnotationsH8 { + String name(); + String value(); +} diff --git a/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/expected.txt b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/test.cfg b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6df81d4c39812808f498f2b2dd40e2b87ba9de64 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0081-rt-parent-MethodExExecutablegetGenericParameterTypesExceptions/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExExecutablegetGenericParameterTypesExceptions) +run(MethodExExecutablegetGenericParameterTypesExceptions) diff --git a/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/MethodExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/MethodExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..84ce0cc4295dd6c35b688b7d716f7641d3fb9b2a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/MethodExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private Method[] rp = MethodExObjectnotifyAllIllegalMonitorStateException.class.getMethods(); + public static void main(String argv[]) { + System.out.println(new MethodExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + MethodExObjectnotifyAllIllegalMonitorStateException.res = MethodExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new MethodExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && MethodExObjectnotifyAllIllegalMonitorStateException.res == 68) { + result = 0; + } + return result; + } + private int methodExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + rp[0].notifyAll(); + MethodExObjectnotifyAllIllegalMonitorStateException.res = MethodExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + MethodExObjectnotifyAllIllegalMonitorStateException.res = MethodExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class MethodExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp[0].notifyAll(); + MethodExObjectnotifyAllIllegalMonitorStateException.res = MethodExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + MethodExObjectnotifyAllIllegalMonitorStateException.res = MethodExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1ff38cf5eefae7c4698485ee54b6462da448cc37 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0082-rt-parent-MethodExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectnotifyAllIllegalMonitorStateException) +run(MethodExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/MethodExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/MethodExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..80e7841220b6ef0677ef753f4de88b4f8f3064cc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/MethodExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private Method[] rp = MethodExObjectnotifyIllegalMonitorStateException.class.getMethods(); + public static void main(String argv[]) { + System.out.println(new MethodExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = methodExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + MethodExObjectnotifyIllegalMonitorStateException.res = MethodExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new MethodExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && MethodExObjectnotifyIllegalMonitorStateException.res == 68) { + result = 0; + } + return result; + } + private int methodExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp[0].notify(); + MethodExObjectnotifyIllegalMonitorStateException.res = MethodExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + MethodExObjectnotifyIllegalMonitorStateException.res = MethodExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class MethodExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp[0].notify(); + MethodExObjectnotifyIllegalMonitorStateException.res = MethodExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + MethodExObjectnotifyIllegalMonitorStateException.res = MethodExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0372cfef196ba7a0e11fddae5bc8c9dd8c474048 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0083-rt-parent-MethodExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectnotifyIllegalMonitorStateException) +run(MethodExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/MethodExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/MethodExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..54eea971c255d0fe7e4c62d5236482e9a8d376cb --- /dev/null +++ b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/MethodExObjectwaitIllegalArgumentException.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectwaitIllegalArgumentException { + static int res = 99; + static Method[] methods = MethodExObjectwaitIllegalArgumentException.class.getMethods(); + public static void main(String argv[]) { + System.out.println(new MethodExObjectwaitIllegalArgumentException().run()); + } + private class MethodExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (methods[0]) { + methods[0].notifyAll(); + try { + methods[0].wait(millis); + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class MethodExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (methods[0]) { + methods[0].notifyAll(); + try { + methods[0].wait(millis, nanos); + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + MethodExObjectwaitIllegalArgumentException.res = MethodExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new MethodExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new MethodExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && MethodExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..995cb6b4df2eb58d943e8d0cbcef1ca8c3e90d25 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0084-rt-parent-MethodExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectwaitIllegalArgumentException) +run(MethodExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/MethodExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/MethodExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..5d4b8cb2ae4c88cdff1ce6bfd7e65269fe960e0b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/MethodExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectwaitIllegalMonitorStateException { + static int res = 99; + static Method[] methods = MethodExObjectwaitIllegalMonitorStateException.class.getMethods(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = methodExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = methodExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = methodExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && MethodExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int methodExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + methods[0].wait(); + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int methodExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + methods[0].wait(millis); + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int methodExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + methods[0].wait(millis, nanos); + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitIllegalMonitorStateException.res = MethodExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} diff --git a/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4780c0cf1d86c22f3f03a5a4d4328c8c4c37c904 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0085-rt-parent-MethodExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectwaitIllegalMonitorStateException) +run(MethodExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/MethodExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/MethodExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..be292228d4b4a5f0317572d23db735c62a8a3d47 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/MethodExObjectwaitInterruptedException.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectwaitInterruptedException { + static int res = 99; + static Method[] methods = MethodExObjectwaitInterruptedException.class.getMethods(); + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + System.out.println(new MethodExObjectwaitInterruptedException().run()); + } + private class MethodExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (methods[0]) { + methods[0].notifyAll(); + try { + methods[0].wait(); + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class MethodExObjectwaitInterruptedException12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (methods[0]) { + methods[0].notifyAll(); + try { + methods[0].wait(millis); + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 30; + } + } + } + } + private class MethodExObjectwaitInterruptedException13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (methods[0]) { + methods[0].notifyAll(); + try { + methods[0].wait(millis, nanos); + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwaitInterruptedException.res = MethodExObjectwaitInterruptedException.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new MethodExObjectwaitInterruptedException11()); + Thread t2 = new Thread(new MethodExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new MethodExObjectwaitInterruptedException12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new MethodExObjectwaitInterruptedException13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && MethodExObjectwaitInterruptedException.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5bbab3db59a3bfb15c2a8b90e9a8c7c9c3abf9bc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0086-rt-parent-MethodExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectwaitInterruptedException) +run(MethodExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/MethodExObjectwait.java b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/MethodExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..bcf468b95d5e1c7bd572be8a9e78fdcaa7d53655 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/MethodExObjectwait.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodExObjectwait { + static int res = 99; + private Method[] cal = MethodExObjectwait.class.getMethods(); + private Method[] cal2 = MethodExObjectwait.class.getMethods(); + private Method[] cal3 = MethodExObjectwait.class.getMethods(); + public static void main(String argv[]) { + System.out.println(new MethodExObjectwait().run()); + } + private class MethodExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (cal) { + cal.notifyAll(); + try { + cal.wait(); + MethodExObjectwait.res = MethodExObjectwait.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwait.res = MethodExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwait.res = MethodExObjectwait.res - 30; + } + } + } + } + private class MethodExObjectwait12 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal2) { + cal2.notifyAll(); + try { + cal2.wait(millis); + MethodExObjectwait.res = MethodExObjectwait.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwait.res = MethodExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwait.res = MethodExObjectwait.res - 30; + } + } + } + } + private class MethodExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (cal3) { + cal3.notifyAll(); + try { + cal3.wait(millis, nanos); + MethodExObjectwait.res = MethodExObjectwait.res - 10; + } catch (InterruptedException e1) { + MethodExObjectwait.res = MethodExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + MethodExObjectwait.res = MethodExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new MethodExObjectwait11()); + Thread t2 = new Thread(new MethodExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new MethodExObjectwait12()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new MethodExObjectwait13()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && MethodExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..499198f529759fe3e893835a5569e32d604eefa1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0087-rt-parent-MethodExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodExObjectwait) +run(MethodExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/ModifierExObjectgetClass.java b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/ModifierExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..1cb851dc607377b1f98250630c657a8d87ff23e2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/ModifierExObjectgetClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ModifierExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = modifierExObjectgetClass1(); + } catch (Exception e) { + ModifierExObjectgetClass.res = ModifierExObjectgetClass.res - 20; + } + if (result == 4 && ModifierExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int modifierExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + Modifier mf2 = new Modifier(); + Class px1 = mf2.getClass(); + if (px1.toString().equals("class java.lang.reflect.Modifier")) { + ModifierExObjectgetClass.res = ModifierExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..fc038c707c67e0b5ab96ec70ae166459b3a30b9e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0088-rt-parent-ModifierExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectgetClass) +run(ModifierExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/ModifierExObjecthashCode.java b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/ModifierExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..35f45656b2bef11ce8954ad01fbf524c9a54d549 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/ModifierExObjecthashCode.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ModifierExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = modifierExObjecthashCode1(); + } catch (Exception e) { + ModifierExObjecthashCode.res = ModifierExObjecthashCode.res - 20; + } + if (result == 4 && ModifierExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int modifierExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + Modifier mf0 = new Modifier(); + Modifier mf1 = mf0; + Modifier mf2 = new Modifier(); + int px0 = mf0.hashCode(); + int px1 = mf1.hashCode(); + int px2 = mf2.hashCode(); + if (px0 == px1 && px0 != px2) { + ModifierExObjecthashCode.res = ModifierExObjecthashCode.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cefc8ed79de95e557351356846d375429b7cc4a6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0089-rt-parent-ModifierExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjecthashCode) +run(ModifierExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/ModifierExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/ModifierExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..9c57deb54c6332fa6020fe70fc27bf55ccf0920f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/ModifierExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(new ModifierExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = modifierExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ModifierExObjectnotifyAllIllegalMonitorStateException.res = ModifierExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ModifierExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ModifierExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int modifierExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + mf2.notifyAll(); + ModifierExObjectnotifyAllIllegalMonitorStateException.res = ModifierExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectnotifyAllIllegalMonitorStateException.res = ModifierExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ModifierExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ModifierExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notifyAll(); + ModifierExObjectnotifyAllIllegalMonitorStateException.res = ModifierExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectnotifyAllIllegalMonitorStateException.res = ModifierExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b075c9498bed051f7eb3e3778cdef6860e1a3ae9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0090-rt-parent-ModifierExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectnotifyAllIllegalMonitorStateException) +run(ModifierExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/ModifierExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/ModifierExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..30e84832d13d1ff2d0a43e8e78b12a317d24ed13 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/ModifierExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectnotifyIllegalMonitorStateException { + static int res = 99; + Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(new ModifierExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = modifierExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ModifierExObjectnotifyIllegalMonitorStateException.res = ModifierExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ModifierExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ModifierExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int modifierExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + mf2.notify(); + ModifierExObjectnotifyIllegalMonitorStateException.res = ModifierExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectnotifyIllegalMonitorStateException.res = ModifierExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ModifierExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ModifierExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notify(); + ModifierExObjectnotifyIllegalMonitorStateException.res = ModifierExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectnotifyIllegalMonitorStateException.res = ModifierExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d696f0da4bd19d49d32e78686f33a0db4d99b4b3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0091-rt-parent-ModifierExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectnotifyIllegalMonitorStateException) +run(ModifierExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/ModifierExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/ModifierExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..922bc7bafaee6068fa7b2c9e923fbb8c95b7092a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/ModifierExObjectwaitInterruptedException.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectwaitInterruptedException { + static int res = 99; + private static Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(new ModifierExObjectwaitInterruptedException().run()); + } + private class ModifierExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ModifierExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(); + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ModifierExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ModifierExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ModifierExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ModifierExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwaitInterruptedException.res = ModifierExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ModifierExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ModifierExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ModifierExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && ModifierExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1663b520f4bd4838d440488700fb7afaba0ab4ae --- /dev/null +++ b/testsuite/java_test/parent_test/RT0092-rt-parent-ModifierExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectwaitInterruptedException) +run(ModifierExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/ModifierExObjectwait.java b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/ModifierExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..78293ec764ebfed926e1d91bd4077a0bfeeb2365 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/ModifierExObjectwait.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectwait { + static int res = 99; + private Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(new ModifierExObjectwait().run()); + } + private class ModifierExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ModifierExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(); + ModifierExObjectwait.res = ModifierExObjectwait.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 10; + } + } + } + } + private class ModifierExObjectwait21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ModifierExObjectwait21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notify(); + try { + mf2.wait(millis); + ModifierExObjectwait.res = ModifierExObjectwait.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 5; + } + } + } + } + private class ModifierExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ModifierExObjectwait31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + ModifierExObjectwait.res = ModifierExObjectwait.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwait.res = ModifierExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * + * @param thread want join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ModifierExObjectwait11(1)); + Thread t2 = new Thread(new ModifierExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ModifierExObjectwait21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ModifierExObjectwait31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + t1.interrupt(); + t2.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && ModifierExObjectwait.res == 54) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..baa09463cbda3ebc8661731492cc839246ec76e5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0093-rt-parent-ModifierExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectwait) +run(ModifierExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/ParameterExObjectgetClass.java b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/ParameterExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..0dd0321768763e87a7e6462c18e5ff41d5da1f5c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/ParameterExObjectgetClass.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ParameterExObjectgetClass().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterExObjectgetClass1(); + } catch (Exception e) { + System.out.println(e); + ParameterExObjectgetClass.res = ParameterExObjectgetClass.res - 20; + } + if (result == 4 && ParameterExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int parameterExObjectgetClass1() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + // System.out.println("-0-"); + Method method = Parameter01a.class.getMethod("getName", new Class[]{String.class}); + // System.out.println("-1-"); + Parameter[] parameters = method.getParameters(); + // System.out.println("-2-"); + Class px1 = parameters[0].getClass(); + // System.out.println(px1); + if (px1.toString().equals("class java.lang.reflect.Parameter")) { + ParameterExObjectgetClass.res = ParameterExObjectgetClass.res - 10; + } + return result1; + } +} +class Parameter01a { + String name = "default"; + public String getName(String str1) { + return this.name; + } +} diff --git a/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..22adf1866f79abb51dfcc004c6a7f3e785c9365f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0094-rt-parent-ParameterExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterExObjectgetClass) +run(ParameterExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/ParameterExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/ParameterExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..74b3a323afd24985349e63e0fd7157232e5a17fb --- /dev/null +++ b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/ParameterExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Parameter; +import java.lang.reflect.Method; +public class ParameterExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ParameterExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ParameterExObjectnotifyAllIllegalMonitorStateException.res = ParameterExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ParameterExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ParameterExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int parameterExObjectnotifyAllIllegalMonitorStateException1() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + Method method = Parameter03a.class.getMethod("getName", new Class[]{String.class}); + Parameter[] parameters = method.getParameters(); + try { + parameters[0].notifyAll(); + ParameterExObjectnotifyAllIllegalMonitorStateException.res = ParameterExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectnotifyAllIllegalMonitorStateException.res = ParameterExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ParameterExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ParameterExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + Method me = null; + try { + me = Parameter03a.class.getMethod("getName", new Class[]{String.class}); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + Parameter[] parameters = me.getParameters(); + synchronized (parameters[0]) { + try { + parameters[0].notifyAll(); + ParameterExObjectnotifyAllIllegalMonitorStateException.res = ParameterExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectnotifyAllIllegalMonitorStateException.res = ParameterExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} +class Parameter03a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4c13e7f146c569e14413ea6a52546caf1e5d4ca5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0095-rt-parent-ParameterExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterExObjectnotifyAllIllegalMonitorStateException) +run(ParameterExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/ParameterExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/ParameterExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..40b2def88a0b375e72b3994da93265352bebd3b9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/ParameterExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Parameter; +import java.lang.reflect.Method; +public class ParameterExObjectnotifyIllegalMonitorStateException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ParameterExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = parameterExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ParameterExObjectnotifyIllegalMonitorStateException.res = ParameterExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ParameterExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ParameterExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int parameterExObjectnotifyIllegalMonitorStateException1() throws NoSuchMethodException, SecurityException { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + Method method = Parameter02a.class.getMethod("getName", new Class[]{String.class}); + Parameter[] parameters = method.getParameters(); + try { + parameters[0].notify(); + ParameterExObjectnotifyIllegalMonitorStateException.res = ParameterExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectnotifyIllegalMonitorStateException.res = ParameterExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ParameterExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ParameterExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + Method me = null; + try { + me = Parameter02a.class.getMethod("getName", new Class[]{String.class}); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + Parameter[] parameters = me.getParameters(); + synchronized (parameters[0]) { + try { + parameters[0].notify(); + ParameterExObjectnotifyIllegalMonitorStateException.res = ParameterExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectnotifyIllegalMonitorStateException.res = ParameterExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} +class Parameter02a { + private String name = "default"; + public String getName(String str1) { + return str1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6a184ef73b89ea6fd6e016ec5644e1fa3004f922 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0096-rt-parent-ParameterExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterExObjectnotifyIllegalMonitorStateException) +run(ParameterExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/ParameterExObjectwait.java b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/ParameterExObjectwait.java new file mode 100644 index 0000000000000000000000000000000000000000..fdc0607d0d6c08b56f330d8ef50a2f733c95733f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/ParameterExObjectwait.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Parameter; +public class ParameterExObjectwait { + static int res = 99; + private static Parameter[] param = null; + public static void main(String argv[]) { + try { + param = ParameterExObjectwait.class.getMethod("sleep", new Class[]{int.class}).getParameters(); + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + System.out.println(new ParameterExObjectwait().run()); + } + private class ParameterExObjectwait_11 implements Runnable { + // final void wait() + private int remainder; + private ParameterExObjectwait_11(int remainder) { + this.remainder = remainder; + } + public void run() { + synchronized (param[0]) { + param[0].notifyAll(); + try { + param[0].wait(); + ParameterExObjectwait.res = ParameterExObjectwait.res - 15; + } catch (InterruptedException e1) { + //System.out.println("111"); + ParameterExObjectwait.res = ParameterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + //System.out.println("222"); + ParameterExObjectwait.res = ParameterExObjectwait.res - 10; + } + } + } + } + private class ParameterExObjectwait_21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ParameterExObjectwait_21(int remainder) { + this.remainder = remainder; + } + public void run() { + synchronized (param[0]) { + param[0].notify(); + try { + param[0].wait(millis); + ParameterExObjectwait.res = ParameterExObjectwait.res - 15; + } catch (InterruptedException e1) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 5; + } + } + } + } + private class ParameterExObjectwait_31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ParameterExObjectwait_31(int remainder) { + this.remainder = remainder; + } + public void run() { + synchronized (param[0]) { + param[0].notifyAll(); + try { + param[0].wait(millis, nanos); + ParameterExObjectwait.res = ParameterExObjectwait.res - 15; + } catch (InterruptedException e1) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ParameterExObjectwait.res = ParameterExObjectwait.res - 5; + } + } + } + } + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public int run() { + int result = 2; /*STATUS_FAILED*/ + //check api normal + // final void wait() + Thread t1 = new Thread(new ParameterExObjectwait_11(1)); + Thread t2 = new Thread(new ParameterExObjectwait_11(2)); + //final void wait(long millis) + Thread t3 = new Thread(new ParameterExObjectwait_21(3)); + //final void wait(long millis, int nanos) + Thread t5 = new Thread(new ParameterExObjectwait_31(5)); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + t1.interrupt(); + t2.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && ParameterExObjectwait.res == 54) { + result = 0; + } +// System.out.println("result: " + result); +// System.out.println("ParameterExObjectwait.res: " + ParameterExObjectwait.res); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..42d1a457675e69d7efae532f2a11f552c3b8c532 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0097-rt-parent-ParameterExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterExObjectwait) +run(ParameterExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/ProxyExObjecthashCode.java b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/ProxyExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..3fd44e08a73acec2f6cc90cfff6765095627d0b6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/ProxyExObjecthashCode.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +public class ProxyExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = proxyExObjecthashCode1(); + } catch (Exception e) { + ProxyExObjecthashCode.res = ProxyExObjecthashCode.res - 20; + } + if (result == 4 && ProxyExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private static int proxyExObjecthashCode1() { + // int hashCode() + int result1 = 4; /*STATUS_FAILED*/ + MyProxy1 px0 = new MyProxy1(new MyInvocationHandler()); + MyProxy1 px1 = px0; + MyProxy1 px2 = new MyProxy1(new MyInvocationHandler()); + try { + int int0 = px0.hashCode(); + int int1 = px1.hashCode(); + int int2 = px2.hashCode(); + if (px0 == px1 && px0 != px2) { + ProxyExObjecthashCode.res = ProxyExObjecthashCode.res - 10; + } + } catch (IllegalMonitorStateException e) { + ProxyExObjecthashCode.res = ProxyExObjecthashCode.res - 1; + } + return result1; + } +} +class MyProxy1 extends Proxy { + MyProxy1(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler implements InvocationHandler { + /** + * invoke test + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..96ddcd586998117e1d5be1ce98b46c9a0711d0ec --- /dev/null +++ b/testsuite/java_test/parent_test/RT0098-rt-parent-ProxyExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjecthashCode) +run(ProxyExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/ProxyExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/ProxyExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..fb1ed6df2ccb7f59f94f3c120c00431a1637e414 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/ProxyExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +public class ProxyExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private MyProxy3 proxy = new MyProxy3(new MyInvocationHandler2()); + public static void main(String argv[]) { + System.out.println(new ProxyExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = proxyExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ProxyExObjectnotifyAllIllegalMonitorStateException.res = ProxyExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ProxyExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ProxyExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int proxyExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + proxy.notifyAll(); + ProxyExObjectnotifyAllIllegalMonitorStateException.res = ProxyExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectnotifyAllIllegalMonitorStateException.res = ProxyExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ProxyExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ProxyExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + try { + proxy.notifyAll(); + ProxyExObjectnotifyAllIllegalMonitorStateException.res = ProxyExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectnotifyAllIllegalMonitorStateException.res = ProxyExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} +class MyProxy3 extends Proxy { + MyProxy3(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler2 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f3b8c8ecdf5a0935a6c1437e343374acafd31e82 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0099-rt-parent-ProxyExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectnotifyAllIllegalMonitorStateException) +run(ProxyExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/ProxyExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/ProxyExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..45227caae4d170c2ade4b38939ccdbf24fc6686f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/ProxyExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +public class ProxyExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private MyProxy2 proxy = new MyProxy2(new MyInvocationHandler1()); + public static void main(String argv[]) { + System.out.println(new ProxyExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = proxyExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ProxyExObjectnotifyIllegalMonitorStateException.res = ProxyExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ProxyExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ProxyExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int proxyExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + proxy.notify(); + ProxyExObjectnotifyIllegalMonitorStateException.res = ProxyExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectnotifyIllegalMonitorStateException.res = ProxyExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ProxyExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ProxyExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + try { + proxy.notify(); + ProxyExObjectnotifyIllegalMonitorStateException.res = ProxyExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectnotifyIllegalMonitorStateException.res = ProxyExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} +class MyProxy2 extends Proxy { + MyProxy2(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler1 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..20f1ea067b8ae1d196f38eb987d0cfb79dac1c2d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0100-rt-parent-ProxyExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectnotifyIllegalMonitorStateException) +run(ProxyExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/ProxyExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/ProxyExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..f20a2345aec41986a17320b9b698681f11d07720 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/ProxyExObjectwaitIllegalArgumentException.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +public class ProxyExObjectwaitIllegalArgumentException { + static int res = 99; + private MyProxy5 proxy = new MyProxy5(new MyInvocationHandler5()); + public static void main(String argv[]) { + System.out.println(new ProxyExObjectwaitIllegalArgumentException().run()); + } + private class ProxyExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ProxyExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis); + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ProxyExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ProxyExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis, nanos); + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwaitIllegalArgumentException.res = ProxyExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ProxyExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ProxyExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ProxyExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} +class MyProxy5 extends Proxy { + MyProxy5(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler5 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cdbe00da00ea32ed9bc3c4ba827b66254125a5e8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0101-rt-parent-ProxyExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectwaitIllegalArgumentException) +run(ProxyExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/ProxyExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/ProxyExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..5f48c09d07969c032d768e0ff34ed4c1dfdc65d5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/ProxyExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +public class ProxyExObjectwaitIllegalMonitorStateException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = proxyExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = proxyExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = proxyExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ProxyExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int proxyExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + MyProxy7 proxy = new MyProxy7(new MyInvocationHandler6()); + try { + proxy.wait(); + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int proxyExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + MyProxy7 proxy = new MyProxy7(new MyInvocationHandler6()); + long millis = 123; + try { + proxy.wait(millis); + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int proxyExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + MyProxy7 proxy = new MyProxy7(new MyInvocationHandler6()); + long millis = 123; + int nanos = 10; + try { + proxy.wait(millis, nanos); + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitIllegalMonitorStateException.res = ProxyExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} +class MyProxy7 extends Proxy { + MyProxy7(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler6 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e1be3ffc45b16f5d0ceb48106d5ac65cde529f71 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0102-rt-parent-ProxyExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectwaitIllegalMonitorStateException) +run(ProxyExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/ProxyExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/ProxyExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..7dd63783f512c5bc79a69543fe428df2e89a2477 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/ProxyExObjectwaitInterruptedException.java @@ -0,0 +1,190 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationHandler; +public class ProxyExObjectwaitInterruptedException { + static int res = 99; + private MyProxy8 proxy = new MyProxy8(new MyInvocationHandler7()); + public static void main(String argv[]) { + System.out.println(new ProxyExObjectwaitInterruptedException().run()); + } + private class ProxyExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ProxyExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(); + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ProxyExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ProxyExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis); + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ProxyExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ProxyExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis, nanos); + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwaitInterruptedException.res = ProxyExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ProxyExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ProxyExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ProxyExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && ProxyExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} +class MyProxy8 extends Proxy { + MyProxy8(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler7 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..45a454d742b900b8bc07fd1bd1c8d326bbcb7df2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0103-rt-parent-ProxyExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectwaitInterruptedException) +run(ProxyExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/ProxyExObjectwait.java b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/ProxyExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..e8b507514c60e128bc07df53e1c883fc20436a40 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/ProxyExObjectwait.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +public class ProxyExObjectwait { + static int res = 99; + private MyProxy4 proxy = new MyProxy4(new MyInvocationHandler3()); + public static void main(String argv[]) { + System.out.println(new ProxyExObjectwait().run()); + } + private class ProxyExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ProxyExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(); + ProxyExObjectwait.res = ProxyExObjectwait.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 10; + } + } + } + } + private class ProxyExObjectwait21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ProxyExObjectwait21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis); + ProxyExObjectwait.res = ProxyExObjectwait.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 5; + } + } + } + } + private class ProxyExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ProxyExObjectwait31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (proxy) { + proxy.notifyAll(); + try { + proxy.wait(millis, nanos); + ProxyExObjectwait.res = ProxyExObjectwait.res - 15; + } catch (InterruptedException e1) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ProxyExObjectwait.res = ProxyExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ProxyExObjectwait11(1)); + Thread t2 = new Thread(new ProxyExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ProxyExObjectwait21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ProxyExObjectwait31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + t2.interrupt(); + if (result == 2 && ProxyExObjectwait.res == 54) { + result = 0; + } + return result; + } +} +class MyProxy4 extends Proxy { + MyProxy4(InvocationHandler h) { + super(h); + } + InvocationHandler getInvocationHandlerField() { + return h; + } +} +class MyInvocationHandler3 implements InvocationHandler { + /** + * invoke test + * + * @param proxy proxy test + * @param method method for test + * @param args object[] for test + * @return any implementation + * @throws Throwable exception + */ + + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return new Object(); // any implementation + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a8c6633b36969316cd7688e7adf7a01ed481b572 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0104-rt-parent-ProxyExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ProxyExObjectwait) +run(ProxyExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/ReflectPermissionExBasicPermissionimplies.java b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/ReflectPermissionExBasicPermissionimplies.java new file mode 100755 index 0000000000000000000000000000000000000000..e930adb01c570bd96192deaea96ce3bcf40687ff --- /dev/null +++ b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/ReflectPermissionExBasicPermissionimplies.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExBasicPermissionimplies { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExBasicPermissionimplies1(); + } catch (Exception e) { + ReflectPermissionExBasicPermissionimplies.res = ReflectPermissionExBasicPermissionimplies.res - 20; + } + if (result == 4 && ReflectPermissionExBasicPermissionimplies.res == 89) { + result = 0; + } + return result; + } + private static int reflectPermissionExBasicPermissionimplies1() { + // boolean implies(Permission p) + int result1 = 4; /*STATUS_FAILED*/ + String name = "name"; + String actions = null; + ReflectPermission rp = new ReflectPermission(name, actions); + if (rp.implies(rp)) { + ReflectPermissionExBasicPermissionimplies.res = ReflectPermissionExBasicPermissionimplies.res - 10; + } else { + ReflectPermissionExBasicPermissionimplies.res = ReflectPermissionExBasicPermissionimplies.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/expected.txt b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/test.cfg b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c0849813eef1debdeeb5dabee001c031eada4f99 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0105-rt-parent-ReflectPermissionExBasicPermissionimplies/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExBasicPermissionimplies) +run(ReflectPermissionExBasicPermissionimplies) diff --git a/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/ReflectPermissionExObjectgetClass.java b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/ReflectPermissionExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..e774f7113072e4449dcfd84b0dfa41835896fe2c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/ReflectPermissionExObjectgetClass.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExObjectgetClass1(); + } catch (Exception e) { + ReflectPermissionExObjectgetClass.res = ReflectPermissionExObjectgetClass.res - 20; + } + if (result == 4 && ReflectPermissionExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private static int reflectPermissionExObjectgetClass1() throws ClassNotFoundException { + // final Class getClass() + int result1 = 4; /*STATUS_FAILED*/ + String name = "name"; + String actions = null; + ReflectPermission rp = new ReflectPermission(name, actions); + try { + Class cls1 = rp.getClass(); + if (cls1.toString().equals("class java.lang.reflect.ReflectPermission")) { + ReflectPermissionExObjectgetClass.res = ReflectPermissionExObjectgetClass.res - 10; + } + } catch (IllegalMonitorStateException e) { + ReflectPermissionExObjectgetClass.res = ReflectPermissionExObjectgetClass.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7f116f302338275254a6f8568e518a193fd8593a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0106-rt-parent-ReflectPermissionExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectgetClass) +run(ReflectPermissionExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..26ece96ba4647629c0cd59b6cecdb64f4c718255 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private String name = "name"; + private String actions = null; + private ReflectPermission rp = new ReflectPermission(name, actions); + public static void main(String argv[]) { + System.out.println(new ReflectPermissionExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ReflectPermissionExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int reflectPermissionExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + rp.notifyAll(); + ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ReflectPermissionExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ReflectPermissionExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notifyAll(); + ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..40780c541ff7f10920935388a8a3c69df218ed39 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0107-rt-parent-ReflectPermissionExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectnotifyAllIllegalMonitorStateException) +run(ReflectPermissionExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/ReflectPermissionExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/ReflectPermissionExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..10e234d2ce21c251b83c6522615c2c54c0c1e1ca --- /dev/null +++ b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/ReflectPermissionExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private String name = "name"; + private String actions = null; + private ReflectPermission rp = new ReflectPermission(name, actions); + public static void main(String argv[]) { + System.out.println(new ReflectPermissionExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ReflectPermissionExObjectnotifyIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ReflectPermissionExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ReflectPermissionExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int reflectPermissionExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + rp.notify(); + ReflectPermissionExObjectnotifyIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectnotifyIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ReflectPermissionExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ReflectPermissionExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notify(); + ReflectPermissionExObjectnotifyIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectnotifyIllegalMonitorStateException.res = ReflectPermissionExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..921b46e4afa84fd7678f75f3332f28eaf264b79f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0108-rt-parent-ReflectPermissionExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectnotifyIllegalMonitorStateException) +run(ReflectPermissionExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/ReflectPermissionExObjecttoString.java b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/ReflectPermissionExObjecttoString.java new file mode 100755 index 0000000000000000000000000000000000000000..f50001c62a0b73266b9e9a3fa32f4fb817e029e2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/ReflectPermissionExObjecttoString.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjecttoString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExObjecttoString1(); + } catch (Exception e) { + ReflectPermissionExObjecttoString.res = ReflectPermissionExObjecttoString.res - 20; + } + if (result == 4 && ReflectPermissionExObjecttoString.res == 89) { + result = 0; + } + return result; + } + private static int reflectPermissionExObjecttoString1() { + int result1 = 4; /*STATUS_FAILED*/ + // String toString() + String name = "name"; + String actions = null; + ReflectPermission rp = new ReflectPermission(name, actions); + try { + String str1 = rp.toString(); + if (str1.contains("java.lang.reflect.ReflectPermission")) { + ReflectPermissionExObjecttoString.res = ReflectPermissionExObjecttoString.res - 10; + } + } catch (IllegalMonitorStateException e) { + ReflectPermissionExObjecttoString.res = ReflectPermissionExObjecttoString.res - 1; + } + return result1; + } +} diff --git a/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/expected.txt b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/test.cfg b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..db282210bf66c73043a42bca5cf27c5dd761642c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0109-rt-parent-ReflectPermissionExObjecttoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjecttoString) +run(ReflectPermissionExObjecttoString) diff --git a/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/ReflectPermissionExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/ReflectPermissionExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..a6bfc4062b76a8313b103a7b5533349063fd7e61 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/ReflectPermissionExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectwaitIllegalMonitorStateException { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = reflectPermissionExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = reflectPermissionExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = reflectPermissionExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ReflectPermissionExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int reflectPermissionExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + String name = "name"; + String actions = null; + ReflectPermission rp = new ReflectPermission(name, actions); + try { + rp.wait(); + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int reflectPermissionExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + String name = "name"; + String actions = null; + long millis = 123; + ReflectPermission rp = new ReflectPermission(name, actions); + try { + rp.wait(millis); + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int reflectPermissionExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + String name = "name"; + String actions = null; + long millis = 123; + int nanos = 10; + ReflectPermission rp = new ReflectPermission(name, actions); + try { + rp.wait(millis, nanos); + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitIllegalMonitorStateException.res = ReflectPermissionExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ee5e9b5069815930ec4171b70e1abf8db43defc2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0110-rt-parent-ReflectPermissionExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectwaitIllegalMonitorStateException) +run(ReflectPermissionExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/ReflectPermissionExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/ReflectPermissionExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..11af72a75b5d4fabc14fc389deaffed381ec5094 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/ReflectPermissionExObjectwaitInterruptedException.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectwaitInterruptedException { + static int res = 99; + private static String name = "name"; + private static String action = null; + private static ReflectPermission RP = new ReflectPermission(name, action); + public static void main(String argv[]) { + System.out.println(new ReflectPermissionExObjectwaitInterruptedException().run()); + } + private class ReflectPermissionExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ReflectPermissionExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP) { + RP.notifyAll(); + try { + RP.wait(); + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ReflectPermissionExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ReflectPermissionExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP) { + RP.notifyAll(); + try { + RP.wait(millis); + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ReflectPermissionExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ReflectPermissionExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP) { + RP.notifyAll(); + try { + RP.wait(millis, nanos); + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ReflectPermissionExObjectwaitInterruptedException.res = ReflectPermissionExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ReflectPermissionExObjectwaitInterruptedException.ReflectPermissionExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ReflectPermissionExObjectwaitInterruptedException.ReflectPermissionExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ReflectPermissionExObjectwaitInterruptedException.ReflectPermissionExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && ReflectPermissionExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e256a5a088d966456e811368cee031f3a4d7c7f9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0111-rt-parent-ReflectPermissionExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectwaitInterruptedException) +run(ReflectPermissionExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/ReflectPermissionExObjectwait.java b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/ReflectPermissionExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..f49158c6f7b1a49a49d9f244f7b9e91443ba9e18 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/ReflectPermissionExObjectwait.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExObjectwait { + static int res = 99; + private String name = "name"; + private String action = null; + private ReflectPermission RP = new ReflectPermission(name, action); + private ReflectPermission RP2 = new ReflectPermission(name, action); + private ReflectPermission RP3 = new ReflectPermission(name, action); + public static void main(String argv[]) { + System.out.println(new ReflectPermissionExObjectwait().run()); + } + private class ReflectPermissionExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ReflectPermissionExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP) { + RP.notifyAll(); + try { + RP.wait(); + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 30; + } + } + } + } + private class ReflectPermissionExObjectwait12 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ReflectPermissionExObjectwait12(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP2) { + RP2.notifyAll(); + try { + RP2.wait(millis); + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 30; + } + } + } + } + private class ReflectPermissionExObjectwait13 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ReflectPermissionExObjectwait13(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (RP3) { + RP3.notifyAll(); + try { + RP3.wait(millis, nanos); + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 10; + } catch (InterruptedException e1) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ReflectPermissionExObjectwait.res = ReflectPermissionExObjectwait.res - 30; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + Thread t1 = new Thread(new ReflectPermissionExObjectwait11(1)); + Thread t2 = new Thread(new ReflectPermissionExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ReflectPermissionExObjectwait12(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ReflectPermissionExObjectwait13(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + try { + t1.join(); + t3.join(); + t5.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 2 && ReflectPermissionExObjectwait.res == 69) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b38f741a4864f16297e375de82c5c22ce082adfb --- /dev/null +++ b/testsuite/java_test/parent_test/RT0112-rt-parent-ReflectPermissionExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExObjectwait) +run(ReflectPermissionExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/ReflectPermissionExPermissioncheckGuard.java b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/ReflectPermissionExPermissioncheckGuard.java new file mode 100755 index 0000000000000000000000000000000000000000..1518dff961ef592ec9451c958353eec93bf18edd --- /dev/null +++ b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/ReflectPermissionExPermissioncheckGuard.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.ReflectPermission; +public class ReflectPermissionExPermissioncheckGuard { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = reflectPermissionExPermissioncheckGuard1(); + } catch (Exception e) { + ReflectPermissionExPermissioncheckGuard.res = ReflectPermissionExPermissioncheckGuard.res - 20; + } + if (result == 4 && ReflectPermissionExPermissioncheckGuard.res == 89) { + result = 0; + } + return result; + } + private static int reflectPermissionExPermissioncheckGuard1() { + int result1 = 4; /*STATUS_FAILED*/ + // void checkGuard(Object object) + String name = "name"; + String actions = null; + final Object obj = new Object(); + ReflectPermission rp = new ReflectPermission(name, actions); + try { + rp.checkGuard(obj); + ReflectPermissionExPermissioncheckGuard.res = ReflectPermissionExPermissioncheckGuard.res - 10; + } catch (IllegalMonitorStateException e) { + ReflectPermissionExPermissioncheckGuard.res = ReflectPermissionExPermissioncheckGuard.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/expected.txt b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/test.cfg b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6a97ccbce90ef59a9aca9ff2a1c6934a4490d052 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0113-rt-parent-ReflectPermissionExPermissioncheckGuard/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectPermissionExPermissioncheckGuard) +run(ReflectPermissionExPermissioncheckGuard) diff --git a/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/StringBufferExObjectgetClass.java b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/StringBufferExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..e639bdc5c81504ab12096ca99e87a25d8d097a86 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/StringBufferExObjectgetClass.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Class; +public class StringBufferExObjectgetClass { + static int res = 99; + private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + public static void main(String argv[]) { + System.out.println(new StringBufferExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBufferExObjectgetClass1(); + } catch (Exception e) { + StringBufferExObjectgetClass.res = StringBufferExObjectgetClass.res - 20; + } + if (result == 4 && StringBufferExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int stringBufferExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + StringBuffer sb = null; + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuffer(stringArray[i]); + } + Class px1 = sb.getClass(); + if (px1.toString().equals("class java.lang.StringBuffer")) { + StringBufferExObjectgetClass.res = StringBufferExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5808326e6b3dbbc8880bd624315a441c0925aef8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0114-rt-parent-StringBufferExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectgetClass) +run(StringBufferExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/StringBufferExObjecthashCode.java b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/StringBufferExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..843553b0a18f5cc987824a40ef77938c37fe4cff --- /dev/null +++ b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/StringBufferExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new StringBufferExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBufferExObjecthashCode1(); + } catch (Exception e) { + StringBufferExObjecthashCode.res = StringBufferExObjecthashCode.res - 20; + } + if (result == 4 && StringBufferExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int stringBufferExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + StringBuffer sb1 = new StringBuffer("aa"); + StringBuffer sb2 = sb1; + StringBuffer sb3 = new StringBuffer("╬の〆"); + if (sb1.hashCode() == sb2.hashCode() && sb1.hashCode() != sb3.hashCode()) { + StringBufferExObjecthashCode.res = StringBufferExObjecthashCode.res - 10; + } else { + StringBufferExObjecthashCode.res = StringBufferExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2cc6a4cf56f2cc05f1b53a4440952cebc40f9033 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0115-rt-parent-StringBufferExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjecthashCode) +run(StringBufferExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/StringBufferExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/StringBufferExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..d29d89e1ace59a970122db5bebb258eb2c38fa78 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/StringBufferExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuffer sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuffer(stringArray[i]); + } + System.out.println(new StringBufferExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBufferExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + StringBufferExObjectnotifyAllIllegalMonitorStateException.res = StringBufferExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringBufferExObjectnotifyAllIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringBufferExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringBufferExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + sb.notifyAll(); + StringBufferExObjectnotifyAllIllegalMonitorStateException.res = StringBufferExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectnotifyAllIllegalMonitorStateException.res = StringBufferExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringBufferExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notifyAll(); + StringBufferExObjectnotifyAllIllegalMonitorStateException.res = StringBufferExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectnotifyAllIllegalMonitorStateException.res = StringBufferExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0b417c4c1aa6372bf71e3cbc905989e65690ea8f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0116-rt-parent-StringBufferExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectnotifyAllIllegalMonitorStateException) +run(StringBufferExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/StringBufferExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/StringBufferExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..f37296a5802fce8e33af0ee26cb6c1fd5a149b2e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/StringBufferExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjectnotifyIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuffer sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuffer(stringArray[i]); + } + System.out.println(new StringBufferExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBufferExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + StringBufferExObjectnotifyIllegalMonitorStateException.res = StringBufferExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringBufferExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringBufferExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringBufferExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + sb.notify(); + StringBufferExObjectnotifyIllegalMonitorStateException.res = StringBufferExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectnotifyIllegalMonitorStateException.res = StringBufferExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringBufferExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notify(); + StringBufferExObjectnotifyIllegalMonitorStateException.res = StringBufferExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectnotifyIllegalMonitorStateException.res = StringBufferExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} diff --git a/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..146ef943c72d402ea4293f61835823b61d5e22ee --- /dev/null +++ b/testsuite/java_test/parent_test/RT0117-rt-parent-StringBufferExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectnotifyIllegalMonitorStateException) +run(StringBufferExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/StringBufferExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/StringBufferExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..e3eab6deb9de40d64c61d5860e2b5d3c4feeea37 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/StringBufferExObjectwaitIllegalArgumentException.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjectwaitIllegalArgumentException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuffer mf2 = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + mf2 = new StringBuffer(stringArray[i]); + } + System.out.println(new StringBufferExObjectwaitIllegalArgumentException().run()); + } + private class StringBufferExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class StringBufferExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringBufferExObjectwaitIllegalArgumentException.res = StringBufferExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new StringBufferExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringBufferExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && StringBufferExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e3610bd4a31a609a7a61399a10e465abbfa6a072 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0118-rt-parent-StringBufferExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectwaitIllegalArgumentException) +run(StringBufferExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/StringBufferExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/StringBufferExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..9fc8706525265c7375b601c06a7476a7064566b3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/StringBufferExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjectwaitIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuffer mf2 = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + mf2 = new StringBuffer(stringArray[i]); + } + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = stringBufferExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = stringBufferExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = stringBufferExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && StringBufferExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int stringBufferExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + mf2.wait(); + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringBufferExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + mf2.wait(millis); + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringBufferExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + mf2.wait(millis, nanos); + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwaitIllegalMonitorStateException.res = StringBufferExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..fe0455c95d55e50b9f7bfde2a3d5b2b460835644 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0119-rt-parent-StringBufferExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectwaitIllegalMonitorStateException) +run(StringBufferExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/StringBufferExObjectwait.java b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/StringBufferExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..020291b4adedec982bb05f8df40e38273b851d9a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/StringBufferExObjectwait.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuffer; +public class StringBufferExObjectwait { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuffer sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuffer(stringArray[i]); + } + System.out.println(new StringBufferExObjectwait().run()); + } + private class StringBufferExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(); + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 15; + } catch (InterruptedException e1) { + // System.out.println("111"); + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + System.out.println("222"); + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 10; + } + } + } + } + private class StringBufferExObjectwait21 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notify(); + try { + sb.wait(millis); + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 5; + } + } + } + } + private class StringBufferExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(millis, nanos); + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringBufferExObjectwait.res = StringBufferExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new StringBufferExObjectwait11()); + Thread t2 = new Thread(new StringBufferExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new StringBufferExObjectwait21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringBufferExObjectwait31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && StringBufferExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..37f38c5f2ae93c2a052e96e02356a44045af8be9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0120-rt-parent-StringBufferExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExObjectwait) +run(StringBufferExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/StringBuilderExObjectgetClass.java b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/StringBuilderExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..f0b79173852f89b286e777410cf32d02e62e183e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/StringBuilderExObjectgetClass.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.String; +public class StringBuilderExObjectgetClass { + static int res = 99; + private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + public static void main(String argv[]) { + System.out.println(new StringBuilderExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBuilderExObjectgetClass1(); + } catch (Exception e) { + StringBuilderExObjectgetClass.res = StringBuilderExObjectgetClass.res - 20; + } + if (result == 4 && StringBuilderExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int stringBuilderExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + StringBuilder sb = null; + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuilder(stringArray[i]); + } + Class px1 = sb.getClass(); + if (px1.toString().equals("class java.lang.StringBuilder")) { + StringBuilderExObjectgetClass.res = StringBuilderExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6cbef43a4eb97610db2102da2c92bc5d8fe8c924 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0121-rt-parent-StringBuilderExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectgetClass) +run(StringBuilderExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/StringBuilderExObjecthashCode.java b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/StringBuilderExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..770f6d8a5b4b02e53e34598728acb79ecbe2cb1f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/StringBuilderExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new StringBuilderExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBuilderExObjecthashCode1(); + } catch (Exception e) { + StringBuilderExObjecthashCode.res = StringBuilderExObjecthashCode.res - 20; + } + if (result == 4 && StringBuilderExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int stringBuilderExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + StringBuilder sb1 = new StringBuilder("aa"); + StringBuilder sb2 = sb1; + StringBuilder sb3 = new StringBuilder("╬の〆"); + if (sb1.hashCode() == sb2.hashCode() && sb1.hashCode() != sb3.hashCode()) { + StringBuilderExObjecthashCode.res = StringBuilderExObjecthashCode.res - 10; + } else { + StringBuilderExObjecthashCode.res = StringBuilderExObjecthashCode.res - 5; + } + return result1; + } +} diff --git a/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4b27fdf2ce630b38a39dd9143d202f0837841978 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0122-rt-parent-StringBuilderExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjecthashCode) +run(StringBuilderExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/StringBuilderExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/StringBuilderExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..eb32bee3aae3060e592b348c1cf4dd0e0bb04f54 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/StringBuilderExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuilder sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuilder(stringArray[i]); + } + System.out.println(new StringBuilderExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBuilderExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + StringBuilderExObjectnotifyAllIllegalMonitorStateException.res = StringBuilderExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringBuilderExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringBuilderExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringBuilderExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + sb.notifyAll(); + StringBuilderExObjectnotifyAllIllegalMonitorStateException.res = StringBuilderExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectnotifyAllIllegalMonitorStateException.res = StringBuilderExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringBuilderExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private StringBuilderExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notifyAll(); + StringBuilderExObjectnotifyAllIllegalMonitorStateException.res = StringBuilderExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectnotifyAllIllegalMonitorStateException.res = StringBuilderExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..71ed6d36639714feb58f1669c7237771c28c05f9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0123-rt-parent-StringBuilderExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectnotifyAllIllegalMonitorStateException) +run(StringBuilderExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/StringBuilderExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/StringBuilderExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..6d9a3adbf473b0606cb4683febda66fc62be24d2 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/StringBuilderExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjectnotifyIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuilder sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuilder(stringArray[i]); + } + System.out.println(new StringBuilderExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringBuilderExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + StringBuilderExObjectnotifyIllegalMonitorStateException.res = StringBuilderExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringBuilderExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringBuilderExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringBuilderExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + sb.notify(); + StringBuilderExObjectnotifyIllegalMonitorStateException.res = StringBuilderExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectnotifyIllegalMonitorStateException.res = StringBuilderExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringBuilderExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private StringBuilderExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notify(); + StringBuilderExObjectnotifyIllegalMonitorStateException.res = StringBuilderExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectnotifyIllegalMonitorStateException.res = StringBuilderExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9108c3bbab50ffe951842c3a9dd7ccfa2b9befd7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0124-rt-parent-StringBuilderExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectnotifyIllegalMonitorStateException) +run(StringBuilderExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/StringBuilderExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/StringBuilderExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..eea47c9dc192ef03f374ef861f512e713e32f69a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/StringBuilderExObjectwaitIllegalArgumentException.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjectwaitIllegalArgumentException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuilder mf2 = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + mf2 = new StringBuilder(stringArray[i]); + } + System.out.println(new StringBuilderExObjectwaitIllegalArgumentException().run()); + } + private class StringBuilderExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private StringBuilderExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class StringBuilderExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private StringBuilderExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringBuilderExObjectwaitIllegalArgumentException.res = StringBuilderExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new StringBuilderExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringBuilderExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && StringBuilderExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..99941f969217604cf57b8b285f3f383c3165c6f4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0125-rt-parent-StringBuilderExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectwaitIllegalArgumentException) +run(StringBuilderExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/StringBuilderExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/StringBuilderExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..459ea721a0ae12219168f2ff9d6688b2b635ac6e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/StringBuilderExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjectwaitIllegalMonitorStateException { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuilder mf2 = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + mf2 = new StringBuilder(stringArray[i]); + } + System.out.println(run()); + } + /** + * main test fun + * + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = stringBuilderExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = stringBuilderExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = stringBuilderExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && StringBuilderExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int stringBuilderExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + mf2.wait(); + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringBuilderExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + mf2.wait(millis); + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringBuilderExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + mf2.wait(millis, nanos); + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwaitIllegalMonitorStateException.res = StringBuilderExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f18649a988262ae12015738216e8bd449f1295b5 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0126-rt-parent-StringBuilderExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectwaitIllegalMonitorStateException) +run(StringBuilderExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/StringBuilderExObjectwait.java b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/StringBuilderExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..78c4e5d3e02048f516a9d34cf747fa914849b73b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/StringBuilderExObjectwait.java @@ -0,0 +1,192 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.StringBuilder; +public class StringBuilderExObjectwait { + static int res = 99; + static private String[] stringArray = { + "", "a", "b", "c", "ab", "ac", "abc", "aaaabbbccc" + }; + static private StringBuilder sb = null; + public static void main(String argv[]) { + for (int i = 0; i < stringArray.length; i++) { + sb = new StringBuilder(stringArray[i]); + } + System.out.println(new StringBuilderExObjectwait().run()); + } + private class StringBuilderExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private StringBuilderExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(); + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 15; + } catch (InterruptedException e1) { + // System.out.println("111"); + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + // System.out.println("222"); + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 10; + } + } + } + } + private class StringBuilderExObjectwait21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private StringBuilderExObjectwait21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notify(); + try { + sb.wait(millis); + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 5; + } + } + } + } + private class StringBuilderExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private StringBuilderExObjectwait31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(millis, nanos); + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringBuilderExObjectwait.res = StringBuilderExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new StringBuilderExObjectwait11(1)); + Thread t2 = new Thread(new StringBuilderExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new StringBuilderExObjectwait21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringBuilderExObjectwait31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t3.start(); + sleep(100); + t5.start(); + sleep(100); + t2.start(); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && StringBuilderExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..06c2a79129a43ad212ceb66f78f465d2ab3cf0fc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0127-rt-parent-StringBuilderExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExObjectwait) +run(StringBuilderExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/StringExObjectgetClass.java b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/StringExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..52dad43415907a5e8290dd4ff33622482a7840b4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/StringExObjectgetClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Class; +public class StringExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new StringExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringExObjectgetClass1(); + } catch (Exception e) { + StringExObjectgetClass.res = StringExObjectgetClass.res - 20; + } + if (result == 4 && StringExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int stringExObjectgetClass1() { + // final Class getClass() + int result1 = 4; /*STATUS_FAILED*/ + String tr2 = "this is a test"; + Class cls1 = tr2.getClass(); + if (cls1.toString().equals("class java.lang.String")) { + StringExObjectgetClass.res = StringExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3024c68173fd3063346d133e43cd311051e9d79f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0128-rt-parent-StringExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectgetClass) +run(StringExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/StringExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/StringExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..7f1e9a41dd6e684636e4c001a3231475a8284c9a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/StringExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class StringExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + String mf2 = "this is a test"; + public static void main(String argv[]) { + System.out.println(new StringExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + StringExObjectnotifyAllIllegalMonitorStateException.res = StringExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringExObjectnotifyAllIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + mf2.notifyAll(); + StringExObjectnotifyAllIllegalMonitorStateException.res = StringExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringExObjectnotifyAllIllegalMonitorStateException.res = StringExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notifyAll(); + StringExObjectnotifyAllIllegalMonitorStateException.res = StringExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringExObjectnotifyAllIllegalMonitorStateException.res = StringExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1644061d178f0ace3ef1c6167becd50bcb50a205 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0129-rt-parent-StringExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectnotifyAllIllegalMonitorStateException) +run(StringExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/StringExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/StringExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..2af46cd67ebe1ade63825e33400d1e000739d112 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/StringExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class StringExObjectnotifyIllegalMonitorStateException { + static int res = 99; + String mf2 = "this is a test"; + public static void main(String argv[]) { + System.out.println(new StringExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = stringExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + StringExObjectnotifyIllegalMonitorStateException.res = StringExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new StringExObjectnotifyIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && StringExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int stringExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + mf2.notify(); + StringExObjectnotifyIllegalMonitorStateException.res = StringExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + StringExObjectnotifyIllegalMonitorStateException.res = StringExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class StringExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + try { + mf2.notify(); + StringExObjectnotifyIllegalMonitorStateException.res = StringExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + StringExObjectnotifyIllegalMonitorStateException.res = StringExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..af76da9b957bf5015614ef81e161d3db2332b110 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0130-rt-parent-StringExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectnotifyIllegalMonitorStateException) +run(StringExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/StringExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/StringExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..588238820b39760cb83634a1dd9f1b0cf4961d3d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/StringExObjectwaitIllegalArgumentException.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class StringExObjectwaitIllegalArgumentException { + static int res = 99; + private static String mf2 = "this is a test"; + public static void main(String argv[]) { + System.out.println(new StringExObjectwaitIllegalArgumentException().run()); + } + private class StringExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + long millis = -1; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class StringExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + long millis = -2; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + StringExObjectwaitIllegalArgumentException.res = StringExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new StringExObjectwaitIllegalArgumentException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringExObjectwaitIllegalArgumentException31()); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && StringExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..999db5c00a3ccec826780e56dd424fd0615344f0 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0131-rt-parent-StringExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectwaitIllegalArgumentException) +run(StringExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/StringExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/StringExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..b8e3443a3086325f88cacb6858777f490eaa97b6 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/StringExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class StringExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static String mf2 = "this is a test"; + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = stringExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = stringExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = stringExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && StringExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int stringExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + mf2.wait(); + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + mf2.wait(millis); + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int stringExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + mf2.wait(millis, nanos); + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + StringExObjectwaitIllegalMonitorStateException.res = StringExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4e967bad18a4ac66ba23a09cd0109417700a5b72 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0132-rt-parent-StringExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectwaitIllegalMonitorStateException) +run(StringExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/StringExObjectwait.java b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/StringExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..84d3f57686fff6e859c3a9d2693a9536b56d9f3c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/StringExObjectwait.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class StringExObjectwait { + static int res = 99; + private String mf2 = "this is a test"; + static Thread t2; + public static void main(String argv[]) { + System.out.println(new StringExObjectwait().run()); + t2.interrupt(); + } + private class StringExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(); + StringExObjectwait.res = StringExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringExObjectwait.res = StringExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringExObjectwait.res = StringExObjectwait.res - 10; + } + } + } + } + private class StringExObjectwait21 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notify(); + try { + mf2.wait(millis); + StringExObjectwait.res = StringExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringExObjectwait.res = StringExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringExObjectwait.res = StringExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringExObjectwait.res = StringExObjectwait.res - 5; + } + } + } + } + private class StringExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + StringExObjectwait.res = StringExObjectwait.res - 15; + } catch (InterruptedException e1) { + StringExObjectwait.res = StringExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + StringExObjectwait.res = StringExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + StringExObjectwait.res = StringExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new StringExObjectwait11()); + t2 = new Thread(new StringExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new StringExObjectwait21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new StringExObjectwait31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && StringExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b45c95bd35bc27d333eab88394ff4645c82cad45 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0133-rt-parent-StringExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringExObjectwait) +run(StringExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/ThreadExObjecthashCode.java b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/ThreadExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..8f2c333a8f57c3ab2a87c4c23ad085d818e93206 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/ThreadExObjecthashCode.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadExObjecthashCode1(); + } catch (Exception e) { + ThreadExObjecthashCode.res = ThreadExObjecthashCode.res - 20; + } + if (result == 4 && ThreadExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int threadExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + Thread thr1 = new Thread(); + Thread thr2 = thr1; + Thread thr3 = new Thread(); + thr1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + thr2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + thr3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + if (thr1.hashCode() == thr2.hashCode() && thr1.hashCode() != thr3.hashCode()) { + ThreadExObjecthashCode.res = ThreadExObjecthashCode.res - 10; + } else { + ThreadExObjecthashCode.res = ThreadExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..63911350ffbdb6986809f1fcebe01fe4df232ba9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0134-rt-parent-ThreadExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjecthashCode) +run(ThreadExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/ThreadExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/ThreadExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..72936a40f993cf461a018ad001daf3ddb0851fa8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/ThreadExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + Thread sb = new Thread(); + public static void main(String argv[]) { + System.out.println(new ThreadExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadExObjectnotifyAllIllegalMonitorStateException.res = ThreadExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + sb.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + sb.notifyAll(); + ThreadExObjectnotifyAllIllegalMonitorStateException.res = ThreadExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectnotifyAllIllegalMonitorStateException.res = ThreadExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ThreadExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notifyAll(); + ThreadExObjectnotifyAllIllegalMonitorStateException.res = ThreadExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectnotifyAllIllegalMonitorStateException.res = ThreadExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2b6287c26a447bfc0d3e884e89ff1f2b3cd86b57 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0135-rt-parent-ThreadExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjectnotifyAllIllegalMonitorStateException) +run(ThreadExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/ThreadExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/ThreadExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..c36d689f3361e11ecc56e962f3e79d45d8e87666 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/ThreadExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjectnotifyIllegalMonitorStateException { + static int res = 99; + Thread sb = new Thread(); + public static void main(String argv[]) { + System.out.println(new ThreadExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadExObjectnotifyIllegalMonitorStateException.res = ThreadExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + sb.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + sb.notify(); + ThreadExObjectnotifyIllegalMonitorStateException.res = ThreadExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectnotifyIllegalMonitorStateException.res = ThreadExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ThreadExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + try { + sb.notify(); + ThreadExObjectnotifyIllegalMonitorStateException.res = ThreadExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectnotifyIllegalMonitorStateException.res = ThreadExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..eb4623dd98bc1a64b2040c4967e8a95112c2d3e9 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0136-rt-parent-ThreadExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjectnotifyIllegalMonitorStateException) +run(ThreadExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/ThreadExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/ThreadExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..b55744f1eef0db3980c3c1dfb8552931560bed82 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/ThreadExObjectwaitIllegalArgumentException.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjectwaitIllegalArgumentException { + static int res = 99; + private Thread mf2 = new Thread(); + public static void main(String argv[]) { + System.out.println(new ThreadExObjectwaitIllegalArgumentException().run()); + } + private class ThreadExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ThreadExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ThreadExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ThreadExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadExObjectwaitIllegalArgumentException.res = ThreadExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ThreadExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadExObjectwaitIllegalArgumentException31(5)); + mf2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ThreadExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8936198013f83dc65b710457e0573027ab0c72d4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0137-rt-parent-ThreadExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjectwaitIllegalArgumentException) +run(ThreadExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/ThreadExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/ThreadExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..1f636d4791baa1a991044f510da1afe50d66770c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/ThreadExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjectwaitIllegalMonitorStateException { + static int res = 99; + static Thread mf2 = new Thread(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + mf2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + // final void wait() + try { + result = threadExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = threadExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = threadExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ThreadExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int threadExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + mf2.wait(); + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + mf2.wait(millis); + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + mf2.wait(millis, nanos); + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwaitIllegalMonitorStateException.res = ThreadExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6c87c114a27146f84f2c54b384cd5c96ed1e9396 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0138-rt-parent-ThreadExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjectwaitIllegalMonitorStateException) +run(ThreadExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/ThreadExObjectwait.java b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/ThreadExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..ea8628a2e66456b70c16363fc92ae8cba2a6334c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/ThreadExObjectwait.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadExObjectwait { + static int res = 99; + Thread sb = new Thread(); + public static void main(String argv[]) { + System.out.println(new ThreadExObjectwait().run()); + } + private class ThreadExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ThreadExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(); + ThreadExObjectwait.res = ThreadExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 10; + } + } + } + } + private class ThreadExObjectwait21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ThreadExObjectwait21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notify(); + try { + sb.wait(millis); + ThreadExObjectwait.res = ThreadExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 5; + } + } + } + } + private class ThreadExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ThreadExObjectwait31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (sb) { + sb.notifyAll(); + try { + sb.wait(millis, nanos); + ThreadExObjectwait.res = ThreadExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ThreadExObjectwait.res = ThreadExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private void sbSetUncaught() { + sb.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ThreadExObjectwait11(1)); + Thread t2 = new Thread(new ThreadExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ThreadExObjectwait21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadExObjectwait31(5)); + sbSetUncaught(); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && ThreadExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d264133c50ab0ef40d081cf5abddd6c3b64c3764 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0139-rt-parent-ThreadExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadExObjectwait) +run(ThreadExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/ThreadGroupExObjectequals.java b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/ThreadGroupExObjectequals.java new file mode 100755 index 0000000000000000000000000000000000000000..cebe8076c531bd8d02b3a78ba89f7ee2bb7bcb07 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/ThreadGroupExObjectequals.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjectequals { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectequals().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjectequals1(); + } catch (Exception e) { + ThreadGroupExObjectequals.res = ThreadGroupExObjectequals.res - 20; + } + if (result == 4 && ThreadGroupExObjectequals.res == 89) { + result = 0; + } + return result; + } + private int threadGroupExObjectequals1() { + int result1 = 4; /*STATUS_FAILED*/ + // boolean equals(Object obj) + ThreadGroup gr1 = new ThreadGroup("Thread3251"); + ThreadGroup gr2 = new ThreadGroup("Thread3252"); + boolean ret = gr1.equals(gr2); + if (!ret) { + ThreadGroupExObjectequals.res = ThreadGroupExObjectequals.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/expected.txt b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/test.cfg b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4c265c7d5e3400c07edf043393174f5eaee7827f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0140-rt-parent-ThreadGroupExObjectequals/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectequals) +run(ThreadGroupExObjectequals) diff --git a/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/ThreadGroupExObjectgetClass.java b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/ThreadGroupExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..00eaba73bd3493ad744222c2735eed1dae7fb45d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/ThreadGroupExObjectgetClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjectgetClass1(); + } catch (Exception e) { + ThreadGroupExObjectgetClass.res = ThreadGroupExObjectgetClass.res - 20; + } + if (result == 4 && ThreadGroupExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int threadGroupExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + ThreadGroup gr1 = new ThreadGroup("Thread8023"); + Class px1 = gr1.getClass(); + if (px1.toString().equals("class java.lang.ThreadGroup")) { + ThreadGroupExObjectgetClass.res = ThreadGroupExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2b80b90ef799526f76b4d53149db87d2523f3745 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0141-rt-parent-ThreadGroupExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectgetClass) +run(ThreadGroupExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/ThreadGroupExObjecthashCode.java b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/ThreadGroupExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..7e5db6aa16151f97ea64851c607b79ac45d23f4c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/ThreadGroupExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadGroup; +public class ThreadGroupExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjecthashCode1(); + } catch (Exception e) { + ThreadGroupExObjecthashCode.res = ThreadGroupExObjecthashCode.res - 20; + } + if (result == 4 && ThreadGroupExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int threadGroupExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + ThreadGroup gr1 = new ThreadGroup("Thread8023"); + ThreadGroup gr2 = gr1; + ThreadGroup gr3 = new ThreadGroup("Thread1988"); + if (gr1.hashCode() == gr2.hashCode() && gr1.hashCode() != gr3.hashCode()) { + ThreadGroupExObjecthashCode.res = ThreadGroupExObjecthashCode.res - 10; + } else { + ThreadGroupExObjecthashCode.res = ThreadGroupExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..eb4a47ae0759c602c593ea26dbf881e7e8a6030c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0142-rt-parent-ThreadGroupExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjecthashCode) +run(ThreadGroupExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/ThreadGroupExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/ThreadGroupExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..3280abae72ca377261a52209bd99dcc456d29138 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/ThreadGroupExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + ThreadGroup gr1 = new ThreadGroup("Thread8023"); + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res = ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadGroupExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadGroupExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + gr1.notifyAll(); + ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res = ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res = ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadGroupExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ThreadGroupExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + try { + gr1.notifyAll(); + ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res = ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res = ThreadGroupExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a64215c85eeb2454db1ebffd24d211d6c65ea781 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0143-rt-parent-ThreadGroupExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectnotifyAllIllegalMonitorStateException) +run(ThreadGroupExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/ThreadGroupExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/ThreadGroupExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..44f112b73d1d5ef4dba51b55c9aadee2baff8c0d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/ThreadGroupExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private ThreadGroup gr1 = new ThreadGroup("Thread8023"); + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadGroupExObjectnotifyIllegalMonitorStateException.res = ThreadGroupExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadGroupExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadGroupExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadGroupExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + gr1.notify(); + ThreadGroupExObjectnotifyIllegalMonitorStateException.res = ThreadGroupExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectnotifyIllegalMonitorStateException.res = ThreadGroupExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadGroupExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ThreadGroupExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + try { + gr1.notify(); + ThreadGroupExObjectnotifyIllegalMonitorStateException.res = ThreadGroupExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectnotifyIllegalMonitorStateException.res = ThreadGroupExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a6a97cef11bae2e265218a5f80897ecf8e5560ba --- /dev/null +++ b/testsuite/java_test/parent_test/RT0144-rt-parent-ThreadGroupExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectnotifyIllegalMonitorStateException) +run(ThreadGroupExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/ThreadGroupExObjecttoString.java b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/ThreadGroupExObjecttoString.java new file mode 100755 index 0000000000000000000000000000000000000000..5a88cc31a4857728f6cb7365ab23dbd2a9d6b6ce --- /dev/null +++ b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/ThreadGroupExObjecttoString.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjecttoString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjecttoString().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadGroupExObjecttoString1(); + } catch (Exception e) { + ThreadGroupExObjecttoString.res = ThreadGroupExObjecttoString.res - 20; + } + if (result == 4 && ThreadGroupExObjecttoString.res == 89) { + result = 0; + } + return result; + } + private int threadGroupExObjecttoString1() { + int result1 = 4; /*STATUS_FAILED*/ + // String toString() + ThreadGroup gr1 = new ThreadGroup("Thread8023"); + String str1 = gr1.toString(); + if (str1.equals("java.lang.ThreadGroup[name=Thread8023,maxpri=10]")) { + ThreadGroupExObjecttoString.res = ThreadGroupExObjecttoString.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/expected.txt b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/test.cfg b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..68326f825c533a398b7408e832f1019696231aa8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0145-rt-parent-ThreadGroupExObjecttoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjecttoString) +run(ThreadGroupExObjecttoString) diff --git a/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/ThreadGroupExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/ThreadGroupExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..4e52ce1ebc88bdc9b49bc649b78bf6d00cec22d4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/ThreadGroupExObjectwaitIllegalArgumentException.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadGroupExObjectwaitIllegalArgumentException { + static int res = 99; + ThreadGroup gr1 = new ThreadGroup("Thread8023"); + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectwaitIllegalArgumentException().run()); + } + private class ThreadGroupExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ThreadGroupExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + gr1.notifyAll(); + try { + gr1.wait(millis); + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ThreadGroupExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ThreadGroupExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + gr1.notifyAll(); + try { + gr1.wait(millis, nanos); + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadGroupExObjectwaitIllegalArgumentException.res = ThreadGroupExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ThreadGroupExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadGroupExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ThreadGroupExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5f6acfef50743cba4975cd4b45bce05619b77915 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0146-rt-parent-ThreadGroupExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectwaitIllegalArgumentException) +run(ThreadGroupExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/ThreadGroupExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/ThreadGroupExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..9eedd495427e72bde2a241cc8cf3175ed1ba2a6b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/ThreadGroupExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadGroup; +public class ThreadGroupExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static ThreadGroup gr1 = new ThreadGroup("Thread8023"); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = threadGroupExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = threadGroupExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = threadGroupExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ThreadGroupExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int threadGroupExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + gr1.wait(); + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadGroupExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + gr1.wait(millis); + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadGroupExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + gr1.wait(millis, nanos); + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitIllegalMonitorStateException.res = ThreadGroupExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b300124832c9ac1198cd8001ad99ccee0b8a18ea --- /dev/null +++ b/testsuite/java_test/parent_test/RT0147-rt-parent-ThreadGroupExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectwaitIllegalMonitorStateException) +run(ThreadGroupExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/ThreadGroupExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/ThreadGroupExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..4f569b070d956b2e83afd4f098f0880e4daa32e4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/ThreadGroupExObjectwaitInterruptedException.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadGroup; +public class ThreadGroupExObjectwaitInterruptedException { + static int res = 99; + private static ThreadGroup gr1 = new ThreadGroup("Thread8023"); + public static void main(String argv[]) { + System.out.println(new ThreadGroupExObjectwaitInterruptedException().run()); + } + private class ThreadGroupExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ThreadGroupExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + gr1.notifyAll(); + try { + gr1.wait(); + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ThreadGroupExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ThreadGroupExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + gr1.notifyAll(); + try { + gr1.wait(millis); + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ThreadGroupExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ThreadGroupExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (gr1) { + gr1.notifyAll(); + try { + gr1.wait(millis, nanos); + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadGroupExObjectwaitInterruptedException.res = ThreadGroupExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ThreadGroupExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ThreadGroupExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadGroupExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && ThreadGroupExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1f0fe3f269aa9c4e98a6179afa79c42b68972feb --- /dev/null +++ b/testsuite/java_test/parent_test/RT0148-rt-parent-ThreadGroupExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadGroupExObjectwaitInterruptedException) +run(ThreadGroupExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/ThreadLocalExObjectgetClass.java b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/ThreadLocalExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..c171e7a34cd9db597fb91bbffdb2d482578da143 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/ThreadLocalExObjectgetClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadLocal; +public class ThreadLocalExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjectgetClass().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadLocalExObjectgetClass1(); + } catch (Exception e) { + ThreadLocalExObjectgetClass.res = ThreadLocalExObjectgetClass.res - 20; + } + if (result == 4 && ThreadLocalExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int threadLocalExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + ThreadLocal threadLocal1 = new ThreadLocal(); + Class px1 = threadLocal1.getClass(); + if (px1.toString().equals("class java.lang.ThreadLocal")) { + ThreadLocalExObjectgetClass.res = ThreadLocalExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3b64cdff65d00b6f45fd72111b172481cd57ac88 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0149-rt-parent-ThreadLocalExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectgetClass) +run(ThreadLocalExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/ThreadLocalExObjecthashCode.java b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/ThreadLocalExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..a1aabca116735c7ec4dcf54ec2d32bf7854e5495 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/ThreadLocalExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadLocal; +public class ThreadLocalExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadLocalExObjecthashCode1(); + } catch (Exception e) { + ThreadLocalExObjecthashCode.res = ThreadLocalExObjecthashCode.res - 20; + } + if (result == 4 && ThreadLocalExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int threadLocalExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + ThreadLocal threadLocal1 = new ThreadLocal(); + ThreadLocal threadLocal2 = threadLocal1; + ThreadLocal threadLocal3 = new ThreadLocal(); + if (threadLocal1.hashCode() == threadLocal2.hashCode() && threadLocal1.hashCode() != threadLocal3.hashCode()) { + ThreadLocalExObjecthashCode.res = ThreadLocalExObjecthashCode.res - 10; + } else { + ThreadLocalExObjecthashCode.res = ThreadLocalExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..dbc1db68e8f97a3bb197ee4881115ab57b1ad7b3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0150-rt-parent-ThreadLocalExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjecthashCode) +run(ThreadLocalExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/ThreadLocalExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/ThreadLocalExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..affbbf64d2e13dcd33a7a7bef8df2e13d66c37ba --- /dev/null +++ b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/ThreadLocalExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadLocalExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + ThreadLocal tl1 = new ThreadLocal(); + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadLocalExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res = ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadLocalExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadLocalExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + tl1.notifyAll(); + ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res = ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res = ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadLocalExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ThreadLocalExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + try { + tl1.notifyAll(); + ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res = ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res = ThreadLocalExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ee7059919e94bf2985ff140277e92aba6bb224a4 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0151-rt-parent-ThreadLocalExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectnotifyAllIllegalMonitorStateException) +run(ThreadLocalExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/ThreadLocalExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/ThreadLocalExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..46fe8e42d287307e37a65192935e4b1fc532c23c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/ThreadLocalExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadLocal; +public class ThreadLocalExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private ThreadLocal tl1 = new ThreadLocal(); + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadLocalExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadLocalExObjectnotifyIllegalMonitorStateException.res = ThreadLocalExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThreadLocalExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThreadLocalExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int threadLocalExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + tl1.notify(); + ThreadLocalExObjectnotifyIllegalMonitorStateException.res = ThreadLocalExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectnotifyIllegalMonitorStateException.res = ThreadLocalExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThreadLocalExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ThreadLocalExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + try { + tl1.notify(); + ThreadLocalExObjectnotifyIllegalMonitorStateException.res = ThreadLocalExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectnotifyIllegalMonitorStateException.res = ThreadLocalExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1c31a2206e2f36ee3e5f51f69a64aad7d5465add --- /dev/null +++ b/testsuite/java_test/parent_test/RT0152-rt-parent-ThreadLocalExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectnotifyIllegalMonitorStateException) +run(ThreadLocalExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/ThreadLocalExObjecttoString.java b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/ThreadLocalExObjecttoString.java new file mode 100755 index 0000000000000000000000000000000000000000..89a75ced3818f511c7cb013e132091a122c81574 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/ThreadLocalExObjecttoString.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ThreadLocal; +public class ThreadLocalExObjecttoString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjecttoString().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = threadLocalExObjecttoString1(); + } catch (Exception e) { + ThreadLocalExObjecttoString.res = ThreadLocalExObjecttoString.res - 20; + } + if (result == 4 && ThreadLocalExObjecttoString.res == 89) { + result = 0; + } + return result; + } + private int threadLocalExObjecttoString1() { + int result1 = 4; /*STATUS_FAILED*/ + // String toString() + ThreadLocal threadLocal1 = new ThreadLocal(); + String str1 = threadLocal1.toString(); + if (str1.contains("java.lang.ThreadLocal")) { + ThreadLocalExObjecttoString.res = ThreadLocalExObjecttoString.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/expected.txt b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/test.cfg b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..efe2c051154feb27f19b3cebab63c79ad6b2f824 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0153-rt-parent-ThreadLocalExObjecttoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjecttoString) +run(ThreadLocalExObjecttoString) diff --git a/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/ThreadLocalExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/ThreadLocalExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..985fed1fce71a183ef83eaeb55c275014bcfcfc3 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/ThreadLocalExObjectwaitIllegalArgumentException.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadLocalExObjectwaitIllegalArgumentException { + static int res = 99; + ThreadLocal tl1 = new ThreadLocal(); + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjectwaitIllegalArgumentException().run()); + } + private class ThreadLocalExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ThreadLocalExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + tl1.notifyAll(); + try { + tl1.wait(millis); + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ThreadLocalExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ThreadLocalExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + tl1.notifyAll(); + try { + tl1.wait(millis, nanos); + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadLocalExObjectwaitIllegalArgumentException.res = ThreadLocalExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ThreadLocalExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadLocalExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ThreadLocalExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ce3cfbbff699837fad8243877484ddb101fc4173 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0154-rt-parent-ThreadLocalExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectwaitIllegalArgumentException) +run(ThreadLocalExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/ThreadLocalExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/ThreadLocalExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..4c004e67e584c32594a4554adcb93f4f81573aea --- /dev/null +++ b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/ThreadLocalExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadLocalExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static ThreadLocal tl1 = new ThreadLocal<>(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = threadLocalExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = threadLocalExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = threadLocalExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ThreadLocalExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int threadLocalExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + tl1.wait(); + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadLocalExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + tl1.wait(millis); + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int threadLocalExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + tl1.wait(millis, nanos); + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitIllegalMonitorStateException.res = ThreadLocalExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..03404c08adb6b7e5dd3b4d393f67721853507b05 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0155-rt-parent-ThreadLocalExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectwaitIllegalMonitorStateException) +run(ThreadLocalExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/ThreadLocalExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/ThreadLocalExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..7231e35dc2a92fb586b8562db58e1a0a130bd88a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/ThreadLocalExObjectwaitInterruptedException.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThreadLocalExObjectwaitInterruptedException { + static int res = 99; + static ThreadLocal tl1 = new ThreadLocal<>(); + public static void main(String argv[]) { + System.out.println(new ThreadLocalExObjectwaitInterruptedException().run()); + } + private class ThreadLocalExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ThreadLocalExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + tl1.notifyAll(); + try { + tl1.wait(); + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ThreadLocalExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ThreadLocalExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + tl1.notifyAll(); + try { + tl1.wait(millis); + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ThreadLocalExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ThreadLocalExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (tl1) { + tl1.notifyAll(); + try { + tl1.wait(millis, nanos); + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThreadLocalExObjectwaitInterruptedException.res = ThreadLocalExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ThreadLocalExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ThreadLocalExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThreadLocalExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && ThreadLocalExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..296eb088dc1ab856b38d20992ccfd4dbd93ba9a8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0156-rt-parent-ThreadLocalExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThreadLocalExObjectwaitInterruptedException) +run(ThreadLocalExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/ThrowableExObjecthashCode.java b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/ThrowableExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..1339a07ef05456b6e8455efae1a7fbda57cf64e1 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/ThrowableExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Throwable; +public class ThrowableExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new ThrowableExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = throwableExObjecthashCode1(); + } catch (Exception e) { + ThrowableExObjecthashCode.res = ThrowableExObjecthashCode.res - 20; + } + if (result == 4 && ThrowableExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int throwableExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + Throwable cause1 = new Throwable("detailed message of cause1"); + Throwable cause2 = cause1; + Throwable cause3 = new Throwable("detailed message of cause3"); + if (cause1.hashCode() == cause2.hashCode() && cause1.hashCode() != cause3.hashCode()) { + ThrowableExObjecthashCode.res = ThrowableExObjecthashCode.res - 10; + } else { + ThrowableExObjecthashCode.res = ThrowableExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..233e4b4d72932a6ac346987a5b0213bf04b3c905 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0157-rt-parent-ThrowableExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjecthashCode) +run(ThrowableExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/ThrowableExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/ThrowableExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..17b736b284ea97c47d7aee9bb47c79db5a4b7da8 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/ThrowableExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThrowableExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(new ThrowableExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = throwableExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + ThrowableExObjectnotifyAllIllegalMonitorStateException.res = ThrowableExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThrowableExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThrowableExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int throwableExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // + // final void notifyAll() + try { + cause.notifyAll(); + ThrowableExObjectnotifyAllIllegalMonitorStateException.res = ThrowableExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectnotifyAllIllegalMonitorStateException.res = ThrowableExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThrowableExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private ThrowableExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + try { + cause.notifyAll(); + ThrowableExObjectnotifyAllIllegalMonitorStateException.res = ThrowableExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectnotifyAllIllegalMonitorStateException.res = ThrowableExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5b2342932fc65ca42bec56f286023a0d934c6a9c --- /dev/null +++ b/testsuite/java_test/parent_test/RT0158-rt-parent-ThrowableExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectnotifyAllIllegalMonitorStateException) +run(ThrowableExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/ThrowableExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/ThrowableExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..500328bad7a90f5621af4b50e96d1c11b0d4e90e --- /dev/null +++ b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/ThrowableExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThrowableExObjectnotifyIllegalMonitorStateException { + static int res = 99; + private Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(new ThrowableExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = throwableExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + ThrowableExObjectnotifyIllegalMonitorStateException.res = ThrowableExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new ThrowableExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && ThrowableExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int throwableExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + cause.notify(); + ThrowableExObjectnotifyIllegalMonitorStateException.res = ThrowableExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectnotifyIllegalMonitorStateException.res = ThrowableExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class ThrowableExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private ThrowableExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + try { + cause.notify(); + ThrowableExObjectnotifyIllegalMonitorStateException.res = ThrowableExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectnotifyIllegalMonitorStateException.res = ThrowableExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a343aab76dbd00a117a0b25d09e286b87288a880 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0159-rt-parent-ThrowableExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectnotifyIllegalMonitorStateException) +run(ThrowableExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/ThrowableExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/ThrowableExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..69e5e455545ae811c030781fe1831df51fa75898 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/ThrowableExObjectwaitIllegalArgumentException.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class ThrowableExObjectwaitIllegalArgumentException { + static int res = 99; + private Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(new ThrowableExObjectwaitIllegalArgumentException().run()); + } + private class ThrowableExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ThrowableExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(millis); + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ThrowableExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ThrowableExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(millis, nanos); + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwaitIllegalArgumentException.res = ThrowableExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ThrowableExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThrowableExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ThrowableExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} diff --git a/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d0a730a0bb8fafa62618913ef82b5d2e56404ae7 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0160-rt-parent-ThrowableExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectwaitIllegalArgumentException) +run(ThrowableExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/ThrowableExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/ThrowableExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..f539211004e0f40661f7df83bf0638763369e18d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/ThrowableExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Throwable; +public class ThrowableExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = throwableExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = throwableExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = throwableExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ThrowableExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int throwableExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + cause.wait(); + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int throwableExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + cause.wait(millis); + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int throwableExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + cause.wait(millis, nanos); + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitIllegalMonitorStateException.res = ThrowableExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..42f9bbe77c7a24915c46e7faa897a7d8650f0f09 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0161-rt-parent-ThrowableExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectwaitIllegalMonitorStateException) +run(ThrowableExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/ThrowableExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/ThrowableExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..9b6bfe00da35cfb479b80ef1e7d375fc3962c013 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/ThrowableExObjectwaitInterruptedException.java @@ -0,0 +1,165 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Throwable; +public class ThrowableExObjectwaitInterruptedException { + static int res = 99; + static Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(new ThrowableExObjectwaitInterruptedException().run()); + } + private class ThrowableExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private ThrowableExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(); + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class ThrowableExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private ThrowableExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(millis); + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class ThrowableExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private ThrowableExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(millis, nanos); + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwaitInterruptedException.res = ThrowableExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ThrowableExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new ThrowableExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThrowableExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && ThrowableExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..212af1106846b458de8158e83039441814bf7696 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0162-rt-parent-ThrowableExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectwaitInterruptedException) +run(ThrowableExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/ThrowableExObjectwait.java b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/ThrowableExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..33fd224ac45f923aa049404b8036ba7006d42227 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/ThrowableExObjectwait.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Throwable; +public class ThrowableExObjectwait { + static int res = 99; + private Throwable cause = new Throwable("detailed message of cause"); + public static void main(String argv[]) { + System.out.println(new ThrowableExObjectwait().run()); + } + private class ThrowableExObjectwait11 implements Runnable { + // final void wait() + private int remainder; + private ThrowableExObjectwait11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(); + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 10; + } + } + } + } + private class ThrowableExObjectwait21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10; + private ThrowableExObjectwait21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notify(); + try { + cause.wait(millis); + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 5; + } + } + } + } + private class ThrowableExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10; + int nanos = 10; + private ThrowableExObjectwait31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (cause) { + cause.notifyAll(); + try { + cause.wait(millis, nanos); + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 15; + } catch (InterruptedException e1) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + ThrowableExObjectwait.res = ThrowableExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new ThrowableExObjectwait11(1)); + Thread t2 = new Thread(new ThrowableExObjectwait11(2)); + // final void wait(long millis) + Thread t3 = new Thread(new ThrowableExObjectwait21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ThrowableExObjectwait31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && ThrowableExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..32c6b5684a1446c7318d2a1383549d1f5b68b74b --- /dev/null +++ b/testsuite/java_test/parent_test/RT0163-rt-parent-ThrowableExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ThrowableExObjectwait) +run(ThrowableExObjectwait) diff --git a/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/UnicodeBlockExObjectgetClass.java b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/UnicodeBlockExObjectgetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..bcf95dc746f7c338e37ca129de09637796590209 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/UnicodeBlockExObjectgetClass.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectgetClass { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new UnicodeBlockExObjectgetClass().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = unicodeBlockExObjectgetClass1(); + } catch (Exception e) { + UnicodeBlockExObjectgetClass.res = UnicodeBlockExObjectgetClass.res - 20; + } + if (result == 4 && UnicodeBlockExObjectgetClass.res == 89) { + result = 0; + } + return result; + } + private int unicodeBlockExObjectgetClass1() { + int result1 = 4; /*STATUS_FAILED*/ + // final Class getClass() + Character.UnicodeBlock unB1 = null; + for (int cp = 0; cp <= 10; ++cp) { + unB1 = Character.UnicodeBlock.of(cp); + } + Class px1 = unB1.getClass(); + if (px1.toString().equals("class java.lang.Character$UnicodeBlock")) { + UnicodeBlockExObjectgetClass.res = UnicodeBlockExObjectgetClass.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/expected.txt b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/test.cfg b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..de74baf628203322e761b09c3348cce83d2bfe86 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0164-rt-parent-UnicodeBlockExObjectgetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectgetClass) +run(UnicodeBlockExObjectgetClass) diff --git a/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/UnicodeBlockExObjecthashCode.java b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/UnicodeBlockExObjecthashCode.java new file mode 100755 index 0000000000000000000000000000000000000000..3402f147998708510f48844459eb686c6913b52d --- /dev/null +++ b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/UnicodeBlockExObjecthashCode.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjecthashCode { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new UnicodeBlockExObjecthashCode().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = unicodeBlockExObjecthashCode1(); + } catch (Exception e) { + UnicodeBlockExObjecthashCode.res = UnicodeBlockExObjecthashCode.res - 20; + } + if (result == 4 && UnicodeBlockExObjecthashCode.res == 89) { + result = 0; + } + return result; + } + private int unicodeBlockExObjecthashCode1() { + int result1 = 4; /*STATUS_FAILED*/ + // int hashCode() + Character.UnicodeBlock unB1 = Character.UnicodeBlock.of(10); + Character.UnicodeBlock unB2 = Character.UnicodeBlock.of(10); + Character.UnicodeBlock unB3 = Character.UnicodeBlock.of('〆'); + if (unB1.hashCode() == unB2.hashCode() && unB1.hashCode() != unB3.hashCode()) { + UnicodeBlockExObjecthashCode.res = UnicodeBlockExObjecthashCode.res - 10; + } else { + UnicodeBlockExObjecthashCode.res = UnicodeBlockExObjecthashCode.res - 5; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/expected.txt b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/test.cfg b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1d189e510cf2b2f9fc57813ed1246acc7d8856ba --- /dev/null +++ b/testsuite/java_test/parent_test/RT0165-rt-parent-UnicodeBlockExObjecthashCode/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjecthashCode) +run(UnicodeBlockExObjecthashCode) diff --git a/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..b225381ef199e477c1d045925cabb7f325b7528a --- /dev/null +++ b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private static Character.UnicodeBlock unb1 = null; + public static void main(String argv[]) { + for (int cp = 0; cp <= 10; ++cp) { + unb1 = Character.UnicodeBlock.of(cp); + } + System.out.println(new UnicodeBlockExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = unicodeBlockExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new UnicodeBlockExObjectnotifyAllIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int unicodeBlockExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + unb1.notifyAll(); + UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class UnicodeBlockExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + private int remainder; + private UnicodeBlockExObjectnotifyAllIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + try { + unb1.notifyAll(); + UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5d833da6cff09bda17bd35b69852c79383e9cd66 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0166-rt-parent-UnicodeBlockExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectnotifyAllIllegalMonitorStateException) +run(UnicodeBlockExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/UnicodeBlockExObjectnotifyIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/UnicodeBlockExObjectnotifyIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..d61228d016f1a85f608e5f85984c0e0aea854574 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/UnicodeBlockExObjectnotifyIllegalMonitorStateException.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectnotifyIllegalMonitorStateException { + static int res = 99; + static Character.UnicodeBlock unb1 = null; + public static void main(String argv[]) { + for (int cp = 0; cp <= 10; ++cp) { + unb1 = Character.UnicodeBlock.of(cp); + } + System.out.println(new UnicodeBlockExObjectnotifyIllegalMonitorStateException().run()); + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = unicodeBlockExObjectnotifyIllegalMonitorStateException1(); + } catch (Exception e) { + UnicodeBlockExObjectnotifyIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new UnicodeBlockExObjectnotifyIllegalMonitorStateException11(1)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && UnicodeBlockExObjectnotifyIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int unicodeBlockExObjectnotifyIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notify() + try { + unb1.notify(); + UnicodeBlockExObjectnotifyIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectnotifyIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyIllegalMonitorStateException.res - 1; + } + return result1; + } + private class UnicodeBlockExObjectnotifyIllegalMonitorStateException11 implements Runnable { + // final void notify() + private int remainder; + private UnicodeBlockExObjectnotifyIllegalMonitorStateException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + try { + unb1.notify(); + UnicodeBlockExObjectnotifyIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectnotifyIllegalMonitorStateException.res = UnicodeBlockExObjectnotifyIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..46bf368ebc75e5ee78c1901569923c582acc992f --- /dev/null +++ b/testsuite/java_test/parent_test/RT0167-rt-parent-UnicodeBlockExObjectnotifyIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectnotifyIllegalMonitorStateException) +run(UnicodeBlockExObjectnotifyIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/UnicodeBlockExObjecttoString.java b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/UnicodeBlockExObjecttoString.java new file mode 100755 index 0000000000000000000000000000000000000000..20794a49c73c8d142e0b127b76c1cf082fe61155 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/UnicodeBlockExObjecttoString.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjecttoString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(new UnicodeBlockExObjecttoString().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = unicodeBlockExObjecttoString1(); + } catch (Exception e) { + UnicodeBlockExObjecttoString.res = UnicodeBlockExObjecttoString.res - 20; + } + if (result == 4 && UnicodeBlockExObjecttoString.res == 89) { + result = 0; + } + return result; + } + private int unicodeBlockExObjecttoString1() { + int result1 = 4; /*STATUS_FAILED*/ + // final String toString() + Character.UnicodeBlock unB1 = null; + for (int cp = 0; cp <= 10; ++cp) { + unB1 = Character.UnicodeBlock.of(cp); + } + String px1 = unB1.toString(); + if (px1.equals("BASIC_LATIN")) { + UnicodeBlockExObjecttoString.res = UnicodeBlockExObjecttoString.res - 10; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/expected.txt b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/test.cfg b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..94dc043fe3f276ffc48adf61fbe199ee27894027 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0168-rt-parent-UnicodeBlockExObjecttoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjecttoString) +run(UnicodeBlockExObjecttoString) diff --git a/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/UnicodeBlockExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/UnicodeBlockExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..9a7eca22794113ea793a0de3697a451a3f8adc96 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/UnicodeBlockExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static Character.UnicodeBlock unb1 = null; + public static void main(String argv[]) { + for (int cp = 0; cp <= 10; ++cp) { + unb1 = Character.UnicodeBlock.of(cp); + } + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = unicodeBlockExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = unicodeBlockExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = unicodeBlockExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && UnicodeBlockExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int unicodeBlockExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait() + try { + unb1.wait(); + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int unicodeBlockExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + unb1.wait(millis); + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int unicodeBlockExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + unb1.wait(millis, nanos); + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitIllegalMonitorStateException.res = UnicodeBlockExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a75771b682b194a1c27a5c3576c588dc33f0e4de --- /dev/null +++ b/testsuite/java_test/parent_test/RT0169-rt-parent-UnicodeBlockExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectwaitIllegalMonitorStateException) +run(UnicodeBlockExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/UnicodeBlockExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/UnicodeBlockExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..33f6d664b9dc94a3edf6c36776d828070d7a1c99 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/UnicodeBlockExObjectwaitInterruptedException.java @@ -0,0 +1,168 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectwaitInterruptedException { + static int res = 99; + private static Character.UnicodeBlock unb1 = null; + public static void main(String argv[]) { + for (int cp = 0; cp <= 10; ++cp) { + unb1 = Character.UnicodeBlock.of(cp); + } + System.out.println(new UnicodeBlockExObjectwaitInterruptedException().run()); + } + private class UnicodeBlockExObjectwaitInterruptedException11 implements Runnable { + // final void wait() + private int remainder; + private UnicodeBlockExObjectwaitInterruptedException11(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notifyAll(); + try { + unb1.wait(); + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class UnicodeBlockExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + private int remainder; + long millis = 10000; + private UnicodeBlockExObjectwaitInterruptedException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notifyAll(); + try { + unb1.wait(millis); + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class UnicodeBlockExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + private int remainder; + long millis = 10000; + int nanos = 100; + private UnicodeBlockExObjectwaitInterruptedException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notifyAll(); + try { + unb1.wait(millis, nanos); + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + UnicodeBlockExObjectwaitInterruptedException.res = UnicodeBlockExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new UnicodeBlockExObjectwaitInterruptedException11(1)); + // final void wait(long millis) + Thread t3 = new Thread(new UnicodeBlockExObjectwaitInterruptedException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new UnicodeBlockExObjectwaitInterruptedException31(5)); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t1.interrupt(); + sleep(1000); + t3.start(); + sleep(1000); + t3.interrupt(); + sleep(1000); + t5.start(); + sleep(1000); + t5.interrupt(); + sleep(1000); + if (result == 2 && UnicodeBlockExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f0609bc4d0df4108c6e16453323d7875dd8f22dc --- /dev/null +++ b/testsuite/java_test/parent_test/RT0170-rt-parent-UnicodeBlockExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectwaitInterruptedException) +run(UnicodeBlockExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/UnicodeBlockExObjectwait.java b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/UnicodeBlockExObjectwait.java new file mode 100755 index 0000000000000000000000000000000000000000..6798e9d5a7754979fef6991f7394508b6fca1a38 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/UnicodeBlockExObjectwait.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Character; +public class UnicodeBlockExObjectwait { + static int res = 99; + private static Character.UnicodeBlock unb1 = null; + public static void main(String argv[]) { + for (int cp = 0; cp <= 10; ++cp) { + unb1 = Character.UnicodeBlock.of(cp); + } + System.out.println(new UnicodeBlockExObjectwait().run()); + } + private class UnicodeBlockExObjectwait11 implements Runnable { + // final void wait() + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notifyAll(); + try { + unb1.wait(); + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 10; + } + } + } + } + private class UnicodeBlockExObjectwait21 implements Runnable { + // final void wait(long millis) + long millis = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notify(); + try { + unb1.wait(millis); + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 5; + } + } + } + } + private class UnicodeBlockExObjectwait31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10; + int nanos = 10; + /** + * Thread run fun + */ + + public void run() { + synchronized (unb1) { + unb1.notifyAll(); + try { + unb1.wait(millis, nanos); + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 15; + } catch (InterruptedException e1) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 1; + } catch (IllegalMonitorStateException e2) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 10; + } catch (IllegalArgumentException e3) { + UnicodeBlockExObjectwait.res = UnicodeBlockExObjectwait.res - 5; + } + } + } + } + /** + * sleep fun + * + * @param slpnum wait time + */ + + public void sleep(int slpnum) { + try { + Thread.sleep(slpnum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * join fun + * @param thread wait join thread + */ + + private void waitFinish(Thread thread) { + try { + thread.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new UnicodeBlockExObjectwait11()); + Thread t2 = new Thread(new UnicodeBlockExObjectwait11()); + // final void wait(long millis) + Thread t3 = new Thread(new UnicodeBlockExObjectwait21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new UnicodeBlockExObjectwait31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t2.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(1000); + t3.start(); + sleep(1000); + t5.start(); + sleep(1000); + t2.start(); + sleep(1000); + t1.interrupt(); + waitFinish(t1); + waitFinish(t3); + waitFinish(t5); + if (result == 2 && UnicodeBlockExObjectwait.res == 54) { + result = 0; + } + t2.interrupt(); + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/expected.txt b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/test.cfg b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6838c2cfc333dc82672368c1bbe8faaf10d9f430 --- /dev/null +++ b/testsuite/java_test/parent_test/RT0171-rt-parent-UnicodeBlockExObjectwait/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnicodeBlockExObjectwait) +run(UnicodeBlockExObjectwait) diff --git a/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/AccessibleObjectExObjectwaitInterruptedException.java b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/AccessibleObjectExObjectwaitInterruptedException.java new file mode 100755 index 0000000000000000000000000000000000000000..d4626b760d3802177e1a741f281e6da7e9a93d73 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/AccessibleObjectExObjectwaitInterruptedException.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.AccessibleObject; +public class AccessibleObjectExObjectwaitInterruptedException { + static int res = 99; + private static AccessibleObject sampleField1 = null; + public static void main(String argv[]) throws NoSuchFieldException, SecurityException { + sampleField1 = AccessibleObjectExObjectwaitInterruptedException.class.getDeclaredField("res"); + System.out.println(new AccessibleObjectExObjectwaitInterruptedException().run()); + } + private class AccessibleObjectExObjectwaitInterruptedException11 implements Runnable { + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(); + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 10; + } + } + } + } + private class AccessibleObjectExObjectwaitInterruptedException21 implements Runnable { + // final void wait(long millis) + long millis = 10000; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis); + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 5; + } + } + } + } + private class AccessibleObjectExObjectwaitInterruptedException31 implements Runnable { + // final void wait(long millis, int nanos) + long millis = 10000; + int nanos = 100; + /** + * Thread run fun + */ + + public void run() { + synchronized (sampleField1) { + sampleField1.notifyAll(); + try { + sampleField1.wait(millis, nanos); + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 15; + } catch (InterruptedException e1) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 1; + } catch (IllegalMonitorStateException e2) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 10; + } catch (IllegalArgumentException e3) { + AccessibleObjectExObjectwaitInterruptedException.res = AccessibleObjectExObjectwaitInterruptedException.res - 5; + } + } + } + } + /** + * sleep fun + * @param sleepNum wait time + */ + + public void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // check api normal + // final void wait() + Thread t1 = new Thread(new AccessibleObjectExObjectwaitInterruptedException11()); + // final void wait(long millis) + Thread t3 = new Thread(new AccessibleObjectExObjectwaitInterruptedException21()); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new AccessibleObjectExObjectwaitInterruptedException31()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + sleep(100); + t1.interrupt(); + sleep(100); + t3.start(); + sleep(100); + t3.interrupt(); + sleep(100); + t5.start(); + sleep(100); + t5.interrupt(); + sleep(100); + if (result == 2 && AccessibleObjectExObjectwaitInterruptedException.res == 96) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/expected.txt b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/test.cfg b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b1e8d2cae881059f827526f346fdae5d7ed31dbc --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0646-rt-parent-AccessibleObjectExObjectwaitInterruptedException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AccessibleObjectExObjectwaitInterruptedException) +run(AccessibleObjectExObjectwaitInterruptedException) diff --git a/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/CharacterExObjectnotifyAllIllegalMonitorStateException.java b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/CharacterExObjectnotifyAllIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..a55d137196c0131d1b154dbc632d56e9a8864001 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/CharacterExObjectnotifyAllIllegalMonitorStateException.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Thread; +public class CharacterExObjectnotifyAllIllegalMonitorStateException { + static int res = 99; + private char name = 'A'; + private Character rp = new Character(name); + public static void main(String argv[]) { + System.out.println(new CharacterExObjectnotifyAllIllegalMonitorStateException().run()); + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + try { + result = characterExObjectnotifyAllIllegalMonitorStateException1(); + } catch (Exception e) { + CharacterExObjectnotifyAllIllegalMonitorStateException.res = CharacterExObjectnotifyAllIllegalMonitorStateException.res - 20; + } + Thread t1 = new Thread(new CharacterExObjectnotifyAllIllegalMonitorStateException11()); + t1.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t1.start(); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (result == 4 && CharacterExObjectnotifyAllIllegalMonitorStateException.res == 58) { + result = 0; + } + return result; + } + private int characterExObjectnotifyAllIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void notifyAll() + try { + rp.notifyAll(); + CharacterExObjectnotifyAllIllegalMonitorStateException.res = CharacterExObjectnotifyAllIllegalMonitorStateException.res - 10; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectnotifyAllIllegalMonitorStateException.res = CharacterExObjectnotifyAllIllegalMonitorStateException.res - 1; + } + return result1; + } + private class CharacterExObjectnotifyAllIllegalMonitorStateException11 implements Runnable { + // final void notifyAll() + /** + * Thread run fun + */ + + public void run() { + synchronized (rp) { + try { + rp.notifyAll(); + CharacterExObjectnotifyAllIllegalMonitorStateException.res = CharacterExObjectnotifyAllIllegalMonitorStateException.res - 40; + } catch (IllegalMonitorStateException e2) { + CharacterExObjectnotifyAllIllegalMonitorStateException.res = CharacterExObjectnotifyAllIllegalMonitorStateException.res - 30; + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..889dae6f62940a52e8ebb40249f53721d733109a --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0654-rt-parent-CharacterExObjectnotifyAllIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CharacterExObjectnotifyAllIllegalMonitorStateException) +run(CharacterExObjectnotifyAllIllegalMonitorStateException) diff --git a/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/ModifierExObjectwaitIllegalArgumentException.java b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/ModifierExObjectwaitIllegalArgumentException.java new file mode 100755 index 0000000000000000000000000000000000000000..5b93f9fcc9a86fe0dcf191cd4b6f21409f061989 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/ModifierExObjectwaitIllegalArgumentException.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectwaitIllegalArgumentException { + static int res = 99; + static Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(new ModifierExObjectwaitIllegalArgumentException().run()); + } + private class ModifierExObjectwaitIllegalArgumentException21 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative. + // final void wait(long millis) + private int remainder; + long millis = -1; + private ModifierExObjectwaitIllegalArgumentException21(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis); + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + private class ModifierExObjectwaitIllegalArgumentException31 implements Runnable { + // IllegalArgumentException - if the value of timeout is negative or the value of nanos is not in the range 0-999999. + // final void wait(long millis, int nanos) + private int remainder; + long millis = -2; + int nanos = 10; + private ModifierExObjectwaitIllegalArgumentException31(int remainder) { + this.remainder = remainder; + } + /** + * Thread run fun + */ + + public void run() { + synchronized (mf2) { + mf2.notifyAll(); + try { + mf2.wait(millis, nanos); + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 15; + } catch (InterruptedException e1) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 20; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 10; + } catch (IllegalArgumentException e3) { + ModifierExObjectwaitIllegalArgumentException.res = ModifierExObjectwaitIllegalArgumentException.res - 5; + } + } + } + } + /** + * sleep fun + * @param slpNum wait time + */ + + public void sleep(int slpNum) { + try { + Thread.sleep(slpNum); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + /** + * main test fun + * @return status code + */ + + public int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait(long millis) + Thread t3 = new Thread(new ModifierExObjectwaitIllegalArgumentException21(3)); + // final void wait(long millis, int nanos) + Thread t5 = new Thread(new ModifierExObjectwaitIllegalArgumentException31(5)); + t3.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t5.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(Thread t, Throwable e) { + System.out.println(t.getName() + " : " + e.getMessage()); + } + }); + t3.start(); + t5.start(); + sleep(1000); + if (result == 2 && ModifierExObjectwaitIllegalArgumentException.res == 89) { + result = 0; + } + return result; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/expected.txt b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/test.cfg b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8e0ade7830f9a4fc7923f04424ee0acdbfbe8714 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0733-rt-parent-ModifierExObjectwaitIllegalArgumentException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectwaitIllegalArgumentException) +run(ModifierExObjectwaitIllegalArgumentException) diff --git a/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/ModifierExObjectwaitIllegalMonitorStateException.java b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/ModifierExObjectwaitIllegalMonitorStateException.java new file mode 100755 index 0000000000000000000000000000000000000000..43483abf81a6d1a5c3b919f4d91c010a7101289b --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/ModifierExObjectwaitIllegalMonitorStateException.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class ModifierExObjectwaitIllegalMonitorStateException { + static int res = 99; + private static Modifier mf2 = new Modifier(); + public static void main(String argv[]) { + System.out.println(run()); + } + /** + * main test fun + * @return status code + */ + + public static int run() { + int result = 2; /*STATUS_FAILED*/ + // final void wait() + try { + result = modifierExObjectwaitIllegalMonitorStateException1(); + } catch (Exception e) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis) + try { + result = modifierExObjectwaitIllegalMonitorStateException2(); + } catch (Exception e) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 20; + } + // final void wait(long millis, int nanos) + try { + result = modifierExObjectwaitIllegalMonitorStateException3(); + } catch (Exception e) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 20; + } + if (result == 4 && ModifierExObjectwaitIllegalMonitorStateException.res == 96) { + result = 0; + } + return result; + } + private static int modifierExObjectwaitIllegalMonitorStateException1() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // + // final void wait() + try { + mf2.wait(); + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int modifierExObjectwaitIllegalMonitorStateException2() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis) + long millis = 123; + try { + mf2.wait(millis); + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } + private static int modifierExObjectwaitIllegalMonitorStateException3() { + int result1 = 4; /*STATUS_FAILED*/ + // IllegalMonitorStateException - if the current thread is not the owner of the object's monitor. + // final void wait(long millis, int nanos) + long millis = 123; + int nanos = 10; + try { + mf2.wait(millis, nanos); + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 10; + } catch (InterruptedException e1) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 30; + } catch (IllegalMonitorStateException e2) { + ModifierExObjectwaitIllegalMonitorStateException.res = ModifierExObjectwaitIllegalMonitorStateException.res - 1; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/expected.txt b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/test.cfg b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..dd15fe2816bf482c6f2a8bb9f731c35794f36f74 --- /dev/null +++ b/testsuite/java_test/parent_test/issue-RT0734-rt-parent-ModifierExObjectwaitIllegalMonitorStateException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ModifierExObjectwaitIllegalMonitorStateException) +run(ModifierExObjectwaitIllegalMonitorStateException) diff --git a/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..d4c7c7dddc27c4164b13acda12270651c69d80b9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/Cycle_a_00180.java @@ -0,0 +1,193 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a8_0.a; + } +} +class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +public class Cycle_a_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + if (result == 1994) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/expected.txt b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/test.cfg b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3c5df4bae1ff42abd6ef4e8ae2723caecda11ee0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0001-rc-function-Cycle_a_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00180) +run(Cycle_a_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..644d792b523dfdb0a958e350167caf0db3f17262 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/Cycle_a_00190.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a10_0.a; + } +} +class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } +} +public class Cycle_a_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + if (result == 2215) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/expected.txt b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/test.cfg b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3c66ccdc652dc9fd6bd5ee0faa895bc10d7649ee --- /dev/null +++ b/testsuite/java_test/rc_test/RC0002-rc-function-Cycle_a_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00190) +run(Cycle_a_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..449e969fac780d60389e4505fdd5c6df7b22a52e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/Cycle_a_00200.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } +} +class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Cycle_a_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + if (result == 1773) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/expected.txt b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/test.cfg b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..293a9fde4b8a21528e9b8988fb93e64825dc01a4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0003-rc-function-Cycle_a_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00200) +run(Cycle_a_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..8f3e9b57bfd84dbb9be52e8e3f40897850c08b5a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/Cycle_a_00210.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } +} +class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + if (result == 1662) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/expected.txt b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/test.cfg b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d9507f27d5db45d80256a94490c1459114bc5f8b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0004-rc-function-Cycle_a_00210/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00210) +run(Cycle_a_00210,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..ed17cb300818f6282ba089a052442b9bee7f67a0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/Cycle_a_00220.java @@ -0,0 +1,162 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } +} +class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } +} +class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Cycle_a_00220 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + if (result == 1772) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/expected.txt b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/test.cfg b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cf2551828d90011c25d0b2de0af8d21e7a7ee762 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0005-rc-function-Cycle_a_00220/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00220) +run(Cycle_a_00220,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..e6943838a85d040877b5b73a186f3151ffa09990 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/Cycle_a_00230.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } +} +class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } +} +class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Cycle_a_00230 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + if (result == 1773) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/expected.txt b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/test.cfg b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..54a61fbb9e8570aa6a713cc4d32be51fc5e5d773 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0006-rc-function-Cycle_a_00230/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00230) +run(Cycle_a_00230,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..1fdc1ccb5b9a700487d7d2d3db2a38288018caf3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/Cycle_a_00240.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a6_0.a; + } +} +class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } +} +class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_a_00240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + if (result == 1660) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/expected.txt b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/test.cfg b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fed100c0c60ec04f097d2d837790e59ee1a054d6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0007-rc-function-Cycle_a_00240/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00240) +run(Cycle_a_00240,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java new file mode 100755 index 0000000000000000000000000000000000000000..fab49b4ef4b9afcab9359ac86313a1e326890ae3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/Cycle_a_00250.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00250 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1238) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/expected.txt b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/test.cfg b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cb13542d605afa2065aab84cadc46df8792bef7c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0008-rc-function-Cycle_a_00250/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00250) +run(Cycle_a_00250,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java new file mode 100755 index 0000000000000000000000000000000000000000..b574894398ca7e23cd24d0b3bd15bc5ebed3a5f5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/Cycle_a_00260.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} +class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00260 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1239) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/expected.txt b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/test.cfg b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..214257eeda6ddaf3ce0705332ef9265b350f169a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0009-rc-function-Cycle_a_00260/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00260) +run(Cycle_a_00260,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java new file mode 100755 index 0000000000000000000000000000000000000000..414f41783a29d6e2397d61f193654b578a19c770 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/Cycle_a_00270.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00270 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1240) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/expected.txt b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/test.cfg b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..599f7f1613b9107e32ff6980b323d174ade64d34 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0010-rc-function-Cycle_a_00270/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00270) +run(Cycle_a_00270,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java new file mode 100755 index 0000000000000000000000000000000000000000..ca4088e1ee5bca4f670f893a21ff2bcf2ed72ec6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/Cycle_a_00280.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} +class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00280 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1443) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/expected.txt b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/test.cfg b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..85155c6df347bec2347ec181eb37ca3a942f4c13 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0011-rc-function-Cycle_a_00280/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00280) +run(Cycle_a_00280,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java new file mode 100755 index 0000000000000000000000000000000000000000..795ab22aa870a3e1003db65725448325734f5d89 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/Cycle_a_00290.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } +} +class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_a_00290 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + if (result == 1447) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/expected.txt b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/test.cfg b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0140173176498d45b9ed963ddd38aef8552f9790 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0012-rc-function-Cycle_a_00290/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00290) +run(Cycle_a_00290,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java new file mode 100755 index 0000000000000000000000000000000000000000..e2fedf5aa9cd9dc88e836fc7ceb80c598e5cf50a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/Cycle_a_00300.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } +} +class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a6_0.a; + } +} +class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00300 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1448) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/expected.txt b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/test.cfg b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7c18d0fcbf7a1e3317c40e73bbc7a23ff7d23362 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0013-rc-function-Cycle_a_00300/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00300) +run(Cycle_a_00300,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java new file mode 100755 index 0000000000000000000000000000000000000000..a591702330c8a0dc708a8d60764170077ddeea26 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/Cycle_a_00310.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } +} +class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +public class Cycle_a_00310 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1552) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/expected.txt b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/test.cfg b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..711a9a311ef48d20195e573189fc3713d0d70c50 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0014-rc-function-Cycle_a_00310/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00310) +run(Cycle_a_00310,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java new file mode 100755 index 0000000000000000000000000000000000000000..380acf3f4d434745d31012b110a9820ed2e7c2da --- /dev/null +++ b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/Cycle_a_00320.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} +public class Cycle_a_00320 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1551) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/expected.txt b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/test.cfg b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a1f9bad48ce8991f79fb918b59d3036debf3751 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0015-rc-function-Cycle_a_00320/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00320) +run(Cycle_a_00320,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java new file mode 100755 index 0000000000000000000000000000000000000000..e1ace17b024ee95f75fcf4d0d57bd547865114da --- /dev/null +++ b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/Cycle_a_00330.java @@ -0,0 +1,186 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +public class Cycle_a_00330 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + if (result == 2080) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/expected.txt b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/test.cfg b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f7e7805e52982b888fc01a6aa2bf45db2180b6b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0016-rc-function-Cycle_a_00330/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00330) +run(Cycle_a_00330,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java new file mode 100755 index 0000000000000000000000000000000000000000..fad0f43be6a2707277cb8f58816bd2af77a25821 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/Cycle_a_00340.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } +} +class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +public class Cycle_a_00340 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/expected.txt b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/test.cfg b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..38f6b53285a41dfc34b6a89e30c75c977f027ced --- /dev/null +++ b/testsuite/java_test/rc_test/RC0017-rc-function-Cycle_a_00340/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00340) +run(Cycle_a_00340,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java new file mode 100644 index 0000000000000000000000000000000000000000..e3528a828c0b3e0d355284672e84bd091658827b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/Cycle_a_00350.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a7_0.a; + } +} +public class Cycle_a_00350 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + if (result == 2079) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/expected.txt b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/test.cfg b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..110aa71be14e3c813bd8d56ca7e9dfe73a4818a5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0018-rc-function-Cycle_a_00350/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00350) +run(Cycle_a_00350,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java new file mode 100755 index 0000000000000000000000000000000000000000..b0234fae2fe182a93d5e7c7f313397d35d229a7a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/Cycle_a_00360.java @@ -0,0 +1,209 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } +} +class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_a_00360 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2399) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/expected.txt b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/test.cfg b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..89a033014e5e1ed3044f0f4be81456f5ecc2681a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0019-rc-function-Cycle_a_00360/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00360) +run(Cycle_a_00360,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java new file mode 100755 index 0000000000000000000000000000000000000000..f8ae369eb81b1fa6099445aa2469209214982ca5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/Cycle_a_00370.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} +class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +public class Cycle_a_00370 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2623) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/expected.txt b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/test.cfg b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a407f86d03390e74077427997af8af3f794f1c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0020-rc-function-Cycle_a_00370/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00370) +run(Cycle_a_00370,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java new file mode 100755 index 0000000000000000000000000000000000000000..3d045cd6f7addea1f170a19c350743ba0c976d30 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/Cycle_a_00380.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +public class Cycle_a_00380 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 815) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/expected.txt b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/test.cfg b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b37cb609212665675470675eca9b8bfea98d2bde --- /dev/null +++ b/testsuite/java_test/rc_test/RC0021-rc-function-Cycle_a_00380/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00380) +run(Cycle_a_00380,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java new file mode 100755 index 0000000000000000000000000000000000000000..531f68787e16167c9aa40988458524c1105bde33 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/Cycle_a_00390.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +public class Cycle_a_00390 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 918) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/expected.txt b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/test.cfg b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f99a3359949b0d00fda2e8e764cfee3312a0c342 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0022-rc-function-Cycle_a_00390/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00390) +run(Cycle_a_00390,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java new file mode 100755 index 0000000000000000000000000000000000000000..5145ec675b2d84a4c02a1047df1db275abfb77a7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/Cycle_a_00400.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } +} +class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_a_00400 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/expected.txt b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/test.cfg b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a3f922ee3d0c1ff83398ce8d32aa61141e29971e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0023-rc-function-Cycle_a_00400/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00400) +run(Cycle_a_00400,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java new file mode 100755 index 0000000000000000000000000000000000000000..7412b390eb09f477c0da6be6a0c9a29832366d28 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/Cycle_a_00410.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_a_00410 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 921) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/expected.txt b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/test.cfg b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b2c435f7cce306b4824c3c41f49a718786b62c85 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0024-rc-function-Cycle_a_00410/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00410) +run(Cycle_a_00410,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java new file mode 100755 index 0000000000000000000000000000000000000000..51c0351cd09b9d43709089e15d22364048bf247f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/Cycle_a_00420.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_a_00420 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + if (result == 923) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/expected.txt b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/test.cfg b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ecd5f39b657c8f56cea9526b1c610d211be9d5b6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0025-rc-function-Cycle_a_00420/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00420) +run(Cycle_a_00420,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java new file mode 100755 index 0000000000000000000000000000000000000000..857957a23dc5b3b6e48d49fb9317bd5f6a39cc5b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/Cycle_a_00430.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +public class Cycle_a_00430 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1124) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/expected.txt b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/test.cfg b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ae99669a84e92d6558971e6bb79a6be4fe8beab2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0026-rc-function-Cycle_a_00430/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00430) +run(Cycle_a_00430,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java new file mode 100755 index 0000000000000000000000000000000000000000..0eeab655eef9437879dffc73fcbb0cf5ee7916ca --- /dev/null +++ b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/Cycle_a_00440.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_a_00440 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + if (result == 1023) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/expected.txt b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/test.cfg b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..39abef7be3eb9ea7f63c94cb67fc04b43bda737e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0027-rc-function-Cycle_a_00440/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00440) +run(Cycle_a_00440,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java new file mode 100755 index 0000000000000000000000000000000000000000..83ea8155cdcaff44bd4ed300afafdace993f34c9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/Cycle_a_00450.java @@ -0,0 +1,144 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a7_0.a; + } +} +class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_a_00450 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1453) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/expected.txt b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/test.cfg b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b3309e0711fb831b72878a3e255d97544b76cfd9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0028-rc-function-Cycle_a_00450/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00450) +run(Cycle_a_00450,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java new file mode 100755 index 0000000000000000000000000000000000000000..64ff77244788230b89df5456223ee8085203fbae --- /dev/null +++ b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/Cycle_a_00460.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } +} +class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +public class Cycle_a_00460 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/expected.txt b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/test.cfg b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a5680c1745d80ea255e970ad7991f0ce9063f2de --- /dev/null +++ b/testsuite/java_test/rc_test/RC0029-rc-function-Cycle_a_00460/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00460) +run(Cycle_a_00460,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java new file mode 100755 index 0000000000000000000000000000000000000000..49bccfccd227034fd9bb2e5cb4c2343fe072cf85 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/Cycle_a_00470.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +public class Cycle_a_00470 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + if (result == 1446) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/expected.txt b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/test.cfg b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2ad9abca1628872b0f6abe8197f6e1af9ddd216a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0030-rc-function-Cycle_a_00470/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00470) +run(Cycle_a_00470,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java new file mode 100755 index 0000000000000000000000000000000000000000..4d761befc40d1c53114c450aacd805341bae9f53 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/Cycle_a_00480.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} +public class Cycle_a_00480 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + if (result == 1550) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/expected.txt b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/test.cfg b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e4ef6e41dce4b3cc2d1fd8dfc85b72fa2b1845a4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0031-rc-function-Cycle_a_00480/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00480) +run(Cycle_a_00480,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java new file mode 100755 index 0000000000000000000000000000000000000000..13c00c1ac25826c30ec956ec2f86a56cd23a4e70 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/Cycle_a_00490.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a + a5_0.a; + } +} +class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } +} +public class Cycle_a_00490 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + if (result == 2098) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/expected.txt b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/test.cfg b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f14764225afbf8e2aa52155703e42989806e6b5b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0032-rc-function-Cycle_a_00490/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00490) +run(Cycle_a_00490,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java new file mode 100755 index 0000000000000000000000000000000000000000..b8fbc2d987c0f0b458e62828a201000f9cfce4f6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/Cycle_a_00500.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } +} +public class Cycle_a_00500 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + if (result == 2099) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/expected.txt b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/test.cfg b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..12ebaa2df0590833567d1d150386bb9a872c579e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0033-rc-function-Cycle_a_00500/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_00500) +run(Cycle_a_00500,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..19c4a020e1ccdb468f4ad7b44faa21f28e1450a0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/Cycle_a_10010.java @@ -0,0 +1,323 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } +} +class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } +} +class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } +} +class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +public class Cycle_a_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + result += result2; + if (result == 3852) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/expected.txt b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/test.cfg b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..45234fd72a0ed6596c2ff32056ca028b7e4ecf19 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0034-rc-function-Cycle_a_10010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_10010) +run(Cycle_a_10010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..42894df0ebd9fc9644fd859b553b828364bd03b7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/Cycle_a_10020.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} +class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +public class Cycle_a_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == (2623 + 815)) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/expected.txt b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/test.cfg b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2b0580aa1763c7b47b58475ce7b9930fdb7cd27f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0035-rc-function-Cycle_a_10020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_a_10020) +run(Cycle_a_10020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..77c7e99f3f1fe2c8f1b3d4b2d49b36afffd0f0aa --- /dev/null +++ b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/Cycle_B_1_00010.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/expected.txt b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/test.cfg b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dc15224b821747cb375c0682af944dab2c70b94d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0036-rc-function-Cycle_B_1_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00010) +run(Cycle_B_1_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..3a519ba361e2c52b83c3dfdc891b5ff08c96fe8a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/Cycle_B_1_00020.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum); + if (nsum == 6) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/expected.txt b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/test.cfg b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cdd065262fe82a9dbbee631206cf10eb1cf85ecc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0037-rc-function-Cycle_B_1_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00020) +run(Cycle_B_1_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..4152fa480f85cf1a33866396260cdc3fc58f1700 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/Cycle_B_1_00030.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + if (nsum == 12) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/expected.txt b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/test.cfg b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2f1039e4fc29f7dafd1b25ba9059eeaa033c3641 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0038-rc-function-Cycle_B_1_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00030) +run(Cycle_B_1_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..e955fecd5050d51caa09c9ec8fabdf1b72a252b6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/Cycle_B_1_00040.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00040_A4 { + int a; + int sum; + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } +} +public class Cycle_B_1_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + if (nsum == 21) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/expected.txt b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/test.cfg b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8b2cabbfe6daad61bff7df6ca660f0811d3ec712 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0039-rc-function-Cycle_B_1_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00040) +run(Cycle_B_1_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..3532ce6019041847c7a50fdafa6db1007564eeab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/Cycle_B_1_00050.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00050_A4 { + int a; + int sum; + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } +} +class Cycle_B_1_00050_A5 { + int a; + int sum; + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } +} +public class Cycle_B_1_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 34) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/expected.txt b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/test.cfg b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7291748468bb758b883e9c7a0ab636bdb1550e83 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0040-rc-function-Cycle_B_1_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00050) +run(Cycle_B_1_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..9071e0e5ee0dac72f29a405a09361398ed6f77ea --- /dev/null +++ b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/Cycle_B_1_00060.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_1_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + if (nsum == 19) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/expected.txt b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/test.cfg b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4367d4501a07fa6476982e1947041bf9dfd7bd82 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0041-rc-function-Cycle_B_1_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00060) +run(Cycle_B_1_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..6d875e99a1a4c6ca6729b462d9604490a5527cf7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/Cycle_B_1_00070.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00070_A4 { + int a; + int sum; + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } +} +public class Cycle_B_1_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + if (nsum == 21) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/expected.txt b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/test.cfg b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5c001212283ee9ad523f4d6a08e305068abcd68b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0042-rc-function-Cycle_B_1_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00070) +run(Cycle_B_1_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..6989a0a3659ea189a37448e57cd950f54f3da1d7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/Cycle_B_1_00080.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } +} +class Cycle_B_1_00080_A4 { + int a; + int sum; + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } +} +class Cycle_B_1_00080_A5 { + int a; + int sum; + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } +} +public class Cycle_B_1_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 56) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/expected.txt b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/test.cfg b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1a721e43137532eb261a3ba1e775896c2cb12da8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0043-rc-function-Cycle_B_1_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00080) +run(Cycle_B_1_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..d3757bae34d6533c69c715216749fd4e239a7c24 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/Cycle_B_1_00090.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_1_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 25) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/expected.txt b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/test.cfg b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..02e01c29ec65e3a54de63e28118561ddd97d41c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0044-rc-function-Cycle_B_1_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00090) +run(Cycle_B_1_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..dc68a38f743b5e87e7847739ed24312deb77a665 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/Cycle_B_1_00100.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00100_A4 { + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} +class Cycle_B_1_00100_A5 { + int a; + int sum; + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } +} +public class Cycle_B_1_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/expected.txt b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/test.cfg b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4ad4062eab5cbb06279b2e70a4026610e8a5711e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0045-rc-function-Cycle_B_1_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00100) +run(Cycle_B_1_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..39c8f74042dc76d8b632a2729d500462fe07294a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/Cycle_B_1_00110.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_1_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 27) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/expected.txt b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/test.cfg b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c211b9e3d33edef5e22e5720e0d33e161495e7e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0046-rc-function-Cycle_B_1_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00110) +run(Cycle_B_1_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..53621bef08d01b17942df7225e701dec4a1f90a7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/Cycle_B_1_00120.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_1_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/expected.txt b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/test.cfg b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..42e446d1ff0e5cc726381f6b072efcb80b74dc1b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0047-rc-function-Cycle_B_1_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00120) +run(Cycle_B_1_00120,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..bdf7e989d8fae26d4417d216152bf14261e5256d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/Cycle_B_1_00130.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/expected.txt b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/test.cfg b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f4d4be1cfcacece508e7782fcfacf02d4ae113bb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0048-rc-function-Cycle_B_1_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00130) +run(Cycle_B_1_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..f980cf79abb238abf65338b6451c9c0f58911601 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/Cycle_B_1_00140.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_1_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/expected.txt b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/test.cfg b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..be0f8a3bf6b7a78d99eae8310e471b9f119d88a3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0049-rc-function-Cycle_B_1_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00140) +run(Cycle_B_1_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..b65374b9be6455012b989ca2e2c423e3a68d7015 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/Cycle_B_1_00150.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00150_A4 { + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} +class Cycle_B_1_00150_A5 { + int a; + int sum; + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } +} +public class Cycle_B_1_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/expected.txt b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/test.cfg b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..76425dffc0b9232e81b7e712313dad76f87c7ccb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0050-rc-function-Cycle_B_1_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00150) +run(Cycle_B_1_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..c64705bc294490f917c7b10a76ad32ef34cbbcc6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/Cycle_B_1_00160.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 17) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/expected.txt b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/test.cfg b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a4db4d7501eb22f2406e4dcdfa83000c87e5b062 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0051-rc-function-Cycle_B_1_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00160) +run(Cycle_B_1_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..ff151fb1d13b42adb11f4f610d3a7a3a275a0b15 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/Cycle_B_1_00170.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_1_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 26) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/expected.txt b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/test.cfg b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3bcf4740956b0ebdc89b2184a5cd1292c4a87629 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0052-rc-function-Cycle_B_1_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00170) +run(Cycle_B_1_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..e7adb12138eb8c87268d50e3a8a3d76d8446c75f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/Cycle_B_1_00180.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/expected.txt b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/test.cfg b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7be95e00840ae35bd7fd0fe0d284fcf135b6b295 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0053-rc-function-Cycle_B_1_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00180) +run(Cycle_B_1_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..094dcb37296c00547fc1365b07ea07303d8ec4c9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/Cycle_B_1_00190.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00190_A4 { + int a; + int sum; + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } +} +public class Cycle_B_1_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/expected.txt b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/test.cfg b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..01c0c8af12eec7fbaefd9500d65026f17355c89f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0054-rc-function-Cycle_B_1_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00190) +run(Cycle_B_1_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..1407fe1bd824d2ad0735d9c97227da02731bd402 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/Cycle_B_1_00200.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00200_A4 { + int a; + int sum; + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } +} +class Cycle_B_1_00200_A5 { + int a; + int sum; + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } +} +public class Cycle_B_1_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 38) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/expected.txt b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/test.cfg b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4cbb0f4898cd9b9a8eede376895096a9dbe8a3ac --- /dev/null +++ b/testsuite/java_test/rc_test/RC0055-rc-function-Cycle_B_1_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_00200) +run(Cycle_B_1_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..2b9285ba76c0963dcaf3b82b57ace35df5dead66 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/Cycle_B_1_10010.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_1_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + if (nsum == 24) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/expected.txt b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/test.cfg b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e99a6b702fc72547161862f7bf85845f324d05cd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0056-rc-function-Cycle_B_1_10010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_10010) +run(Cycle_B_1_10010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..e618c0b6681b2ea9fdba8f4059cf9ecd691df720 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/Cycle_B_1_10020.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_10020_2A4 { + int a; + int sum; + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } +} +class Cycle_B_1_10020_2A5 { + int a; + int sum; + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } +} +public class Cycle_B_1_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + if (nsum == 61) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/expected.txt b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/test.cfg b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3596709e815a88c1833856c079dd996c85001568 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0057-rc-function-Cycle_B_1_10020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_1_10020) +run(Cycle_B_1_10020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..bb3ada7d270dfe43abdb61bdf2ce07973d72ce31 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/Cycle_B_2_00010.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_2_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 18) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/expected.txt b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/test.cfg b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..69dce2eed35958793f53f1c5b9fe985a3a4be201 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0058-rc-function-Cycle_B_2_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00010) +run(Cycle_B_2_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..1259a3911cdb3321d31dcf583e9a94453d93f49f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/Cycle_B_2_00020.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_2_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/expected.txt b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/test.cfg b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..134cfafb4a9c6b954468ac1aedf29eeddb0a6cbe --- /dev/null +++ b/testsuite/java_test/rc_test/RC0059-rc-function-Cycle_B_2_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00020) +run(Cycle_B_2_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..2ce41586eaa248edacbe9def3ecc3fe68ae325b7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/Cycle_B_2_00030.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/expected.txt b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/test.cfg b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73fd6bb2e46a61a366c235779f7691160757a2dc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0060-rc-function-Cycle_B_2_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00030) +run(Cycle_B_2_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..ced1bfb99da903dadb9ff1df0c9488e375cf5b4c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/Cycle_B_2_00040.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_2_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/expected.txt b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/test.cfg b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2dff7bf98c6d3b0f250ebed66cd6db7a01ee0936 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0061-rc-function-Cycle_B_2_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00040) +run(Cycle_B_2_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..8fa0b1b7ded2d32ee00931d00ec79031dd31854b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/Cycle_B_2_00050.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_2_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/expected.txt b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/test.cfg b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..613c6547b5d55f103e22a4fe95954e315f8009d3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0062-rc-function-Cycle_B_2_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00050) +run(Cycle_B_2_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..ad3021351e7ff48ed41479895b584226bb4711b3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/Cycle_B_2_00060.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_2_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/expected.txt b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/test.cfg b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a758483e4bfb03460fa92225b8cc162c3d215c21 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0063-rc-function-Cycle_B_2_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00060) +run(Cycle_B_2_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..8854c70946115549ddc87c4d95ab0032002e0115 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/Cycle_B_2_00070.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_2_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + if (nsum == 37) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/expected.txt b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/test.cfg b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..df0c433c096b947f23a6afa94d76a78353e2fd79 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0064-rc-function-Cycle_B_2_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00070) +run(Cycle_B_2_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..f5c84429a6cbdd31139db3057dbd05d0a8d1490b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/Cycle_B_2_00080.java @@ -0,0 +1,117 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_2_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/expected.txt b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/test.cfg b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0248b2f5e5ec0a449c677e0417f488ffb2c779e0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0065-rc-function-Cycle_B_2_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00080) +run(Cycle_B_2_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..2d64cea277ac5ad11ef23e5781a8f366932b4440 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/Cycle_B_2_00090.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_2_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 9) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/expected.txt b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/test.cfg b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..183e3b37490ab53220858f1f6b0342f93a3edab6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0066-rc-function-Cycle_B_2_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00090) +run(Cycle_B_2_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..e294740c102074d9067ab7753b2d54a654c8ec42 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/Cycle_B_2_00100.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_B_2_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 29) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/expected.txt b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/test.cfg b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9077254336049d4d34ce9bb72a57e0b2f4322c46 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0067-rc-function-Cycle_B_2_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00100) +run(Cycle_B_2_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..8888881255bff67fe322e4093660945b76bd45e7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/Cycle_B_2_00110.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_2_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/expected.txt b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/test.cfg b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dfe3fcd3ef7fd846229ad8d713d2568b9553a997 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0068-rc-function-Cycle_B_2_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00110) +run(Cycle_B_2_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..4391fb9eacca378685799efb50285296e97537be --- /dev/null +++ b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/Cycle_B_2_00120.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 27) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/expected.txt b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/test.cfg b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60d2796d0b0faa5230ad6c9daaf928c3d89b6022 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0069-rc-function-Cycle_B_2_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00120) +run(Cycle_B_2_00120,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..d25d07f0f28185d7e4c6be366e01e3bf0eba0eb6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/Cycle_B_2_00130.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +public class Cycle_B_2_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + if (nsum == 45) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/expected.txt b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/test.cfg b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..814544b8e1ef25f13bb54bb3d7df57ef0fadd363 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0070-rc-function-Cycle_B_2_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00130) +run(Cycle_B_2_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..835ed89c5b9227af15a2fd299b1fa81bd70250d1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/Cycle_B_2_00140.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a1_0.a; + } +} +class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/expected.txt b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/test.cfg b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3a5ee87a9fb6dcf331e09eba6d02294e2e8031e9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0071-rc-function-Cycle_B_2_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00140) +run(Cycle_B_2_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..97b5cce38a2a4f75aeb0c90961e0e549ced2a9f1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/Cycle_B_2_00150.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +public class Cycle_B_2_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 14) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/expected.txt b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/test.cfg b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9240ab6e876d6c652d0d54d3f8d9f38ccabc15b0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0072-rc-function-Cycle_B_2_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00150) +run(Cycle_B_2_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..773cc47b2274806530742c3dbd4245938a5f4ccc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/Cycle_B_2_00160.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/expected.txt b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/test.cfg b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e5f8ccc0b6c4058f263690c94ba64b68fa8f86fd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0073-rc-function-Cycle_B_2_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00160) +run(Cycle_B_2_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..76b8ae3a103fc4391c18a3bd09290c238033a598 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/Cycle_B_2_00170.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/expected.txt b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/test.cfg b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e050fe2b2e768976c6e3d60d5dd5eac8bb8d53c8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0074-rc-function-Cycle_B_2_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00170) +run(Cycle_B_2_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..f3378e1576e1d45a12c9bd2d027b945b3d8dc038 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/Cycle_B_2_00180.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a4_0.a; + } +} +class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_B_2_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/expected.txt b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/test.cfg b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ffa159edeea38acbb50b54b83f2d0552a97b728e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0075-rc-function-Cycle_B_2_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00180) +run(Cycle_B_2_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..5ddf7ebd83d6531ec4f4855d90e649e84563f53f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/Cycle_B_2_00190.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_2_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/expected.txt b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/test.cfg b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..215847d9e7e2f5757aaa7625336d65e16fceaefc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0076-rc-function-Cycle_B_2_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00190) +run(Cycle_B_2_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..499395b7fe41937c7376508d8acc524a0ac0656c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/Cycle_B_2_00200.java @@ -0,0 +1,92 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a + a1_0.a; + } +} +class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +public class Cycle_B_2_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/expected.txt b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/test.cfg b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8f674a2682591a434e7af4a40da08904b00d1d96 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0077-rc-function-Cycle_B_2_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00200) +run(Cycle_B_2_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..f0af9b98e8576780524af86f39f45e4809299988 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/Cycle_B_2_00210.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a8_0.a; + } +} +class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_2_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/expected.txt b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/test.cfg b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7e56114197b6912a42a137ada5e66b62671a21f4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0078-rc-function-Cycle_B_2_00210/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00210) +run(Cycle_B_2_00210,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..ff611dab6106eda269533c11f853a16ee5ac56a1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/Cycle_B_2_00220.java @@ -0,0 +1,167 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a8_0.a; + } +} +class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class Cycle_B_2_00220 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/expected.txt b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/test.cfg b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b95ba7a766d31033b1e8ef2e47567296f798795b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0079-rc-function-Cycle_B_2_00220/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00220) +run(Cycle_B_2_00220,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..fdc4698aa3c1aee8f5985b8dbde085954114c025 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/Cycle_B_2_00230.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a10_0.a; + } +} +class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + void add() { + sum = a + a8_0.a; + } +} +public class Cycle_B_2_00230 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 97) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/expected.txt b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/test.cfg b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..737a79c7174d751813d338c7f686c55f884554a8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0080-rc-function-Cycle_B_2_00230/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00230) +run(Cycle_B_2_00230,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..bb7ed961925afbdf8a4b4a7f41ccc8ab72589475 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/Cycle_B_2_00240.java @@ -0,0 +1,187 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_B_2_00240_A1 { + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00240_A2 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } +} +class Cycle_B_2_00240_A3 { + Cycle_B_2_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00240_A4 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } +} +class Cycle_B_2_00240_B1 { + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_B2 b2_0; + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + Cycle_B_2_00240_B1() { + a3_0 = null; + b2_0 = null; + c2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a3_0.a + b2_0.a + c2_0.a; + } +} +class Cycle_B_2_00240_B2 { + Cycle_B_2_00240_B1 b1_0; + int a; + int sum; + Cycle_B_2_00240_B2() { + b1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_B_2_00240_C1 { + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_B_2_00240_C1(String strObjectName) { + c2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + c2_0.a; + } +} +class Nocycle_B_2_00240_C2 { + int a; + int sum; + String strObjectName; + Nocycle_B_2_00240_C2(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } +} +public class Cycle_B_2_00240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00240_A1 a1_main = new Cycle_B_2_00240_A1("a1_main"); + a1_main.a2_0 = new Cycle_B_2_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_B_2_00240_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_B_2_00240_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + Cycle_B_2_00240_B1 b1_0 = new Cycle_B_2_00240_B1(); + b1_0.a3_0 = new Cycle_B_2_00240_A3("a3_b1"); + b1_0.b2_0 = new Cycle_B_2_00240_B2(); + b1_0.c2_0 = new Nocycle_B_2_00240_C2("c2_b1"); + b1_0.b2_0.b1_0 = b1_0; + b1_0.add(); + b1_0.b2_0.add(); + int nsum = (b1_0.sum + b1_0.b2_0.sum); + Nocycle_B_2_00240_C1 c1_main = new Nocycle_B_2_00240_C1("c1_main"); + c1_main.c2_0 = new Nocycle_B_2_00240_C2("c2_0"); + c1_main.add(); + c1_main.c2_0.add(); + int result2 = c1_main.sum + c1_main.c2_0.sum; + if (result == 1124 && nsum == 310 && result2 == 704) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/expected.txt b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/test.cfg b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ef4f5434001a6a0559bff0dd12854ce6b08e048 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0081-rc-function-Cycle_B_2_00240/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_B_2_00240) +run(Cycle_B_2_00240,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..49f5876adb812feb202cf2caeb52f60e389502ae --- /dev/null +++ b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/Nocycle_a_00010.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00010_A1 { + Nocycle_a_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + public static void rc_testcase_main_wrapper() { + Nocycle_a_00010_A1 a1_main = new Nocycle_a_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 704) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/expected.txt b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/test.cfg b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73671ef51d3917b564b540a0ff0e45454a019606 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0082-rc-function-Nocycle_a_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00010) +run(Nocycle_a_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..eb86d2e754c4294f30e9942898b7131991edb1b8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/Nocycle_a_00020.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1310) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/expected.txt b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/test.cfg b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4198f69bbbb772273657d30b344da4c0b9d4b88d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0083-rc-function-Nocycle_a_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00020) +run(Nocycle_a_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..0ec60b1bff0c176678e592d1ddc198bbc614dbd5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/Nocycle_a_00030.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + if (result == 1919) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/expected.txt b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/test.cfg b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e1ae92585286e870ecee94f3e046402a605a0def --- /dev/null +++ b/testsuite/java_test/rc_test/RC0084-rc-function-Nocycle_a_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00030) +run(Nocycle_a_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..f6a853972110e3d5dd70a98489e355ebbf98075f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/Nocycle_a_00040.java @@ -0,0 +1,223 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } +} +class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + if (result == 6266) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/expected.txt b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/test.cfg b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..15fc6a3bc3b95c9e19607582ede4474b97aadd2f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0085-rc-function-Nocycle_a_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00040) +run(Nocycle_a_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..17bdb9b3e5ca3f24aeda5f0efec4419df481e7ec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/Nocycle_a_00050.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5048) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/expected.txt b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/test.cfg b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bb00c26e215fddb925c6291a6ec900b21a483d50 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0086-rc-function-Nocycle_a_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00050) +run(Nocycle_a_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..9e57bdab8d272da78488175f28612051889a032a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/Nocycle_a_00060.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + if (result == 5047) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/expected.txt b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/test.cfg b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ca4c33c7f602ad30b3b0a01066241f15baad5c30 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0087-rc-function-Nocycle_a_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00060) +run(Nocycle_a_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..2587d284b2ce47d1a053f796d23450e77173d6fc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/Nocycle_a_00070.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5045) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/expected.txt b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/test.cfg b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2623d5d696dced954d53a9a7872def919b399ad4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0088-rc-function-Nocycle_a_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00070) +run(Nocycle_a_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..3e517a52526281bebe5a17ea91f8c03c1eda123c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/Nocycle_a_00080.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1406) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/expected.txt b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/test.cfg b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..91bd7adb713b86ca053839bfec40fb220aea165a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0089-rc-function-Nocycle_a_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00080) +run(Nocycle_a_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..401917056ae118fd8a70c7643c17d788ec8eeb16 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/Nocycle_a_00090.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2308) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/expected.txt b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/test.cfg b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..529548b2da8a5ed073d07c520c332f15e3fcc9c1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0090-rc-function-Nocycle_a_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00090) +run(Nocycle_a_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..370186be6f6fd450fd6878d859cd75dc374b6b91 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/Nocycle_a_00100.java @@ -0,0 +1,205 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } +} +class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } +} +class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } +} +class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } +} +class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } +} +class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } +} +class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + if (result == 11920) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/expected.txt b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/test.cfg b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..787649b33ee1c14b75800aff33557d2fa6a9af4f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0091-rc-function-Nocycle_a_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00100) +run(Nocycle_a_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..90e4c793ed08ce93315e9ff9444de977a7eabbd1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/Nocycle_a_00110.java @@ -0,0 +1,258 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } +} +class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c2_0.a; + } +} +class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c3_0.a; + } +} +class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d3_0.a + d4_0.a; + } +} +class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + if (result == 9881) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/expected.txt b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/test.cfg b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..575b6648e7390602eac7f1ff5be2d10dc31f4ec2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0092-rc-function-Nocycle_a_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00110) +run(Nocycle_a_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java new file mode 100644 index 0000000000000000000000000000000000000000..c3da44b89cc89bdf6957f53e1dcc93b40052307b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/Nocycle_a_00120.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00120 { + public static void main(String[] args) { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + if (result == 1007) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/expected.txt b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/test.cfg b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..00b5684f6b26d94b6c681b3bedbbbcc8079a0780 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0093-rc-function-Nocycle_a_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00120) +run(Nocycle_a_00120,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..dbe0cdb3026a90c3309bede01eb829558a5e3c73 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/Nocycle_a_00130.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + if (result == 3467) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/expected.txt b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/test.cfg b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bd12e0ccecb336f29b7841eac4b0e2236dc30e39 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0094-rc-function-Nocycle_a_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00130) +run(Nocycle_a_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..3cfa16da0abc47a2c6917f6f2c43e0c435775273 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/Nocycle_a_00140.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1613) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/expected.txt b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/test.cfg b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a986d3437ab34dbe0a690b6e1b796ba6beb2e380 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0095-rc-function-Nocycle_a_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00140) +run(Nocycle_a_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..1667cfa96cd2e85862f5594b1d864e87ba001748 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/Nocycle_a_00150.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1815) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/expected.txt b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/test.cfg b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0f84b7da82152b7eb373f182f7832a54c735ce38 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0096-rc-function-Nocycle_a_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00150) +run(Nocycle_a_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..5c87a3405ba25c31d77b97923830ff9c59f88c38 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/Nocycle_a_00160.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 2828) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/expected.txt b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/test.cfg b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6e092475e24bf06ffdbebdeaa72b188f2323c660 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0097-rc-function-Nocycle_a_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00160) +run(Nocycle_a_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..70bd5b9adb9f1335a00abecb01ad00589b45e240 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/Nocycle_a_00170.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + if (result == 4046) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/expected.txt b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/test.cfg b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e892894fa3ea879d7ef2e2eee08145d82840c21a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0098-rc-function-Nocycle_a_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00170) +run(Nocycle_a_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..bd5a06313aee9177f3f74c153d302c0b907ac694 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/Nocycle_a_00180.java @@ -0,0 +1,283 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + if (result == 9260) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/expected.txt b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/test.cfg b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9d6a6f7b15c383764d5af0b63016cf3fb215d325 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0099-rc-function-Nocycle_a_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_00180) +run(Nocycle_a_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..76dcc8be82935b4f7e16ea4d29c0f1096042262d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/Nocycle_a_2_00010.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } +} +class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_2_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + if (result == 1939) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/expected.txt b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/test.cfg b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4456b407bd15ae71fb35c38ba7ff627b60224163 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0100-rc-function-Nocycle_a_2_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_2_00010) +run(Nocycle_a_2_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..76b4212d60e03aba34fc6e2c96a453907f3d8516 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/Nocycle_a_2_00020.java @@ -0,0 +1,608 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } +} +class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } +} +class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } +} +class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } +} +class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } +} +class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } +} +class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } +} +class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_a_2_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + int result = result1 + result2 + result3; + if (result == 26225) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/expected.txt b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/test.cfg b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8e24acd1265f56046fe31b61f0aa8193349cd35d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0101-rc-function-Nocycle_a_2_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_a_2_00020) +run(Nocycle_a_2_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/RC_basic.java b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/RC_basic.java new file mode 100755 index 0000000000000000000000000000000000000000..9f5781a24314e5e6887ef901cf6397a707c4b832 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/RC_basic.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class RC_basic { + private Object obj; + private String[] str; + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + public static void rc_testcase_main_wrapper() { + RC_basic rc = new RC_basic(); + rc.obj = new Object(); + rc.str = new String[10]; + Test1(); + Test2(); + Test3(); + Test4(rc); + Test5(rc); + Test6(rc); + Test7(rc); + Test8(); + Test9(); + Test10(); + } + // simple new and recycle + static void Test1() { + RC_basic obj = new RC_basic(); + consume(obj); + } + // new and return + static RC_basic Test2() { + RC_basic obj = new RC_basic(); + return obj; + } + // new and consume and return + static Object Test3() { + RC_basic obj = new RC_basic(); + consume(obj); + return obj; + } + // load and dec + static void Test4(RC_basic rc) { + Object obj = rc.obj; + consume(obj); + } + // load and dec + static void Test5(RC_basic rc) { + consume(rc.obj); + } + // load and return + static Object Test6(RC_basic rc) { + return rc.obj; + } + // load consume and return + static Object Test7(RC_basic rc) { + Object o = rc.str; + consume(o); + return o; + } + // call and consume + static void Test8() { + RC_basic obj = Test2(); + consume(obj); + } + // call consume and return + static Object Test9() { + RC_basic obj = Test2(); + consume(obj); + return obj; + } + // call and not consume + static void Test10() { + Test2(); + } + public static void consume(Object obj) { + //System.out.println("do noting"); + } +} diff --git a/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/expected.txt b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/test.cfg b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..677d70f22762dd5e2300e30390119663082d388e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0102-rc-function-RC_basic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_basic) +run(RC_basic,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java new file mode 100755 index 0000000000000000000000000000000000000000..8e76e1a331bac3d9eac41903678fce92a4a95897 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/RC_eh_01.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.nio.charset.IllegalCharsetNameException; +public class RC_eh_01 { + static int res = 0; + public static void main(String argv[]) { + run1(); + System.out.println("ExpectResult"); + } + public static void run1() { + try { + new RC_eh_01().run2(); + } catch (IllegalArgumentException e) { + RC_eh_01.res = 1; + } + } + public void run2() { + Foo f1 = new Foo(1); + Foo f2 = new Foo(2); + run3(); + int result=f1.i+f2.i; + } + public static void run3() { + try { + Integer.parseInt("123#456"); + } catch (IllegalCharsetNameException e) { + RC_eh_01.res = 3; + } + } + class Foo{ + public int i; + public Foo(int i){ + this.i=i; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/expected.txt b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/test.cfg b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7bab6d1611438491c1464df3f54fbbcad27ad00d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0103-rc-function-RC_eh_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_eh_01) +run(RC_eh_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java new file mode 100755 index 0000000000000000000000000000000000000000..906f7f2db35815931b0f75600c514c77464e4d92 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/RC_Finalize_01.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class C { + static A a; +} +class A { + B b; + public A(B b) { + this.b = b; + } + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("A finalize"); + C.a = this; + } +} +class B { + int num1; + int num2; + public B(int num1, int num2) { + this.num1 = num1; + this.num2 = num2; + } + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } + public int sum() { + return num1 + num2; + } +} +public class RC_Finalize_01 { + public static void main(String[] args) throws Exception { + A a = new A(new B(12, 18)); + a = null; + //System.gc(); + Thread.sleep(5000); + System.out.println("ExpectResult"); +} +} diff --git a/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/expected.txt b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/test.cfg b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..278a0f8da4c2dc0728fcc64ecb7940b6adc10f6a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0104-rc-function-RC_Finalize_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Finalize_01) +run(RC_Finalize_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/RC_flow.java b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/RC_flow.java new file mode 100755 index 0000000000000000000000000000000000000000..38382fe899496b5d4c8c5f7e142cfb1ef93bb118 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/RC_flow.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class RC_flow { + private Object obj; + private byte[] b; + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + public static void rc_testcase_main_wrapper() { + TestFlow1(21); + TestFlow2(30); + TestFlow3(56); + } + static Object TestFlow1(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = new RC_flow(); + } + } + return rc; + } + static Object TestFlow2(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + return rc; + } + static void TestFlow3(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + } + static RC_flow Test2() { + RC_flow obj = new RC_flow(); + return obj; + } +} diff --git a/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/expected.txt b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/test.cfg b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3bc714f9f499476b25f96ded6192ec1fbe42d426 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0105-rc-function-RC_flow/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_flow) +run(RC_flow,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/RC_multest.java b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/RC_multest.java new file mode 100755 index 0000000000000000000000000000000000000000..513261ca9f97be43c458a92b7ae7e95e64ab38ed --- /dev/null +++ b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/RC_multest.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class RC_multest { + static Foo f; + private Object obj; + private byte[] b; + { + f = new Bar(); + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + TestSimple(); + TestParam(); + TestFlow(); + f = null; + } + static void TestSimple() { + RC_multest rc = new RC_multest(); + rc.obj = new Object(); + rc.b = new byte[10]; + Test1(); + Test2(); + Test3(); + Test4(rc); + Test5(rc); + Test6(rc); + Test7(rc); + Test8(); + Test9(); + Test10(); + } + static void TestParam() { + RC_multest rc = new RC_multest(); + rc.obj = new Object(); + rc.b = new byte[10]; + TestParam1(rc); + TestParam2(rc); + TestParam3(rc); + } + static void TestFlow() { + TestFlow1(21); + TestFlow2(30); + } + // simple new and recycle + static void Test1() { + RC_multest obj = new RC_multest(); + consume(obj); + } + // new and return + static RC_multest Test2() { + RC_multest obj = new RC_multest(); + return obj; + } + // new and consume and return + static Object Test3() { + RC_multest obj = new RC_multest(); + consume(obj); + return obj; + } + // load and dec + static void Test4(RC_multest rc) { + Object obj = rc.obj; + consume(obj); + } + // load and dec + static void Test5(RC_multest rc) { + consume(rc.obj); + } + // load and return + static Object Test6(RC_multest rc) { + return rc.obj; + } + // load consume and return + static Object Test7(RC_multest rc) { + Object o = rc.b; + consume(o); + return o; + } + // call and consume + static void Test8() { + RC_multest obj = Test2(); + consume(obj); + } + // call consume and return + static Object Test9() { + RC_multest obj = Test2(); + consume(obj); + return obj; + } + // call and not consume + static void Test10() { + Test2(); + } + // parameter related + // 1. parameter is returned + // 2. parameter is redefined + // 3. parameter is redefined conditionally + static Object TestParam1(RC_multest rc) { + consume(rc); + return rc; + } + static Object TestParam2(RC_multest rc) { + consume(rc); + rc = Test2(); + return rc; + } + static Object TestParam3(RC_multest rc) { + consume(rc); + if (rc.b != null) { + rc = Test2(); + } + return rc; + } + static Object TestParam4() { + RC_multest rc = new RC_multest(); + consume_return(rc); + return rc; + } + // object field store + // local variable + // 1. local varaible is redefined in if/loop + static Object TestFlow1(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = new RC_multest(); + } + } + return rc; + } + static Object TestFlow2(int num) { + Object rc = null; + for (int i = 1; i < num; i++) { + if ((i % 5) == 0) { + rc = Test2(); + } + } + return rc; + } + // class info + // exception + static Object consume_return(Object obj) { + return obj; + } + static void consume(Object obj) { + f.consume(obj); + } +} +class Foo { + void consume(Object obj) { + } +} +class Bar extends Foo { + void consume(Object obj) { + } +} diff --git a/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/expected.txt b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/test.cfg b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..634c1910175bf0ee5125e90c2699f42dd1885dee --- /dev/null +++ b/testsuite/java_test/rc_test/RC0106-rc-function-RC_multest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_multest) +run(RC_multest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..4518460d2ff6105d368dd59e5af219a23e5a4ee9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/Cycle_aDec_00010.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_aDec_00010_A1 { + Cycle_aDec_00010_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_aDec_00010_A2 { + Cycle_aDec_00010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_aDec_00010_A3 { + Cycle_aDec_00010_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_aDec_00010_A4 { + Cycle_aDec_00010_A1 a1_0; + Cycle_aDec_00010_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_aDec_00010_A5 { + Cycle_aDec_00010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_aDec_00010_A6 { + Cycle_aDec_00010_A1 a1_0; + Cycle_aDec_00010_A4 a4_0; + Cycle_aDec_00010_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00010_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} +public class Cycle_aDec_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void Modify(Cycle_aDec_00010_A1 a1_main) { + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + } + private static void rc_testcase_main_wrapper() { + Cycle_aDec_00010_A1 a1_main = new Cycle_aDec_00010_A1("a1_main"); + Cycle_aDec_00010_A5 a5_main = new Cycle_aDec_00010_A5("a5_main"); + a1_main.a2_0 = new Cycle_aDec_00010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_aDec_00010_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_aDec_00010_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_aDec_00010_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + Modify(a1_main); + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0 = null; + int result = a1_main.sum + a5_main.sum + a5_main.a3_0.sum + a5_main.a3_0.a4_0.sum + a5_main.a3_0.a4_0.a6_0.sum; + if (result == 1137) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/expected.txt b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/test.cfg b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..14b325233c81549f96c660d66b8cebdb0c50a500 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0107-rc-function-RC_Dec-Cycle_aDec_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_aDec_00010) +run(Cycle_aDec_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..6c2cc341b6d714292ee2348e4a8440c7f4789113 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/Cycle_aDec_00020.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_aDec_00020_A1 { + Cycle_aDec_00020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Cycle_aDec_00020_A2 { + Cycle_aDec_00020_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_aDec_00020_A3 { + Cycle_aDec_00020_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_aDec_00020_A4 { + Cycle_aDec_00020_A1 a1_0; + Cycle_aDec_00020_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } +} +class Cycle_aDec_00020_A5 { + Cycle_aDec_00020_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_aDec_00020_A6 { + Cycle_aDec_00020_A1 a1_0; + Cycle_aDec_00020_A4 a4_0; + Cycle_aDec_00020_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_aDec_00020_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } +} +public class Cycle_aDec_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void Modify(Cycle_aDec_00020_A1 a1_main) { + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + } + private static void rc_testcase_main_wrapper() { + Cycle_aDec_00020_A1 a1_main = new Cycle_aDec_00020_A1("a1_main"); + Cycle_aDec_00020_A5 a5_main = new Cycle_aDec_00020_A5("a5_main"); + a1_main.a2_0 = new Cycle_aDec_00020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_aDec_00020_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_aDec_00020_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_aDec_00020_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + Modify(a1_main); + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0 = null; + a5_main = null; + a1_main.add(); + int result = a1_main.sum; + if (result == 202) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/expected.txt b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/test.cfg b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..19855983008db33294e2c49c283b14ccf250e9ec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0108-rc-function-RC_Dec-Cycle_aDec_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_aDec_00020) +run(Cycle_aDec_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..6f1f062002077052f25e15906af749deb7b364a1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/Cycle_BDec_00010.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_BDec_00010_A1 { + Cycle_BDec_00010_A2 a2_0; + int a; + int sum; + Cycle_BDec_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_BDec_00010_A2 { + Cycle_BDec_00010_A1 a1_0; + int a; + int sum; + Cycle_BDec_00010_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class Cycle_BDec_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static boolean ModifyA1(Cycle_BDec_00010_A1 a1_0) { + a1_0.add(); + a1_0.a2_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + if (nsum == 6) + return true; + else + return false; + } + public static void rc_testcase_main_wrapper() { + Cycle_BDec_00010_A1 a1_0 = new Cycle_BDec_00010_A1(); + a1_0.a2_0 = new Cycle_BDec_00010_A2(); + a1_0.a2_0.a1_0 = a1_0; + boolean ret = ModifyA1(a1_0); + a1_0 = null; + if (ret == true && a1_0 == null) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/expected.txt b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/test.cfg b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4372da4d06a73db0d55f0d692252399cf113ca8d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0109-rc-function-RC_Dec-Cycle_BDec_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_BDec_00010) +run(Cycle_BDec_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..f991ea92d3f511c6042007bd76fb1c0dcbf7fec7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/Cycle_BDec_00020.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_BDec_00020_A1 { + Cycle_BDec_00020_A2 a2_0; + int a; + int sum; + Cycle_BDec_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_BDec_00020_A2 { + Cycle_BDec_00020_A3 a3_0; + Cycle_BDec_00020_A4 a4_0; + int a; + int sum; + Cycle_BDec_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_BDec_00020_A3 { + Cycle_BDec_00020_A1 a1_0; + int a; + int sum; + Cycle_BDec_00020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_BDec_00020_A4 { + int a; + int sum; + Cycle_BDec_00020_A5 a5_0; + Cycle_BDec_00020_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } +} +class Cycle_BDec_00020_A5 { + int a; + int sum; + Cycle_BDec_00020_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } +} +public class Cycle_BDec_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void ModifyA1(Cycle_BDec_00020_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + } + public static void rc_testcase_main_wrapper() { + Cycle_BDec_00020_A1 a1_0 = new Cycle_BDec_00020_A1(); + a1_0.a2_0 = new Cycle_BDec_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00020_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_BDec_00020_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_BDec_00020_A5(); + ModifyA1(a1_0); + a1_0.a2_0.a4_0 = null; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int result = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum; + if (result == 12) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/expected.txt b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/test.cfg b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..52c81fb336950afc8500939b1e83cc1515765e64 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0110-rc-function-RC_Dec-Cycle_BDec_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_BDec_00020) +run(Cycle_BDec_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..95f4a4e0997b9d0f7c54b8c5acfc5e1bb8d5e649 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/Cycle_BDec_00030.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_BDec_00030_A1 { + Cycle_BDec_00030_A2 a2_0; + int a; + int sum; + Cycle_BDec_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_BDec_00030_A2 { + Cycle_BDec_00030_A3 a3_0; + Cycle_BDec_00030_A4 a4_0; + int a; + int sum; + Cycle_BDec_00030_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_BDec_00030_A3 { + Cycle_BDec_00030_A1 a1_0; + Cycle_BDec_00030_A4 a4_0; + int a; + int sum; + Cycle_BDec_00030_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_BDec_00030_A4 { + Cycle_BDec_00030_A3 a3_0; + int a; + int sum; + Cycle_BDec_00030_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_BDec_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void ModifyA1(Cycle_BDec_00030_A1 a1) { + a1 = null; + a1 = new Cycle_BDec_00030_A1(); + } + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00030_A1 a1_0 = new Cycle_BDec_00030_A1(); + a1_0.a2_0 = new Cycle_BDec_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00030_A3(); + Cycle_BDec_00030_A4 a4_0 = new Cycle_BDec_00030_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + ModifyA1(a1_0); + a1_0 = null; + a4_0.add(); + a4_0.a3_0.add(); + int nsum = (a4_0.a3_0.sum + a4_0.sum); + if (nsum == 14) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/expected.txt b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/test.cfg b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..82124cfc9210a363a55407cd482004bb0c1150c0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0111-rc-function-RC_Dec-Cycle_BDec_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_BDec_00030) +run(Cycle_BDec_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..2e645b633dd7bd3c40c105c7c8fcc800af5db825 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/Cycle_BDec_00040.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_BDec_00040_A1 { + Cycle_BDec_00040_A2 a2_0; + int a; + int sum; + Cycle_BDec_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_BDec_00040_A2 { + Cycle_BDec_00040_A3 a3_0; + Cycle_BDec_00040_A4 a4_0; + int a; + int sum; + Cycle_BDec_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_BDec_00040_A3 { + Cycle_BDec_00040_A1 a1_0; + Cycle_BDec_00040_A4 a4_0; + int a; + int sum; + Cycle_BDec_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_BDec_00040_A4 { + Cycle_BDec_00040_A3 a3_0; + int a; + int sum; + Cycle_BDec_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_BDec_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void modifyA1(Cycle_BDec_00040_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + a1.a2_0.a3_0.a4_0.add(); + } + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00040_A1 a1_0 = new Cycle_BDec_00040_A1(); + a1_0.a2_0 = new Cycle_BDec_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00040_A3(); + Cycle_BDec_00040_A4 a4_0 = new Cycle_BDec_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + modifyA1(a1_0); + a1_0 = null; + a4_0 = null; + } +} diff --git a/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/expected.txt b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/test.cfg b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..668c29eb5e53ec97559c7761496c701d1474ab5a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0112-rc-function-RC_Dec-Cycle_BDec_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_BDec_00040) +run(Cycle_BDec_00040,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..47d45d40df9eba3312ec770783caa965305856c1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/Cycle_BDec_00050.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cycle_BDec_00050_A1 { + Cycle_BDec_00050_A2 a2_0; + int a; + int sum; + Cycle_BDec_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_BDec_00050_A2 { + Cycle_BDec_00050_A3 a3_0; + Cycle_BDec_00050_A4 a4_0; + int a; + int sum; + Cycle_BDec_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_BDec_00050_A3 { + Cycle_BDec_00050_A1 a1_0; + Cycle_BDec_00050_A4 a4_0; + int a; + int sum; + Cycle_BDec_00050_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_BDec_00050_A4 { + Cycle_BDec_00050_A3 a3_0; + int a; + int sum; + Cycle_BDec_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +public class Cycle_BDec_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void modifyA1(Cycle_BDec_00050_A1 a1) { + a1.add(); + a1.a2_0.add(); + a1.a2_0.a3_0.add(); + a1.a2_0.a3_0.a4_0.add(); + } + private static void rc_testcase_main_wrapper() { + Cycle_BDec_00050_A1 a1_0 = new Cycle_BDec_00050_A1(); + a1_0.a2_0 = new Cycle_BDec_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_BDec_00050_A3(); + Cycle_BDec_00050_A4 a4_0 = new Cycle_BDec_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + modifyA1(a1_0); + //cancel inline by for flow + int sum=0; + for(int i=0;i<100;i++) + sum +=i; + a1_0.a2_0.a3_0.a1_0 = null; + a4_0.a3_0 = null; + } +} diff --git a/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/expected.txt b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/test.cfg b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f5368f2ea248c08b978f3ca2cd37631c6943ad6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0113-rc-function-RC_Dec-Cycle_BDec_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_BDec_00050) +run(Cycle_BDec_00050,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..aad038e796c82333f3a3657f39991aa7c7f42a8d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/Nocycle_aDec_00010.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00010_A1 { + Nocycle_aDec_00010_B1 b1_0; + Nocycle_aDec_00010_B2 b2_0; + Nocycle_aDec_00010_B3 b3_0; + Nocycle_aDec_00010_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_aDec_00010_B1 { + Nocycle_aDec_00010_C1 c1_0; + Nocycle_aDec_00010_C2 c2_0; + Nocycle_aDec_00010_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_aDec_00010_B2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00010_B3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00010_B4 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00010_C1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00010_C2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00010_C3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00010_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00010_A1 a1_main = new Nocycle_aDec_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00010_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00010_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00010_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00010_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00010_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00010_B4("b4_0"); + Nocycle_aDec_00010_A1 a1_copy = modifyA1(a1_main); + a1_main = null; + a1_copy.add(); + a1_copy.b1_0.add(); + a1_copy.b2_0.add(); + a1_copy.b3_0.add(); + a1_copy.b4_0.add(); + a1_copy.b1_0.c1_0.add(); + a1_copy.b1_0.c2_0.add(); + a1_copy.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_copy.sum+a1_copy.b1_0.sum+a1_copy.b2_0.sum+a1_copy.b3_0.sum+a1_copy.b4_0.sum+a1_copy.b1_0.c1_0.sum+a1_copy.b1_0.c2_0.sum+a1_copy.b1_0.c3_0.sum); + int result = a1_copy.sum + a1_copy.b1_0.sum + a1_copy.b2_0.sum + a1_copy.b3_0.sum + a1_copy.b4_0.sum + a1_copy.b1_0.c1_0.sum + a1_copy.b1_0.c2_0.sum + a1_copy.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5049) + System.out.println("ExpectResult"); + } + public static Nocycle_aDec_00010_A1 modifyA1(Nocycle_aDec_00010_A1 a1) { + a1.a = 102; + return a1; + } +} diff --git a/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/expected.txt b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/test.cfg b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..732712b185977448182f70eb73f2d941872fb387 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0114-rc-function-RC_Dec-Nocycle_aDec_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00010) +run(Nocycle_aDec_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..f95d7329347adbaa48bd86e106595cfb8bfe6578 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/Nocycle_aDec_00020.java @@ -0,0 +1,169 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00020_A1 { + Nocycle_aDec_00020_B1 b1_0; + Nocycle_aDec_00020_B2 b2_0; + Nocycle_aDec_00020_B3 b3_0; + Nocycle_aDec_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_aDec_00020_B1 { + Nocycle_aDec_00020_C1 c1_0; + Nocycle_aDec_00020_C2 c2_0; + Nocycle_aDec_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } +} +class Nocycle_aDec_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00020_B3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00020_B4 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00020_C1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00020_C2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00020_C3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00020_A1 a1_main = new Nocycle_aDec_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00020_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00020_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00020_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00020_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00020_B4("b4_0"); + modifyB1(a1_main.b1_0); + a1_main.b1_0 = null; + a1_main.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + int result = a1_main.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum; + if (result == 1928) + System.out.println("ExpectResult"); + } + public static void modifyB1(Nocycle_aDec_00020_B1 b1) { + b1.a = 202; + } +} diff --git a/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/expected.txt b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/test.cfg b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2bde5655049ca0752534356abe4d46fffe08b944 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0115-rc-function-RC_Dec-Nocycle_aDec_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00020) +run(Nocycle_aDec_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..0bb8b664285fc7a254ec197cfeb97d72c92d1503 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/Nocycle_aDec_00030.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00030_A1 { + Nocycle_aDec_00030_B1 b1_0; + Nocycle_aDec_00030_B2 b2_0; + Nocycle_aDec_00030_B3 b3_0; + Nocycle_aDec_00030_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } +} +class Nocycle_aDec_00030_B1 { + Nocycle_aDec_00030_C1 c1_0; + Nocycle_aDec_00030_C2 c2_0; + Nocycle_aDec_00030_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a; + } +} +class Nocycle_aDec_00030_B2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00030_B3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00030_B4 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00030_C1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00030_C2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00030_C3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00030_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00030_A1 a1_main = new Nocycle_aDec_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_aDec_00030_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_aDec_00030_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_aDec_00030_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_aDec_00030_C3("c3_0"); + a1_main.b2_0 = new Nocycle_aDec_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_aDec_00030_B3("b3_0"); + a1_main.b4_0 = new Nocycle_aDec_00030_B4("b4_0"); + modifyC3(a1_main.b1_0.c3_0); + a1_main.b1_0.c3_0 = null; + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum; + if (result == 4139) + System.out.println("ExpectResult"); + } + public static void modifyC3(Nocycle_aDec_00030_C3 c3) { + c3.a += 1; + } +} diff --git a/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/expected.txt b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/test.cfg b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ee45d063e0b68d673b3dd2798cb852c65bf23373 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0116-rc-function-RC_Dec-Nocycle_aDec_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00030) +run(Nocycle_aDec_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..2ca13e19440d943bced0424336cf3a73ab6ea00c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/Nocycle_aDec_00040.java @@ -0,0 +1,288 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00040_A1 { + Nocycle_aDec_00040_B1 b1_0; + Nocycle_aDec_00040_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_aDec_00040_A2 { + Nocycle_aDec_00040_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class Nocycle_aDec_00040_A3 { + Nocycle_aDec_00040_B2 b2_0; + Nocycle_aDec_00040_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class Nocycle_aDec_00040_A4 { + Nocycle_aDec_00040_B3 b3_0; + Nocycle_aDec_00040_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_aDec_00040_B1 { + Nocycle_aDec_00040_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_aDec_00040_B2 { + Nocycle_aDec_00040_C1 c1_0; + Nocycle_aDec_00040_D1 d1_0; + Nocycle_aDec_00040_D2 d2_0; + Nocycle_aDec_00040_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00040_B3 { + Nocycle_aDec_00040_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_aDec_00040_C1 { + Nocycle_aDec_00040_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_aDec_00040_C2 { + Nocycle_aDec_00040_D2 d2_0; + Nocycle_aDec_00040_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00040_D1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00040_D2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00040_D3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00040_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00040_A1 a1_main = new Nocycle_aDec_00040_A1("a1_main"); + Nocycle_aDec_00040_A2 a2_main = new Nocycle_aDec_00040_A2("a2_main"); + Nocycle_aDec_00040_A3 a3_main = new Nocycle_aDec_00040_A3("a3_main"); + Nocycle_aDec_00040_A4 a4_main = new Nocycle_aDec_00040_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00040_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00040_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00040_D2("d2_0"); + a2_main.b2_0 = new Nocycle_aDec_00040_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00040_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00040_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00040_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + a3_main.c2_0 = new Nocycle_aDec_00040_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00040_D3("d3_0"); + a4_main.b3_0 = new Nocycle_aDec_00040_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + modifyA1(a1_main); + a1_main = null; + a2_main.add(); + a3_main.add(); + a4_main.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a2_main.sum + a3_main.sum + a4_main.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a4_main.b3_0.c1_0.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + if (result == 7954) + System.out.println("ExpectResult"); + } + private static void modifyA1(Nocycle_aDec_00040_A1 a1) { + a1.a += 1; + a1.add(); + a1.b1_0.add(); + a1.d1_0.add(); + a1.b1_0.d2_0.add(); + } +} diff --git a/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/expected.txt b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/test.cfg b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..be74f300d749c636f202676e6fdbdd062b7c1f2b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0117-rc-function-RC_Dec-Nocycle_aDec_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00040) +run(Nocycle_aDec_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..25d60cb0fd7ea8337cf3003c0d297be7a01a8627 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/Nocycle_aDec_00050.java @@ -0,0 +1,283 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00050_A1 { + Nocycle_aDec_00050_B1 b1_0; + Nocycle_aDec_00050_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_aDec_00050_A2 { + Nocycle_aDec_00050_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00050_A3 { + Nocycle_aDec_00050_B2 b2_0; + Nocycle_aDec_00050_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + c2_0.a; + } +} +class Nocycle_aDec_00050_A4 { + Nocycle_aDec_00050_B3 b3_0; + Nocycle_aDec_00050_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_aDec_00050_B1 { + Nocycle_aDec_00050_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_aDec_00050_B2 { + Nocycle_aDec_00050_C1 c1_0; + Nocycle_aDec_00050_D1 d1_0; + Nocycle_aDec_00050_D2 d2_0; + Nocycle_aDec_00050_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00050_B3 { + Nocycle_aDec_00050_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_aDec_00050_C1 { + Nocycle_aDec_00050_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_aDec_00050_C2 { + Nocycle_aDec_00050_D2 d2_0; + Nocycle_aDec_00050_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00050_D1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00050_D2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00050_D3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00050_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00050_A1 a1_main = new Nocycle_aDec_00050_A1("a1_main"); + Nocycle_aDec_00050_A2 a2_main = new Nocycle_aDec_00050_A2("a2_main"); + Nocycle_aDec_00050_A3 a3_main = new Nocycle_aDec_00050_A3("a3_main"); + Nocycle_aDec_00050_A4 a4_main = new Nocycle_aDec_00050_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00050_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00050_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00050_D2("d2_0"); + a2_main.b2_0 = new Nocycle_aDec_00050_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00050_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00050_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00050_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + a3_main.c2_0 = new Nocycle_aDec_00050_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00050_D3("d3_0"); + a4_main.b3_0 = new Nocycle_aDec_00050_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + modifyB2(a2_main.b2_0); + a2_main.b2_0 = null; + a3_main.b2_0 = null; + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a4_main.b3_0.sum + a4_main.b3_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + if (result == 7249) + System.out.println("ExpectResult"); + } + private static void modifyB2(Nocycle_aDec_00050_B2 b2) { + b2.a += 1; + b2.add(); + b2.c1_0.add(); + b2.d1_0.add(); + b2.d2_0.add(); + b2.d3_0.add(); + b2.c1_0.d1_0.add(); + } +} diff --git a/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/expected.txt b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/test.cfg b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..de0bd9c656da973c757e77bb32f9f7ab0aa7ee03 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0118-rc-function-RC_Dec-Nocycle_aDec_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00050) +run(Nocycle_aDec_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..361995cdb0427cc448b6c48e730c5a2291ece947 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/Nocycle_aDec_00060.java @@ -0,0 +1,295 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Nocycle_aDec_00060_A1 { + Nocycle_aDec_00060_B1 b1_0; + Nocycle_aDec_00060_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_aDec_00060_A2 { + Nocycle_aDec_00060_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class Nocycle_aDec_00060_A3 { + Nocycle_aDec_00060_B2 b2_0; + Nocycle_aDec_00060_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class Nocycle_aDec_00060_A4 { + Nocycle_aDec_00060_B3 b3_0; + Nocycle_aDec_00060_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_aDec_00060_B1 { + Nocycle_aDec_00060_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_aDec_00060_B2 { + Nocycle_aDec_00060_C1 c1_0; + Nocycle_aDec_00060_D1 d1_0; + Nocycle_aDec_00060_D2 d2_0; + Nocycle_aDec_00060_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00060_B3 { + Nocycle_aDec_00060_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_aDec_00060_C1 { + Nocycle_aDec_00060_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_aDec_00060_C2 { + Nocycle_aDec_00060_D2 d2_0; + Nocycle_aDec_00060_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_aDec_00060_D1 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00060_D2 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_aDec_00060_D3 { + int a; + int sum; + String strObjectName; + Nocycle_aDec_00060_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class Nocycle_aDec_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_aDec_00060_A1 a1_main = new Nocycle_aDec_00060_A1("a1_main"); + Nocycle_aDec_00060_A2 a2_main = new Nocycle_aDec_00060_A2("a2_main"); + Nocycle_aDec_00060_A3 a3_main = new Nocycle_aDec_00060_A3("a3_main"); + Nocycle_aDec_00060_A4 a4_main = new Nocycle_aDec_00060_A4("a4_main"); + a1_main.b1_0 = new Nocycle_aDec_00060_B1("b1_0"); + a1_main.d1_0 = new Nocycle_aDec_00060_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_aDec_00060_D2("d2_0"); + a2_main.b2_0 = new Nocycle_aDec_00060_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_aDec_00060_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = new Nocycle_aDec_00060_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_aDec_00060_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a2_main.b2_0.c1_0.d1_0; + a3_main.b2_0.d1_0 = a2_main.b2_0.d1_0; + a3_main.b2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + a3_main.c2_0 = new Nocycle_aDec_00060_C2("c2_0"); + a3_main.c2_0.d2_0 = a2_main.b2_0.d2_0; + a3_main.c2_0.d3_0 = new Nocycle_aDec_00060_D3("d3_0"); + a4_main.b3_0 = new Nocycle_aDec_00060_B3("b3_0"); + a4_main.b3_0.c1_0 = a3_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a3_main.b2_0.c1_0.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a3_main.c2_0.d2_0; + a4_main.c2_0.d3_0 = a3_main.c2_0.d3_0; + ModifyA1(a1_main); + ModifyA2(a2_main); + ModifyA3(a3_main); + a4_main.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a4_main.sum + a4_main.b3_0.sum + a4_main.b3_0.c1_0.sum + a4_main.c2_0.sum + a4_main.b3_0.c1_0.d1_0.sum + a4_main.c2_0.d2_0.sum + a4_main.c2_0.d3_0.sum; + if (result == 5334) + System.out.println("ExpectResult"); + } + private static void ModifyA1(Nocycle_aDec_00060_A1 a1) { + a1.a += 1; + a1.add(); + a1.b1_0.add(); + a1.d1_0.add(); + a1.b1_0.d2_0.add(); + } + private static void ModifyA2(Nocycle_aDec_00060_A2 a2) { + a2.a += 1; + a2.add(); + a2.b2_0.add(); + a2.b2_0.c1_0.add(); + a2.b2_0.d1_0.add(); + a2.b2_0.d2_0.add(); + a2.b2_0.d3_0.add(); + a2.b2_0.c1_0.d1_0.add(); + } + private static void ModifyA3(Nocycle_aDec_00060_A3 a3) { + a3.a += 1; + a3.add(); + a3.b2_0.add(); + a3.b2_0.c1_0.add(); + a3.b2_0.c1_0.d1_0.add(); + a3.b2_0.d1_0.add(); + a3.b2_0.d2_0.add(); + a3.b2_0.d3_0.add(); + a3.c2_0.add(); + a3.c2_0.d2_0.add(); + a3.c2_0.d3_0.add(); + } +} diff --git a/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/expected.txt b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/test.cfg b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3704a7650abfb77076f3c56deadbb7bf21b393f9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0119-rc-function-RC_Dec-Nocycle_aDec_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_aDec_00060) +run(Nocycle_aDec_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..b1ecf69936eab8a6302e458a356b96882522c0ed --- /dev/null +++ b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/Cycle_am_00180.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00180 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1994) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00180 A1_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A2_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A3_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A4_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A5_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + ThreadRc_Cycle_am_00180 A6_Cycle_am_00180 = new ThreadRc_Cycle_am_00180(); + A1_Cycle_am_00180.start(); + A2_Cycle_am_00180.start(); + A3_Cycle_am_00180.start(); + A4_Cycle_am_00180.start(); + A5_Cycle_am_00180.start(); + A6_Cycle_am_00180.start(); + try { + A1_Cycle_am_00180.join(); + A2_Cycle_am_00180.join(); + A3_Cycle_am_00180.join(); + A4_Cycle_am_00180.join(); + A5_Cycle_am_00180.join(); + A6_Cycle_am_00180.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00180.check() && A2_Cycle_am_00180.check() && A3_Cycle_am_00180.check() && A4_Cycle_am_00180.check() && A5_Cycle_am_00180.check() && A6_Cycle_am_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/expected.txt b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/test.cfg b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73e7d2df7f84b850d86e2467937282a07130a423 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0120-rc-function-RC_Thread01-Cycle_am_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00180) +run(Cycle_am_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..f9c88a49eeb868239f640060799d0c495e2cc735 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/Cycle_am_00190.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00190 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2215) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_am_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00190 A1_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A2_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A3_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A4_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A5_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + ThreadRc_Cycle_am_00190 A6_Cycle_am_00190 = new ThreadRc_Cycle_am_00190(); + A1_Cycle_am_00190.start(); + A2_Cycle_am_00190.start(); + A3_Cycle_am_00190.start(); + A4_Cycle_am_00190.start(); + A5_Cycle_am_00190.start(); + A6_Cycle_am_00190.start(); + try { + A1_Cycle_am_00190.join(); + A2_Cycle_am_00190.join(); + A3_Cycle_am_00190.join(); + A4_Cycle_am_00190.join(); + A5_Cycle_am_00190.join(); + A6_Cycle_am_00190.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00190.check() && A2_Cycle_am_00190.check() && A3_Cycle_am_00190.check() && A4_Cycle_am_00190.check() && A5_Cycle_am_00190.check() && A6_Cycle_am_00190.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/expected.txt b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/test.cfg b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..80eaf1893d8f0d121db82448ed638ac265ad7ae1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0121-rc-function-RC_Thread01-Cycle_am_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00190) +run(Cycle_am_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..f617118c721ec8ceeb150baeaf7c2218f468b072 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/Cycle_am_00200.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00200 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Cycle_am_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00200 A1_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A2_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A3_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A4_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A5_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + ThreadRc_Cycle_am_00200 A6_Cycle_am_00200 = new ThreadRc_Cycle_am_00200(); + A1_Cycle_am_00200.start(); + A2_Cycle_am_00200.start(); + A3_Cycle_am_00200.start(); + A4_Cycle_am_00200.start(); + A5_Cycle_am_00200.start(); + A6_Cycle_am_00200.start(); + try { + A1_Cycle_am_00200.join(); + A2_Cycle_am_00200.join(); + A3_Cycle_am_00200.join(); + A4_Cycle_am_00200.join(); + A5_Cycle_am_00200.join(); + A6_Cycle_am_00200.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00200.check() && A2_Cycle_am_00200.check() && A3_Cycle_am_00200.check() && A4_Cycle_am_00200.check() && A5_Cycle_am_00200.check() && A6_Cycle_am_00200.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/expected.txt b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/test.cfg b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e7af34a757db6645d6dcd8efd993aa55fb25a52c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0122-rc-function-RC_Thread01-Cycle_am_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00200) +run(Cycle_am_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..5b3deca822aba9b3671ab386022728918136fd36 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/Cycle_am_00210.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00210 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1662) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } + } + class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00210 A1_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A2_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A3_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A4_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A5_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + ThreadRc_Cycle_am_00210 A6_Cycle_am_00210 = new ThreadRc_Cycle_am_00210(); + A1_Cycle_am_00210.start(); + A2_Cycle_am_00210.start(); + A3_Cycle_am_00210.start(); + A4_Cycle_am_00210.start(); + A5_Cycle_am_00210.start(); + A6_Cycle_am_00210.start(); + try { + A1_Cycle_am_00210.join(); + A2_Cycle_am_00210.join(); + A3_Cycle_am_00210.join(); + A4_Cycle_am_00210.join(); + A5_Cycle_am_00210.join(); + A6_Cycle_am_00210.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00210.check() && A2_Cycle_am_00210.check() && A3_Cycle_am_00210.check() && A4_Cycle_am_00210.check() && A5_Cycle_am_00210.check() && A6_Cycle_am_00210.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/expected.txt b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/test.cfg b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..972bf5ad68fa75369c0f11358eadac8df2365ca3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0123-rc-function-RC_Thread01-Cycle_am_00210/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00210) +run(Cycle_am_00210,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..38765c1e085300458e4c4535b66ae979771f70ef --- /dev/null +++ b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/Cycle_am_00220.java @@ -0,0 +1,195 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00220 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1772) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Cycle_am_00220 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00220 A1_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A2_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A3_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A4_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A5_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + ThreadRc_Cycle_am_00220 A6_Cycle_am_00220 = new ThreadRc_Cycle_am_00220(); + A1_Cycle_am_00220.start(); + A2_Cycle_am_00220.start(); + A3_Cycle_am_00220.start(); + A4_Cycle_am_00220.start(); + A5_Cycle_am_00220.start(); + A6_Cycle_am_00220.start(); + try { + A1_Cycle_am_00220.join(); + A2_Cycle_am_00220.join(); + A3_Cycle_am_00220.join(); + A4_Cycle_am_00220.join(); + A5_Cycle_am_00220.join(); + A6_Cycle_am_00220.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00220.check() && A2_Cycle_am_00220.check() && A3_Cycle_am_00220.check() && A4_Cycle_am_00220.check() && A5_Cycle_am_00220.check() && A6_Cycle_am_00220.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/expected.txt b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/test.cfg b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2fb96c57c669b303998a0604761bd713ffab2f42 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0124-rc-function-RC_Thread01-Cycle_am_00220/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00220) +run(Cycle_am_00220,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..f9baf13258eef4ffbb592f2b17ca63835837deb7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/Cycle_am_00230.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00230 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Cycle_am_00230 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00230 A1_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A2_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A3_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A4_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A5_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + ThreadRc_Cycle_am_00230 A6_Cycle_am_00230 = new ThreadRc_Cycle_am_00230(); + A1_Cycle_am_00230.start(); + A2_Cycle_am_00230.start(); + A3_Cycle_am_00230.start(); + A4_Cycle_am_00230.start(); + A5_Cycle_am_00230.start(); + A6_Cycle_am_00230.start(); + try { + A1_Cycle_am_00230.join(); + A2_Cycle_am_00230.join(); + A3_Cycle_am_00230.join(); + A4_Cycle_am_00230.join(); + A5_Cycle_am_00230.join(); + A6_Cycle_am_00230.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00230.check() && A2_Cycle_am_00230.check() && A3_Cycle_am_00230.check() && A4_Cycle_am_00230.check() && A5_Cycle_am_00230.check() && A6_Cycle_am_00230.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/expected.txt b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/test.cfg b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..14356a62dec44e1f99447cf195d078b79cb347e9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0125-rc-function-RC_Thread01-Cycle_am_00230/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00230) +run(Cycle_am_00230,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..d1e321fc27f5acba334e523870ce1805ba715d03 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/Cycle_am_00240.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00240 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1660) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a6_0.a; + } + } + class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_am_00240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00240 A1_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A2_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A3_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A4_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A5_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + ThreadRc_Cycle_am_00240 A6_Cycle_am_00240 = new ThreadRc_Cycle_am_00240(); + A1_Cycle_am_00240.start(); + A2_Cycle_am_00240.start(); + A3_Cycle_am_00240.start(); + A4_Cycle_am_00240.start(); + A5_Cycle_am_00240.start(); + A6_Cycle_am_00240.start(); + try { + A1_Cycle_am_00240.join(); + A2_Cycle_am_00240.join(); + A3_Cycle_am_00240.join(); + A4_Cycle_am_00240.join(); + A5_Cycle_am_00240.join(); + A6_Cycle_am_00240.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00240.check() && A2_Cycle_am_00240.check() && A3_Cycle_am_00240.check() && A4_Cycle_am_00240.check() && A5_Cycle_am_00240.check() && A6_Cycle_am_00240.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/expected.txt b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/test.cfg b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5e98504eb031771d785522a1171f33a447a12ad8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0126-rc-function-RC_Thread01-Cycle_am_00240/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00240) +run(Cycle_am_00240,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java new file mode 100755 index 0000000000000000000000000000000000000000..24999b7054c7849af12b837c91ccec88dac65913 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/Cycle_am_00250.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00250 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1238) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00250 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00250 A1_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A2_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A3_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A4_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A5_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + ThreadRc_Cycle_am_00250 A6_Cycle_am_00250 = new ThreadRc_Cycle_am_00250(); + A1_Cycle_am_00250.start(); + A2_Cycle_am_00250.start(); + A3_Cycle_am_00250.start(); + A4_Cycle_am_00250.start(); + A5_Cycle_am_00250.start(); + A6_Cycle_am_00250.start(); + try { + A1_Cycle_am_00250.join(); + A2_Cycle_am_00250.join(); + A3_Cycle_am_00250.join(); + A4_Cycle_am_00250.join(); + A5_Cycle_am_00250.join(); + A6_Cycle_am_00250.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00250.check() && A2_Cycle_am_00250.check() && A3_Cycle_am_00250.check() && A4_Cycle_am_00250.check() && A5_Cycle_am_00250.check() && A6_Cycle_am_00250.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/expected.txt b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/test.cfg b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..67fb8d32dadcf9899db3e727f64a970cd8bfc659 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0127-rc-function-RC_Thread01-Cycle_am_00250/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00250) +run(Cycle_am_00250,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java new file mode 100755 index 0000000000000000000000000000000000000000..ae01e119e0b1d1740354edcf1086a0db624907da --- /dev/null +++ b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/Cycle_am_00260.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00260 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1239) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00260 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00260 A1_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A2_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A3_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A4_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A5_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + ThreadRc_Cycle_am_00260 A6_Cycle_am_00260 = new ThreadRc_Cycle_am_00260(); + A1_Cycle_am_00260.start(); + A2_Cycle_am_00260.start(); + A3_Cycle_am_00260.start(); + A4_Cycle_am_00260.start(); + A5_Cycle_am_00260.start(); + A6_Cycle_am_00260.start(); + try { + A1_Cycle_am_00260.join(); + A2_Cycle_am_00260.join(); + A3_Cycle_am_00260.join(); + A4_Cycle_am_00260.join(); + A5_Cycle_am_00260.join(); + A6_Cycle_am_00260.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00260.check() && A2_Cycle_am_00260.check() && A3_Cycle_am_00260.check() && A4_Cycle_am_00260.check() && A5_Cycle_am_00260.check() && A6_Cycle_am_00260.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/expected.txt b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/test.cfg b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f4e831516a0df11483d4359e0e064d8cd65e6975 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0128-rc-function-RC_Thread01-Cycle_am_00260/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00260) +run(Cycle_am_00260,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java new file mode 100755 index 0000000000000000000000000000000000000000..3ee33cdecf02117fe608558a19c6c0f5d4c6f1d8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/Cycle_am_00270.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00270 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1240) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00270 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00270 A1_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A2_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A3_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A4_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A5_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + ThreadRc_Cycle_am_00270 A6_Cycle_am_00270 = new ThreadRc_Cycle_am_00270(); + A1_Cycle_am_00270.start(); + A2_Cycle_am_00270.start(); + A3_Cycle_am_00270.start(); + A4_Cycle_am_00270.start(); + A5_Cycle_am_00270.start(); + A6_Cycle_am_00270.start(); + try { + A1_Cycle_am_00270.join(); + A2_Cycle_am_00270.join(); + A3_Cycle_am_00270.join(); + A4_Cycle_am_00270.join(); + A5_Cycle_am_00270.join(); + A6_Cycle_am_00270.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00270.check() && A2_Cycle_am_00270.check() && A3_Cycle_am_00270.check() && A4_Cycle_am_00270.check() && A5_Cycle_am_00270.check() && A6_Cycle_am_00270.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/expected.txt b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/test.cfg b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c68791d67cce4210b1ef278a0fe42a6401027b67 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0129-rc-function-RC_Thread01-Cycle_am_00270/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00270) +run(Cycle_am_00270,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java new file mode 100755 index 0000000000000000000000000000000000000000..4e4c2a2f199171a6706668b5e887be29d9038935 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/Cycle_am_00280.java @@ -0,0 +1,164 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00280 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00280 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00280 A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A3_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A4_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A5_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A6_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A3_Cycle_am_00280.start(); + A4_Cycle_am_00280.start(); + A5_Cycle_am_00280.start(); + A6_Cycle_am_00280.start(); + try { + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A3_Cycle_am_00280.join(); + A4_Cycle_am_00280.join(); + A5_Cycle_am_00280.join(); + A6_Cycle_am_00280.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A3_Cycle_am_00280.check() && A4_Cycle_am_00280.check() && A5_Cycle_am_00280.check() && A6_Cycle_am_00280.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/expected.txt b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/test.cfg b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..848de86fbfbbed8fe07f8ea020c7621236154bab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0130-rc-function-RC_Thread01-Cycle_am_00280/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00280) +run(Cycle_am_00280,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java new file mode 100755 index 0000000000000000000000000000000000000000..f9d682e2080559158aee85140e32339e2ef6b7ab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/Cycle_am_00290.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00290 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1447) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } + } + class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_am_00290 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00290 A1_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A2_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A3_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A4_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A5_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + ThreadRc_Cycle_am_00290 A6_Cycle_am_00290 = new ThreadRc_Cycle_am_00290(); + A1_Cycle_am_00290.start(); + A2_Cycle_am_00290.start(); + A3_Cycle_am_00290.start(); + A4_Cycle_am_00290.start(); + A5_Cycle_am_00290.start(); + A6_Cycle_am_00290.start(); + try { + A1_Cycle_am_00290.join(); + A2_Cycle_am_00290.join(); + A3_Cycle_am_00290.join(); + A4_Cycle_am_00290.join(); + A5_Cycle_am_00290.join(); + A6_Cycle_am_00290.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00290.check() && A2_Cycle_am_00290.check() && A3_Cycle_am_00290.check() && A4_Cycle_am_00290.check() && A5_Cycle_am_00290.check() && A6_Cycle_am_00290.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/expected.txt b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/test.cfg b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b275d3869a45268d52c1370d0aef6417eb5884c7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0131-rc-function-RC_Thread01-Cycle_am_00290/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00290) +run(Cycle_am_00290,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java new file mode 100755 index 0000000000000000000000000000000000000000..13a2239cb0903270c0d81fe4c219a0ee908be308 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/Cycle_am_00300.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00300 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1448) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a6_0.a; + } + } + class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00300 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00300 A1_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A2_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A3_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A4_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A5_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + ThreadRc_Cycle_am_00300 A6_Cycle_am_00300 = new ThreadRc_Cycle_am_00300(); + A1_Cycle_am_00300.start(); + A2_Cycle_am_00300.start(); + A3_Cycle_am_00300.start(); + A4_Cycle_am_00300.start(); + A5_Cycle_am_00300.start(); + A6_Cycle_am_00300.start(); + try { + A1_Cycle_am_00300.join(); + A2_Cycle_am_00300.join(); + A3_Cycle_am_00300.join(); + A4_Cycle_am_00300.join(); + A5_Cycle_am_00300.join(); + A6_Cycle_am_00300.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00300.check() && A2_Cycle_am_00300.check() && A3_Cycle_am_00300.check() && A4_Cycle_am_00300.check() && A5_Cycle_am_00300.check() && A6_Cycle_am_00300.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/expected.txt b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/test.cfg b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e40f10dbd2bdd60bee3b967472df7540903f740f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0132-rc-function-RC_Thread01-Cycle_am_00300/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00300) +run(Cycle_am_00300,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java new file mode 100755 index 0000000000000000000000000000000000000000..30f9afccd487d9990619f7d519efc85fa8b1be5f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/Cycle_am_00310.java @@ -0,0 +1,181 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00310 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1552) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } +} +public class Cycle_am_00310 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00310 A1_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A2_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A3_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A4_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A5_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + ThreadRc_Cycle_am_00310 A6_Cycle_am_00310 = new ThreadRc_Cycle_am_00310(); + A1_Cycle_am_00310.start(); + A2_Cycle_am_00310.start(); + A3_Cycle_am_00310.start(); + A4_Cycle_am_00310.start(); + A5_Cycle_am_00310.start(); + A6_Cycle_am_00310.start(); + try { + A1_Cycle_am_00310.join(); + A2_Cycle_am_00310.join(); + A3_Cycle_am_00310.join(); + A4_Cycle_am_00310.join(); + A5_Cycle_am_00310.join(); + A6_Cycle_am_00310.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00310.check() && A2_Cycle_am_00310.check() && A3_Cycle_am_00310.check() && A4_Cycle_am_00310.check() && A5_Cycle_am_00310.check() && A6_Cycle_am_00310.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/expected.txt b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/test.cfg b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..baff2a9f080c0743fea054f68756d2a9bfe749ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0133-rc-function-RC_Thread01-Cycle_am_00310/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00310) +run(Cycle_am_00310,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java new file mode 100755 index 0000000000000000000000000000000000000000..3aa85b07ee89fcff9177a79b93f80dc54208522f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/Cycle_am_00320.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00320 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1551) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} +public class Cycle_am_00320 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00320 A1_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A2_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A3_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A4_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A5_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + ThreadRc_Cycle_am_00320 A6_Cycle_am_00320 = new ThreadRc_Cycle_am_00320(); + A1_Cycle_am_00320.start(); + A2_Cycle_am_00320.start(); + A3_Cycle_am_00320.start(); + A4_Cycle_am_00320.start(); + A5_Cycle_am_00320.start(); + A6_Cycle_am_00320.start(); + try { + A1_Cycle_am_00320.join(); + A2_Cycle_am_00320.join(); + A3_Cycle_am_00320.join(); + A4_Cycle_am_00320.join(); + A5_Cycle_am_00320.join(); + A6_Cycle_am_00320.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00320.check() && A2_Cycle_am_00320.check() && A3_Cycle_am_00320.check() && A4_Cycle_am_00320.check() && A5_Cycle_am_00320.check() && A6_Cycle_am_00320.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/expected.txt b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/test.cfg b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..de009c55e549fad15025dc380f17d6e5cb096d61 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0134-rc-function-RC_Thread01-Cycle_am_00320/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00320) +run(Cycle_am_00320,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java new file mode 100755 index 0000000000000000000000000000000000000000..74c4fdaa37713a683a2fdbc92aad0835822cce94 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/Cycle_am_00330.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00330 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2080) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_00330 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00330 A1_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A2_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A3_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A4_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A5_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + ThreadRc_Cycle_am_00330 A6_Cycle_am_00330 = new ThreadRc_Cycle_am_00330(); + A1_Cycle_am_00330.start(); + A2_Cycle_am_00330.start(); + A3_Cycle_am_00330.start(); + A4_Cycle_am_00330.start(); + A5_Cycle_am_00330.start(); + A6_Cycle_am_00330.start(); + try { + A1_Cycle_am_00330.join(); + A2_Cycle_am_00330.join(); + A3_Cycle_am_00330.join(); + A4_Cycle_am_00330.join(); + A5_Cycle_am_00330.join(); + A6_Cycle_am_00330.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00330.check() && A2_Cycle_am_00330.check() && A3_Cycle_am_00330.check() && A4_Cycle_am_00330.check() && A5_Cycle_am_00330.check() && A6_Cycle_am_00330.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/expected.txt b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/test.cfg b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fd440f31c53b9716c761b427e5646b02ba61a661 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0135-rc-function-RC_Thread01-Cycle_am_00330/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00330) +run(Cycle_am_00330,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java new file mode 100755 index 0000000000000000000000000000000000000000..263421e861ec9dece9788f28b2dc34855d4fb318 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/Cycle_am_00340.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00340 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } + } + class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_00340 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00340 A1_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A2_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A3_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A4_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A5_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + ThreadRc_Cycle_am_00340 A6_Cycle_am_00340 = new ThreadRc_Cycle_am_00340(); + A1_Cycle_am_00340.start(); + A2_Cycle_am_00340.start(); + A3_Cycle_am_00340.start(); + A4_Cycle_am_00340.start(); + A5_Cycle_am_00340.start(); + A6_Cycle_am_00340.start(); + try { + A1_Cycle_am_00340.join(); + A2_Cycle_am_00340.join(); + A3_Cycle_am_00340.join(); + A4_Cycle_am_00340.join(); + A5_Cycle_am_00340.join(); + A6_Cycle_am_00340.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00340.check() && A2_Cycle_am_00340.check() && A3_Cycle_am_00340.check() && A4_Cycle_am_00340.check() && A5_Cycle_am_00340.check() && A6_Cycle_am_00340.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/expected.txt b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/test.cfg b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..025943d7c9958de50ccb146b1c4839dd445e0b04 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0136-rc-function-RC_Thread01-Cycle_am_00340/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00340) +run(Cycle_am_00340,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java new file mode 100755 index 0000000000000000000000000000000000000000..5c9d6589c65a243abebd1f0ac3443c52c3fdf22b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/Cycle_am_00350.java @@ -0,0 +1,219 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00350 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_00350 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00350 A1_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A2_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A3_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A4_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A5_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + ThreadRc_Cycle_am_00350 A6_Cycle_am_00350 = new ThreadRc_Cycle_am_00350(); + A1_Cycle_am_00350.start(); + A2_Cycle_am_00350.start(); + A3_Cycle_am_00350.start(); + A4_Cycle_am_00350.start(); + A5_Cycle_am_00350.start(); + A6_Cycle_am_00350.start(); + try { + A1_Cycle_am_00350.join(); + A2_Cycle_am_00350.join(); + A3_Cycle_am_00350.join(); + A4_Cycle_am_00350.join(); + A5_Cycle_am_00350.join(); + A6_Cycle_am_00350.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00350.check() && A2_Cycle_am_00350.check() && A3_Cycle_am_00350.check() && A4_Cycle_am_00350.check() && A5_Cycle_am_00350.check() && A6_Cycle_am_00350.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/expected.txt b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/test.cfg b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc1fc8e896155bcfbb0bdd0a7435ec435d079fd0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0137-rc-function-RC_Thread01-Cycle_am_00350/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00350) +run(Cycle_am_00350,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java new file mode 100755 index 0000000000000000000000000000000000000000..ab9b0582e8200a7eb467db12428b5106cbfc1ed9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/Cycle_am_00360.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00360 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2399) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } + } + class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_am_00360 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00360 A1_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A2_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A3_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A4_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A5_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + ThreadRc_Cycle_am_00360 A6_Cycle_am_00360 = new ThreadRc_Cycle_am_00360(); + A1_Cycle_am_00360.start(); + A2_Cycle_am_00360.start(); + A3_Cycle_am_00360.start(); + A4_Cycle_am_00360.start(); + A5_Cycle_am_00360.start(); + A6_Cycle_am_00360.start(); + try { + A1_Cycle_am_00360.join(); + A2_Cycle_am_00360.join(); + A3_Cycle_am_00360.join(); + A4_Cycle_am_00360.join(); + A5_Cycle_am_00360.join(); + A6_Cycle_am_00360.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00360.check() && A2_Cycle_am_00360.check() && A3_Cycle_am_00360.check() && A4_Cycle_am_00360.check() && A5_Cycle_am_00360.check() && A6_Cycle_am_00360.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/expected.txt b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/test.cfg b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c5e7483001dee096bab545f744eb2a88d14bbca5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0138-rc-function-RC_Thread01-Cycle_am_00360/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00360) +run(Cycle_am_00360,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java new file mode 100755 index 0000000000000000000000000000000000000000..7f80d7de54aece43d5910b9214ef1be15a46518b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/Cycle_am_00370.java @@ -0,0 +1,259 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00370 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } +} +public class Cycle_am_00370 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00370 A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A3_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A4_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A5_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A6_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A3_Cycle_am_00370.start(); + A4_Cycle_am_00370.start(); + A5_Cycle_am_00370.start(); + A6_Cycle_am_00370.start(); + try { + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A3_Cycle_am_00370.join(); + A4_Cycle_am_00370.join(); + A5_Cycle_am_00370.join(); + A6_Cycle_am_00370.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A3_Cycle_am_00370.check() && A4_Cycle_am_00370.check() && A5_Cycle_am_00370.check() && A6_Cycle_am_00370.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/expected.txt b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/test.cfg b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..05569f4cba0d4e44ca21a731ee22af418eeb55e6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0139-rc-function-RC_Thread01-Cycle_am_00370/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00370) +run(Cycle_am_00370,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java new file mode 100755 index 0000000000000000000000000000000000000000..94779f0d5b68a254f5d237019c60d5cb46ec6a32 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/Cycle_am_00380.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00380 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 815) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +public class Cycle_am_00380 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00380 A1_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A2_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A3_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A4_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A5_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + ThreadRc_Cycle_am_00380 A6_Cycle_am_00380 = new ThreadRc_Cycle_am_00380(); + A1_Cycle_am_00380.start(); + A2_Cycle_am_00380.start(); + A3_Cycle_am_00380.start(); + A4_Cycle_am_00380.start(); + A5_Cycle_am_00380.start(); + A6_Cycle_am_00380.start(); + try { + A1_Cycle_am_00380.join(); + A2_Cycle_am_00380.join(); + A3_Cycle_am_00380.join(); + A4_Cycle_am_00380.join(); + A5_Cycle_am_00380.join(); + A6_Cycle_am_00380.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00380.check() && A2_Cycle_am_00380.check() && A3_Cycle_am_00380.check() && A4_Cycle_am_00380.check() && A5_Cycle_am_00380.check() && A6_Cycle_am_00380.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/expected.txt b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/test.cfg b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6b09dfaf8f5715a56a9955407918283b2fe74847 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0140-rc-function-RC_Thread01-Cycle_am_00380/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00380) +run(Cycle_am_00380,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java new file mode 100755 index 0000000000000000000000000000000000000000..f3e3c94fb288f5f42981c518af9297109a7aa8eb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/Cycle_am_00390.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00390 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 918) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +public class Cycle_am_00390 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00390 A1_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A2_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A3_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A4_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A5_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + ThreadRc_Cycle_am_00390 A6_Cycle_am_00390 = new ThreadRc_Cycle_am_00390(); + A1_Cycle_am_00390.start(); + A2_Cycle_am_00390.start(); + A3_Cycle_am_00390.start(); + A4_Cycle_am_00390.start(); + A5_Cycle_am_00390.start(); + A6_Cycle_am_00390.start(); + try { + A1_Cycle_am_00390.join(); + A2_Cycle_am_00390.join(); + A3_Cycle_am_00390.join(); + A4_Cycle_am_00390.join(); + A5_Cycle_am_00390.join(); + A6_Cycle_am_00390.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00390.check() && A2_Cycle_am_00390.check() && A3_Cycle_am_00390.check() && A4_Cycle_am_00390.check() && A5_Cycle_am_00390.check() && A6_Cycle_am_00390.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/expected.txt b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/test.cfg b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eb96618ae90e2a10db7b74cde7fed60e95c53693 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0141-rc-function-RC_Thread01-Cycle_am_00390/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00390) +run(Cycle_am_00390,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java new file mode 100755 index 0000000000000000000000000000000000000000..df93d31cb54ab73aff9722dd8dcd08f6b1304267 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/Cycle_am_00400.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00400 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_am_00400 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00400 A1_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A2_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A3_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A4_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A5_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + ThreadRc_Cycle_am_00400 A6_Cycle_am_00400 = new ThreadRc_Cycle_am_00400(); + A1_Cycle_am_00400.start(); + A2_Cycle_am_00400.start(); + A3_Cycle_am_00400.start(); + A4_Cycle_am_00400.start(); + A5_Cycle_am_00400.start(); + A6_Cycle_am_00400.start(); + try { + A1_Cycle_am_00400.join(); + A2_Cycle_am_00400.join(); + A3_Cycle_am_00400.join(); + A4_Cycle_am_00400.join(); + A5_Cycle_am_00400.join(); + A6_Cycle_am_00400.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00400.check() && A2_Cycle_am_00400.check() && A3_Cycle_am_00400.check() && A4_Cycle_am_00400.check() && A5_Cycle_am_00400.check() && A6_Cycle_am_00400.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/expected.txt b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/test.cfg b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4ffe4c6a8f51531ad0cd0aa3bc39668e660c4908 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0142-rc-function-RC_Thread01-Cycle_am_00400/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00400) +run(Cycle_am_00400,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java new file mode 100755 index 0000000000000000000000000000000000000000..f70fc789ff48508723b28bbd1fff7af08b7ec2ae --- /dev/null +++ b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/Cycle_am_00410.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00410 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 921) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_am_00410 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00410 A1_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A2_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A3_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A4_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A5_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + ThreadRc_Cycle_am_00410 A6_Cycle_am_00410 = new ThreadRc_Cycle_am_00410(); + A1_Cycle_am_00410.start(); + A2_Cycle_am_00410.start(); + A3_Cycle_am_00410.start(); + A4_Cycle_am_00410.start(); + A5_Cycle_am_00410.start(); + A6_Cycle_am_00410.start(); + try { + A1_Cycle_am_00410.join(); + A2_Cycle_am_00410.join(); + A3_Cycle_am_00410.join(); + A4_Cycle_am_00410.join(); + A5_Cycle_am_00410.join(); + A6_Cycle_am_00410.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00410.check() && A2_Cycle_am_00410.check() && A3_Cycle_am_00410.check() && A4_Cycle_am_00410.check() && A5_Cycle_am_00410.check() && A6_Cycle_am_00410.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/expected.txt b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/test.cfg b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..97f3ecdb3a2c0340c4d26e802c122745da3e3676 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0143-rc-function-RC_Thread01-Cycle_am_00410/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00410) +run(Cycle_am_00410,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java new file mode 100755 index 0000000000000000000000000000000000000000..b7575ffc84f88b9902310fb55b4edbed82c33a59 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/Cycle_am_00420.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00420 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); +// Cycle_a_00420_A4 a4_main = new Cycle_a_00420_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_am_00420 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00420 A1_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A2_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A3_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A4_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A5_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + ThreadRc_Cycle_am_00420 A6_Cycle_am_00420 = new ThreadRc_Cycle_am_00420(); + A1_Cycle_am_00420.start(); + A2_Cycle_am_00420.start(); + A3_Cycle_am_00420.start(); + A4_Cycle_am_00420.start(); + A5_Cycle_am_00420.start(); + A6_Cycle_am_00420.start(); + try { + A1_Cycle_am_00420.join(); + A2_Cycle_am_00420.join(); + A3_Cycle_am_00420.join(); + A4_Cycle_am_00420.join(); + A5_Cycle_am_00420.join(); + A6_Cycle_am_00420.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00420.check() && A2_Cycle_am_00420.check() && A3_Cycle_am_00420.check() && A4_Cycle_am_00420.check() && A5_Cycle_am_00420.check() && A6_Cycle_am_00420.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/expected.txt b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/test.cfg b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a3a868e3f5035caeca9c91d8fb90528af342691a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0144-rc-function-RC_Thread01-Cycle_am_00420/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00420) +run(Cycle_am_00420,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java new file mode 100755 index 0000000000000000000000000000000000000000..cb5ccfae54581751553d53d3ba4158dbbe730f3e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/Cycle_am_00430.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00430 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1124) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +public class Cycle_am_00430 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00430 A1_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A2_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A3_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A4_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A5_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + ThreadRc_Cycle_am_00430 A6_Cycle_am_00430 = new ThreadRc_Cycle_am_00430(); + A1_Cycle_am_00430.start(); + A2_Cycle_am_00430.start(); + A3_Cycle_am_00430.start(); + A4_Cycle_am_00430.start(); + A5_Cycle_am_00430.start(); + A6_Cycle_am_00430.start(); + try { + A1_Cycle_am_00430.join(); + A2_Cycle_am_00430.join(); + A3_Cycle_am_00430.join(); + A4_Cycle_am_00430.join(); + A5_Cycle_am_00430.join(); + A6_Cycle_am_00430.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00430.check() && A2_Cycle_am_00430.check() && A3_Cycle_am_00430.check() && A4_Cycle_am_00430.check() && A5_Cycle_am_00430.check() && A6_Cycle_am_00430.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/expected.txt b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/test.cfg b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..36305bd58f8bcde6a8b0fba87b1a25fd95f4f183 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0145-rc-function-RC_Thread01-Cycle_am_00430/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00430) +run(Cycle_am_00430,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java new file mode 100755 index 0000000000000000000000000000000000000000..b155b0d14958dbf5dc054d153987a009e80063f6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/Cycle_am_00440.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00440 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1023) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_am_00440 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00440 A1_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A2_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A3_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A4_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A5_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + ThreadRc_Cycle_am_00440 A6_Cycle_am_00440 = new ThreadRc_Cycle_am_00440(); + A1_Cycle_am_00440.start(); + A2_Cycle_am_00440.start(); + A3_Cycle_am_00440.start(); + A4_Cycle_am_00440.start(); + A5_Cycle_am_00440.start(); + A6_Cycle_am_00440.start(); + try { + A1_Cycle_am_00440.join(); + A2_Cycle_am_00440.join(); + A3_Cycle_am_00440.join(); + A4_Cycle_am_00440.join(); + A5_Cycle_am_00440.join(); + A6_Cycle_am_00440.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00440.check() && A2_Cycle_am_00440.check() && A3_Cycle_am_00440.check() && A4_Cycle_am_00440.check() && A5_Cycle_am_00440.check() && A6_Cycle_am_00440.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/expected.txt b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/test.cfg b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7129a600507fb0e39c382f2a3d17eb6070445286 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0146-rc-function-RC_Thread01-Cycle_am_00440/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00440) +run(Cycle_am_00440,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java new file mode 100755 index 0000000000000000000000000000000000000000..ffac1b822a29802ee260993d336bbaa3f91d24d6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/Cycle_am_00450.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00450 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1453) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_am_00450 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00450 A1_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A2_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A3_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A4_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A5_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + ThreadRc_Cycle_am_00450 A6_Cycle_am_00450 = new ThreadRc_Cycle_am_00450(); + A1_Cycle_am_00450.start(); + A2_Cycle_am_00450.start(); + A3_Cycle_am_00450.start(); + A4_Cycle_am_00450.start(); + A5_Cycle_am_00450.start(); + A6_Cycle_am_00450.start(); + try { + A1_Cycle_am_00450.join(); + A2_Cycle_am_00450.join(); + A3_Cycle_am_00450.join(); + A4_Cycle_am_00450.join(); + A5_Cycle_am_00450.join(); + A6_Cycle_am_00450.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00450.check() && A2_Cycle_am_00450.check() && A3_Cycle_am_00450.check() && A4_Cycle_am_00450.check() && A5_Cycle_am_00450.check() && A6_Cycle_am_00450.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/expected.txt b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/test.cfg b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..78428a5ff2ad30c756d353b3ca2c60c9be9a367e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0147-rc-function-RC_Thread01-Cycle_am_00450/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00450) +run(Cycle_am_00450,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java new file mode 100755 index 0000000000000000000000000000000000000000..a3dbfc2c40e0624761d56481c833a80ce1d7cce0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/Cycle_am_00460.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00460 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } +} +public class Cycle_am_00460 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00460 A1_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A2_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A3_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A4_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A5_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + ThreadRc_Cycle_am_00460 A6_Cycle_am_00460 = new ThreadRc_Cycle_am_00460(); + A1_Cycle_am_00460.start(); + A2_Cycle_am_00460.start(); + A3_Cycle_am_00460.start(); + A4_Cycle_am_00460.start(); + A5_Cycle_am_00460.start(); + A6_Cycle_am_00460.start(); + try { + A1_Cycle_am_00460.join(); + A2_Cycle_am_00460.join(); + A3_Cycle_am_00460.join(); + A4_Cycle_am_00460.join(); + A5_Cycle_am_00460.join(); + A6_Cycle_am_00460.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00460.check() && A2_Cycle_am_00460.check() && A3_Cycle_am_00460.check() && A4_Cycle_am_00460.check() && A5_Cycle_am_00460.check() && A6_Cycle_am_00460.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/expected.txt b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/test.cfg b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..68c2a15b8e24f284b7a21421028f96b59c4c996b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0148-rc-function-RC_Thread01-Cycle_am_00460/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00460) +run(Cycle_am_00460,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java new file mode 100755 index 0000000000000000000000000000000000000000..294838183b1b28a1f991917e235604321fd80a43 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/Cycle_am_00470.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00470 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1446) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } +} +public class Cycle_am_00470 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00470 A1_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A2_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A3_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A4_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A5_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + ThreadRc_Cycle_am_00470 A6_Cycle_am_00470 = new ThreadRc_Cycle_am_00470(); + A1_Cycle_am_00470.start(); + A2_Cycle_am_00470.start(); + A3_Cycle_am_00470.start(); + A4_Cycle_am_00470.start(); + A5_Cycle_am_00470.start(); + A6_Cycle_am_00470.start(); + try { + A1_Cycle_am_00470.join(); + A2_Cycle_am_00470.join(); + A3_Cycle_am_00470.join(); + A4_Cycle_am_00470.join(); + A5_Cycle_am_00470.join(); + A6_Cycle_am_00470.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00470.check() && A2_Cycle_am_00470.check() && A3_Cycle_am_00470.check() && A4_Cycle_am_00470.check() && A5_Cycle_am_00470.check() && A6_Cycle_am_00470.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/expected.txt b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/test.cfg b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e89344a3e70c3d57fe8e421a71ca5acaaa8ab079 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0149-rc-function-RC_Thread01-Cycle_am_00470/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00470) +run(Cycle_am_00470,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java new file mode 100755 index 0000000000000000000000000000000000000000..0b07e6b00b95a144b22736c6634a34d1e1f3946a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/Cycle_am_00480.java @@ -0,0 +1,194 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00480 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a5_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a1_0.add(); + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a5_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a5_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a1_main.a2_0.a3_0.a4_0.sum+a1_main.a2_0.a3_0.a4_0.a6_0.sum); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } + } +} +public class Cycle_am_00480 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00480 A1_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A2_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A3_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A4_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A5_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + ThreadRc_Cycle_am_00480 A6_Cycle_am_00480 = new ThreadRc_Cycle_am_00480(); + A1_Cycle_am_00480.start(); + A2_Cycle_am_00480.start(); + A3_Cycle_am_00480.start(); + A4_Cycle_am_00480.start(); + A5_Cycle_am_00480.start(); + A6_Cycle_am_00480.start(); + try { + A1_Cycle_am_00480.join(); + A2_Cycle_am_00480.join(); + A3_Cycle_am_00480.join(); + A4_Cycle_am_00480.join(); + A5_Cycle_am_00480.join(); + A6_Cycle_am_00480.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00480.check() && A2_Cycle_am_00480.check() && A3_Cycle_am_00480.check() && A4_Cycle_am_00480.check() && A5_Cycle_am_00480.check() && A6_Cycle_am_00480.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/expected.txt b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/test.cfg b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5b5fa26c27a653e17146fd1219d575835bf4add5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0150-rc-function-RC_Thread01-Cycle_am_00480/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00480) +run(Cycle_am_00480,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java new file mode 100755 index 0000000000000000000000000000000000000000..2b16b507657c9d6a38ab2e1212bc964ac8b6661b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/Cycle_am_00490.java @@ -0,0 +1,254 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00490 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; +// a4_main.a5_0.a6_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); +// +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2098) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a + a5_0.a; + } + } + class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_am_00490 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00490 A1_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A2_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A3_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A4_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A5_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + ThreadRc_Cycle_am_00490 A6_Cycle_am_00490 = new ThreadRc_Cycle_am_00490(); + A1_Cycle_am_00490.start(); + A2_Cycle_am_00490.start(); + A3_Cycle_am_00490.start(); + A4_Cycle_am_00490.start(); + A5_Cycle_am_00490.start(); + A6_Cycle_am_00490.start(); + try { + A1_Cycle_am_00490.join(); + A2_Cycle_am_00490.join(); + A3_Cycle_am_00490.join(); + A4_Cycle_am_00490.join(); + A5_Cycle_am_00490.join(); + A6_Cycle_am_00490.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00490.check() && A2_Cycle_am_00490.check() && A3_Cycle_am_00490.check() && A4_Cycle_am_00490.check() && A5_Cycle_am_00490.check() && A6_Cycle_am_00490.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/expected.txt b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f33a8592d2316dcaefb376e2e77d12a354a4918e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/expected.txt @@ -0,0 +1,4 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/test.cfg b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b3fb11844d56ab6a97e25ee599dcfa069632e68 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0151-rc-function-RC_Thread01-Cycle_am_00490/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00490) +run(Cycle_am_00490,EXPECTNUM=4) diff --git a/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java new file mode 100755 index 0000000000000000000000000000000000000000..424c025fb73e5a8e290ac16a716dcbcb3e3dbe86 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/Cycle_am_00500.java @@ -0,0 +1,252 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00500 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2099) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_am_00500 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00500 A1_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A2_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A3_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A4_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A5_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + ThreadRc_Cycle_am_00500 A6_Cycle_am_00500 = new ThreadRc_Cycle_am_00500(); + A1_Cycle_am_00500.start(); + A2_Cycle_am_00500.start(); + A3_Cycle_am_00500.start(); + A4_Cycle_am_00500.start(); + A5_Cycle_am_00500.start(); + A6_Cycle_am_00500.start(); + try { + A1_Cycle_am_00500.join(); + A2_Cycle_am_00500.join(); + A3_Cycle_am_00500.join(); + A4_Cycle_am_00500.join(); + A5_Cycle_am_00500.join(); + A6_Cycle_am_00500.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00500.check() && A2_Cycle_am_00500.check() && A3_Cycle_am_00500.check() && A4_Cycle_am_00500.check() && A5_Cycle_am_00500.check() && A6_Cycle_am_00500.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/expected.txt b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f33a8592d2316dcaefb376e2e77d12a354a4918e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/expected.txt @@ -0,0 +1,4 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/test.cfg b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f1aea5c8bb7c4875abff45d899a78792753c5e0f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0152-rc-function-RC_Thread01-Cycle_am_00500/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00500) +run(Cycle_am_00500,EXPECTNUM=4) diff --git a/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java new file mode 100755 index 0000000000000000000000000000000000000000..13e43e4bea66e01b3501d9286e0a27c785d6a4ec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/Cycle_am_00510.java @@ -0,0 +1,4779 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_00180B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00180_A1 a1_main = new Cycle_a_00180_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00180_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00180_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00180_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00180_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00180_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a8_0 = new Cycle_a_00180_A8("a8_0"); + a1_main.a8_0.a9_0 = new Cycle_a_00180_A9("a9_0"); + a1_main.a8_0.a9_0.a7_0 = new Cycle_a_00180_A7("a7_0"); + a1_main.a8_0.a9_0.a7_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_main.a8_0.add(); + a1_main.a8_0.a9_0.add(); + a1_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_main.a8_0.sum + a1_main.a8_0.a9_0.sum + a1_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1994) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00180_A1 { + Cycle_a_00180_A2 a2_0; + Cycle_a_00180_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A1(String strObjectName) { + a2_0 = null; + a8_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + class Cycle_a_00180_A2 { + Cycle_a_00180_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00180_A3 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00180_A4 { + Cycle_a_00180_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00180_A5 { + Cycle_a_00180_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00180_A6 { + Cycle_a_00180_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A6(String strObjectName) { + a1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00180_A7 { + Cycle_a_00180_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A7(String strObjectName) { + a4_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00180_A8 { + Cycle_a_00180_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00180_A9 { + Cycle_a_00180_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00180_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +class ThreadRc_Cycle_am_00190B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00190_A1 a1_main = new Cycle_a_00190_A1("a1_main"); + Cycle_a_00190_A10 a10_main = new Cycle_a_00190_A10("a10_main"); + a1_main.a2_0 = new Cycle_a_00190_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00190_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00190_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = new Cycle_a_00190_A5("a5_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_a_00190_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_main; + a10_main.a8_0 = new Cycle_a_00190_A8("a8_0"); + a10_main.a8_0.a9_0 = new Cycle_a_00190_A9("a9_0"); + a10_main.a8_0.a9_0.a7_0 = new Cycle_a_00190_A7("a7_0"); + a10_main.a8_0.a9_0.a7_0.a5_0 = a1_main.a2_0.a3_0.a4_0.a5_0; + a1_main.add(); + a10_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.add(); + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_main.a8_0.add(); + a10_main.a8_0.a9_0.add(); + a10_main.a8_0.a9_0.a7_0.add(); + int result = a1_main.sum + a10_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.sum + a1_main.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_main.a8_0.sum + a10_main.a8_0.a9_0.sum + a10_main.a8_0.a9_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2215) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00190_A1 { + Cycle_a_00190_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00190_A2 { + Cycle_a_00190_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00190_A3 { + Cycle_a_00190_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00190_A4 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00190_A5 { + Cycle_a_00190_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00190_A6 { + Cycle_a_00190_A1 a1_0; + Cycle_a_00190_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A6(String strObjectName) { + a1_0 = null; + a10_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + class Cycle_a_00190_A7 { + Cycle_a_00190_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A7(String strObjectName) { + a5_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00190_A8 { + Cycle_a_00190_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A8(String strObjectName) { + a9_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00190_A9 { + Cycle_a_00190_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A9(String strObjectName) { + a7_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00190_A10 { + Cycle_a_00190_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00190_A10(String strObjectName) { + a8_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +class ThreadRc_Cycle_am_00200B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00200_A1 a1_main = new Cycle_a_00200_A1("a1_main"); + Cycle_a_00200_A4 a4_main = new Cycle_a_00200_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00200_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00200_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00200_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a6_0 = new Cycle_a_00200_A6("a6_0"); + a1_main.a2_0.a6_0.a7_0 = new Cycle_a_00200_A7("a7_0"); + a1_main.a2_0.a7_0 = a1_main.a2_0.a6_0.a7_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a6_0.add(); + a1_main.a2_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a6_0.sum + a1_main.a2_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00200_A1 { + Cycle_a_00200_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00200_A2 { + Cycle_a_00200_A3 a3_0; + Cycle_a_00200_A6 a6_0; + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A2(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00200_A3 { + Cycle_a_00200_A1 a1_0; + Cycle_a_00200_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00200_A4 { + Cycle_a_00200_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00200_A5 { + Cycle_a_00200_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00200_A6 { + Cycle_a_00200_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00200_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00200_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00200_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_Cycle_am_00210B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00210_A1 a1_main = new Cycle_a_00210_A1("a1_main"); + Cycle_a_00210_A4 a4_main = new Cycle_a_00210_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00210_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00210_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00210_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00210_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a7_0 = new Cycle_a_00210_A7("a7_0"); + a1_main.a2_0.a3_0.a6_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + a1_main.a2_0.a3_0.a6_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a6_0.sum + a1_main.a2_0.a3_0.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1662) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00210_A1 { + Cycle_a_00210_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00210_A2 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00210_A3 { + Cycle_a_00210_A1 a1_0; + Cycle_a_00210_A5 a5_0; + Cycle_a_00210_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a6_0.a; + } + } + class Cycle_a_00210_A4 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00210_A5 { + Cycle_a_00210_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A5(String strObjectName) { + a4_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00210_A6 { + Cycle_a_00210_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00210_A7 { + Cycle_a_00210_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00210_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00220B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00220_A1 a1_main = new Cycle_a_00220_A1("a1_main"); + Cycle_a_00220_A4 a4_main = new Cycle_a_00220_A4("a4_main"); + Cycle_a_00220_A6 a6_main = new Cycle_a_00220_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00220_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00220_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00220_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_00220_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1772) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00220_A1 { + Cycle_a_00220_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00220_A2 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00220_A3 { + Cycle_a_00220_A1 a1_0; + Cycle_a_00220_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00220_A4 { + Cycle_a_00220_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00220_A5 { + Cycle_a_00220_A4 a4_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + class Cycle_a_00220_A6 { + Cycle_a_00220_A5 a5_0; + Cycle_a_00220_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00220_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + class Cycle_a_00220_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00220_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_Cycle_am_00230B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00230_A1 a1_main = new Cycle_a_00230_A1("a1_main"); + Cycle_a_00230_A5 a5_main = new Cycle_a_00230_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00230_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00230_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00230_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a7_0 = new Cycle_a_00230_A7("a7_0"); + a5_main.a6_0 = new Cycle_a_00230_A6("a6_0"); + a5_main.a6_0.a7_0 = a5_main.a7_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a5_main.a7_0.add(); + a5_main.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a5_main.a6_0.sum + a5_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1773) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00230_A1 { + Cycle_a_00230_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00230_A2 { + Cycle_a_00230_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00230_A3 { + Cycle_a_00230_A1 a1_0; + Cycle_a_00230_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00230_A4 { + Cycle_a_00230_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00230_A5 { + Cycle_a_00230_A3 a3_0; + Cycle_a_00230_A6 a6_0; + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A5(String strObjectName) { + a3_0 = null; + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00230_A6 { + Cycle_a_00230_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00230_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00230_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_00230_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_Cycle_am_00240B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00240_A1 a1_main = new Cycle_a_00240_A1("a1_main"); + Cycle_a_00240_A5 a5_main = new Cycle_a_00240_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00240_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00240_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a6_0 = new Cycle_a_00240_A6("a6_0"); + a1_main.a6_0.a7_0 = new Cycle_a_00240_A7("a7_0"); + a1_main.a6_0.a7_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a6_0.add(); + a1_main.a6_0.a7_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a6_0.sum + a1_main.a6_0.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1660) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00240_A1 { + Cycle_a_00240_A2 a2_0; + Cycle_a_00240_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A1(String strObjectName) { + a2_0 = null; + a6_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a6_0.a; + } + } + class Cycle_a_00240_A2 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00240_A3 { + Cycle_a_00240_A1 a1_0; + Cycle_a_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00240_A4 { + Cycle_a_00240_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00240_A5 { + Cycle_a_00240_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00240_A6 { + Cycle_a_00240_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A6(String strObjectName) { + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00240_A7 { + Cycle_a_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00240_A7(String strObjectName) { + a1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_am_00250B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00250_A1 a1_main = new Cycle_a_00250_A1("a1_main"); + Cycle_a_00250_A6 a6_main = new Cycle_a_00250_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00250_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00250_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00250_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1238) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00250_A1 { + Cycle_a_00250_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00250_A2 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00250_A3 { + Cycle_a_00250_A1 a1_0; + Cycle_a_00250_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00250_A5 { + Cycle_a_00250_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00250_A6 { + Cycle_a_00250_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00250_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00260B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00260_A1 a1_main = new Cycle_a_00260_A1("a1_main"); + Cycle_a_00260_A6 a6_main = new Cycle_a_00260_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00260_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00260_A3("a3_0"); + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00260_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1239) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00260_A1 { + Cycle_a_00260_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00260_A2 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00260_A3 { + Cycle_a_00260_A1 a1_0; + Cycle_a_00260_A2 a2_0; + Cycle_a_00260_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + class Cycle_a_00260_A5 { + Cycle_a_00260_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00260_A6 { + Cycle_a_00260_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00260_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00270B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00270_A1 a1_main = new Cycle_a_00270_A1("a1_main"); + Cycle_a_00270_A6 a6_main = new Cycle_a_00270_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00270_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00270_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00270_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1240) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00270_A1 { + Cycle_a_00270_A2 a2_0; + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00270_A2 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00270_A3 { + Cycle_a_00270_A1 a1_0; + Cycle_a_00270_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00270_A5 { + Cycle_a_00270_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00270_A6 { + Cycle_a_00270_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00270_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00280B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00280_A2 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00280_A3 { + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + class Cycle_a_00280_A5 { + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00280_A6 { + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00290B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00290_A1 a1_main = new Cycle_a_00290_A1("a1_main"); + Cycle_a_00290_A5 a5_main = new Cycle_a_00290_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00290_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00290_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00290_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a6_0 = new Cycle_a_00290_A6("a6_0"); + a1_main.a2_0.a3_0.a6_0.a2_0 = a1_main.a2_0; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1447) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00290_A1 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00290_A2 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00290_A3 { + Cycle_a_00290_A1 a1_0; + Cycle_a_00290_A4 a4_0; + Cycle_a_00290_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a6_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a6_0.a; + } + } + class Cycle_a_00290_A4 { + Cycle_a_00290_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00290_A5 { + Cycle_a_00290_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00290_A6 { + Cycle_a_00290_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00290_A6(String strObjectName) { + a2_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00300B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00300_A1 a1_main = new Cycle_a_00300_A1("a1_main"); + Cycle_a_00300_A5 a5_main = new Cycle_a_00300_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00300_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00300_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00300_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a6_0 = new Cycle_a_00300_A6("a6_0"); + a5_main.a3_0.a4_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0.a5_0 = a5_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1448) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00300_A1 { + Cycle_a_00300_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00300_A2 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00300_A3 { + Cycle_a_00300_A1 a1_0; + Cycle_a_00300_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A3(String strObjectName) { + a1_0 = null; + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_a_00300_A4 { + Cycle_a_00300_A5 a5_0; + Cycle_a_00300_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A4(String strObjectName) { + a5_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a6_0.a; + } + } + class Cycle_a_00300_A5 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00300_A6 { + Cycle_a_00300_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00300_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00310B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00310_A1 a1_main = new Cycle_a_00310_A1("a1_main"); + Cycle_a_00310_A4 a4_main = new Cycle_a_00310_A4("a4_main"); + Cycle_a_00310_A6 a6_main = new Cycle_a_00310_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00310_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00310_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00310_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a4_0 = a4_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0.a5_0 = a1_main.a2_0.a3_0.a5_0; + a4_main.a6_0 = a6_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1552) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00310_A1 { + Cycle_a_00310_A2 a2_0; + Cycle_a_00310_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00310_A2 { + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00310_A3 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00310_A4 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A4(String strObjectName) { + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00310_A5 { + Cycle_a_00310_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00310_A6 { + Cycle_a_00310_A1 a1_0; + Cycle_a_00310_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00310_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00320B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00320_A1 a1_main = new Cycle_a_00320_A1("a1_main"); + Cycle_a_00320_A4 a4_main = new Cycle_a_00320_A4("a4_main"); + Cycle_a_00320_A6 a6_main = new Cycle_a_00320_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00320_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00320_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00320_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a6_main.a4_0 = a4_main; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1551) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00320_A1 { + Cycle_a_00320_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00320_A2 { + Cycle_a_00320_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00320_A3 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00320_A4 { + Cycle_a_00320_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00320_A5 { + Cycle_a_00320_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00320_A6 { + Cycle_a_00320_A1 a1_0; + Cycle_a_00320_A3 a3_0; + Cycle_a_00320_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00320_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} +class ThreadRc_Cycle_am_00330B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00330_A1 a1_main = new Cycle_a_00330_A1("a1_main"); + Cycle_a_00330_A4 a4_main = new Cycle_a_00330_A4("a4_main"); + Cycle_a_00330_A6 a6_main = new Cycle_a_00330_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00330_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00330_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00330_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00330_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00330_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_main.a2_0.a3_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2080) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00330_A1 { + Cycle_a_00330_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00330_A2 { + Cycle_a_00330_A3 a3_0; + Cycle_a_00330_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00330_A3 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00330_A4 { + Cycle_a_00330_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00330_A5 { + Cycle_a_00330_A6 a6_0; + Cycle_a_00330_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00330_A6 { + Cycle_a_00330_A1 a1_0; + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00330_A7 { + Cycle_a_00330_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00330_A8 { + Cycle_a_00330_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00330_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +class ThreadRc_Cycle_am_00340B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00340_A1 a1_main = new Cycle_a_00340_A1("a1_main"); + Cycle_a_00340_A4 a4_main = new Cycle_a_00340_A4("a4_main"); + Cycle_a_00340_A6 a6_main = new Cycle_a_00340_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00340_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00340_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00340_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a2_0.a3_0.a8_0 = new Cycle_a_00340_A8("a8_0"); + a1_main.a2_0.a3_0.a8_0.a7_0 = new Cycle_a_00340_A7("a7_0"); + a1_main.a2_0.a3_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a1_0 = a1_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a8_0.add(); + a1_main.a2_0.a3_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a8_0.a7_0.sum + a6_main.a3_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00340_A1 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00340_A2 { + Cycle_a_00340_A3 a3_0; + Cycle_a_00340_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00340_A3 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A5 a5_0; + Cycle_a_00340_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a8_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a8_0.a; + } + } + class Cycle_a_00340_A4 { + Cycle_a_00340_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00340_A5 { + Cycle_a_00340_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00340_A6 { + Cycle_a_00340_A1 a1_0; + Cycle_a_00340_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00340_A7 { + Cycle_a_00340_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00340_A8 { + Cycle_a_00340_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00340_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +class ThreadRc_Cycle_am_00350B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00350_A1 a1_main = new Cycle_a_00350_A1("a1_main"); + Cycle_a_00350_A4 a4_main = new Cycle_a_00350_A4("a4_main"); + Cycle_a_00350_A6 a6_main = new Cycle_a_00350_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00350_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00350_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00350_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00350_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00350_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2079) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00350_A1 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00350_A2 { + Cycle_a_00350_A3 a3_0; + Cycle_a_00350_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00350_A3 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00350_A4 { + Cycle_a_00350_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00350_A5 { + Cycle_a_00350_A6 a6_0; + Cycle_a_00350_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00350_A6 { + Cycle_a_00350_A1 a1_0; + Cycle_a_00350_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00350_A7 { + Cycle_a_00350_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00350_A8 { + Cycle_a_00350_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00350_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +class ThreadRc_Cycle_am_00360B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00360_A1 a1_main = new Cycle_a_00360_A1("a1_main"); + Cycle_a_00360_A4 a4_main = new Cycle_a_00360_A4("a4_main"); + Cycle_a_00360_A6 a6_main = new Cycle_a_00360_A6("a6_main"); + Cycle_a_00360_A9 a9_main = new Cycle_a_00360_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00360_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00360_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00360_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00360_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00360_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0.a9_0 = a9_main; + a9_main.a2_0 = a1_main.a2_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2399) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00360_A1 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00360_A2 { + Cycle_a_00360_A3 a3_0; + Cycle_a_00360_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00360_A3 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00360_A4 { + Cycle_a_00360_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00360_A5 { + Cycle_a_00360_A6 a6_0; + Cycle_a_00360_A8 a8_0; + Cycle_a_00360_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a9_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a + a9_0.a; + } + } + class Cycle_a_00360_A6 { + Cycle_a_00360_A1 a1_0; + Cycle_a_00360_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00360_A7 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00360_A8 { + Cycle_a_00360_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00360_A9 { + Cycle_a_00360_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00360_A9(String strObjectName) { + a2_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00370B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00370_A3 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + class Cycle_a_00370_A4 { + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00370_A5 { + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00370_A6 { + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00370_A7 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00370_A9 { + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00370_A10 { + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } +} +class ThreadRc_Cycle_am_00380B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00380_A1 a1_main = new Cycle_a_00380_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00380_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00380_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 815) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00380_A1 { + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00380_A2 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00380_A3 { + Cycle_a_00380_A1 a1_0; + Cycle_a_00380_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00380_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00390B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00390_A1 a1_main = new Cycle_a_00390_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00390_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00390_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 918) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00390_A1 { + Cycle_a_00390_A2 a2_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00390_A2 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00390_A3 { + Cycle_a_00390_A1 a1_0; + Cycle_a_00390_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00390_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00400B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00400_A1 a1_main = new Cycle_a_00400_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00400_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00400_A3("a3_0"); + a1_main.a4_0 = new Cycle_a_00400_A4("a4_0"); + a1_main.a4_0.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00400_A1 { + Cycle_a_00400_A2 a2_0; + Cycle_a_00400_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00400_A2 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00400_A3 { + Cycle_a_00400_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00400_A4 { + Cycle_a_00400_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00400_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_am_00410B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00410_A1 a1_main = new Cycle_a_00410_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00410_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00410_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00410_A4("a4_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 921) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00410_A1 { + Cycle_a_00410_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00410_A2 { + Cycle_a_00410_A3 a3_0; + Cycle_a_00410_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00410_A3 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00410_A4 { + Cycle_a_00410_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00410_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_am_00420B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00420_A1 a1_main = new Cycle_a_00420_A1("a1_main"); +// Cycle_a_00420_A4 a4_main = new Cycle_a_00420_A4("a4_main"); + a1_main.a2_0 = new Cycle_a_00420_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00420_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00420_A4("a4_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 923) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00420_A1 { + Cycle_a_00420_A2 a2_0; + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00420_A2 { + Cycle_a_00420_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00420_A3 { + Cycle_a_00420_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00420_A4 { + Cycle_a_00420_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00420_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_am_00430B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00430_A1 a1_main = new Cycle_a_00430_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00430_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00430_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00430_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1124) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00430_A1 { + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00430_A2 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A3 a3_0; + Cycle_a_00430_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00430_A3 { + Cycle_a_00430_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00430_A4 { + Cycle_a_00430_A1 a1_0; + Cycle_a_00430_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00430_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00440B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00440_A1 a1_main = new Cycle_a_00440_A1("a1_main"); + a1_main.a2_0 = new Cycle_a_00440_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00440_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_a_00440_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1023) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00440_A1 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00440_A2 { + Cycle_a_00440_A1 a1_0; + Cycle_a_00440_A3 a3_0; + Cycle_a_00440_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00440_A3 { + Cycle_a_00440_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00440_A4 { + Cycle_a_00440_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00440_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00450B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00450_A1 a1_main = new Cycle_a_00450_A1("a1_main"); + Cycle_a_00450_A6 a6_main = new Cycle_a_00450_A6("a6_main"); + Cycle_a_00450_A7 a7_main = new Cycle_a_00450_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00450_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00450_A3("a3_0"); + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00450_A5("a5_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = a7_main; + a7_main.a2_0 = a1_main.a2_0; + a1_main.add(); + a6_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1453) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00450_A1 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00450_A2 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00450_A3 { + Cycle_a_00450_A1 a1_0; + Cycle_a_00450_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00450_A5 { + Cycle_a_00450_A6 a6_0; + Cycle_a_00450_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A5(String strObjectName) { + a6_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a7_0.a; + } + } + class Cycle_a_00450_A6 { + Cycle_a_00450_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00450_A7 { + Cycle_a_00450_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00450_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_00460B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00460_A1 a1_main = new Cycle_a_00460_A1("a1_main"); + Cycle_a_00460_A5 a5_main = new Cycle_a_00460_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00460_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00460_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00460_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00460_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00460_A1 { + Cycle_a_00460_A2 a2_0; + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A1(String strObjectName) { + a2_0 = null; + a4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a4_0.a; + } + } + class Cycle_a_00460_A2 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00460_A3 { + Cycle_a_00460_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00460_A4 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00460_A5 { + Cycle_a_00460_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00460_A6 { + Cycle_a_00460_A1 a1_0; + Cycle_a_00460_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00460_A6(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } +} +class ThreadRc_Cycle_am_00470B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00470_A1 a1_main = new Cycle_a_00470_A1("a1_main"); + Cycle_a_00470_A5 a5_main = new Cycle_a_00470_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00470_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00470_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00470_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00470_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a1_0 = a1_main; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1446) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00470_A1 { + Cycle_a_00470_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00470_A2 { + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00470_A3 { + Cycle_a_00470_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00470_A4 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00470_A5 { + Cycle_a_00470_A1 a1_0; + Cycle_a_00470_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A5(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00470_A6 { + Cycle_a_00470_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00470_A6(String strObjectName) { + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } +} +class ThreadRc_Cycle_am_00480B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00480_A1 a1_main = new Cycle_a_00480_A1("a1_main"); + Cycle_a_00480_A5 a5_main = new Cycle_a_00480_A5("a5_main"); + a1_main.a2_0 = new Cycle_a_00480_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00480_A3("a3_0"); + a1_main.a2_0.a3_0.a4_0 = new Cycle_a_00480_A4("a4_0"); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a4_0.a6_0 = new Cycle_a_00480_A6("a6_0"); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a1_main.a2_0.a3_0.a4_0.a6_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.a2_0.a3_0.a4_0.a6_0.a1_0 = a1_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a5_main.a3_0.a4_0 = a1_main.a2_0.a3_0.a4_0; + a1_main.add(); + a5_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a4_0.add(); + a1_main.a2_0.a3_0.a4_0.a1_0.add(); + a1_main.a2_0.a3_0.a4_0.a6_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a5_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.add(); +// a1_main.a2_0.a3_0.a4_0.a6_0.a1_0.add(); + a5_main.a3_0.add(); + a5_main.a3_0.a4_0.add(); +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a5_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.sum); +// System.out.println("a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum:"+a1_main.a2_0.a3_0.a4_0.a6_0.a4_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a5_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a1_main.a2_0.a3_0.a4_0.sum+a1_main.a2_0.a3_0.a4_0.a6_0.sum); + int result = a1_main.sum + a5_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a4_0.sum + a1_main.a2_0.a3_0.a4_0.a6_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1550) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00480_A1 { + Cycle_a_00480_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00480_A2 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00480_A3 { + Cycle_a_00480_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A3(String strObjectName) { + a4_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00480_A4 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A4(String strObjectName) { + a1_0 = null; + a6_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_a_00480_A5 { + Cycle_a_00480_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A5(String strObjectName) { + a3_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00480_A6 { + Cycle_a_00480_A1 a1_0; + Cycle_a_00480_A4 a4_0; + Cycle_a_00480_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00480_A6(String strObjectName) { + a1_0 = null; + a4_0 = null; + a5_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a4_0.a + a5_0.a; + } + } +} +class ThreadRc_Cycle_am_00490B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00490_A1 a1_main = new Cycle_a_00490_A1("a1_main"); + Cycle_a_00490_A4 a4_main = new Cycle_a_00490_A4("a4_main"); + Cycle_a_00490_A7 a7_main = new Cycle_a_00490_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00490_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00490_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00490_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; +// a4_main.a5_0.a6_0.a3_0 = new Cycle_a_00490_A3("a3_0"); + a4_main.a5_0.a6_0.a3_0 = a1_main.a2_0.a3_0; + a4_main.a5_0.a6_0.a3_0.a1_0 = a1_main; + a7_main.a9_0 = new Cycle_a_00490_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00490_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a7_main.a9_0.a8_0.a5_0 = a4_main.a5_0; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a6_0.a3_0.add(); + a4_main.a5_0.a6_0.a3_0.a1_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + a7_main.a9_0.a8_0.a5_0.add(); +// +// System.out.println("a1_main.sum:"+a1_main.sum); +// System.out.println("a4_main.sum:"+a4_main.sum); +// System.out.println("a7_main.sum:"+a7_main.sum); +// System.out.println("a1_main.a2_0.sum:"+a1_main.a2_0.sum); +// System.out.println("a1_main.a2_0.a3_0.sum:"+a1_main.a2_0.a3_0.sum); +// System.out.println("a4_main.a5_0.sum:"+a4_main.a5_0.sum); +// System.out.println("a4_main.a5_0.a6_0.sum:"+a4_main.a5_0.a6_0.sum); +// System.out.println("a7_main.a9_0.sum:"+a7_main.a9_0.sum); +// System.out.println("a7_main.a9_0.a8_0.sum:"+a7_main.a9_0.a8_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a4_main.sum+a7_main.sum+a1_main.a2_0.sum+a1_main.a2_0.a3_0.sum+a4_main.a5_0.sum+a4_main.a5_0.a6_0.sum+a7_main.a9_0.sum+a7_main.a9_0.a8_0.sum); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2098) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00490_A1 { + Cycle_a_00490_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00490_A2 { + Cycle_a_00490_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00490_A3 { + Cycle_a_00490_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00490_A4 { + Cycle_a_00490_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_a_00490_A5 { + Cycle_a_00490_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00490_A6 { + Cycle_a_00490_A3 a3_0; + Cycle_a_00490_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A6(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00490_A7 { + Cycle_a_00490_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00490_A8 { + Cycle_a_00490_A5 a5_0; + Cycle_a_00490_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A8(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a + a5_0.a; + } + } + class Cycle_a_00490_A9 { + Cycle_a_00490_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00490_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +class ThreadRc_Cycle_am_00500B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00500_A1 a1_main = new Cycle_a_00500_A1("a1_main"); + Cycle_a_00500_A4 a4_main = new Cycle_a_00500_A4("a4_main"); + Cycle_a_00500_A7 a7_main = new Cycle_a_00500_A7("a7_main"); + a1_main.a2_0 = new Cycle_a_00500_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00500_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a4_main.a1_0 = a1_main; + a4_main.a5_0 = new Cycle_a_00500_A5("a5_0"); + a4_main.a5_0.a6_0 = new Cycle_a_00500_A6("a6_0"); + a4_main.a5_0.a6_0.a4_0 = a4_main; + a4_main.a5_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a4_main.a5_0.a8_0.a7_0 = a7_main; + a7_main.a9_0 = new Cycle_a_00500_A9("a9_0"); + a7_main.a9_0.a8_0 = new Cycle_a_00500_A8("a8_0"); + a7_main.a9_0.a8_0.a7_0 = a7_main; + a1_main.add(); + a4_main.add(); + a7_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a1_0.add(); + a4_main.a1_0.add(); + a4_main.a5_0.add(); + a4_main.a5_0.a6_0.add(); + a4_main.a5_0.a6_0.a4_0.add(); + a4_main.a5_0.a8_0.add(); + a4_main.a5_0.a8_0.a7_0.add(); + a7_main.a9_0.add(); + a7_main.a9_0.a8_0.add(); + a7_main.a9_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a7_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a4_main.a5_0.sum + a4_main.a5_0.a6_0.sum + a7_main.a9_0.sum + a7_main.a9_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2099) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00500_A1 { + Cycle_a_00500_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00500_A2 { + Cycle_a_00500_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_00500_A3 { + Cycle_a_00500_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00500_A4 { + Cycle_a_00500_A1 a1_0; + Cycle_a_00500_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A4(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_00500_A5 { + Cycle_a_00500_A6 a6_0; + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00500_A6 { + Cycle_a_00500_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A6(String strObjectName) { + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_a_00500_A7 { + Cycle_a_00500_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A7(String strObjectName) { + a9_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_00500_A8 { + Cycle_a_00500_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00500_A9 { + Cycle_a_00500_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00500_A9(String strObjectName) { + a8_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_am_00510 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00180B A1_Cycle_am_00180 = new ThreadRc_Cycle_am_00180B(); + ThreadRc_Cycle_am_00180B A2_Cycle_am_00180 = new ThreadRc_Cycle_am_00180B(); + ThreadRc_Cycle_am_00190B A1_Cycle_am_00190 = new ThreadRc_Cycle_am_00190B(); + ThreadRc_Cycle_am_00190B A2_Cycle_am_00190 = new ThreadRc_Cycle_am_00190B(); + ThreadRc_Cycle_am_00200B A1_Cycle_am_00200 = new ThreadRc_Cycle_am_00200B(); + ThreadRc_Cycle_am_00200B A2_Cycle_am_00200 = new ThreadRc_Cycle_am_00200B(); + ThreadRc_Cycle_am_00210B A1_Cycle_am_00210 = new ThreadRc_Cycle_am_00210B(); + ThreadRc_Cycle_am_00210B A2_Cycle_am_00210 = new ThreadRc_Cycle_am_00210B(); + ThreadRc_Cycle_am_00220B A1_Cycle_am_00220 = new ThreadRc_Cycle_am_00220B(); + ThreadRc_Cycle_am_00220B A2_Cycle_am_00220 = new ThreadRc_Cycle_am_00220B(); + ThreadRc_Cycle_am_00230B A1_Cycle_am_00230 = new ThreadRc_Cycle_am_00230B(); + ThreadRc_Cycle_am_00230B A2_Cycle_am_00230 = new ThreadRc_Cycle_am_00230B(); + ThreadRc_Cycle_am_00240B A1_Cycle_am_00240 = new ThreadRc_Cycle_am_00240B(); + ThreadRc_Cycle_am_00240B A2_Cycle_am_00240 = new ThreadRc_Cycle_am_00240B(); + ThreadRc_Cycle_am_00250B A1_Cycle_am_00250 = new ThreadRc_Cycle_am_00250B(); + ThreadRc_Cycle_am_00250B A2_Cycle_am_00250 = new ThreadRc_Cycle_am_00250B(); + ThreadRc_Cycle_am_00260B A1_Cycle_am_00260 = new ThreadRc_Cycle_am_00260B(); + ThreadRc_Cycle_am_00260B A2_Cycle_am_00260 = new ThreadRc_Cycle_am_00260B(); + ThreadRc_Cycle_am_00270B A1_Cycle_am_00270 = new ThreadRc_Cycle_am_00270B(); + ThreadRc_Cycle_am_00270B A2_Cycle_am_00270 = new ThreadRc_Cycle_am_00270B(); + ThreadRc_Cycle_am_00280B A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280B(); + ThreadRc_Cycle_am_00280B A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280B(); + ThreadRc_Cycle_am_00290B A1_Cycle_am_00290 = new ThreadRc_Cycle_am_00290B(); + ThreadRc_Cycle_am_00290B A2_Cycle_am_00290 = new ThreadRc_Cycle_am_00290B(); + ThreadRc_Cycle_am_00300B A1_Cycle_am_00300 = new ThreadRc_Cycle_am_00300B(); + ThreadRc_Cycle_am_00300B A2_Cycle_am_00300 = new ThreadRc_Cycle_am_00300B(); + ThreadRc_Cycle_am_00310B A1_Cycle_am_00310 = new ThreadRc_Cycle_am_00310B(); + ThreadRc_Cycle_am_00310B A2_Cycle_am_00310 = new ThreadRc_Cycle_am_00310B(); + ThreadRc_Cycle_am_00320B A1_Cycle_am_00320 = new ThreadRc_Cycle_am_00320B(); + ThreadRc_Cycle_am_00320B A2_Cycle_am_00320 = new ThreadRc_Cycle_am_00320B(); + ThreadRc_Cycle_am_00330B A1_Cycle_am_00330 = new ThreadRc_Cycle_am_00330B(); + ThreadRc_Cycle_am_00330B A2_Cycle_am_00330 = new ThreadRc_Cycle_am_00330B(); + ThreadRc_Cycle_am_00340B A1_Cycle_am_00340 = new ThreadRc_Cycle_am_00340B(); + ThreadRc_Cycle_am_00340B A2_Cycle_am_00340 = new ThreadRc_Cycle_am_00340B(); + ThreadRc_Cycle_am_00350B A1_Cycle_am_00350 = new ThreadRc_Cycle_am_00350B(); + ThreadRc_Cycle_am_00350B A2_Cycle_am_00350 = new ThreadRc_Cycle_am_00350B(); + ThreadRc_Cycle_am_00360B A1_Cycle_am_00360 = new ThreadRc_Cycle_am_00360B(); + ThreadRc_Cycle_am_00360B A2_Cycle_am_00360 = new ThreadRc_Cycle_am_00360B(); + ThreadRc_Cycle_am_00370B A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370B(); + ThreadRc_Cycle_am_00370B A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370B(); + ThreadRc_Cycle_am_00380B A1_Cycle_am_00380 = new ThreadRc_Cycle_am_00380B(); + ThreadRc_Cycle_am_00380B A2_Cycle_am_00380 = new ThreadRc_Cycle_am_00380B(); + ThreadRc_Cycle_am_00390B A1_Cycle_am_00390 = new ThreadRc_Cycle_am_00390B(); + ThreadRc_Cycle_am_00390B A2_Cycle_am_00390 = new ThreadRc_Cycle_am_00390B(); + ThreadRc_Cycle_am_00400B A1_Cycle_am_00400 = new ThreadRc_Cycle_am_00400B(); + ThreadRc_Cycle_am_00400B A2_Cycle_am_00400 = new ThreadRc_Cycle_am_00400B(); + ThreadRc_Cycle_am_00410B A1_Cycle_am_00410 = new ThreadRc_Cycle_am_00410B(); + ThreadRc_Cycle_am_00410B A2_Cycle_am_00410 = new ThreadRc_Cycle_am_00410B(); + ThreadRc_Cycle_am_00420B A1_Cycle_am_00420 = new ThreadRc_Cycle_am_00420B(); + ThreadRc_Cycle_am_00420B A2_Cycle_am_00420 = new ThreadRc_Cycle_am_00420B(); + ThreadRc_Cycle_am_00430B A1_Cycle_am_00430 = new ThreadRc_Cycle_am_00430B(); + ThreadRc_Cycle_am_00430B A2_Cycle_am_00430 = new ThreadRc_Cycle_am_00430B(); + ThreadRc_Cycle_am_00440B A1_Cycle_am_00440 = new ThreadRc_Cycle_am_00440B(); + ThreadRc_Cycle_am_00440B A2_Cycle_am_00440 = new ThreadRc_Cycle_am_00440B(); + ThreadRc_Cycle_am_00450B A1_Cycle_am_00450 = new ThreadRc_Cycle_am_00450B(); + ThreadRc_Cycle_am_00450B A2_Cycle_am_00450 = new ThreadRc_Cycle_am_00450B(); + ThreadRc_Cycle_am_00460B A1_Cycle_am_00460 = new ThreadRc_Cycle_am_00460B(); + ThreadRc_Cycle_am_00460B A2_Cycle_am_00460 = new ThreadRc_Cycle_am_00460B(); + ThreadRc_Cycle_am_00470B A1_Cycle_am_00470 = new ThreadRc_Cycle_am_00470B(); + ThreadRc_Cycle_am_00470B A2_Cycle_am_00470 = new ThreadRc_Cycle_am_00470B(); + ThreadRc_Cycle_am_00480B A1_Cycle_am_00480 = new ThreadRc_Cycle_am_00480B(); + ThreadRc_Cycle_am_00480B A2_Cycle_am_00480 = new ThreadRc_Cycle_am_00480B(); + ThreadRc_Cycle_am_00490B A1_Cycle_am_00490 = new ThreadRc_Cycle_am_00490B(); + ThreadRc_Cycle_am_00490B A2_Cycle_am_00490 = new ThreadRc_Cycle_am_00490B(); + ThreadRc_Cycle_am_00500B A1_Cycle_am_00500 = new ThreadRc_Cycle_am_00500B(); + ThreadRc_Cycle_am_00500B A2_Cycle_am_00500 = new ThreadRc_Cycle_am_00500B(); + A1_Cycle_am_00180.start(); + A2_Cycle_am_00180.start(); + A1_Cycle_am_00190.start(); + A2_Cycle_am_00190.start(); + A1_Cycle_am_00200.start(); + A2_Cycle_am_00200.start(); + A1_Cycle_am_00210.start(); + A2_Cycle_am_00210.start(); + A1_Cycle_am_00220.start(); + A2_Cycle_am_00220.start(); + A1_Cycle_am_00230.start(); + A2_Cycle_am_00230.start(); + A1_Cycle_am_00240.start(); + A2_Cycle_am_00240.start(); + A1_Cycle_am_00250.start(); + A2_Cycle_am_00250.start(); + A1_Cycle_am_00260.start(); + A2_Cycle_am_00260.start(); + A1_Cycle_am_00270.start(); + A2_Cycle_am_00270.start(); + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A1_Cycle_am_00290.start(); + A2_Cycle_am_00290.start(); + A1_Cycle_am_00300.start(); + A2_Cycle_am_00300.start(); + A1_Cycle_am_00310.start(); + A2_Cycle_am_00310.start(); + A1_Cycle_am_00320.start(); + A2_Cycle_am_00320.start(); + A1_Cycle_am_00330.start(); + A2_Cycle_am_00330.start(); + A1_Cycle_am_00340.start(); + A2_Cycle_am_00340.start(); + A1_Cycle_am_00350.start(); + A2_Cycle_am_00350.start(); + A1_Cycle_am_00360.start(); + A2_Cycle_am_00360.start(); + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A1_Cycle_am_00380.start(); + A2_Cycle_am_00380.start(); + A1_Cycle_am_00390.start(); + A2_Cycle_am_00390.start(); + A1_Cycle_am_00400.start(); + A2_Cycle_am_00400.start(); + A1_Cycle_am_00410.start(); + A2_Cycle_am_00410.start(); + A1_Cycle_am_00420.start(); + A2_Cycle_am_00420.start(); + A1_Cycle_am_00430.start(); + A2_Cycle_am_00430.start(); + A1_Cycle_am_00440.start(); + A2_Cycle_am_00440.start(); + A1_Cycle_am_00450.start(); + A2_Cycle_am_00450.start(); + A1_Cycle_am_00460.start(); + A2_Cycle_am_00460.start(); + A1_Cycle_am_00470.start(); + A2_Cycle_am_00470.start(); + A1_Cycle_am_00480.start(); + A2_Cycle_am_00480.start(); + A1_Cycle_am_00490.start(); + A2_Cycle_am_00490.start(); + A1_Cycle_am_00500.start(); + A2_Cycle_am_00500.start(); + try { + A1_Cycle_am_00180.join(); + A2_Cycle_am_00180.join(); + A1_Cycle_am_00190.join(); + A2_Cycle_am_00190.join(); + A1_Cycle_am_00200.join(); + A2_Cycle_am_00200.join(); + A1_Cycle_am_00210.join(); + A2_Cycle_am_00210.join(); + A1_Cycle_am_00220.join(); + A2_Cycle_am_00220.join(); + A1_Cycle_am_00230.join(); + A2_Cycle_am_00230.join(); + A1_Cycle_am_00240.join(); + A2_Cycle_am_00240.join(); + A1_Cycle_am_00250.join(); + A2_Cycle_am_00250.join(); + A1_Cycle_am_00260.join(); + A2_Cycle_am_00260.join(); + A1_Cycle_am_00270.join(); + A2_Cycle_am_00270.join(); + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A1_Cycle_am_00290.join(); + A2_Cycle_am_00290.join(); + A1_Cycle_am_00300.join(); + A2_Cycle_am_00300.join(); + A1_Cycle_am_00310.join(); + A2_Cycle_am_00310.join(); + A1_Cycle_am_00320.join(); + A2_Cycle_am_00320.join(); + A1_Cycle_am_00330.join(); + A2_Cycle_am_00330.join(); + A1_Cycle_am_00340.join(); + A2_Cycle_am_00340.join(); + A1_Cycle_am_00350.join(); + A2_Cycle_am_00350.join(); + A1_Cycle_am_00360.join(); + A2_Cycle_am_00360.join(); + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A1_Cycle_am_00380.join(); + A2_Cycle_am_00380.join(); + A1_Cycle_am_00390.join(); + A2_Cycle_am_00390.join(); + A1_Cycle_am_00400.join(); + A2_Cycle_am_00400.join(); + A1_Cycle_am_00410.join(); + A2_Cycle_am_00410.join(); + A1_Cycle_am_00420.join(); + A2_Cycle_am_00420.join(); + A1_Cycle_am_00430.join(); + A2_Cycle_am_00430.join(); + A1_Cycle_am_00440.join(); + A2_Cycle_am_00440.join(); + A1_Cycle_am_00450.join(); + A2_Cycle_am_00450.join(); + A1_Cycle_am_00460.join(); + A2_Cycle_am_00460.join(); + A1_Cycle_am_00470.join(); + A2_Cycle_am_00470.join(); + A1_Cycle_am_00480.join(); + A2_Cycle_am_00480.join(); + A1_Cycle_am_00490.join(); + A2_Cycle_am_00490.join(); + A1_Cycle_am_00500.join(); + A2_Cycle_am_00500.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00180.check() && A2_Cycle_am_00180.check() && A1_Cycle_am_00190.check() && A2_Cycle_am_00190.check() && A1_Cycle_am_00200.check() && A2_Cycle_am_00200.check() && A1_Cycle_am_00210.check() && A2_Cycle_am_00210.check() && A1_Cycle_am_00220.check() && A2_Cycle_am_00220.check() && A1_Cycle_am_00230.check() && A2_Cycle_am_00230.check() && A1_Cycle_am_00240.check() && A2_Cycle_am_00240.check() && A1_Cycle_am_00250.check() && A2_Cycle_am_00250.check() && A1_Cycle_am_00260.check() && A2_Cycle_am_00260.check() && A1_Cycle_am_00270.check() && A2_Cycle_am_00270.check() && A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A1_Cycle_am_00290.check() && A2_Cycle_am_00290.check() && A1_Cycle_am_00300.check() && A2_Cycle_am_00300.check() && A1_Cycle_am_00310.check() && A2_Cycle_am_00310.check() && A1_Cycle_am_00320.check() && A2_Cycle_am_00320.check() && A1_Cycle_am_00330.check() && A2_Cycle_am_00330.check() && A1_Cycle_am_00340.check() && A2_Cycle_am_00340.check() && A1_Cycle_am_00350.check() && A2_Cycle_am_00350.check() && A1_Cycle_am_00360.check() && A2_Cycle_am_00360.check() && A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A1_Cycle_am_00380.check() && A2_Cycle_am_00380.check() && A1_Cycle_am_00390.check() && A2_Cycle_am_00390.check() && A1_Cycle_am_00400.check() && A2_Cycle_am_00400.check() && A1_Cycle_am_00410.check() && A2_Cycle_am_00410.check() && A1_Cycle_am_00420.check() && A2_Cycle_am_00420.check() && A1_Cycle_am_00430.check() && A2_Cycle_am_00430.check() && A1_Cycle_am_00440.check() && A2_Cycle_am_00440.check() && A1_Cycle_am_00450.check() && A2_Cycle_am_00450.check() && A1_Cycle_am_00460.check() && A2_Cycle_am_00460.check() && A1_Cycle_am_00470.check() && A2_Cycle_am_00470.check() && A1_Cycle_am_00480.check() && A2_Cycle_am_00480.check() && A1_Cycle_am_00490.check() && A2_Cycle_am_00490.check() && A1_Cycle_am_00500.check() && A2_Cycle_am_00500.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/expected.txt b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f33a8592d2316dcaefb376e2e77d12a354a4918e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/expected.txt @@ -0,0 +1,4 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/test.cfg b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06e6d972efc9cb749477c0a2993d255daf6f85b1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0153-rc-function-RC_Thread01-Cycle_am_00510/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_00510) +run(Cycle_am_00510,EXPECTNUM=4) diff --git a/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..f8b13d40f5f030533e77667fd6c5f276afa3169d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/Cycle_am_10010.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_10010 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == 3852) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10010 A1_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A2_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A3_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A4_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A5_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + ThreadRc_Cycle_am_10010 A6_Cycle_am_10010 = new ThreadRc_Cycle_am_10010(); + A1_Cycle_am_10010.start(); + A2_Cycle_am_10010.start(); + A3_Cycle_am_10010.start(); + A4_Cycle_am_10010.start(); + A5_Cycle_am_10010.start(); + A6_Cycle_am_10010.start(); + try { + A1_Cycle_am_10010.join(); + A2_Cycle_am_10010.join(); + A3_Cycle_am_10010.join(); + A4_Cycle_am_10010.join(); + A5_Cycle_am_10010.join(); + A6_Cycle_am_10010.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10010.check() && A2_Cycle_am_10010.check() && A3_Cycle_am_10010.check() && A4_Cycle_am_10010.check() && A5_Cycle_am_10010.check() && A6_Cycle_am_10010.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/expected.txt b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/test.cfg b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..15e3f9e661fc12a255a1510ee8ccc842f6004167 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0154-rc-function-RC_Thread01-Cycle_am_10010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_10010) +run(Cycle_am_10010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..029809b7b238587579d677c4e2a9e060ada858c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/Cycle_am_10020.java @@ -0,0 +1,323 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_10020 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == 3438) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +public class Cycle_am_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10020 A1_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A2_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A3_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A4_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A5_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + ThreadRc_Cycle_am_10020 A6_Cycle_am_10020 = new ThreadRc_Cycle_am_10020(); + A1_Cycle_am_10020.start(); + A2_Cycle_am_10020.start(); + A3_Cycle_am_10020.start(); + A4_Cycle_am_10020.start(); + A5_Cycle_am_10020.start(); + A6_Cycle_am_10020.start(); + try { + A1_Cycle_am_10020.join(); + A2_Cycle_am_10020.join(); + A3_Cycle_am_10020.join(); + A4_Cycle_am_10020.join(); + A5_Cycle_am_10020.join(); + A6_Cycle_am_10020.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10020.check() && A2_Cycle_am_10020.check() && A3_Cycle_am_10020.check() && A4_Cycle_am_10020.check() && A5_Cycle_am_10020.check() && A6_Cycle_am_10020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/expected.txt b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/test.cfg b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1cdeea75e6629f7b794dad4d485600ce28fb134 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0155-rc-function-RC_Thread01-Cycle_am_10020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_10020) +run(Cycle_am_10020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java new file mode 100755 index 0000000000000000000000000000000000000000..13d7eefd8f5070e2d5ee6f2e8cb83fbb870c746b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/Cycle_am_10030.java @@ -0,0 +1,651 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_am_10020B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_10020_A1 a1_main = new Cycle_a_10020_A1("a1_main"); + Cycle_a_10020_A4 a4_main = new Cycle_a_10020_A4("a4_main"); + Cycle_a_10020_A6 a6_main = new Cycle_a_10020_A6("a6_main"); + Cycle_a_10020_A9 a9_main = new Cycle_a_10020_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_10020_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10020_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10020_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_10020_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10020_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10020_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a3_0.a5_0.a8_0.a7_0.sum + a6_main.a3_0.a5_0.a8_0.sum + a6_main.a3_0.a10_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10020_2A1 a1_2main = new Cycle_a_10020_2A1("a1_2main"); + a1_2main.a2_0 = new Cycle_a_10020_2A2("a2_0"); + a1_2main.a2_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0 = new Cycle_a_10020_2A3("a3_0"); + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a2_0 = a1_2main.a2_0; + a1_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + int result2 = a1_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == 3438) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_10020_A1 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_A2 { + Cycle_a_10020_A3 a3_0; + Cycle_a_10020_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_10020_A3 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A5 a5_0; + Cycle_a_10020_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + class Cycle_a_10020_A4 { + Cycle_a_10020_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_10020_A5 { + Cycle_a_10020_A6 a6_0; + Cycle_a_10020_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_10020_A6 { + Cycle_a_10020_A1 a1_0; + Cycle_a_10020_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10020_A7 { + Cycle_a_10020_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_A8 { + Cycle_a_10020_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_10020_A9 { + Cycle_a_10020_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_10020_A10 { + Cycle_a_10020_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_a_10020_2A1 { + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10020_2A2 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10020_2A3 { + Cycle_a_10020_2A1 a1_0; + Cycle_a_10020_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10020_2A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +class ThreadRc_Cycle_am_10010B extends Thread { + private boolean checkout; + public void run() { + Cycle_a_10010_A1 a1_main = new Cycle_a_10010_A1("a1_main"); + Cycle_a_10010_A4 a4_main = new Cycle_a_10010_A4("a4_main"); + Cycle_a_10010_A6 a6_main = new Cycle_a_10010_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_10010_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_10010_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_10010_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a4_0 = a4_main; + a4_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0.a5_0.a7_0 = new Cycle_a_10010_A7("a7_0"); + a6_main.a7_0 = a1_main.a2_0.a3_0.a5_0.a7_0; + a6_main.a5_0 = a1_main.a2_0.a3_0.a5_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a5_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a6_main.a7_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_a_10010_2A1 a1_2main = new Cycle_a_10010_2A1("a1_2main"); + Cycle_a_10010_2A4 a4_2main = new Cycle_a_10010_2A4("a4_2main"); + Cycle_a_10010_2A6 a6_2main = new Cycle_a_10010_2A6("a6_2main"); + a1_2main.a2_0 = new Cycle_a_10010_2A2("a2_0"); + a1_2main.a2_0.a3_0 = new Cycle_a_10010_2A3("a3_0"); + a1_2main.a2_0.a4_0 = a4_2main; + a4_2main.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a1_0 = a1_2main; + a1_2main.a2_0.a3_0.a5_0 = new Cycle_a_10010_2A5("a5_0"); + a1_2main.a2_0.a3_0.a5_0.a6_0 = a6_2main; + a1_2main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_10010_2A8("a8_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_10010_2A7("a7_0"); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.a3_0 = a1_2main.a2_0.a3_0; + a6_2main.a1_0 = a1_2main; + a6_2main.a3_0 = a1_2main.a2_0.a3_0; + a1_2main.add(); + a4_2main.add(); + a6_2main.add(); + a1_2main.a2_0.add(); + a1_2main.a2_0.a3_0.add(); + a1_2main.a2_0.a3_0.a5_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.add(); + a1_2main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result2 = a1_2main.sum + a4_2main.sum + a6_2main.sum + a1_2main.a2_0.sum + a1_2main.a2_0.a3_0.sum + a1_2main.a2_0.a3_0.a5_0.sum + a6_2main.a3_0.a5_0.a8_0.a7_0.sum + a6_2main.a3_0.a5_0.a8_0.sum; + //System.out.println("RC-Testing_Result="+result); + result += result2; + if (result == 3852) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_10010_A1 { + Cycle_a_10010_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10010_A2 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_A3 { + Cycle_a_10010_A1 a1_0; + Cycle_a_10010_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_10010_A4 { + Cycle_a_10010_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A4(String strObjectName) { + a3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_A5 { + Cycle_a_10010_A4 a4_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A5(String strObjectName) { + a4_0 = null; + a7_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a4_0.a + a7_0.a; + } + } + class Cycle_a_10010_A6 { + Cycle_a_10010_A5 a5_0; + Cycle_a_10010_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_A6(String strObjectName) { + a5_0 = null; + a7_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a5_0.a + a7_0.a; + } + } + class Cycle_a_10010_A7 { + int a; + int sum; + String strObjectName; + Cycle_a_10010_A7(String strObjectName) { + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Cycle_a_10010_2A1 { + Cycle_a_10010_2A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_10010_2A2 { + Cycle_a_10010_2A3 a3_0; + Cycle_a_10010_2A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_10010_2A3 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + class Cycle_a_10010_2A4 { + Cycle_a_10010_2A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_10010_2A5 { + Cycle_a_10010_2A6 a6_0; + Cycle_a_10010_2A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_10010_2A6 { + Cycle_a_10010_2A1 a1_0; + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_10010_2A7 { + Cycle_a_10010_2A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A7(String strObjectName) { + a3_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_a_10010_2A8 { + Cycle_a_10010_2A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_10010_2A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } +} +public class Cycle_am_10030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_10010B A1_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A2_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A3_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A4_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A5_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10010B A6_Cycle_am_10010 = new ThreadRc_Cycle_am_10010B(); + ThreadRc_Cycle_am_10020B A1_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A2_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A3_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A4_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A5_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + ThreadRc_Cycle_am_10020B A6_Cycle_am_10020 = new ThreadRc_Cycle_am_10020B(); + A1_Cycle_am_10010.start(); + A2_Cycle_am_10010.start(); + A3_Cycle_am_10010.start(); + A4_Cycle_am_10010.start(); + A5_Cycle_am_10010.start(); + A6_Cycle_am_10010.start(); + A1_Cycle_am_10020.start(); + A2_Cycle_am_10020.start(); + A3_Cycle_am_10020.start(); + A4_Cycle_am_10020.start(); + A5_Cycle_am_10020.start(); + A6_Cycle_am_10020.start(); + try { + A1_Cycle_am_10010.join(); + A2_Cycle_am_10010.join(); + A3_Cycle_am_10010.join(); + A4_Cycle_am_10010.join(); + A5_Cycle_am_10010.join(); + A6_Cycle_am_10010.join(); + A1_Cycle_am_10020.join(); + A2_Cycle_am_10020.join(); + A3_Cycle_am_10020.join(); + A4_Cycle_am_10020.join(); + A5_Cycle_am_10020.join(); + A6_Cycle_am_10020.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_10010.check() && A2_Cycle_am_10010.check() && A3_Cycle_am_10010.check() && A4_Cycle_am_10010.check() && A5_Cycle_am_10010.check() && A6_Cycle_am_10010.check() && A1_Cycle_am_10020.check() && A2_Cycle_am_10020.check() && A3_Cycle_am_10020.check() && A4_Cycle_am_10020.check() && A5_Cycle_am_10020.check() && A6_Cycle_am_10020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/expected.txt b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/test.cfg b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0e86eb0d0ab48d2e278c4ddfdfc904459a74d6a7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0156-rc-function-RC_Thread01-Cycle_am_10030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_am_10030) +run(Cycle_am_10030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..0eacb2a770b1053685c07975bd2cf0208422aada --- /dev/null +++ b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/Cycle_Bm_1_00010.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00010 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + //System.out.println(nsum); + if (nsum == 246) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010 A1_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A2_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A3_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A4_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A5_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A6_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + A1_Cycle_Bm_1_00010.start(); + A2_Cycle_Bm_1_00010.start(); + A3_Cycle_Bm_1_00010.start(); + A4_Cycle_Bm_1_00010.start(); + A5_Cycle_Bm_1_00010.start(); + A6_Cycle_Bm_1_00010.start(); + try { + A1_Cycle_Bm_1_00010.join(); + A2_Cycle_Bm_1_00010.join(); + A3_Cycle_Bm_1_00010.join(); + A4_Cycle_Bm_1_00010.join(); + A5_Cycle_Bm_1_00010.join(); + A6_Cycle_Bm_1_00010.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00010.check() && A2_Cycle_Bm_1_00010.check() && A3_Cycle_Bm_1_00010.check() && A4_Cycle_Bm_1_00010.check() && A5_Cycle_Bm_1_00010.check() && A6_Cycle_Bm_1_00010.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/expected.txt b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/test.cfg b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d0ae3ccf1473ffc097738a907ffb82d4c64aac34 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0157-rc-function-RC_Thread01-Cycle_Bm_1_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00010) +run(Cycle_Bm_1_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..561db7bf1e5da96c2d79bb11f89f68cef8ab6051 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/Cycle_Bm_1_00020.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00020 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + if (nsum == 6) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00020 A1_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A2_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A3_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A4_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A5_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + ThreadRc_Cycle_Bm_1_00020 A6_Cycle_Bm_1_00020 = new ThreadRc_Cycle_Bm_1_00020(); + A1_Cycle_Bm_1_00020.start(); + A2_Cycle_Bm_1_00020.start(); + A3_Cycle_Bm_1_00020.start(); + A4_Cycle_Bm_1_00020.start(); + A5_Cycle_Bm_1_00020.start(); + A6_Cycle_Bm_1_00020.start(); + try { + A1_Cycle_Bm_1_00020.join(); + A2_Cycle_Bm_1_00020.join(); + A3_Cycle_Bm_1_00020.join(); + A4_Cycle_Bm_1_00020.join(); + A5_Cycle_Bm_1_00020.join(); + A6_Cycle_Bm_1_00020.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00020.check() && A2_Cycle_Bm_1_00020.check() && A3_Cycle_Bm_1_00020.check() && A4_Cycle_Bm_1_00020.check() && A5_Cycle_Bm_1_00020.check() && A6_Cycle_Bm_1_00020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/expected.txt b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/test.cfg b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8a1498fdab8c076836688344c58d10cd1716cded --- /dev/null +++ b/testsuite/java_test/rc_test/RC0158-rc-function-RC_Thread01-Cycle_Bm_1_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00020) +run(Cycle_Bm_1_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..7492be754c333ed0989cdc2f7bb9d71c7868b8df --- /dev/null +++ b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/Cycle_Bm_1_00030.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00030 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00030 A1_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A2_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A3_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A4_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A5_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + ThreadRc_Cycle_Bm_1_00030 A6_Cycle_Bm_1_00030 = new ThreadRc_Cycle_Bm_1_00030(); + A1_Cycle_Bm_1_00030.start(); + A2_Cycle_Bm_1_00030.start(); + A3_Cycle_Bm_1_00030.start(); + A4_Cycle_Bm_1_00030.start(); + A5_Cycle_Bm_1_00030.start(); + A6_Cycle_Bm_1_00030.start(); + try { + A1_Cycle_Bm_1_00030.join(); + A2_Cycle_Bm_1_00030.join(); + A3_Cycle_Bm_1_00030.join(); + A4_Cycle_Bm_1_00030.join(); + A5_Cycle_Bm_1_00030.join(); + A6_Cycle_Bm_1_00030.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00030.check() && A2_Cycle_Bm_1_00030.check() && A3_Cycle_Bm_1_00030.check() && A4_Cycle_Bm_1_00030.check() && A5_Cycle_Bm_1_00030.check() && A6_Cycle_Bm_1_00030.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/expected.txt b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/test.cfg b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8899d086538f8b7a803bbcf2543f35e4d8b7f32f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0159-rc-function-RC_Thread01-Cycle_Bm_1_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00030) +run(Cycle_Bm_1_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..68d15dc6a430749013decb71e9af2f5c11da8657 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/Cycle_Bm_1_00040.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00040 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00040_A4 { + int a; + int sum; + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +public class Cycle_Bm_1_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00040 A1_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A2_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A3_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A4_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A5_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + ThreadRc_Cycle_Bm_1_00040 A6_Cycle_Bm_1_00040 = new ThreadRc_Cycle_Bm_1_00040(); + A1_Cycle_Bm_1_00040.start(); + A2_Cycle_Bm_1_00040.start(); + A3_Cycle_Bm_1_00040.start(); + A4_Cycle_Bm_1_00040.start(); + A5_Cycle_Bm_1_00040.start(); + A6_Cycle_Bm_1_00040.start(); + try { + A1_Cycle_Bm_1_00040.join(); + A2_Cycle_Bm_1_00040.join(); + A3_Cycle_Bm_1_00040.join(); + A4_Cycle_Bm_1_00040.join(); + A5_Cycle_Bm_1_00040.join(); + A6_Cycle_Bm_1_00040.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00040.check() && A2_Cycle_Bm_1_00040.check() && A3_Cycle_Bm_1_00040.check() && A4_Cycle_Bm_1_00040.check() && A5_Cycle_Bm_1_00040.check() && A6_Cycle_Bm_1_00040.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/expected.txt b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/test.cfg b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f7b3815f9e9183dac47653c7c7e832ec1c45dee9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0160-rc-function-RC_Thread01-Cycle_Bm_1_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00040) +run(Cycle_Bm_1_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..8f41d086c4bce69ff4456b7f42ebd7da3577bc69 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/Cycle_Bm_1_00050.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00050 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 34) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00050_A4 { + int a; + int sum; + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } + class Cycle_B_1_00050_A5 { + int a; + int sum; + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } + } +} +public class Cycle_Bm_1_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00050 A1_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A2_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A3_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A4_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A5_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + ThreadRc_Cycle_Bm_1_00050 A6_Cycle_Bm_1_00050 = new ThreadRc_Cycle_Bm_1_00050(); + A1_Cycle_Bm_1_00050.start(); + A2_Cycle_Bm_1_00050.start(); + A3_Cycle_Bm_1_00050.start(); + A4_Cycle_Bm_1_00050.start(); + A5_Cycle_Bm_1_00050.start(); + A6_Cycle_Bm_1_00050.start(); + try { + A1_Cycle_Bm_1_00050.join(); + A2_Cycle_Bm_1_00050.join(); + A3_Cycle_Bm_1_00050.join(); + A4_Cycle_Bm_1_00050.join(); + A5_Cycle_Bm_1_00050.join(); + A6_Cycle_Bm_1_00050.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00050.check() && A2_Cycle_Bm_1_00050.check() && A3_Cycle_Bm_1_00050.check() && A4_Cycle_Bm_1_00050.check() && A5_Cycle_Bm_1_00050.check() && A6_Cycle_Bm_1_00050.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/expected.txt b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/test.cfg b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..80c73978749e18c4c2b8e2833710205cf82edba9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0161-rc-function-RC_Thread01-Cycle_Bm_1_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00050) +run(Cycle_Bm_1_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..edb18ca35e7f9bc4f2152a1a5892c6ebae4e1c19 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/Cycle_Bm_1_00060.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00060 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_1_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00060 A1_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A2_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A3_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A4_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A5_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + ThreadRc_Cycle_Bm_1_00060 A6_Cycle_Bm_1_00060 = new ThreadRc_Cycle_Bm_1_00060(); + A1_Cycle_Bm_1_00060.start(); + A2_Cycle_Bm_1_00060.start(); + A3_Cycle_Bm_1_00060.start(); + A4_Cycle_Bm_1_00060.start(); + A5_Cycle_Bm_1_00060.start(); + A6_Cycle_Bm_1_00060.start(); + try { + A1_Cycle_Bm_1_00060.join(); + A2_Cycle_Bm_1_00060.join(); + A3_Cycle_Bm_1_00060.join(); + A4_Cycle_Bm_1_00060.join(); + A5_Cycle_Bm_1_00060.join(); + A6_Cycle_Bm_1_00060.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00060.check() && A2_Cycle_Bm_1_00060.check() && A3_Cycle_Bm_1_00060.check() && A4_Cycle_Bm_1_00060.check() && A5_Cycle_Bm_1_00060.check() && A6_Cycle_Bm_1_00060.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/expected.txt b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/test.cfg b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e44ea35cb8fb5a9a9233f3c111475553c455c00f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0162-rc-function-RC_Thread01-Cycle_Bm_1_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00060) +run(Cycle_Bm_1_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..7065b75bf2c10d91f871344c0b6e954705c6c010 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/Cycle_Bm_1_00070.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00070 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00070_A4 { + int a; + int sum; + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +public class Cycle_Bm_1_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00070 A1_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A2_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A3_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A4_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A5_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + ThreadRc_Cycle_Bm_1_00070 A6_Cycle_Bm_1_00070 = new ThreadRc_Cycle_Bm_1_00070(); + A1_Cycle_Bm_1_00070.start(); + A2_Cycle_Bm_1_00070.start(); + A3_Cycle_Bm_1_00070.start(); + A4_Cycle_Bm_1_00070.start(); + A5_Cycle_Bm_1_00070.start(); + A6_Cycle_Bm_1_00070.start(); + try { + A1_Cycle_Bm_1_00070.join(); + A2_Cycle_Bm_1_00070.join(); + A3_Cycle_Bm_1_00070.join(); + A4_Cycle_Bm_1_00070.join(); + A5_Cycle_Bm_1_00070.join(); + A6_Cycle_Bm_1_00070.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00070.check() && A2_Cycle_Bm_1_00070.check() && A3_Cycle_Bm_1_00070.check() && A4_Cycle_Bm_1_00070.check() && A5_Cycle_Bm_1_00070.check() && A6_Cycle_Bm_1_00070.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/expected.txt b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/test.cfg b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..343f62a5a7cb2a21ded1f7dc9e24596112ada275 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0163-rc-function-RC_Thread01-Cycle_Bm_1_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00070) +run(Cycle_Bm_1_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..41bd7b55a14a5d3fd0c8482bccfa70c862898315 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/Cycle_Bm_1_00080.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00080 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 56) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } + } + class Cycle_B_1_00080_A4 { + int a; + int sum; + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } + class Cycle_B_1_00080_A5 { + int a; + int sum; + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } + } +} +public class Cycle_Bm_1_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00080 A1_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A2_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A3_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A4_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A5_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + ThreadRc_Cycle_Bm_1_00080 A6_Cycle_Bm_1_00080 = new ThreadRc_Cycle_Bm_1_00080(); + A1_Cycle_Bm_1_00080.start(); + A2_Cycle_Bm_1_00080.start(); + A3_Cycle_Bm_1_00080.start(); + A4_Cycle_Bm_1_00080.start(); + A5_Cycle_Bm_1_00080.start(); + A6_Cycle_Bm_1_00080.start(); + try { + A1_Cycle_Bm_1_00080.join(); + A2_Cycle_Bm_1_00080.join(); + A3_Cycle_Bm_1_00080.join(); + A4_Cycle_Bm_1_00080.join(); + A5_Cycle_Bm_1_00080.join(); + A6_Cycle_Bm_1_00080.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00080.check() && A2_Cycle_Bm_1_00080.check() && A3_Cycle_Bm_1_00080.check() && A4_Cycle_Bm_1_00080.check() && A5_Cycle_Bm_1_00080.check() && A6_Cycle_Bm_1_00080.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/expected.txt b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/test.cfg b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c7acb6d04b2b1cc7ec9e1dce4daa48e0aca03978 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0164-rc-function-RC_Thread01-Cycle_Bm_1_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00080) +run(Cycle_Bm_1_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..a59028a6038e44fe1bf82343727b9945288a1859 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/Cycle_Bm_1_00090.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00090 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 25) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_1_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00090 A1_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A2_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A3_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A4_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A5_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + ThreadRc_Cycle_Bm_1_00090 A6_Cycle_Bm_1_00090 = new ThreadRc_Cycle_Bm_1_00090(); + A1_Cycle_Bm_1_00090.start(); + A2_Cycle_Bm_1_00090.start(); + A3_Cycle_Bm_1_00090.start(); + A4_Cycle_Bm_1_00090.start(); + A5_Cycle_Bm_1_00090.start(); + A6_Cycle_Bm_1_00090.start(); + try { + A1_Cycle_Bm_1_00090.join(); + A2_Cycle_Bm_1_00090.join(); + A3_Cycle_Bm_1_00090.join(); + A4_Cycle_Bm_1_00090.join(); + A5_Cycle_Bm_1_00090.join(); + A6_Cycle_Bm_1_00090.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00090.check() && A2_Cycle_Bm_1_00090.check() && A3_Cycle_Bm_1_00090.check() && A4_Cycle_Bm_1_00090.check() && A5_Cycle_Bm_1_00090.check() && A6_Cycle_Bm_1_00090.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/expected.txt b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/test.cfg b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d0431211bd82db6d42da693c9fc17604983b47de --- /dev/null +++ b/testsuite/java_test/rc_test/RC0165-rc-function-RC_Thread01-Cycle_Bm_1_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00090) +run(Cycle_Bm_1_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..9e213a7963051dc4c9fbe3d7c368800bdeac6654 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/Cycle_Bm_1_00100.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00100 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00100_A4 { + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + class Cycle_B_1_00100_A5 { + int a; + int sum; + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } +} +public class Cycle_Bm_1_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00100 A1_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A2_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A3_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A4_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A5_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + ThreadRc_Cycle_Bm_1_00100 A6_Cycle_Bm_1_00100 = new ThreadRc_Cycle_Bm_1_00100(); + A1_Cycle_Bm_1_00100.start(); + A2_Cycle_Bm_1_00100.start(); + A3_Cycle_Bm_1_00100.start(); + A4_Cycle_Bm_1_00100.start(); + A5_Cycle_Bm_1_00100.start(); + A6_Cycle_Bm_1_00100.start(); + try { + A1_Cycle_Bm_1_00100.join(); + A2_Cycle_Bm_1_00100.join(); + A3_Cycle_Bm_1_00100.join(); + A4_Cycle_Bm_1_00100.join(); + A5_Cycle_Bm_1_00100.join(); + A6_Cycle_Bm_1_00100.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00100.check() && A2_Cycle_Bm_1_00100.check() && A3_Cycle_Bm_1_00100.check() && A4_Cycle_Bm_1_00100.check() && A5_Cycle_Bm_1_00100.check() && A6_Cycle_Bm_1_00100.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/expected.txt b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/test.cfg b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0652592e88d7d890d7284dea4da81cb5c142df09 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0166-rc-function-RC_Thread01-Cycle_Bm_1_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00100) +run(Cycle_Bm_1_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..4becd61d5c5797372e12545811231be653a1f580 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/Cycle_Bm_1_00110.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00110 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_1_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00110 A1_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A2_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A3_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A4_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A5_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + ThreadRc_Cycle_Bm_1_00110 A6_Cycle_Bm_1_00110 = new ThreadRc_Cycle_Bm_1_00110(); + A1_Cycle_Bm_1_00110.start(); + A2_Cycle_Bm_1_00110.start(); + A3_Cycle_Bm_1_00110.start(); + A4_Cycle_Bm_1_00110.start(); + A5_Cycle_Bm_1_00110.start(); + A6_Cycle_Bm_1_00110.start(); + try { + A1_Cycle_Bm_1_00110.join(); + A2_Cycle_Bm_1_00110.join(); + A3_Cycle_Bm_1_00110.join(); + A4_Cycle_Bm_1_00110.join(); + A5_Cycle_Bm_1_00110.join(); + A6_Cycle_Bm_1_00110.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00110.check() && A2_Cycle_Bm_1_00110.check() && A3_Cycle_Bm_1_00110.check() && A4_Cycle_Bm_1_00110.check() && A5_Cycle_Bm_1_00110.check() && A6_Cycle_Bm_1_00110.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/expected.txt b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/test.cfg b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e71b0dafb4546e0a6601fd5218e884b188eba1be --- /dev/null +++ b/testsuite/java_test/rc_test/RC0167-rc-function-RC_Thread01-Cycle_Bm_1_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00110) +run(Cycle_Bm_1_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..b0e0d9d745a1c4c6c7b1f6e3ffe4e91f58caf98b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/Cycle_Bm_1_00120.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00120 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_1_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00120 A1_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A2_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A3_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A4_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A5_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + ThreadRc_Cycle_Bm_1_00120 A6_Cycle_Bm_1_00120 = new ThreadRc_Cycle_Bm_1_00120(); + A1_Cycle_Bm_1_00120.start(); + A2_Cycle_Bm_1_00120.start(); + A3_Cycle_Bm_1_00120.start(); + A4_Cycle_Bm_1_00120.start(); + A5_Cycle_Bm_1_00120.start(); + A6_Cycle_Bm_1_00120.start(); + try { + A1_Cycle_Bm_1_00120.join(); + A2_Cycle_Bm_1_00120.join(); + A3_Cycle_Bm_1_00120.join(); + A4_Cycle_Bm_1_00120.join(); + A5_Cycle_Bm_1_00120.join(); + A6_Cycle_Bm_1_00120.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00120.check() && A2_Cycle_Bm_1_00120.check() && A3_Cycle_Bm_1_00120.check() && A4_Cycle_Bm_1_00120.check() && A5_Cycle_Bm_1_00120.check() && A6_Cycle_Bm_1_00120.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/expected.txt b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/test.cfg b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ae3158598a6a9936e2de2e67637c341342b7cc54 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0168-rc-function-RC_Thread01-Cycle_Bm_1_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00120) +run(Cycle_Bm_1_00120,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..c45edfb231e1066ec90ad0693e164dae8a8ae7c6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/Cycle_Bm_1_00130.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00130 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00130 A1_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A2_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A3_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A4_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A5_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + ThreadRc_Cycle_Bm_1_00130 A6_Cycle_Bm_1_00130 = new ThreadRc_Cycle_Bm_1_00130(); + A1_Cycle_Bm_1_00130.start(); + A2_Cycle_Bm_1_00130.start(); + A3_Cycle_Bm_1_00130.start(); + A4_Cycle_Bm_1_00130.start(); + A5_Cycle_Bm_1_00130.start(); + A6_Cycle_Bm_1_00130.start(); + try { + A1_Cycle_Bm_1_00130.join(); + A2_Cycle_Bm_1_00130.join(); + A3_Cycle_Bm_1_00130.join(); + A4_Cycle_Bm_1_00130.join(); + A5_Cycle_Bm_1_00130.join(); + A6_Cycle_Bm_1_00130.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00130.check() && A2_Cycle_Bm_1_00130.check() && A3_Cycle_Bm_1_00130.check() && A4_Cycle_Bm_1_00130.check() && A5_Cycle_Bm_1_00130.check() && A6_Cycle_Bm_1_00130.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/expected.txt b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/test.cfg b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b03622472e5a22c660e3b367acfe93546d0f06e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0169-rc-function-RC_Thread01-Cycle_Bm_1_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00130) +run(Cycle_Bm_1_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..ed3f9343e05cc419e577ac3366ae7796c2174778 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/Cycle_Bm_1_00140.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00140 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_1_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00140 A1_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A2_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A3_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A4_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A5_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + ThreadRc_Cycle_Bm_1_00140 A6_Cycle_Bm_1_00140 = new ThreadRc_Cycle_Bm_1_00140(); + A1_Cycle_Bm_1_00140.start(); + A2_Cycle_Bm_1_00140.start(); + A3_Cycle_Bm_1_00140.start(); + A4_Cycle_Bm_1_00140.start(); + A5_Cycle_Bm_1_00140.start(); + A6_Cycle_Bm_1_00140.start(); + try { + A1_Cycle_Bm_1_00140.join(); + A2_Cycle_Bm_1_00140.join(); + A3_Cycle_Bm_1_00140.join(); + A4_Cycle_Bm_1_00140.join(); + A5_Cycle_Bm_1_00140.join(); + A6_Cycle_Bm_1_00140.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00140.check() && A2_Cycle_Bm_1_00140.check() && A3_Cycle_Bm_1_00140.check() && A4_Cycle_Bm_1_00140.check() && A5_Cycle_Bm_1_00140.check() && A6_Cycle_Bm_1_00140.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/expected.txt b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/test.cfg b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc9cd42b64e2b9c7d8f659a000b60c9523fd1fa1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0170-rc-function-RC_Thread01-Cycle_Bm_1_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00140) +run(Cycle_Bm_1_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..8ffa8b1d6aa2486290abc7596652e8cc4eac0ee4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/Cycle_Bm_1_00150.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00150 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + ; + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00150_A4 { + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + class Cycle_B_1_00150_A5 { + int a; + int sum; + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } +} +public class Cycle_Bm_1_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00150 A1_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A2_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A3_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A4_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A5_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + ThreadRc_Cycle_Bm_1_00150 A6_Cycle_Bm_1_00150 = new ThreadRc_Cycle_Bm_1_00150(); + A1_Cycle_Bm_1_00150.start(); + A2_Cycle_Bm_1_00150.start(); + A3_Cycle_Bm_1_00150.start(); + A4_Cycle_Bm_1_00150.start(); + A5_Cycle_Bm_1_00150.start(); + A6_Cycle_Bm_1_00150.start(); + try { + A1_Cycle_Bm_1_00150.join(); + A2_Cycle_Bm_1_00150.join(); + A3_Cycle_Bm_1_00150.join(); + A4_Cycle_Bm_1_00150.join(); + A5_Cycle_Bm_1_00150.join(); + A6_Cycle_Bm_1_00150.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00150.check() && A2_Cycle_Bm_1_00150.check() && A3_Cycle_Bm_1_00150.check() && A4_Cycle_Bm_1_00150.check() && A5_Cycle_Bm_1_00150.check() && A6_Cycle_Bm_1_00150.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/expected.txt b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/test.cfg b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b758ffb351a60639a306fee8d6c9ace3d5d73094 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0171-rc-function-RC_Thread01-Cycle_Bm_1_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00150) +run(Cycle_Bm_1_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..f0f2b5f12c221dc4b2a6ce3c903e7f877b656cbb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/Cycle_Bm_1_00160.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00160 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 17) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00160 A1_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A2_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A3_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A4_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A5_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + ThreadRc_Cycle_Bm_1_00160 A6_Cycle_Bm_1_00160 = new ThreadRc_Cycle_Bm_1_00160(); + A1_Cycle_Bm_1_00160.start(); + A2_Cycle_Bm_1_00160.start(); + A3_Cycle_Bm_1_00160.start(); + A4_Cycle_Bm_1_00160.start(); + A5_Cycle_Bm_1_00160.start(); + A6_Cycle_Bm_1_00160.start(); + try { + A1_Cycle_Bm_1_00160.join(); + A2_Cycle_Bm_1_00160.join(); + A3_Cycle_Bm_1_00160.join(); + A4_Cycle_Bm_1_00160.join(); + A5_Cycle_Bm_1_00160.join(); + A6_Cycle_Bm_1_00160.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00160.check() && A2_Cycle_Bm_1_00160.check() && A3_Cycle_Bm_1_00160.check() && A4_Cycle_Bm_1_00160.check() && A5_Cycle_Bm_1_00160.check() && A6_Cycle_Bm_1_00160.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/expected.txt b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/test.cfg b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9d85077b264f8980c1fa1235fe52a423e1152164 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0172-rc-function-RC_Thread01-Cycle_Bm_1_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00160) +run(Cycle_Bm_1_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..135d94e73a5713fa60d35877acb72ddd17e4c413 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/Cycle_Bm_1_00170.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00170 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 26) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_1_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00170 A1_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A2_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A3_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A4_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A5_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + ThreadRc_Cycle_Bm_1_00170 A6_Cycle_Bm_1_00170 = new ThreadRc_Cycle_Bm_1_00170(); + A1_Cycle_Bm_1_00170.start(); + A2_Cycle_Bm_1_00170.start(); + A3_Cycle_Bm_1_00170.start(); + A4_Cycle_Bm_1_00170.start(); + A5_Cycle_Bm_1_00170.start(); + A6_Cycle_Bm_1_00170.start(); + try { + A1_Cycle_Bm_1_00170.join(); + A2_Cycle_Bm_1_00170.join(); + A3_Cycle_Bm_1_00170.join(); + A4_Cycle_Bm_1_00170.join(); + A5_Cycle_Bm_1_00170.join(); + A6_Cycle_Bm_1_00170.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00170.check() && A2_Cycle_Bm_1_00170.check() && A3_Cycle_Bm_1_00170.check() && A4_Cycle_Bm_1_00170.check() && A5_Cycle_Bm_1_00170.check() && A6_Cycle_Bm_1_00170.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/expected.txt b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/test.cfg b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bf5c1b29f07f971a84d58d0d58f97199a27c986a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0173-rc-function-RC_Thread01-Cycle_Bm_1_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00170) +run(Cycle_Bm_1_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..d63b5ea3c5e365ddf312ed6990453ebd553fcc6e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/Cycle_Bm_1_00180.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00180 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00180 A1_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A2_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A3_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A4_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A5_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A6_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + A1_Cycle_Bm_1_00180.start(); + A2_Cycle_Bm_1_00180.start(); + A3_Cycle_Bm_1_00180.start(); + A4_Cycle_Bm_1_00180.start(); + A5_Cycle_Bm_1_00180.start(); + A6_Cycle_Bm_1_00180.start(); + try { + A1_Cycle_Bm_1_00180.join(); + A2_Cycle_Bm_1_00180.join(); + A3_Cycle_Bm_1_00180.join(); + A4_Cycle_Bm_1_00180.join(); + A5_Cycle_Bm_1_00180.join(); + A6_Cycle_Bm_1_00180.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00180.check() && A2_Cycle_Bm_1_00180.check() && A3_Cycle_Bm_1_00180.check() && A4_Cycle_Bm_1_00180.check() && A5_Cycle_Bm_1_00180.check() && A6_Cycle_Bm_1_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/expected.txt b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/test.cfg b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..708d9270d23ac27d13fec051084c58c531d5e635 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0174-rc-function-RC_Thread01-Cycle_Bm_1_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00180) +run(Cycle_Bm_1_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..0690ed81e4c450f5b1422594021a9ba629685785 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/Cycle_Bm_1_00190.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00190 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00190_A4 { + int a; + int sum; + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +public class Cycle_Bm_1_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00190 A1_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A2_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A3_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A4_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A5_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + ThreadRc_Cycle_Bm_1_00190 A6_Cycle_Bm_1_00190 = new ThreadRc_Cycle_Bm_1_00190(); + A1_Cycle_Bm_1_00190.start(); + A2_Cycle_Bm_1_00190.start(); + A3_Cycle_Bm_1_00190.start(); + A4_Cycle_Bm_1_00190.start(); + A5_Cycle_Bm_1_00190.start(); + A6_Cycle_Bm_1_00190.start(); + try { + A1_Cycle_Bm_1_00190.join(); + A2_Cycle_Bm_1_00190.join(); + A3_Cycle_Bm_1_00190.join(); + A4_Cycle_Bm_1_00190.join(); + A5_Cycle_Bm_1_00190.join(); + A6_Cycle_Bm_1_00190.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00190.check() && A2_Cycle_Bm_1_00190.check() && A3_Cycle_Bm_1_00190.check() && A4_Cycle_Bm_1_00190.check() && A5_Cycle_Bm_1_00190.check() && A6_Cycle_Bm_1_00190.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/expected.txt b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/test.cfg b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..37974e08c99ca77f0b919b160fb6318f50198011 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0175-rc-function-RC_Thread01-Cycle_Bm_1_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00190) +run(Cycle_Bm_1_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..7bab6f5510ba26c0b9a328b673b3e37430b8620d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/Cycle_Bm_1_00200.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00200 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00200_A4 { + int a; + int sum; + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } + class Cycle_B_1_00200_A5 { + int a; + int sum; + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } + } +} +public class Cycle_Bm_1_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00200 A1_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A2_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A3_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A4_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A5_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + ThreadRc_Cycle_Bm_1_00200 A6_Cycle_Bm_1_00200 = new ThreadRc_Cycle_Bm_1_00200(); + A1_Cycle_Bm_1_00200.start(); + A2_Cycle_Bm_1_00200.start(); + A3_Cycle_Bm_1_00200.start(); + A4_Cycle_Bm_1_00200.start(); + A5_Cycle_Bm_1_00200.start(); + A6_Cycle_Bm_1_00200.start(); + try { + A1_Cycle_Bm_1_00200.join(); + A2_Cycle_Bm_1_00200.join(); + A3_Cycle_Bm_1_00200.join(); + A4_Cycle_Bm_1_00200.join(); + A5_Cycle_Bm_1_00200.join(); + A6_Cycle_Bm_1_00200.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00200.check() && A2_Cycle_Bm_1_00200.check() && A3_Cycle_Bm_1_00200.check() && A4_Cycle_Bm_1_00200.check() && A5_Cycle_Bm_1_00200.check() && A6_Cycle_Bm_1_00200.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/expected.txt b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/test.cfg b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a7af8788223c195e2fbad3171e87ad560840c6f7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0176-rc-function-RC_Thread01-Cycle_Bm_1_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00200) +run(Cycle_Bm_1_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..a5c01a61d813d9005c9759af28251fe0a7cd7058 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/Cycle_Bm_1_00210.java @@ -0,0 +1,1692 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_00010B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + //System.out.println(nsum); + if (nsum == 246) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00010_A1 { + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00020B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00020_A1 a1_0 = new Cycle_B_1_00020_A1(); + a1_0.a2_0 = new Cycle_B_1_00020_A2(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum); + //System.out.println(nsum); + if (nsum == 6) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00020_A1 { + Cycle_B_1_00020_A2 a2_0; + int a; + int sum; + Cycle_B_1_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00020_A2 { + Cycle_B_1_00020_A1 a1_0; + int a; + int sum; + Cycle_B_1_00020_A2() { + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00030B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00030_A1 a1_0 = new Cycle_B_1_00030_A1(); + a1_0.a2_0 = new Cycle_B_1_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00030_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00030_A1 { + Cycle_B_1_00030_A2 a2_0; + int a; + int sum; + Cycle_B_1_00030_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00030_A2 { + Cycle_B_1_00030_A3 a3_0; + int a; + int sum; + Cycle_B_1_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00030_A3 { + Cycle_B_1_00030_A1 a1_0; + int a; + int sum; + Cycle_B_1_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00040B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00040_A1 a1_0 = new Cycle_B_1_00040_A1(); + a1_0.a2_0 = new Cycle_B_1_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00040_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00040_A4(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00040_A1 { + Cycle_B_1_00040_A2 a2_0; + int a; + int sum; + Cycle_B_1_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00040_A2 { + Cycle_B_1_00040_A3 a3_0; + int a; + int sum; + Cycle_B_1_00040_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00040_A3 { + Cycle_B_1_00040_A1 a1_0; + Cycle_B_1_00040_A4 a4_0; + int a; + int sum; + Cycle_B_1_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00040_A4 { + int a; + int sum; + Cycle_B_1_00040_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +class ThreadRc_Cycle_Bm_1_00050B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00050_A1 a1_0 = new Cycle_B_1_00050_A1(); + a1_0.a2_0 = new Cycle_B_1_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00050_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_1_00050_A4(); + a1_0.a2_0.a5_0 = new Cycle_B_1_00050_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 34) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00050_A1 { + Cycle_B_1_00050_A2 a2_0; + int a; + int sum; + Cycle_B_1_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00050_A2 { + Cycle_B_1_00050_A3 a3_0; + Cycle_B_1_00050_A4 a4_0; + Cycle_B_1_00050_A5 a5_0; + int a; + int sum; + Cycle_B_1_00050_A2() { + a3_0 = null; + a4_0 = null; + a5_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00050_A3 { + Cycle_B_1_00050_A1 a1_0; + int a; + int sum; + Cycle_B_1_00050_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00050_A4 { + int a; + int sum; + Cycle_B_1_00050_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } + class Cycle_B_1_00050_A5 { + int a; + int sum; + Cycle_B_1_00050_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } + } +} +class ThreadRc_Cycle_Bm_1_00060B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00060_A1 a1_0 = new Cycle_B_1_00060_A1(); + a1_0.a2_0 = new Cycle_B_1_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00060_A3(); + Cycle_B_1_00060_A4 a4_0 = new Cycle_B_1_00060_A4(); + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum; + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00060_A1 { + Cycle_B_1_00060_A2 a2_0; + int a; + int sum; + Cycle_B_1_00060_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00060_A2 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00060_A3 { + Cycle_B_1_00060_A1 a1_0; + int a; + int sum; + Cycle_B_1_00060_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00060_A4 { + Cycle_B_1_00060_A3 a3_0; + int a; + int sum; + Cycle_B_1_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00070B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00070_A1 a1_0 = new Cycle_B_1_00070_A1(); + a1_0.a2_0 = new Cycle_B_1_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00070_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum; + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00070_A1 { + Cycle_B_1_00070_A2 a2_0; + int a; + int sum; + Cycle_B_1_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00070_A2 { + Cycle_B_1_00070_A3 a3_0; + int a; + int sum; + Cycle_B_1_00070_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00070_A3 { + Cycle_B_1_00070_A1 a1_0; + Cycle_B_1_00070_A4 a4_0; + int a; + int sum; + Cycle_B_1_00070_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00070_A4 { + int a; + int sum; + Cycle_B_1_00070_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +class ThreadRc_Cycle_Bm_1_00080B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00080_A1 a1_0 = new Cycle_B_1_00080_A1(); + a1_0.a2_0 = new Cycle_B_1_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00080_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00080_A4(); + a1_0.a2_0.a3_0.a5_0 = new Cycle_B_1_00080_A5(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 56) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00080_A1 { + Cycle_B_1_00080_A2 a2_0; + int a; + int sum; + Cycle_B_1_00080_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00080_A2 { + Cycle_B_1_00080_A3 a3_0; + int a; + int sum; + Cycle_B_1_00080_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00080_A3 { + Cycle_B_1_00080_A1 a1_0; + Cycle_B_1_00080_A4 a4_0; + Cycle_B_1_00080_A5 a5_0; + int a; + int sum; + Cycle_B_1_00080_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + a4_0.add(); + a5_0.add(); + sum = a + a1_0.a + a4_0.sum + a5_0.sum; + } + } + class Cycle_B_1_00080_A4 { + int a; + int sum; + Cycle_B_1_00080_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } + class Cycle_B_1_00080_A5 { + int a; + int sum; + Cycle_B_1_00080_A5() { + a = 6; + sum = 0; + } + void add() { + sum = a + 7; + } + } +} +class ThreadRc_Cycle_Bm_1_00090B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00090_A1 a1_0 = new Cycle_B_1_00090_A1(); + a1_0.a2_0 = new Cycle_B_1_00090_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00090_A3(); + Cycle_B_1_00090_A4 a4_0 = new Cycle_B_1_00090_A4(); + Cycle_B_1_00090_A5 a5_0 = new Cycle_B_1_00090_A5(); + a4_0.a2_0 = a1_0.a2_0; + a5_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 25) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00090_A1 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00090_A2 { + Cycle_B_1_00090_A3 a3_0; + int a; + int sum; + Cycle_B_1_00090_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00090_A3 { + Cycle_B_1_00090_A1 a1_0; + int a; + int sum; + Cycle_B_1_00090_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00090_A4 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00090_A5 { + Cycle_B_1_00090_A2 a2_0; + int a; + int sum; + Cycle_B_1_00090_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00100B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00100_A1 a1_0 = new Cycle_B_1_00100_A1(); + a1_0.a2_0 = new Cycle_B_1_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00100_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0 = new Cycle_B_1_00100_A4(); + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_1_00100_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00100_A1 { + Cycle_B_1_00100_A2 a2_0; + int a; + int sum; + Cycle_B_1_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00100_A2 { + Cycle_B_1_00100_A3 a3_0; + Cycle_B_1_00100_A4 a4_0; + int a; + int sum; + Cycle_B_1_00100_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00100_A3 { + Cycle_B_1_00100_A1 a1_0; + int a; + int sum; + Cycle_B_1_00100_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00100_A4 { + int a; + int sum; + Cycle_B_1_00100_A5 a5_0; + Cycle_B_1_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + class Cycle_B_1_00100_A5 { + int a; + int sum; + Cycle_B_1_00100_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } +} +class ThreadRc_Cycle_Bm_1_00110B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00110_A1 a1_0 = new Cycle_B_1_00110_A1(); + a1_0.a2_0 = new Cycle_B_1_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00110_A3(); + Cycle_B_1_00110_A5 a5_0 = new Cycle_B_1_00110_A5(); + a5_0.a4_0 = new Cycle_B_1_00110_A4(); + a5_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00110_A1 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00110_A2 { + Cycle_B_1_00110_A3 a3_0; + int a; + int sum; + Cycle_B_1_00110_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00110_A3 { + Cycle_B_1_00110_A1 a1_0; + int a; + int sum; + Cycle_B_1_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00110_A4 { + Cycle_B_1_00110_A2 a2_0; + int a; + int sum; + Cycle_B_1_00110_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00110_A5 { + Cycle_B_1_00110_A4 a4_0; + int a; + int sum; + Cycle_B_1_00110_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00120B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00120_A1 a1_0 = new Cycle_B_1_00120_A1(); + a1_0.a2_0 = new Cycle_B_1_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00120_A3(); + Cycle_B_1_00120_A5 a5_0 = new Cycle_B_1_00120_A5(); + a5_0.a4_0 = new Cycle_B_1_00120_A4(); + a5_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a5_0.a4_0.add(); + a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a5_0.a4_0.sum + a5_0.sum; + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00120_A1 { + Cycle_B_1_00120_A2 a2_0; + int a; + int sum; + Cycle_B_1_00120_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00120_A2 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00120_A3 { + Cycle_B_1_00120_A1 a1_0; + int a; + int sum; + Cycle_B_1_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00120_A4 { + Cycle_B_1_00120_A3 a3_0; + int a; + int sum; + Cycle_B_1_00120_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00120_A5 { + Cycle_B_1_00120_A4 a4_0; + int a; + int sum; + Cycle_B_1_00120_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00130B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00130_A1 a1_0 = new Cycle_B_1_00130_A1(); + Cycle_B_1_00130_A2 a2_0 = new Cycle_B_1_00130_A2(); + Cycle_B_1_00130_A3 a3_0 = new Cycle_B_1_00130_A3(); + a1_0.a3_0 = a3_0; + a2_0.a3_0 = a3_0; + a3_0.a1_0 = a1_0; + a1_0.add(); + a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00130_A1 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A1() { + a3_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00130_A2 { + Cycle_B_1_00130_A3 a3_0; + int a; + int sum; + Cycle_B_1_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00130_A3 { + Cycle_B_1_00130_A1 a1_0; + int a; + int sum; + Cycle_B_1_00130_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00140B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00140_A1 a1_0 = new Cycle_B_1_00140_A1(); + a1_0.a2_0 = new Cycle_B_1_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00140_A3(); + Cycle_B_1_00140_A4 a4_0 = new Cycle_B_1_00140_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 12) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00140_A1 { + Cycle_B_1_00140_A2 a2_0; + int a; + int sum; + Cycle_B_1_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00140_A2 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00140_A3 { + Cycle_B_1_00140_A1 a1_0; + int a; + int sum; + Cycle_B_1_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00140_A4 { + Cycle_B_1_00140_A3 a3_0; + int a; + int sum; + Cycle_B_1_00140_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00150B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00150_A1 a1_0 = new Cycle_B_1_00150_A1(); + a1_0.a2_0 = new Cycle_B_1_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_1_00150_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_1_00150_A5(); + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum; + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00150_A1 { + Cycle_B_1_00150_A2 a2_0; + int a; + int sum; + Cycle_B_1_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00150_A2 { + Cycle_B_1_00150_A3 a3_0; + int a; + int sum; + Cycle_B_1_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00150_A3 { + Cycle_B_1_00150_A1 a1_0; + Cycle_B_1_00150_A4 a4_0; + int a; + int sum; + Cycle_B_1_00150_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00150_A4 { + int a; + int sum; + Cycle_B_1_00150_A5 a5_0; + Cycle_B_1_00150_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + a5_0.add(); + sum = a + a5_0.sum; + } + } + class Cycle_B_1_00150_A5 { + int a; + int sum; + Cycle_B_1_00150_A5() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } +} +class ThreadRc_Cycle_Bm_1_00160B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00160_A1 a1_0 = new Cycle_B_1_00160_A1(); + a1_0.a2_0 = new Cycle_B_1_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00160_A3(); + Cycle_B_1_00160_A4 a4_0 = new Cycle_B_1_00160_A4(); + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 17) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00160_A1 { + Cycle_B_1_00160_A2 a2_0; + int a; + int sum; + Cycle_B_1_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00160_A2 { + Cycle_B_1_00160_A3 a3_0; + int a; + int sum; + Cycle_B_1_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00160_A3 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00160_A4 { + Cycle_B_1_00160_A1 a1_0; + int a; + int sum; + Cycle_B_1_00160_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00170B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00170_A1 a1_0 = new Cycle_B_1_00170_A1(); + a1_0.a2_0 = new Cycle_B_1_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00170_A3(); + Cycle_B_1_00170_A4 a4_0 = new Cycle_B_1_00170_A4(); + Cycle_B_1_00170_A5 a5_0 = new Cycle_B_1_00170_A5(); + a5_0.a4_0 = a4_0; + a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 26) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00170_A1 { + Cycle_B_1_00170_A2 a2_0; + int a; + int sum; + Cycle_B_1_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00170_A2 { + Cycle_B_1_00170_A3 a3_0; + int a; + int sum; + Cycle_B_1_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00170_A3 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00170_A4 { + Cycle_B_1_00170_A1 a1_0; + int a; + int sum; + Cycle_B_1_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00170_A5 { + Cycle_B_1_00170_A4 a4_0; + int a; + int sum; + Cycle_B_1_00170_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00180B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00180_A3 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A4 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A5 { + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_00190B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00190_A1 a1_0 = new Cycle_B_1_00190_A1(); + a1_0.a2_0 = new Cycle_B_1_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00190_A3(); + Cycle_B_1_00190_A4 a4_0 = new Cycle_B_1_00190_A4(); + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00190_A1 { + Cycle_B_1_00190_A2 a2_0; + Cycle_B_1_00190_A4 a4_0; + int a; + int sum; + Cycle_B_1_00190_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00190_A2 { + Cycle_B_1_00190_A3 a3_0; + int a; + int sum; + Cycle_B_1_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00190_A3 { + Cycle_B_1_00190_A1 a1_0; + int a; + int sum; + Cycle_B_1_00190_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00190_A4 { + int a; + int sum; + Cycle_B_1_00190_A4() { + a = 4; + sum = 0; + } + void add() { + sum = a + 5; + } + } +} +class ThreadRc_Cycle_Bm_1_00200B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00200_A1 a1_0 = new Cycle_B_1_00200_A1(); + a1_0.a2_0 = new Cycle_B_1_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00200_A3(); + Cycle_B_1_00200_A4 a4_0 = new Cycle_B_1_00200_A4(); + Cycle_B_1_00200_A5 a5_0 = new Cycle_B_1_00200_A5(); + a1_0.a4_0 = a4_0; + a1_0.a5_0 = a5_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 38) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00200_A1 { + Cycle_B_1_00200_A2 a2_0; + Cycle_B_1_00200_A4 a4_0; + Cycle_B_1_00200_A5 a5_0; + int a; + int sum; + Cycle_B_1_00200_A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00200_A2 { + Cycle_B_1_00200_A3 a3_0; + int a; + int sum; + Cycle_B_1_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00200_A3 { + Cycle_B_1_00200_A1 a1_0; + int a; + int sum; + Cycle_B_1_00200_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00200_A4 { + int a; + int sum; + Cycle_B_1_00200_A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } + class Cycle_B_1_00200_A5 { + int a; + int sum; + Cycle_B_1_00200_A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } + } +} +public class Cycle_Bm_1_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010B A1_00010 = new ThreadRc_Cycle_Bm_1_00010B(); + ThreadRc_Cycle_Bm_1_00010B A2_00010 = new ThreadRc_Cycle_Bm_1_00010B(); + ThreadRc_Cycle_Bm_1_00020B A1_00020 = new ThreadRc_Cycle_Bm_1_00020B(); + ThreadRc_Cycle_Bm_1_00020B A2_00020 = new ThreadRc_Cycle_Bm_1_00020B(); + ThreadRc_Cycle_Bm_1_00030B A1_00030 = new ThreadRc_Cycle_Bm_1_00030B(); + ThreadRc_Cycle_Bm_1_00030B A2_00030 = new ThreadRc_Cycle_Bm_1_00030B(); + ThreadRc_Cycle_Bm_1_00040B A1_00040 = new ThreadRc_Cycle_Bm_1_00040B(); + ThreadRc_Cycle_Bm_1_00040B A2_00040 = new ThreadRc_Cycle_Bm_1_00040B(); + ThreadRc_Cycle_Bm_1_00050B A1_00050 = new ThreadRc_Cycle_Bm_1_00050B(); + ThreadRc_Cycle_Bm_1_00050B A2_00050 = new ThreadRc_Cycle_Bm_1_00050B(); + ThreadRc_Cycle_Bm_1_00060B A1_00060 = new ThreadRc_Cycle_Bm_1_00060B(); + ThreadRc_Cycle_Bm_1_00060B A2_00060 = new ThreadRc_Cycle_Bm_1_00060B(); + ThreadRc_Cycle_Bm_1_00070B A1_00070 = new ThreadRc_Cycle_Bm_1_00070B(); + ThreadRc_Cycle_Bm_1_00070B A2_00070 = new ThreadRc_Cycle_Bm_1_00070B(); + ThreadRc_Cycle_Bm_1_00080B A1_00080 = new ThreadRc_Cycle_Bm_1_00080B(); + ThreadRc_Cycle_Bm_1_00080B A2_00080 = new ThreadRc_Cycle_Bm_1_00080B(); + ThreadRc_Cycle_Bm_1_00090B A1_00090 = new ThreadRc_Cycle_Bm_1_00090B(); + ThreadRc_Cycle_Bm_1_00090B A2_00090 = new ThreadRc_Cycle_Bm_1_00090B(); + ThreadRc_Cycle_Bm_1_00100B A1_00100 = new ThreadRc_Cycle_Bm_1_00100B(); + ThreadRc_Cycle_Bm_1_00100B A2_00100 = new ThreadRc_Cycle_Bm_1_00100B(); + ThreadRc_Cycle_Bm_1_00110B A1_00110 = new ThreadRc_Cycle_Bm_1_00110B(); + ThreadRc_Cycle_Bm_1_00110B A2_00110 = new ThreadRc_Cycle_Bm_1_00110B(); + ThreadRc_Cycle_Bm_1_00120B A1_00120 = new ThreadRc_Cycle_Bm_1_00120B(); + ThreadRc_Cycle_Bm_1_00120B A2_00120 = new ThreadRc_Cycle_Bm_1_00120B(); + ThreadRc_Cycle_Bm_1_00130B A1_00130 = new ThreadRc_Cycle_Bm_1_00130B(); + ThreadRc_Cycle_Bm_1_00130B A2_00130 = new ThreadRc_Cycle_Bm_1_00130B(); + ThreadRc_Cycle_Bm_1_00140B A1_00140 = new ThreadRc_Cycle_Bm_1_00140B(); + ThreadRc_Cycle_Bm_1_00140B A2_00140 = new ThreadRc_Cycle_Bm_1_00140B(); + ThreadRc_Cycle_Bm_1_00150B A1_00150 = new ThreadRc_Cycle_Bm_1_00150B(); + ThreadRc_Cycle_Bm_1_00150B A2_00150 = new ThreadRc_Cycle_Bm_1_00150B(); + ThreadRc_Cycle_Bm_1_00160B A1_00160 = new ThreadRc_Cycle_Bm_1_00160B(); + ThreadRc_Cycle_Bm_1_00160B A2_00160 = new ThreadRc_Cycle_Bm_1_00160B(); + ThreadRc_Cycle_Bm_1_00170B A1_00170 = new ThreadRc_Cycle_Bm_1_00170B(); + ThreadRc_Cycle_Bm_1_00170B A2_00170 = new ThreadRc_Cycle_Bm_1_00170B(); + ThreadRc_Cycle_Bm_1_00180B A1_00180 = new ThreadRc_Cycle_Bm_1_00180B(); + ThreadRc_Cycle_Bm_1_00180B A2_00180 = new ThreadRc_Cycle_Bm_1_00180B(); + ThreadRc_Cycle_Bm_1_00190B A1_00190 = new ThreadRc_Cycle_Bm_1_00190B(); + ThreadRc_Cycle_Bm_1_00190B A2_00190 = new ThreadRc_Cycle_Bm_1_00190B(); + ThreadRc_Cycle_Bm_1_00200B A1_00200 = new ThreadRc_Cycle_Bm_1_00200B(); + ThreadRc_Cycle_Bm_1_00200B A2_00200 = new ThreadRc_Cycle_Bm_1_00200B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + A1_00190.start(); + A2_00190.start(); + A1_00200.start(); + A2_00200.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + A1_00190.join(); + A2_00190.join(); + A1_00200.join(); + A2_00200.join(); + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check() && A1_00190.check() && A2_00190.check() && A1_00200.check() && A2_00200.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/expected.txt b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/test.cfg b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a1429b594aa11c6d6d6c6c53617b12a410ea6fd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0177-rc-function-RC_Thread01-Cycle_Bm_1_00210/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_00210) +run(Cycle_Bm_1_00210,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java new file mode 100755 index 0000000000000000000000000000000000000000..fe7399f663c8082002dc0f88ff17b3019ed516c7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/Cycle_Bm_1_10010.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_10010 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + if (nsum == 24) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_1_10010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10010 A1_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A2_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A3_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A4_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A5_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + ThreadRc_Cycle_Bm_1_10010 A6_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010(); + A1_Cycle_Bm_1_10010.start(); + A2_Cycle_Bm_1_10010.start(); + A3_Cycle_Bm_1_10010.start(); + A4_Cycle_Bm_1_10010.start(); + A5_Cycle_Bm_1_10010.start(); + A6_Cycle_Bm_1_10010.start(); + try { + A1_Cycle_Bm_1_10010.join(); + A2_Cycle_Bm_1_10010.join(); + A3_Cycle_Bm_1_10010.join(); + A4_Cycle_Bm_1_10010.join(); + A5_Cycle_Bm_1_10010.join(); + A6_Cycle_Bm_1_10010.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_10010.check() && A2_Cycle_Bm_1_10010.check() && A3_Cycle_Bm_1_10010.check() && A4_Cycle_Bm_1_10010.check() && A5_Cycle_Bm_1_10010.check() && A6_Cycle_Bm_1_10010.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/expected.txt b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/test.cfg b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..03c2c3c0f7add8e44e9d38bcd9b386c060ab851e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0178-rc-function-RC_Thread01-Cycle_Bm_1_10010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_10010) +run(Cycle_Bm_1_10010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java new file mode 100755 index 0000000000000000000000000000000000000000..bb16aeea637330bdf933df2a39c405e3079181b5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/Cycle_Bm_1_10020.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_10020 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + if (nsum == 61) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_2A4 { + int a; + int sum; + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } + class Cycle_B_1_10020_2A5 { + int a; + int sum; + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } + } +} +public class Cycle_Bm_1_10020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10020 A1_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A2_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A3_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A4_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A5_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + ThreadRc_Cycle_Bm_1_10020 A6_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020(); + A1_Cycle_Bm_1_10020.start(); + A2_Cycle_Bm_1_10020.start(); + A3_Cycle_Bm_1_10020.start(); + A4_Cycle_Bm_1_10020.start(); + A5_Cycle_Bm_1_10020.start(); + A6_Cycle_Bm_1_10020.start(); + try { + A1_Cycle_Bm_1_10020.join(); + A2_Cycle_Bm_1_10020.join(); + A3_Cycle_Bm_1_10020.join(); + A4_Cycle_Bm_1_10020.join(); + A5_Cycle_Bm_1_10020.join(); + A6_Cycle_Bm_1_10020.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_10020.check() && A2_Cycle_Bm_1_10020.check() && A3_Cycle_Bm_1_10020.check() && A4_Cycle_Bm_1_10020.check() && A5_Cycle_Bm_1_10020.check() && A6_Cycle_Bm_1_10020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/expected.txt b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/test.cfg b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f38c26a20271a249ddad4cb37559af7db8715e7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0179-rc-function-RC_Thread01-Cycle_Bm_1_10020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_10020) +run(Cycle_Bm_1_10020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java new file mode 100755 index 0000000000000000000000000000000000000000..deb101f9bfe08eaea1b226090e4e7c3fdbbde356 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/Cycle_Bm_1_10030.java @@ -0,0 +1,343 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_1_10010B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_10010_A1 a1_0 = new Cycle_B_1_10010_A1(); + a1_0.a2_0 = new Cycle_B_1_10010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10010_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + Cycle_B_1_10010_2A1 a1_10 = new Cycle_B_1_10010_2A1(); + a1_10.a2_0 = new Cycle_B_1_10010_2A2(); + a1_10.a2_0.a3_0 = new Cycle_B_1_10010_2A3(); + a1_10.a2_0.a3_0.a1_0 = a1_10; + a1_10.add(); + a1_10.a2_0.add(); + a1_10.a2_0.a3_0.add(); + int nsum2 = (a1_10.sum + a1_10.a2_0.sum + a1_10.a2_0.a3_0.sum); + //System.out.println(nsum); + nsum += nsum2; + if (nsum == 24) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_10010_A1 { + Cycle_B_1_10010_A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10010_A2 { + Cycle_B_1_10010_A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10010_A3 { + Cycle_B_1_10010_A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10010_2A1 { + Cycle_B_1_10010_2A2 a2_0; + int a; + int sum; + Cycle_B_1_10010_2A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10010_2A2 { + Cycle_B_1_10010_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10010_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10010_2A3 { + Cycle_B_1_10010_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10010_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_1_10020B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_10020_A1 a1_0 = new Cycle_B_1_10020_A1(); + a1_0.a2_0 = new Cycle_B_1_10020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_10020_A3(); + Cycle_B_1_10020_A4 a4_0 = new Cycle_B_1_10020_A4(); + Cycle_B_1_10020_A5 a5_0 = new Cycle_B_1_10020_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + Cycle_B_1_10020_2A1 a1_20 = new Cycle_B_1_10020_2A1(); + a1_20.a2_0 = new Cycle_B_1_10020_2A2(); + a1_20.a2_0.a3_0 = new Cycle_B_1_10020_2A3(); + Cycle_B_1_10020_2A4 a4_20 = new Cycle_B_1_10020_2A4(); + Cycle_B_1_10020_2A5 a5_20 = new Cycle_B_1_10020_2A5(); + a1_20.a4_0 = a4_20; + a1_20.a5_0 = a5_20; + a1_20.a2_0.a3_0.a1_0 = a1_20; + a1_20.add(); + a1_20.a2_0.add(); + a1_20.a2_0.a3_0.add(); + a4_20.add(); + a5_20.add(); + int nsum1 = (a1_20.sum + a1_20.a2_0.sum + a1_20.a2_0.a3_0.sum + a4_20.sum + a5_20.sum); + nsum += nsum1; + if (nsum == 61) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_10020_A1 { + Cycle_B_1_10020_A2 a2_0; + int a; + int sum; + Cycle_B_1_10020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10020_A2 { + Cycle_B_1_10020_A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10020_A3 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_A4 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_A5 { + Cycle_B_1_10020_A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_2A1 { + Cycle_B_1_10020_2A2 a2_0; + Cycle_B_1_10020_2A4 a4_0; + Cycle_B_1_10020_2A5 a5_0; + int a; + int sum; + Cycle_B_1_10020_2A1() { + a2_0 = null; + a4_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_10020_2A2 { + Cycle_B_1_10020_2A3 a3_0; + int a; + int sum; + Cycle_B_1_10020_2A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_10020_2A3 { + Cycle_B_1_10020_2A1 a1_0; + int a; + int sum; + Cycle_B_1_10020_2A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_10020_2A4 { + int a; + int sum; + Cycle_B_1_10020_2A4() { + a = 5; + sum = 0; + } + void add() { + sum = a + 6; + } + } + class Cycle_B_1_10020_2A5 { + int a; + int sum; + Cycle_B_1_10020_2A5() { + a = 7; + sum = 0; + } + void add() { + sum = a + 8; + } + } +} +public class Cycle_Bm_1_10030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_10010B A1_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A2_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A3_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A4_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A5_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10010B A6_Cycle_Bm_1_10010 = new ThreadRc_Cycle_Bm_1_10010B(); + ThreadRc_Cycle_Bm_1_10020B A1_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A2_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A3_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A4_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A5_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + ThreadRc_Cycle_Bm_1_10020B A6_Cycle_Bm_1_10020 = new ThreadRc_Cycle_Bm_1_10020B(); + A1_Cycle_Bm_1_10010.start(); + A2_Cycle_Bm_1_10010.start(); + A3_Cycle_Bm_1_10010.start(); + A4_Cycle_Bm_1_10010.start(); + A5_Cycle_Bm_1_10010.start(); + A6_Cycle_Bm_1_10010.start(); + A1_Cycle_Bm_1_10020.start(); + A2_Cycle_Bm_1_10020.start(); + A3_Cycle_Bm_1_10020.start(); + A4_Cycle_Bm_1_10020.start(); + A5_Cycle_Bm_1_10020.start(); + A6_Cycle_Bm_1_10020.start(); + try { + A1_Cycle_Bm_1_10010.join(); + A2_Cycle_Bm_1_10010.join(); + A3_Cycle_Bm_1_10010.join(); + A4_Cycle_Bm_1_10010.join(); + A5_Cycle_Bm_1_10010.join(); + A6_Cycle_Bm_1_10010.join(); + A1_Cycle_Bm_1_10020.join(); + A2_Cycle_Bm_1_10020.join(); + A3_Cycle_Bm_1_10020.join(); + A4_Cycle_Bm_1_10020.join(); + A5_Cycle_Bm_1_10020.join(); + A6_Cycle_Bm_1_10020.join(); + } catch (InterruptedException e) { + e.getStackTrace(); + } + if (A1_Cycle_Bm_1_10010.check() && A2_Cycle_Bm_1_10010.check() && A3_Cycle_Bm_1_10010.check() && A4_Cycle_Bm_1_10010.check() && A5_Cycle_Bm_1_10010.check() && A6_Cycle_Bm_1_10010.check() && A1_Cycle_Bm_1_10020.check() && A2_Cycle_Bm_1_10020.check() && A3_Cycle_Bm_1_10020.check() && A4_Cycle_Bm_1_10020.check() && A5_Cycle_Bm_1_10020.check() && A6_Cycle_Bm_1_10020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/expected.txt b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/test.cfg b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..20463c5ee1234dba2a9bbef9cc3f5dd243fe6035 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0180-rc-function-RC_Thread01-Cycle_Bm_1_10030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_1_10030) +run(Cycle_Bm_1_10030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..c111b8513ac58fbb87ffe08d240f9e98913bfeef --- /dev/null +++ b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/Cycle_Bm_2_00010.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00010 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 18) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00010 A1_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A2_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A3_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A4_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A5_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + ThreadRc_Cycle_Bm_2_00010 A6_Cycle_Bm_2_00010 = new ThreadRc_Cycle_Bm_2_00010(); + A1_Cycle_Bm_2_00010.start(); + A2_Cycle_Bm_2_00010.start(); + A3_Cycle_Bm_2_00010.start(); + A4_Cycle_Bm_2_00010.start(); + A5_Cycle_Bm_2_00010.start(); + A6_Cycle_Bm_2_00010.start(); + try { + A1_Cycle_Bm_2_00010.join(); + A2_Cycle_Bm_2_00010.join(); + A3_Cycle_Bm_2_00010.join(); + A4_Cycle_Bm_2_00010.join(); + A5_Cycle_Bm_2_00010.join(); + A6_Cycle_Bm_2_00010.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00010.check() && A2_Cycle_Bm_2_00010.check() && A3_Cycle_Bm_2_00010.check() && A4_Cycle_Bm_2_00010.check() && A5_Cycle_Bm_2_00010.check() && A6_Cycle_Bm_2_00010.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/expected.txt b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/test.cfg b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..39fbc09750b5efa3f90a36c6a4ad785318361132 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0181-rc-function-RC_Thread01-Cycle_Bm_2_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00010) +run(Cycle_Bm_2_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..e2debc664efe4b48aba3c78f9a06ebd75c8440a7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/Cycle_Bm_2_00020.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00020 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_2_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00020 A1_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A2_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A3_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A4_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A5_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + ThreadRc_Cycle_Bm_2_00020 A6_Cycle_Bm_2_00020 = new ThreadRc_Cycle_Bm_2_00020(); + A1_Cycle_Bm_2_00020.start(); + A2_Cycle_Bm_2_00020.start(); + A3_Cycle_Bm_2_00020.start(); + A4_Cycle_Bm_2_00020.start(); + A5_Cycle_Bm_2_00020.start(); + A6_Cycle_Bm_2_00020.start(); + try { + A1_Cycle_Bm_2_00020.join(); + A2_Cycle_Bm_2_00020.join(); + A3_Cycle_Bm_2_00020.join(); + A4_Cycle_Bm_2_00020.join(); + A5_Cycle_Bm_2_00020.join(); + A6_Cycle_Bm_2_00020.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00020.check() && A2_Cycle_Bm_2_00020.check() && A3_Cycle_Bm_2_00020.check() && A4_Cycle_Bm_2_00020.check() && A5_Cycle_Bm_2_00020.check() && A6_Cycle_Bm_2_00020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/expected.txt b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/test.cfg b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d3feae41644ee46b3613615e293ecf4f05296b42 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0182-rc-function-RC_Thread01-Cycle_Bm_2_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00020) +run(Cycle_Bm_2_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..9d256021b72e1a92bdfc2fafd17e1caa557a0267 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/Cycle_Bm_2_00030.java @@ -0,0 +1,125 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00030 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00030 A1_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A2_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A3_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A4_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A5_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + ThreadRc_Cycle_Bm_2_00030 A6_Cycle_Bm_2_00030 = new ThreadRc_Cycle_Bm_2_00030(); + A1_Cycle_Bm_2_00030.start(); + A2_Cycle_Bm_2_00030.start(); + A3_Cycle_Bm_2_00030.start(); + A4_Cycle_Bm_2_00030.start(); + A5_Cycle_Bm_2_00030.start(); + A6_Cycle_Bm_2_00030.start(); + try { + A1_Cycle_Bm_2_00030.join(); + A2_Cycle_Bm_2_00030.join(); + A3_Cycle_Bm_2_00030.join(); + A4_Cycle_Bm_2_00030.join(); + A5_Cycle_Bm_2_00030.join(); + A6_Cycle_Bm_2_00030.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00030.check() && A2_Cycle_Bm_2_00030.check() && A3_Cycle_Bm_2_00030.check() && A4_Cycle_Bm_2_00030.check() && A5_Cycle_Bm_2_00030.check() && A6_Cycle_Bm_2_00030.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/expected.txt b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/test.cfg b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7a7147a4d99f34429279f4ec9b2a04f532537edb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0183-rc-function-RC_Thread01-Cycle_Bm_2_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00030) +run(Cycle_Bm_2_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..8afd55b6d981c477eb255e24a521dc816f531765 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/Cycle_Bm_2_00040.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00040 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_2_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00040 A1_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A2_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A3_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A4_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A5_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + ThreadRc_Cycle_Bm_2_00040 A6_Cycle_Bm_2_00040 = new ThreadRc_Cycle_Bm_2_00040(); + A1_Cycle_Bm_2_00040.start(); + A2_Cycle_Bm_2_00040.start(); + A3_Cycle_Bm_2_00040.start(); + A4_Cycle_Bm_2_00040.start(); + A5_Cycle_Bm_2_00040.start(); + A6_Cycle_Bm_2_00040.start(); + try { + A1_Cycle_Bm_2_00040.join(); + A2_Cycle_Bm_2_00040.join(); + A3_Cycle_Bm_2_00040.join(); + A4_Cycle_Bm_2_00040.join(); + A5_Cycle_Bm_2_00040.join(); + A6_Cycle_Bm_2_00040.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00040.check() && A2_Cycle_Bm_2_00040.check() && A3_Cycle_Bm_2_00040.check() && A4_Cycle_Bm_2_00040.check() && A5_Cycle_Bm_2_00040.check() && A6_Cycle_Bm_2_00040.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/expected.txt b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/test.cfg b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..58c638a09cb60c70f3677b2233941b1b7f0273a0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0184-rc-function-RC_Thread01-Cycle_Bm_2_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00040) +run(Cycle_Bm_2_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..b046d40d547fcab730a09df6ec11da867dcde88b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/Cycle_Bm_2_00050.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00050 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_2_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00050 A1_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A2_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A3_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A4_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A5_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + ThreadRc_Cycle_Bm_2_00050 A6_Cycle_Bm_2_00050 = new ThreadRc_Cycle_Bm_2_00050(); + A1_Cycle_Bm_2_00050.start(); + A2_Cycle_Bm_2_00050.start(); + A3_Cycle_Bm_2_00050.start(); + A4_Cycle_Bm_2_00050.start(); + A5_Cycle_Bm_2_00050.start(); + A6_Cycle_Bm_2_00050.start(); + try { + A1_Cycle_Bm_2_00050.join(); + A2_Cycle_Bm_2_00050.join(); + A3_Cycle_Bm_2_00050.join(); + A4_Cycle_Bm_2_00050.join(); + A5_Cycle_Bm_2_00050.join(); + A6_Cycle_Bm_2_00050.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00050.check() && A2_Cycle_Bm_2_00050.check() && A3_Cycle_Bm_2_00050.check() && A4_Cycle_Bm_2_00050.check() && A5_Cycle_Bm_2_00050.check() && A6_Cycle_Bm_2_00050.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/expected.txt b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/test.cfg b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..17f63ec3ef3bd2867d85e3d6f4e8256260cebd3d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0185-rc-function-RC_Thread01-Cycle_Bm_2_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00050) +run(Cycle_Bm_2_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..9b01098d375d1557423753ea1ce3f595809cad5a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/Cycle_Bm_2_00060.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00060 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_2_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00060 A1_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A2_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A3_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A4_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A5_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + ThreadRc_Cycle_Bm_2_00060 A6_Cycle_Bm_2_00060 = new ThreadRc_Cycle_Bm_2_00060(); + A1_Cycle_Bm_2_00060.start(); + A2_Cycle_Bm_2_00060.start(); + A3_Cycle_Bm_2_00060.start(); + A4_Cycle_Bm_2_00060.start(); + A5_Cycle_Bm_2_00060.start(); + A6_Cycle_Bm_2_00060.start(); + try { + A1_Cycle_Bm_2_00060.join(); + A2_Cycle_Bm_2_00060.join(); + A3_Cycle_Bm_2_00060.join(); + A4_Cycle_Bm_2_00060.join(); + A5_Cycle_Bm_2_00060.join(); + A6_Cycle_Bm_2_00060.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00060.check() && A2_Cycle_Bm_2_00060.check() && A3_Cycle_Bm_2_00060.check() && A4_Cycle_Bm_2_00060.check() && A5_Cycle_Bm_2_00060.check() && A6_Cycle_Bm_2_00060.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/expected.txt b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/test.cfg b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..19b6f26677309dbf5c5de11daf3696f56669a2bb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0186-rc-function-RC_Thread01-Cycle_Bm_2_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00060) +run(Cycle_Bm_2_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..34672f6c15a6f00239fe84e1728471344bcc9f49 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/Cycle_Bm_2_00070.java @@ -0,0 +1,159 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00070 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + if (nsum == 37) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_2_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00070 A1_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A2_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A3_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A4_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A5_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + ThreadRc_Cycle_Bm_2_00070 A6_Cycle_Bm_2_00070 = new ThreadRc_Cycle_Bm_2_00070(); + A1_Cycle_Bm_2_00070.start(); + A2_Cycle_Bm_2_00070.start(); + A3_Cycle_Bm_2_00070.start(); + A4_Cycle_Bm_2_00070.start(); + A5_Cycle_Bm_2_00070.start(); + A6_Cycle_Bm_2_00070.start(); + try { + A1_Cycle_Bm_2_00070.join(); + A2_Cycle_Bm_2_00070.join(); + A3_Cycle_Bm_2_00070.join(); + A4_Cycle_Bm_2_00070.join(); + A5_Cycle_Bm_2_00070.join(); + A6_Cycle_Bm_2_00070.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00070.check() && A2_Cycle_Bm_2_00070.check() && A3_Cycle_Bm_2_00070.check() && A4_Cycle_Bm_2_00070.check() && A5_Cycle_Bm_2_00070.check() && A6_Cycle_Bm_2_00070.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/expected.txt b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/test.cfg b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ce594fc91a0d1a36720d7f6a356b2862cd93e701 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0187-rc-function-RC_Thread01-Cycle_Bm_2_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00070) +run(Cycle_Bm_2_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..8b5e7dfffa9056811f3e9bbb5883ae33edd6bc9f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/Cycle_Bm_2_00080.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00080 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_2_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00080 A1_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A2_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A3_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A4_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A5_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A6_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + A1_Cycle_Bm_2_00080.start(); + A2_Cycle_Bm_2_00080.start(); + A3_Cycle_Bm_2_00080.start(); + A4_Cycle_Bm_2_00080.start(); + A5_Cycle_Bm_2_00080.start(); + A6_Cycle_Bm_2_00080.start(); + try { + A1_Cycle_Bm_2_00080.join(); + A2_Cycle_Bm_2_00080.join(); + A3_Cycle_Bm_2_00080.join(); + A4_Cycle_Bm_2_00080.join(); + A5_Cycle_Bm_2_00080.join(); + A6_Cycle_Bm_2_00080.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00080.check() && A2_Cycle_Bm_2_00080.check() && A3_Cycle_Bm_2_00080.check() && A4_Cycle_Bm_2_00080.check() && A5_Cycle_Bm_2_00080.check() && A6_Cycle_Bm_2_00080.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/expected.txt b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/test.cfg b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..307ee512b3e6c7b2383481d18783d94f17827b5c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0188-rc-function-RC_Thread01-Cycle_Bm_2_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00080) +run(Cycle_Bm_2_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..c3077551b243f8d4f650043c2004be974a2fe523 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/Cycle_Bm_2_00090.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00090 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 9) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00090 A1_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A2_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A3_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A4_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A5_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + ThreadRc_Cycle_Bm_2_00090 A6_Cycle_Bm_2_00090 = new ThreadRc_Cycle_Bm_2_00090(); + A1_Cycle_Bm_2_00090.start(); + A2_Cycle_Bm_2_00090.start(); + A3_Cycle_Bm_2_00090.start(); + A4_Cycle_Bm_2_00090.start(); + A5_Cycle_Bm_2_00090.start(); + A6_Cycle_Bm_2_00090.start(); + try { + A1_Cycle_Bm_2_00090.join(); + A2_Cycle_Bm_2_00090.join(); + A3_Cycle_Bm_2_00090.join(); + A4_Cycle_Bm_2_00090.join(); + A5_Cycle_Bm_2_00090.join(); + A6_Cycle_Bm_2_00090.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00090.check() && A2_Cycle_Bm_2_00090.check() && A3_Cycle_Bm_2_00090.check() && A4_Cycle_Bm_2_00090.check() && A5_Cycle_Bm_2_00090.check() && A6_Cycle_Bm_2_00090.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/expected.txt b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/test.cfg b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2887cb4e1a90f2ad358d6a569fa78a4b17f5b6d0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0189-rc-function-RC_Thread01-Cycle_Bm_2_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00090) +run(Cycle_Bm_2_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..e5a6bc6342a0668172b478d27a02e10800934be1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/Cycle_Bm_2_00100.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00100 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 29) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +public class Cycle_Bm_2_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00100 A1_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A2_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A3_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A4_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A5_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + ThreadRc_Cycle_Bm_2_00100 A6_Cycle_Bm_2_00100 = new ThreadRc_Cycle_Bm_2_00100(); + A1_Cycle_Bm_2_00100.start(); + A2_Cycle_Bm_2_00100.start(); + A3_Cycle_Bm_2_00100.start(); + A4_Cycle_Bm_2_00100.start(); + A5_Cycle_Bm_2_00100.start(); + A6_Cycle_Bm_2_00100.start(); + try { + A1_Cycle_Bm_2_00100.join(); + A2_Cycle_Bm_2_00100.join(); + A3_Cycle_Bm_2_00100.join(); + A4_Cycle_Bm_2_00100.join(); + A5_Cycle_Bm_2_00100.join(); + A6_Cycle_Bm_2_00100.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00100.check() && A2_Cycle_Bm_2_00100.check() && A3_Cycle_Bm_2_00100.check() && A4_Cycle_Bm_2_00100.check() && A5_Cycle_Bm_2_00100.check() && A6_Cycle_Bm_2_00100.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/expected.txt b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/test.cfg b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..26873e0a59b1d510d06e12f737076d4313efac32 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0190-rc-function-RC_Thread01-Cycle_Bm_2_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00100) +run(Cycle_Bm_2_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..07e90e37892f13c487fc52b9e6caca00ae54661f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/Cycle_Bm_2_00110.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00110 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00110 A1_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A2_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A3_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A4_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A5_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + ThreadRc_Cycle_Bm_2_00110 A6_Cycle_Bm_2_00110 = new ThreadRc_Cycle_Bm_2_00110(); + A1_Cycle_Bm_2_00110.start(); + A2_Cycle_Bm_2_00110.start(); + A3_Cycle_Bm_2_00110.start(); + A4_Cycle_Bm_2_00110.start(); + A5_Cycle_Bm_2_00110.start(); + A6_Cycle_Bm_2_00110.start(); + try { + A1_Cycle_Bm_2_00110.join(); + A2_Cycle_Bm_2_00110.join(); + A3_Cycle_Bm_2_00110.join(); + A4_Cycle_Bm_2_00110.join(); + A5_Cycle_Bm_2_00110.join(); + A6_Cycle_Bm_2_00110.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00110.check() && A2_Cycle_Bm_2_00110.check() && A3_Cycle_Bm_2_00110.check() && A4_Cycle_Bm_2_00110.check() && A5_Cycle_Bm_2_00110.check() && A6_Cycle_Bm_2_00110.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/expected.txt b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/test.cfg b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f8f6e22f3ec9580ee7fdaa078bb0205eb2f67aa2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0191-rc-function-RC_Thread01-Cycle_Bm_2_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00110) +run(Cycle_Bm_2_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..525d358094e78e22381202b46ea68bba3a793c61 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/Cycle_Bm_2_00120.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00120 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00120 A1_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A2_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A3_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A4_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A5_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + ThreadRc_Cycle_Bm_2_00120 A6_Cycle_Bm_2_00120 = new ThreadRc_Cycle_Bm_2_00120(); + A1_Cycle_Bm_2_00120.start(); + A2_Cycle_Bm_2_00120.start(); + A3_Cycle_Bm_2_00120.start(); + A4_Cycle_Bm_2_00120.start(); + A5_Cycle_Bm_2_00120.start(); + A6_Cycle_Bm_2_00120.start(); + try { + A1_Cycle_Bm_2_00120.join(); + A2_Cycle_Bm_2_00120.join(); + A3_Cycle_Bm_2_00120.join(); + A4_Cycle_Bm_2_00120.join(); + A5_Cycle_Bm_2_00120.join(); + A6_Cycle_Bm_2_00120.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00120.check() && A2_Cycle_Bm_2_00120.check() && A3_Cycle_Bm_2_00120.check() && A4_Cycle_Bm_2_00120.check() && A5_Cycle_Bm_2_00120.check() && A6_Cycle_Bm_2_00120.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/expected.txt b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/test.cfg b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2ce74685c7ad52b6ceaee25728668bdcfb7726d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0192-rc-function-RC_Thread01-Cycle_Bm_2_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00120) +run(Cycle_Bm_2_00120,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..f5cb42644dd0b42b4502c29e04bfcadacef5d34d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/Cycle_Bm_2_00130.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00130 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + if (nsum == 45) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} +public class Cycle_Bm_2_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00130 A1_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A2_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A3_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A4_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A5_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + ThreadRc_Cycle_Bm_2_00130 A6_Cycle_Bm_2_00130 = new ThreadRc_Cycle_Bm_2_00130(); + A1_Cycle_Bm_2_00130.start(); + A2_Cycle_Bm_2_00130.start(); + A3_Cycle_Bm_2_00130.start(); + A4_Cycle_Bm_2_00130.start(); + A5_Cycle_Bm_2_00130.start(); + A6_Cycle_Bm_2_00130.start(); + try { + A1_Cycle_Bm_2_00130.join(); + A2_Cycle_Bm_2_00130.join(); + A3_Cycle_Bm_2_00130.join(); + A4_Cycle_Bm_2_00130.join(); + A5_Cycle_Bm_2_00130.join(); + A6_Cycle_Bm_2_00130.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00130.check() && A2_Cycle_Bm_2_00130.check() && A3_Cycle_Bm_2_00130.check() && A4_Cycle_Bm_2_00130.check() && A5_Cycle_Bm_2_00130.check() && A6_Cycle_Bm_2_00130.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/expected.txt b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/test.cfg b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a31f0b6d903900ce130b31b96de2a370a8440a2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0193-rc-function-RC_Thread01-Cycle_Bm_2_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00130) +run(Cycle_Bm_2_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..84cdcc2b7e306c2d72dd46cb4c7823632db9e4a5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/Cycle_Bm_2_00140.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00140 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a1_0.a; + } + } + class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00140 A1_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A2_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A3_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A4_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A5_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + ThreadRc_Cycle_Bm_2_00140 A6_Cycle_Bm_2_00140 = new ThreadRc_Cycle_Bm_2_00140(); + A1_Cycle_Bm_2_00140.start(); + A2_Cycle_Bm_2_00140.start(); + A3_Cycle_Bm_2_00140.start(); + A4_Cycle_Bm_2_00140.start(); + A5_Cycle_Bm_2_00140.start(); + A6_Cycle_Bm_2_00140.start(); + try { + A1_Cycle_Bm_2_00140.join(); + A2_Cycle_Bm_2_00140.join(); + A3_Cycle_Bm_2_00140.join(); + A4_Cycle_Bm_2_00140.join(); + A5_Cycle_Bm_2_00140.join(); + A6_Cycle_Bm_2_00140.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00140.check() && A2_Cycle_Bm_2_00140.check() && A3_Cycle_Bm_2_00140.check() && A4_Cycle_Bm_2_00140.check() && A5_Cycle_Bm_2_00140.check() && A6_Cycle_Bm_2_00140.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/expected.txt b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/test.cfg b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ff49feb86414e7b69cbff8670671fd7df0fe39b1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0194-rc-function-RC_Thread01-Cycle_Bm_2_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00140) +run(Cycle_Bm_2_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..3e5c574f5d9af4dcfe41c7a1d78401da5079af93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/Cycle_Bm_2_00150.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00150 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 14) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00150 A1_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A2_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A3_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A4_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A5_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + ThreadRc_Cycle_Bm_2_00150 A6_Cycle_Bm_2_00150 = new ThreadRc_Cycle_Bm_2_00150(); + A1_Cycle_Bm_2_00150.start(); + A2_Cycle_Bm_2_00150.start(); + A3_Cycle_Bm_2_00150.start(); + A4_Cycle_Bm_2_00150.start(); + A5_Cycle_Bm_2_00150.start(); + A6_Cycle_Bm_2_00150.start(); + try { + A1_Cycle_Bm_2_00150.join(); + A2_Cycle_Bm_2_00150.join(); + A3_Cycle_Bm_2_00150.join(); + A4_Cycle_Bm_2_00150.join(); + A5_Cycle_Bm_2_00150.join(); + A6_Cycle_Bm_2_00150.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00150.check() && A2_Cycle_Bm_2_00150.check() && A3_Cycle_Bm_2_00150.check() && A4_Cycle_Bm_2_00150.check() && A5_Cycle_Bm_2_00150.check() && A6_Cycle_Bm_2_00150.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/expected.txt b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/test.cfg b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cdca3f30f1437bdb92d1932c187fce98ddbbbda0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0195-rc-function-RC_Thread01-Cycle_Bm_2_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00150) +run(Cycle_Bm_2_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..fdd9a11b484233227c076ff1fe6674beb6e63370 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/Cycle_Bm_2_00160.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00160 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00160 A1_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A2_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A3_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A4_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A5_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + ThreadRc_Cycle_Bm_2_00160 A6_Cycle_Bm_2_00160 = new ThreadRc_Cycle_Bm_2_00160(); + A1_Cycle_Bm_2_00160.start(); + A2_Cycle_Bm_2_00160.start(); + A3_Cycle_Bm_2_00160.start(); + A4_Cycle_Bm_2_00160.start(); + A5_Cycle_Bm_2_00160.start(); + A6_Cycle_Bm_2_00160.start(); + try { + A1_Cycle_Bm_2_00160.join(); + A2_Cycle_Bm_2_00160.join(); + A3_Cycle_Bm_2_00160.join(); + A4_Cycle_Bm_2_00160.join(); + A5_Cycle_Bm_2_00160.join(); + A6_Cycle_Bm_2_00160.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00160.check() && A2_Cycle_Bm_2_00160.check() && A3_Cycle_Bm_2_00160.check() && A4_Cycle_Bm_2_00160.check() && A5_Cycle_Bm_2_00160.check() && A6_Cycle_Bm_2_00160.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/expected.txt b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/test.cfg b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4ccf5d21d625aa7f24b596b5b1fa1f0606877011 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0196-rc-function-RC_Thread01-Cycle_Bm_2_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00160) +run(Cycle_Bm_2_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..8c1e2265afdbbd84c154f363c5686723545f90ca --- /dev/null +++ b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/Cycle_Bm_2_00170.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00170 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00170 A1_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A2_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A3_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A4_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A5_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + ThreadRc_Cycle_Bm_2_00170 A6_Cycle_Bm_2_00170 = new ThreadRc_Cycle_Bm_2_00170(); + A1_Cycle_Bm_2_00170.start(); + A2_Cycle_Bm_2_00170.start(); + A3_Cycle_Bm_2_00170.start(); + A4_Cycle_Bm_2_00170.start(); + A5_Cycle_Bm_2_00170.start(); + A6_Cycle_Bm_2_00170.start(); + try { + A1_Cycle_Bm_2_00170.join(); + A2_Cycle_Bm_2_00170.join(); + A3_Cycle_Bm_2_00170.join(); + A4_Cycle_Bm_2_00170.join(); + A5_Cycle_Bm_2_00170.join(); + A6_Cycle_Bm_2_00170.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00170.check() && A2_Cycle_Bm_2_00170.check() && A3_Cycle_Bm_2_00170.check() && A4_Cycle_Bm_2_00170.check() && A5_Cycle_Bm_2_00170.check() && A6_Cycle_Bm_2_00170.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/expected.txt b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/test.cfg b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..291e470854e45f3015fbff3c56ab46e2e0773cef --- /dev/null +++ b/testsuite/java_test/rc_test/RC0197-rc-function-RC_Thread01-Cycle_Bm_2_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00170) +run(Cycle_Bm_2_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..2dede10820194bd464ad77556882fda964cd877b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/Cycle_Bm_2_00180.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00180 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class Cycle_Bm_2_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00180 A1_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A2_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A3_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A4_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A5_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + ThreadRc_Cycle_Bm_2_00180 A6_Cycle_Bm_2_00180 = new ThreadRc_Cycle_Bm_2_00180(); + A1_Cycle_Bm_2_00180.start(); + A2_Cycle_Bm_2_00180.start(); + A3_Cycle_Bm_2_00180.start(); + A4_Cycle_Bm_2_00180.start(); + A5_Cycle_Bm_2_00180.start(); + A6_Cycle_Bm_2_00180.start(); + try { + A1_Cycle_Bm_2_00180.join(); + A2_Cycle_Bm_2_00180.join(); + A3_Cycle_Bm_2_00180.join(); + A4_Cycle_Bm_2_00180.join(); + A5_Cycle_Bm_2_00180.join(); + A6_Cycle_Bm_2_00180.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00180.check() && A2_Cycle_Bm_2_00180.check() && A3_Cycle_Bm_2_00180.check() && A4_Cycle_Bm_2_00180.check() && A5_Cycle_Bm_2_00180.check() && A6_Cycle_Bm_2_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/expected.txt b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/test.cfg b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8c3f6cba6b2f79313512ff2b44dffcab22268149 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0198-rc-function-RC_Thread01-Cycle_Bm_2_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00180) +run(Cycle_Bm_2_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..b0fd61bc91d01da7b586c7acbfa4dd7ec144a74a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/Cycle_Bm_2_00190.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00190 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00190 A1_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A2_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A3_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A4_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A5_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + ThreadRc_Cycle_Bm_2_00190 A6_Cycle_Bm_2_00190 = new ThreadRc_Cycle_Bm_2_00190(); + A1_Cycle_Bm_2_00190.start(); + A2_Cycle_Bm_2_00190.start(); + A3_Cycle_Bm_2_00190.start(); + A4_Cycle_Bm_2_00190.start(); + A5_Cycle_Bm_2_00190.start(); + A6_Cycle_Bm_2_00190.start(); + try { + A1_Cycle_Bm_2_00190.join(); + A2_Cycle_Bm_2_00190.join(); + A3_Cycle_Bm_2_00190.join(); + A4_Cycle_Bm_2_00190.join(); + A5_Cycle_Bm_2_00190.join(); + A6_Cycle_Bm_2_00190.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00190.check() && A2_Cycle_Bm_2_00190.check() && A3_Cycle_Bm_2_00190.check() && A4_Cycle_Bm_2_00190.check() && A5_Cycle_Bm_2_00190.check() && A6_Cycle_Bm_2_00190.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/expected.txt b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/test.cfg b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0fc98cc8cbd09a597b7afe9be6021ed6e89458fe --- /dev/null +++ b/testsuite/java_test/rc_test/RC0199-rc-function-RC_Thread01-Cycle_Bm_2_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00190) +run(Cycle_Bm_2_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java new file mode 100755 index 0000000000000000000000000000000000000000..75df222181253c6733f61d0b765100a29c95219d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/Cycle_Bm_2_00200.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00200 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a + a1_0.a; + } + } + class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +public class Cycle_Bm_2_00200 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00200 A1_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A2_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A3_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A4_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A5_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + ThreadRc_Cycle_Bm_2_00200 A6_Cycle_Bm_2_00200 = new ThreadRc_Cycle_Bm_2_00200(); + A1_Cycle_Bm_2_00200.start(); + A2_Cycle_Bm_2_00200.start(); + A3_Cycle_Bm_2_00200.start(); + A4_Cycle_Bm_2_00200.start(); + A5_Cycle_Bm_2_00200.start(); + A6_Cycle_Bm_2_00200.start(); + try { + A1_Cycle_Bm_2_00200.join(); + A2_Cycle_Bm_2_00200.join(); + A3_Cycle_Bm_2_00200.join(); + A4_Cycle_Bm_2_00200.join(); + A5_Cycle_Bm_2_00200.join(); + A6_Cycle_Bm_2_00200.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00200.check() && A2_Cycle_Bm_2_00200.check() && A3_Cycle_Bm_2_00200.check() && A4_Cycle_Bm_2_00200.check() && A5_Cycle_Bm_2_00200.check() && A6_Cycle_Bm_2_00200.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/expected.txt b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/test.cfg b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b7b591ed244dffb0a27f8332ed00d4885d633e6b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0200-rc-function-RC_Thread01-Cycle_Bm_2_00200/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00200) +run(Cycle_Bm_2_00200,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java new file mode 100755 index 0000000000000000000000000000000000000000..7dae5da9fd8427aeb574f2a591c3f5b065019f0c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/Cycle_Bm_2_00210.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00210 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a8_0.a; + } + } + class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_2_00210 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00210 A1_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A2_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A3_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A4_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A5_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + ThreadRc_Cycle_Bm_2_00210 A6_Cycle_Bm_2_00210 = new ThreadRc_Cycle_Bm_2_00210(); + A1_Cycle_Bm_2_00210.start(); + A2_Cycle_Bm_2_00210.start(); + A3_Cycle_Bm_2_00210.start(); + A4_Cycle_Bm_2_00210.start(); + A5_Cycle_Bm_2_00210.start(); + A6_Cycle_Bm_2_00210.start(); + try { + A1_Cycle_Bm_2_00210.join(); + A2_Cycle_Bm_2_00210.join(); + A3_Cycle_Bm_2_00210.join(); + A4_Cycle_Bm_2_00210.join(); + A5_Cycle_Bm_2_00210.join(); + A6_Cycle_Bm_2_00210.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00210.check() && A2_Cycle_Bm_2_00210.check() && A3_Cycle_Bm_2_00210.check() && A4_Cycle_Bm_2_00210.check() && A5_Cycle_Bm_2_00210.check() && A6_Cycle_Bm_2_00210.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/expected.txt b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/test.cfg b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2fa4b13dcb56d973babd485e08bdeae9d2242c7b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0201-rc-function-RC_Thread01-Cycle_Bm_2_00210/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00210) +run(Cycle_Bm_2_00210,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java new file mode 100755 index 0000000000000000000000000000000000000000..e16920e2d8ae995115569ca13f60ec7c1956f5b0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/Cycle_Bm_2_00220.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00220 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class Cycle_Bm_2_00220 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00220 A1_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A2_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A3_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A4_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A5_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + ThreadRc_Cycle_Bm_2_00220 A6_Cycle_Bm_2_00220 = new ThreadRc_Cycle_Bm_2_00220(); + A1_Cycle_Bm_2_00220.start(); + A2_Cycle_Bm_2_00220.start(); + A3_Cycle_Bm_2_00220.start(); + A4_Cycle_Bm_2_00220.start(); + A5_Cycle_Bm_2_00220.start(); + A6_Cycle_Bm_2_00220.start(); + try { + A1_Cycle_Bm_2_00220.join(); + A2_Cycle_Bm_2_00220.join(); + A3_Cycle_Bm_2_00220.join(); + A4_Cycle_Bm_2_00220.join(); + A5_Cycle_Bm_2_00220.join(); + A6_Cycle_Bm_2_00220.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00220.check() && A2_Cycle_Bm_2_00220.check() && A3_Cycle_Bm_2_00220.check() && A4_Cycle_Bm_2_00220.check() && A5_Cycle_Bm_2_00220.check() && A6_Cycle_Bm_2_00220.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/expected.txt b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/test.cfg b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eeeb6d79c739b1bb66a7b19b796a63300a2ec0c7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0202-rc-function-RC_Thread01-Cycle_Bm_2_00220/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00220) +run(Cycle_Bm_2_00220,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java new file mode 100755 index 0000000000000000000000000000000000000000..154f1632f6e81e5668f887d3bc38c7b4ae8a0f20 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/Cycle_Bm_2_00230.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00230 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 97) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_Bm_2_00230 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00230 A1_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A2_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A3_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A4_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A5_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A6_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + A1_Cycle_Bm_2_00230.start(); + A2_Cycle_Bm_2_00230.start(); + A3_Cycle_Bm_2_00230.start(); + A4_Cycle_Bm_2_00230.start(); + A5_Cycle_Bm_2_00230.start(); + A6_Cycle_Bm_2_00230.start(); + try { + A1_Cycle_Bm_2_00230.join(); + A2_Cycle_Bm_2_00230.join(); + A3_Cycle_Bm_2_00230.join(); + A4_Cycle_Bm_2_00230.join(); + A5_Cycle_Bm_2_00230.join(); + A6_Cycle_Bm_2_00230.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00230.check() && A2_Cycle_Bm_2_00230.check() && A3_Cycle_Bm_2_00230.check() && A4_Cycle_Bm_2_00230.check() && A5_Cycle_Bm_2_00230.check() && A6_Cycle_Bm_2_00230.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/expected.txt b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/test.cfg b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a3d5c6baca002d0b576bfa6723eb1a0b90987442 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0203-rc-function-RC_Thread01-Cycle_Bm_2_00230/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00230) +run(Cycle_Bm_2_00230,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java new file mode 100755 index 0000000000000000000000000000000000000000..d9961fea65961266b4948c304a6ab87fc3a9fd20 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/Cycle_Bm_2_00240.java @@ -0,0 +1,2303 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_00010B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00010_A1 a1_0 = new Cycle_B_2_00010_A1(); + a1_0.a2_0 = new Cycle_B_2_00010_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00010_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00010_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 18) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00010_A1 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00010_A2 { + Cycle_B_2_00010_A3 a3_0; + Cycle_B_2_00010_A4 a4_0; + int a; + int sum; + Cycle_B_2_00010_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00010_A3 { + Cycle_B_2_00010_A1 a1_0; + int a; + int sum; + Cycle_B_2_00010_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00010_A4 { + Cycle_B_2_00010_A2 a2_0; + int a; + int sum; + Cycle_B_2_00010_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00020B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00020_A1 a1_0 = new Cycle_B_2_00020_A1(); + a1_0.a2_0 = new Cycle_B_2_00020_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00020_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00020_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00020_A1 { + Cycle_B_2_00020_A2 a2_0; + int a; + int sum; + Cycle_B_2_00020_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00020_A2 { + Cycle_B_2_00020_A3 a3_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00020_A3 { + Cycle_B_2_00020_A1 a1_0; + Cycle_B_2_00020_A4 a4_0; + int a; + int sum; + Cycle_B_2_00020_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00020_A4 { + Cycle_B_2_00020_A3 a3_0; + int a; + int sum; + Cycle_B_2_00020_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00030B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00030_A1 a1_0 = new Cycle_B_2_00030_A1(); + a1_0.a2_0 = new Cycle_B_2_00030_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00030_A3(); + Cycle_B_2_00030_A4 a4_0 = new Cycle_B_2_00030_A4(); + a4_0.a1_0 = a1_0; + a1_0.a4_0 = a4_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00030_A1 { + Cycle_B_2_00030_A2 a2_0; + Cycle_B_2_00030_A4 a4_0; + int a; + int sum; + Cycle_B_2_00030_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00030_A2 { + Cycle_B_2_00030_A3 a3_0; + int a; + int sum; + Cycle_B_2_00030_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00030_A3 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00030_A4 { + Cycle_B_2_00030_A1 a1_0; + int a; + int sum; + Cycle_B_2_00030_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00040B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00040_A1 a1_0 = new Cycle_B_2_00040_A1(); + a1_0.a2_0 = new Cycle_B_2_00040_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00040_A3(); + Cycle_B_2_00040_A4 a4_0 = new Cycle_B_2_00040_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 19) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00040_A1 { + Cycle_B_2_00040_A2 a2_0; + int a; + int sum; + Cycle_B_2_00040_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00040_A2 { + Cycle_B_2_00040_A3 a3_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00040_A3 { + Cycle_B_2_00040_A1 a1_0; + Cycle_B_2_00040_A4 a4_0; + int a; + int sum; + Cycle_B_2_00040_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00040_A4 { + Cycle_B_2_00040_A3 a3_0; + int a; + int sum; + Cycle_B_2_00040_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00050B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00050_A1 a1_0 = new Cycle_B_2_00050_A1(); + a1_0.a2_0 = new Cycle_B_2_00050_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00050_A3(); + Cycle_B_2_00050_A4 a4_0 = new Cycle_B_2_00050_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00050_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00050_A1 { + Cycle_B_2_00050_A2 a2_0; + int a; + int sum; + Cycle_B_2_00050_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00050_A2 { + Cycle_B_2_00050_A3 a3_0; + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00050_A3 { + Cycle_B_2_00050_A1 a1_0; + Cycle_B_2_00050_A5 a5_0; + int a; + int sum; + Cycle_B_2_00050_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00050_A4 { + Cycle_B_2_00050_A3 a3_0; + int a; + int sum; + Cycle_B_2_00050_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00050_A5 { + Cycle_B_2_00050_A4 a4_0; + int a; + int sum; + Cycle_B_2_00050_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00060B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00060_A1 a1_0 = new Cycle_B_2_00060_A1(); + a1_0.a2_0 = new Cycle_B_2_00060_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00060_A3(); + Cycle_B_2_00060_A4 a4_0 = new Cycle_B_2_00060_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00060_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00060_A1 { + Cycle_B_2_00060_A2 a2_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00060_A2 { + Cycle_B_2_00060_A3 a3_0; + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00060_A3 { + Cycle_B_2_00060_A1 a1_0; + Cycle_B_2_00060_A5 a5_0; + int a; + int sum; + Cycle_B_2_00060_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00060_A4 { + Cycle_B_2_00060_A3 a3_0; + int a; + int sum; + Cycle_B_2_00060_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00060_A5 { + Cycle_B_2_00060_A4 a4_0; + int a; + int sum; + Cycle_B_2_00060_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00070B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00070_A1 a1_0 = new Cycle_B_2_00070_A1(); + a1_0.a2_0 = new Cycle_B_2_00070_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00070_A3(); + Cycle_B_2_00070_A4 a4_0 = new Cycle_B_2_00070_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00070_A5(); + Cycle_B_2_00070_A6 a6_0 = new Cycle_B_2_00070_A6(); + a6_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a6_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum + a6_0.sum); + //System.out.println(nsum); + if (nsum == 37) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00070_A1 { + Cycle_B_2_00070_A2 a2_0; + int a; + int sum; + Cycle_B_2_00070_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00070_A2 { + Cycle_B_2_00070_A3 a3_0; + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00070_A3 { + Cycle_B_2_00070_A1 a1_0; + Cycle_B_2_00070_A5 a5_0; + int a; + int sum; + Cycle_B_2_00070_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00070_A4 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A4() { + a3_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00070_A5 { + Cycle_B_2_00070_A4 a4_0; + int a; + int sum; + Cycle_B_2_00070_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00070_A6 { + Cycle_B_2_00070_A3 a3_0; + int a; + int sum; + Cycle_B_2_00070_A6() { + a3_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00080B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a4_0.a3_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a4_0.a3_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.a5_0 = a4_0.a3_0.a5_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a4_0.a3_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a4_0.a3_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A3 { + Cycle_B_2_00080_A1 a1_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00080_A4 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A5 { + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00090B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00090_A1 a1_0 = new Cycle_B_2_00090_A1(); + Cycle_B_2_00090_A3 a3_0 = new Cycle_B_2_00090_A3(); + a1_0.a2_0 = new Cycle_B_2_00090_A2(); + a1_0.a2_0.a1_0 = a1_0; + a3_0.a2_0 = a1_0.a2_0; + a3_0.a2_0.a3_0 = a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a3_0.sum); + //System.out.println(nsum); + if (nsum == 9) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00090_A1 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00090_A2 { + Cycle_B_2_00090_A1 a1_0; + Cycle_B_2_00090_A3 a3_0; + int a; + int sum; + Cycle_B_2_00090_A2() { + a1_0 = null; + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00090_A3 { + Cycle_B_2_00090_A2 a2_0; + int a; + int sum; + Cycle_B_2_00090_A3() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00100B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00100_A1 a1_0 = new Cycle_B_2_00100_A1(); + a1_0.a2_0 = new Cycle_B_2_00100_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00100_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00100_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00100_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 29) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00100_A1 { + Cycle_B_2_00100_A2 a2_0; + int a; + int sum; + Cycle_B_2_00100_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00100_A2 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00100_A3 { + Cycle_B_2_00100_A1 a1_0; + Cycle_B_2_00100_A4 a4_0; + int a; + int sum; + Cycle_B_2_00100_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00100_A4 { + Cycle_B_2_00100_A5 a5_0; + int a; + int sum; + Cycle_B_2_00100_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00100_A5 { + Cycle_B_2_00100_A3 a3_0; + int a; + int sum; + Cycle_B_2_00100_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00110B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00110_A1 a1_0 = new Cycle_B_2_00110_A1(); + a1_0.a2_0 = new Cycle_B_2_00110_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00110_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00110_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a4_0.a5_0 = new Cycle_B_2_00110_A5(); + a1_0.a2_0.a4_0.a5_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + a1_0.a2_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum + a1_0.a2_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00110_A1 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00110_A2 { + Cycle_B_2_00110_A3 a3_0; + Cycle_B_2_00110_A4 a4_0; + int a; + int sum; + Cycle_B_2_00110_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00110_A3 { + Cycle_B_2_00110_A1 a1_0; + int a; + int sum; + Cycle_B_2_00110_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00110_A4 { + Cycle_B_2_00110_A5 a5_0; + int a; + int sum; + Cycle_B_2_00110_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00110_A5 { + Cycle_B_2_00110_A2 a2_0; + int a; + int sum; + Cycle_B_2_00110_A5() { + a2_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00120B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00120_A1 a1_0 = new Cycle_B_2_00120_A1(); + a1_0.a2_0 = new Cycle_B_2_00120_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00120_A3(); + a1_0.a4_0 = new Cycle_B_2_00120_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a4_0.a5_0 = new Cycle_B_2_00120_A5(); + a1_0.a4_0.a5_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a4_0.add(); + a1_0.a4_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a4_0.sum + a1_0.a4_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 27) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00120_A1 { + Cycle_B_2_00120_A2 a2_0; + Cycle_B_2_00120_A4 a4_0; + int a; + int sum; + Cycle_B_2_00120_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00120_A2 { + Cycle_B_2_00120_A3 a3_0; + int a; + int sum; + Cycle_B_2_00120_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00120_A3 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00120_A4 { + Cycle_B_2_00120_A5 a5_0; + int a; + int sum; + Cycle_B_2_00120_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00120_A5 { + Cycle_B_2_00120_A1 a1_0; + int a; + int sum; + Cycle_B_2_00120_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00130B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00130_A1 a1_0 = new Cycle_B_2_00130_A1(); + a1_0.a2_0 = new Cycle_B_2_00130_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00130_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00130_A4(); + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + Cycle_B_2_00130_A5 a5_0 = new Cycle_B_2_00130_A5(); + a1_0.a2_0.a3_0.a4_0.a6_0 = new Cycle_B_2_00130_A6(); + a1_0.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_0; + a5_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a6_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a5_0.sum + a1_0.a2_0.a3_0.a4_0.a6_0.sum); + //System.out.println(nsum); + if (nsum == 45) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00130_A1 { + Cycle_B_2_00130_A2 a2_0; + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00130_A2 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00130_A3 { + Cycle_B_2_00130_A4 a4_0; + int a; + int sum; + Cycle_B_2_00130_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00130_A4 { + Cycle_B_2_00130_A1 a1_0; + Cycle_B_2_00130_A6 a6_0; + int a; + int sum; + Cycle_B_2_00130_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + class Cycle_B_2_00130_A5 { + Cycle_B_2_00130_A3 a3_0; + int a; + int sum; + Cycle_B_2_00130_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00130_A6 { + Cycle_B_2_00130_A5 a5_0; + int a; + int sum; + Cycle_B_2_00130_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00140B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00140_A1 a1_0 = new Cycle_B_2_00140_A1(); + a1_0.a2_0 = new Cycle_B_2_00140_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00140_A3(); + a1_0.a2_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 13) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00140_A1 { + Cycle_B_2_00140_A2 a2_0; + int a; + int sum; + Cycle_B_2_00140_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00140_A2 { + Cycle_B_2_00140_A3 a3_0; + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A2() { + a3_0 = null; + a1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a1_0.a; + } + } + class Cycle_B_2_00140_A3 { + Cycle_B_2_00140_A1 a1_0; + int a; + int sum; + Cycle_B_2_00140_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00150B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00150_A1 a1_0 = new Cycle_B_2_00150_A1(); + a1_0.a2_0 = new Cycle_B_2_00150_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00150_A3(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 14) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00150_A1 { + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00150_A2 { + Cycle_B_2_00150_A3 a3_0; + int a; + int sum; + Cycle_B_2_00150_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00150_A3 { + Cycle_B_2_00150_A1 a1_0; + Cycle_B_2_00150_A2 a2_0; + int a; + int sum; + Cycle_B_2_00150_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00160B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00160_A1 a1_0 = new Cycle_B_2_00160_A1(); + a1_0.a2_0 = new Cycle_B_2_00160_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00160_A3(); + a1_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00160_A1 { + Cycle_B_2_00160_A2 a2_0; + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_B_2_00160_A2 { + Cycle_B_2_00160_A3 a3_0; + int a; + int sum; + Cycle_B_2_00160_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00160_A3 { + Cycle_B_2_00160_A1 a1_0; + int a; + int sum; + Cycle_B_2_00160_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00170B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00170_A1 a1_0 = new Cycle_B_2_00170_A1(); + a1_0.a2_0 = new Cycle_B_2_00170_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00170_A3(); + a1_0.a2_0.a4_0 = new Cycle_B_2_00170_A4(); + a1_0.a2_0.a4_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a4_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 21) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00170_A1 { + Cycle_B_2_00170_A2 a2_0; + int a; + int sum; + Cycle_B_2_00170_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00170_A2 { + Cycle_B_2_00170_A3 a3_0; + Cycle_B_2_00170_A4 a4_0; + int a; + int sum; + Cycle_B_2_00170_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_B_2_00170_A3 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00170_A4 { + Cycle_B_2_00170_A1 a1_0; + int a; + int sum; + Cycle_B_2_00170_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00180B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00180_A1 a1_0 = new Cycle_B_2_00180_A1(); + a1_0.a2_0 = new Cycle_B_2_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00180_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00180_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00180_A1 { + Cycle_B_2_00180_A2 a2_0; + int a; + int sum; + Cycle_B_2_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00180_A2 { + Cycle_B_2_00180_A3 a3_0; + int a; + int sum; + Cycle_B_2_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00180_A3 { + Cycle_B_2_00180_A1 a1_0; + Cycle_B_2_00180_A4 a4_0; + int a; + int sum; + Cycle_B_2_00180_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a + a4_0.a; + } + } + class Cycle_B_2_00180_A4 { + Cycle_B_2_00180_A1 a1_0; + int a; + int sum; + Cycle_B_2_00180_A4() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00190B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00190_A1 a1_0 = new Cycle_B_2_00190_A1(); + a1_0.a2_0 = new Cycle_B_2_00190_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00190_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00190_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum); + //System.out.println(nsum); + if (nsum == 15) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00190_A1 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00190_A2 { + Cycle_B_2_00190_A3 a3_0; + int a; + int sum; + Cycle_B_2_00190_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00190_A3 { + Cycle_B_2_00190_A1 a1_0; + Cycle_B_2_00190_A4 a4_0; + int a; + int sum; + Cycle_B_2_00190_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00190_A4 { + Cycle_B_2_00190_A2 a2_0; + int a; + int sum; + Cycle_B_2_00190_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00200B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00200_A1 a1_0 = new Cycle_B_2_00200_A1(); + a1_0.a2_0 = new Cycle_B_2_00200_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00200_A3(); + Cycle_B_2_00200_A4 a4_0 = new Cycle_B_2_00200_A4(); + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0 = a4_0; + a4_0.a2_0 = a1_0.a2_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum); + //System.out.println(nsum); + if (nsum == 16) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00200_A1 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00200_A2 { + Cycle_B_2_00200_A3 a3_0; + int a; + int sum; + Cycle_B_2_00200_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00200_A3 { + Cycle_B_2_00200_A1 a1_0; + Cycle_B_2_00200_A4 a4_0; + int a; + int sum; + Cycle_B_2_00200_A3() { + a1_0 = null; + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a + a1_0.a; + } + } + class Cycle_B_2_00200_A4 { + Cycle_B_2_00200_A2 a2_0; + int a; + int sum; + Cycle_B_2_00200_A4() { + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00210B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00210_A1 a1_0 = new Cycle_B_2_00210_A1(); + a1_0.a2_0 = new Cycle_B_2_00210_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00210_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00210_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00210_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00210_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0 = new Cycle_B_2_00210_A8(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0 = new Cycle_B_2_00210_A9(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00210_A7(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00210_A1 { + Cycle_B_2_00210_A2 a2_0; + int a; + int sum; + Cycle_B_2_00210_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00210_A2 { + Cycle_B_2_00210_A3 a3_0; + int a; + int sum; + Cycle_B_2_00210_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00210_A3 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00210_A4 { + Cycle_B_2_00210_A5 a5_0; + int a; + int sum; + Cycle_B_2_00210_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00210_A5 { + Cycle_B_2_00210_A6 a6_0; + int a; + int sum; + Cycle_B_2_00210_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00210_A6 { + Cycle_B_2_00210_A1 a1_0; + Cycle_B_2_00210_A8 a8_0; + int a; + int sum; + Cycle_B_2_00210_A6() { + a1_0 = null; + a8_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a8_0.a; + } + } + class Cycle_B_2_00210_A8 { + Cycle_B_2_00210_A9 a9_0; + int a; + int sum; + Cycle_B_2_00210_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00210_A9 { + Cycle_B_2_00210_A7 a7_0; + int a; + int sum; + Cycle_B_2_00210_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00210_A7 { + Cycle_B_2_00210_A4 a4_0; + int a; + int sum; + Cycle_B_2_00210_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00220B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00220_A1 a1_0 = new Cycle_B_2_00220_A1(); + a1_0.a2_0 = new Cycle_B_2_00220_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00220_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00220_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00220_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00220_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + a1_0.a8_0 = new Cycle_B_2_00220_A8(); + a1_0.a8_0.a9_0 = new Cycle_B_2_00220_A9(); + a1_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00220_A7(); + a1_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a1_0.a8_0.add(); + a1_0.a8_0.a9_0.add(); + a1_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a1_0.a8_0.sum + a1_0.a8_0.a9_0.sum + a1_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 94) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00220_A1 { + Cycle_B_2_00220_A2 a2_0; + Cycle_B_2_00220_A8 a8_0; + int a; + int sum; + Cycle_B_2_00220_A1() { + a2_0 = null; + a8_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a + a8_0.a; + } + } + class Cycle_B_2_00220_A2 { + Cycle_B_2_00220_A3 a3_0; + int a; + int sum; + Cycle_B_2_00220_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00220_A3 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00220_A4 { + Cycle_B_2_00220_A5 a5_0; + int a; + int sum; + Cycle_B_2_00220_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00220_A5 { + Cycle_B_2_00220_A6 a6_0; + int a; + int sum; + Cycle_B_2_00220_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00220_A6 { + Cycle_B_2_00220_A1 a1_0; + int a; + int sum; + Cycle_B_2_00220_A6() { + a1_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00220_A8 { + Cycle_B_2_00220_A9 a9_0; + int a; + int sum; + Cycle_B_2_00220_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00220_A9 { + Cycle_B_2_00220_A7 a7_0; + int a; + int sum; + Cycle_B_2_00220_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00220_A7 { + Cycle_B_2_00220_A4 a4_0; + int a; + int sum; + Cycle_B_2_00220_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +class ThreadRc_Cycle_Bm_2_00230B extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 97) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00230_A6 { + Cycle_B_2_00230_A1 a1_0; + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00230_A7 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + void add() { + sum = a + a8_0.a; + } + } +} +public class Cycle_Bm_2_00240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00010B A1_00010 = new ThreadRc_Cycle_Bm_2_00010B(); + ThreadRc_Cycle_Bm_2_00010B A2_00010 = new ThreadRc_Cycle_Bm_2_00010B(); + ThreadRc_Cycle_Bm_2_00020B A1_00020 = new ThreadRc_Cycle_Bm_2_00020B(); + ThreadRc_Cycle_Bm_2_00020B A2_00020 = new ThreadRc_Cycle_Bm_2_00020B(); + ThreadRc_Cycle_Bm_2_00030B A1_00030 = new ThreadRc_Cycle_Bm_2_00030B(); + ThreadRc_Cycle_Bm_2_00030B A2_00030 = new ThreadRc_Cycle_Bm_2_00030B(); + ThreadRc_Cycle_Bm_2_00040B A1_00040 = new ThreadRc_Cycle_Bm_2_00040B(); + ThreadRc_Cycle_Bm_2_00040B A2_00040 = new ThreadRc_Cycle_Bm_2_00040B(); + ThreadRc_Cycle_Bm_2_00050B A1_00050 = new ThreadRc_Cycle_Bm_2_00050B(); + ThreadRc_Cycle_Bm_2_00050B A2_00050 = new ThreadRc_Cycle_Bm_2_00050B(); + ThreadRc_Cycle_Bm_2_00060B A1_00060 = new ThreadRc_Cycle_Bm_2_00060B(); + ThreadRc_Cycle_Bm_2_00060B A2_00060 = new ThreadRc_Cycle_Bm_2_00060B(); + ThreadRc_Cycle_Bm_2_00070B A1_00070 = new ThreadRc_Cycle_Bm_2_00070B(); + ThreadRc_Cycle_Bm_2_00070B A2_00070 = new ThreadRc_Cycle_Bm_2_00070B(); + ThreadRc_Cycle_Bm_2_00080B A1_00080 = new ThreadRc_Cycle_Bm_2_00080B(); + ThreadRc_Cycle_Bm_2_00080B A2_00080 = new ThreadRc_Cycle_Bm_2_00080B(); + ThreadRc_Cycle_Bm_2_00090B A1_00090 = new ThreadRc_Cycle_Bm_2_00090B(); + ThreadRc_Cycle_Bm_2_00090B A2_00090 = new ThreadRc_Cycle_Bm_2_00090B(); + ThreadRc_Cycle_Bm_2_00100B A1_00100 = new ThreadRc_Cycle_Bm_2_00100B(); + ThreadRc_Cycle_Bm_2_00100B A2_00100 = new ThreadRc_Cycle_Bm_2_00100B(); + ThreadRc_Cycle_Bm_2_00110B A1_00110 = new ThreadRc_Cycle_Bm_2_00110B(); + ThreadRc_Cycle_Bm_2_00110B A2_00110 = new ThreadRc_Cycle_Bm_2_00110B(); + ThreadRc_Cycle_Bm_2_00120B A1_00120 = new ThreadRc_Cycle_Bm_2_00120B(); + ThreadRc_Cycle_Bm_2_00120B A2_00120 = new ThreadRc_Cycle_Bm_2_00120B(); + ThreadRc_Cycle_Bm_2_00130B A1_00130 = new ThreadRc_Cycle_Bm_2_00130B(); + ThreadRc_Cycle_Bm_2_00130B A2_00130 = new ThreadRc_Cycle_Bm_2_00130B(); + ThreadRc_Cycle_Bm_2_00140B A1_00140 = new ThreadRc_Cycle_Bm_2_00140B(); + ThreadRc_Cycle_Bm_2_00140B A2_00140 = new ThreadRc_Cycle_Bm_2_00140B(); + ThreadRc_Cycle_Bm_2_00150B A1_00150 = new ThreadRc_Cycle_Bm_2_00150B(); + ThreadRc_Cycle_Bm_2_00150B A2_00150 = new ThreadRc_Cycle_Bm_2_00150B(); + ThreadRc_Cycle_Bm_2_00160B A1_00160 = new ThreadRc_Cycle_Bm_2_00160B(); + ThreadRc_Cycle_Bm_2_00160B A2_00160 = new ThreadRc_Cycle_Bm_2_00160B(); + ThreadRc_Cycle_Bm_2_00170B A1_00170 = new ThreadRc_Cycle_Bm_2_00170B(); + ThreadRc_Cycle_Bm_2_00170B A2_00170 = new ThreadRc_Cycle_Bm_2_00170B(); + ThreadRc_Cycle_Bm_2_00180B A1_00180 = new ThreadRc_Cycle_Bm_2_00180B(); + ThreadRc_Cycle_Bm_2_00180B A2_00180 = new ThreadRc_Cycle_Bm_2_00180B(); + ThreadRc_Cycle_Bm_2_00190B A1_00190 = new ThreadRc_Cycle_Bm_2_00190B(); + ThreadRc_Cycle_Bm_2_00190B A2_00190 = new ThreadRc_Cycle_Bm_2_00190B(); + ThreadRc_Cycle_Bm_2_00200B A1_00200 = new ThreadRc_Cycle_Bm_2_00200B(); + ThreadRc_Cycle_Bm_2_00200B A2_00200 = new ThreadRc_Cycle_Bm_2_00200B(); + ThreadRc_Cycle_Bm_2_00210B A1_00210 = new ThreadRc_Cycle_Bm_2_00210B(); + ThreadRc_Cycle_Bm_2_00210B A2_00210 = new ThreadRc_Cycle_Bm_2_00210B(); + ThreadRc_Cycle_Bm_2_00220B A1_00220 = new ThreadRc_Cycle_Bm_2_00220B(); + ThreadRc_Cycle_Bm_2_00220B A2_00220 = new ThreadRc_Cycle_Bm_2_00220B(); + ThreadRc_Cycle_Bm_2_00230B A1_00230 = new ThreadRc_Cycle_Bm_2_00230B(); + ThreadRc_Cycle_Bm_2_00230B A2_00230 = new ThreadRc_Cycle_Bm_2_00230B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + A1_00190.start(); + A2_00190.start(); + A1_00200.start(); + A2_00200.start(); + A1_00210.start(); + A2_00210.start(); + A1_00220.start(); + A2_00220.start(); + A1_00230.start(); + A2_00230.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + A1_00190.join(); + A2_00190.join(); + A1_00200.join(); + A2_00200.join(); + A1_00210.join(); + A2_00210.join(); + A1_00220.join(); + A2_00220.join(); + A1_00230.join(); + A2_00230.join(); + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check() && A1_00190.check() && A2_00190.check() && A1_00200.check() && A2_00200.check() && A1_00210.check() && A2_00210.check() && A1_00220.check() && A2_00220.check() && A1_00230.check() && A2_00230.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/expected.txt b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f33a8592d2316dcaefb376e2e77d12a354a4918e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/expected.txt @@ -0,0 +1,4 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/test.cfg b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fc45d3d6df9c19af6f875e92d2c66066c7d5b525 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0204-rc-function-RC_Thread01-Cycle_Bm_2_00240/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_00240) +run(Cycle_Bm_2_00240,EXPECTNUM=4) diff --git a/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java new file mode 100755 index 0000000000000000000000000000000000000000..ed5f86864ecd03b0dde8f85d8169dc36a15c8408 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/Cycle_Bm_2_10240.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Cycle_Bm_2_10240 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00240_A1 a1_main = new Cycle_B_2_00240_A1("a1_main"); + a1_main.a2_0 = new Cycle_B_2_00240_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_B_2_00240_A3("a3_0"); + a1_main.a2_0.a4_0 = new Cycle_B_2_00240_A4("a4_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a4_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a4_0.a1_0 = a1_main; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a4_0.add(); + int result = a1_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a4_0.sum; + //System.out.println("RC-Testing_Result="+result); + Cycle_B_2_00240_B1 b1_0 = new Cycle_B_2_00240_B1(); + b1_0.a3_0 = new Cycle_B_2_00240_A3("a3_b1"); + b1_0.b2_0 = new Cycle_B_2_00240_B2(); + b1_0.c2_0 = new Nocycle_B_2_00240_C2("c2_b1"); + b1_0.b2_0.b1_0 = b1_0; + b1_0.add(); + b1_0.b2_0.add(); + int nsum = (b1_0.sum + b1_0.b2_0.sum); + // System.out.println(nsum); + Nocycle_B_2_00240_C1 c1_main = new Nocycle_B_2_00240_C1("c1_main"); + c1_main.c2_0 = new Nocycle_B_2_00240_C2("c2_0"); + c1_main.add(); + c1_main.c2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",c1_main.sum+c1_main.b1_0.sum); + int result2 = c1_main.sum + c1_main.c2_0.sum; + //System.out.println("RC-Testing_Result="+result2); + if (result == 1124 && nsum == 310 && result2 == 704) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00240_A1 { + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00240_A2 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } + class Cycle_B_2_00240_A3 { + Cycle_B_2_00240_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A3(String strObjectName) { + a1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00240_A4 { + Cycle_B_2_00240_A1 a1_0; + Cycle_B_2_00240_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_B_2_00240_A4(String strObjectName) { + a2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a; + } + } + class Cycle_B_2_00240_B1 { + Cycle_B_2_00240_A3 a3_0; + Cycle_B_2_00240_B2 b2_0; + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + Cycle_B_2_00240_B1() { + a3_0 = null; + b2_0 = null; + c2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a3_0.a + b2_0.a + c2_0.a; + } + } + class Cycle_B_2_00240_B2 { + Cycle_B_2_00240_B1 b1_0; + int a; + int sum; + Cycle_B_2_00240_B2() { + b1_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_B_2_00240_C1 { + Nocycle_B_2_00240_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_B_2_00240_C1(String strObjectName) { + c2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + c2_0.a; + } + } + class Nocycle_B_2_00240_C2 { + int a; + int sum; + String strObjectName; + Nocycle_B_2_00240_C2(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} +public class Cycle_Bm_2_10240 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_10240 A1_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A2_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A3_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A4_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A5_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + ThreadRc_Cycle_Bm_2_10240 A6_Cycle_Bm_2_10240 = new ThreadRc_Cycle_Bm_2_10240(); + A1_Cycle_Bm_2_10240.start(); + A2_Cycle_Bm_2_10240.start(); + A3_Cycle_Bm_2_10240.start(); + A4_Cycle_Bm_2_10240.start(); + A5_Cycle_Bm_2_10240.start(); + A6_Cycle_Bm_2_10240.start(); + try { + A1_Cycle_Bm_2_10240.join(); + A2_Cycle_Bm_2_10240.join(); + A3_Cycle_Bm_2_10240.join(); + A4_Cycle_Bm_2_10240.join(); + A5_Cycle_Bm_2_10240.join(); + A6_Cycle_Bm_2_10240.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_10240.check() && A2_Cycle_Bm_2_10240.check() && A3_Cycle_Bm_2_10240.check() && A4_Cycle_Bm_2_10240.check() && A5_Cycle_Bm_2_10240.check() && A6_Cycle_Bm_2_10240.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/expected.txt b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f33a8592d2316dcaefb376e2e77d12a354a4918e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/expected.txt @@ -0,0 +1,4 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/test.cfg b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9e7a990e2cfbf7b88d6eda6b1648876d26de067a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0205-rc-function-RC_Thread01-Cycle_Bm_2_10240/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Cycle_Bm_2_10240) +run(Cycle_Bm_2_10240,EXPECTNUM=4) diff --git a/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..261f35e5629f06e027b83b5499d39e6235d71870 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/Nocycle_am_00010.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00010 extends Thread { + private boolean checkout; + public void run() { + Nocycle_am_00010_A1 a1_main = new Nocycle_am_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_am_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + // System.out.println("RC-Testing_Result_Thread="+result); + if (result == 704) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_am_00010_A1 { + Nocycle_am_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_am_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_am_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_am_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00010 t_00010 = new ThreadRc_00010(); + t_00010.start(); + ThreadRc_00010 t_00020 = new ThreadRc_00010(); + t_00020.start(); + ThreadRc_00010 t_00030 = new ThreadRc_00010(); + t_00030.start(); + ThreadRc_00010 t_00040 = new ThreadRc_00010(); + t_00040.start(); + ThreadRc_00010 t_00050 = new ThreadRc_00010(); + t_00050.start(); + ThreadRc_00010 t_00060 = new ThreadRc_00010(); + t_00060.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + t_00040.join(); + t_00050.join(); + t_00060.join(); + } catch (InterruptedException e) { + } + if (t_00010.check() == true && t_00060.check() == true && t_00020.check() == true && t_00030.check() == true && t_00040.check() == true && t_00050.check() == true) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/expected.txt b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/test.cfg b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7e601039bbad39dd851465e8259bba9741159908 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0206-rc-function-RC_Thread01-Nocycle_am_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00010) +run(Nocycle_am_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..fe9ec43b918656d2393fb96cfe042ca983f3a039 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/Nocycle_am_00020.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00020 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1310) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00020 A1_00020 = new ThreadRc_00020(); + ThreadRc_00020 A2_00020 = new ThreadRc_00020(); + ThreadRc_00020 A3_00020 = new ThreadRc_00020(); + ThreadRc_00020 A4_00020 = new ThreadRc_00020(); + ThreadRc_00020 A5_00020 = new ThreadRc_00020(); + ThreadRc_00020 A6_00020 = new ThreadRc_00020(); + A1_00020.start(); + A2_00020.start(); + A3_00020.start(); + A4_00020.start(); + A5_00020.start(); + A6_00020.start(); + try { + A1_00020.join(); + A2_00020.join(); + A3_00020.join(); + A4_00020.join(); + A5_00020.join(); + A6_00020.join(); + } catch (InterruptedException e) { + } + if (A1_00020.check() && A2_00020.check() && A3_00020.check() && A4_00020.check() && A5_00020.check() && A6_00020.check()) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/expected.txt b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/test.cfg b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8e72b956fba69ebdbece5529f652abfc705807fc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0207-rc-function-RC_Thread01-Nocycle_am_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00020) +run(Nocycle_am_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..6f01a92598d09de4dbf22a6725c482ad0d2b9d64 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/Nocycle_am_00030.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00030 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1919) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00030 A1_00030 = new ThreadRc_00030(); + ThreadRc_00030 A2_00030 = new ThreadRc_00030(); + ThreadRc_00030 A3_00030 = new ThreadRc_00030(); + ThreadRc_00030 A4_00030 = new ThreadRc_00030(); + ThreadRc_00030 A5_00030 = new ThreadRc_00030(); + ThreadRc_00030 A6_00030 = new ThreadRc_00030(); + A1_00030.start(); + A2_00030.start(); + A3_00030.start(); + A4_00030.start(); + A5_00030.start(); + A6_00030.start(); + try { + A1_00030.join(); + A2_00030.join(); + A3_00030.join(); + A4_00030.join(); + A5_00030.join(); + A6_00030.join(); + } catch (InterruptedException e) { + } + if (A1_00030.check() && A2_00030.check() && A3_00030.check() && A4_00030.check() && A5_00030.check() && A6_00030.check()) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/expected.txt b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/test.cfg b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..759471b719d774ae233d725cfedf4b116a223803 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0208-rc-function-RC_Thread01-Nocycle_am_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00030) +run(Nocycle_am_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java new file mode 100755 index 0000000000000000000000000000000000000000..31e6323670c08023821433a646d76838be9c1830 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/Nocycle_am_00040.java @@ -0,0 +1,257 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00040 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b5_0.sum+a1_main.b6_0.sum+a1_main.b7_0.sum+a1_main.b8_0.sum+a1_main.b9_0.sum+a1_main.b10_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 6266) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } + } + class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00040 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00040 A1_00040 = new ThreadRc_00040(); + ThreadRc_00040 A2_00040 = new ThreadRc_00040(); + ThreadRc_00040 A3_00040 = new ThreadRc_00040(); + ThreadRc_00040 A4_00040 = new ThreadRc_00040(); + ThreadRc_00040 A5_00040 = new ThreadRc_00040(); + ThreadRc_00040 A6_00040 = new ThreadRc_00040(); + A1_00040.start(); + A2_00040.start(); + A3_00040.start(); + A4_00040.start(); + A5_00040.start(); + A6_00040.start(); + try { + A1_00040.join(); + A2_00040.join(); + A3_00040.join(); + A4_00040.join(); + A5_00040.join(); + A6_00040.join(); + } catch (InterruptedException e) { + } + if (A1_00040.check() && A2_00040.check() && A3_00040.check() && A4_00040.check() && A5_00040.check() && A6_00040.check()) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/expected.txt b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/test.cfg b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..254484311df27d8f715da4be59a9493b5c7b29e1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0209-rc-function-RC_Thread01-Nocycle_am_00040/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00040) +run(Nocycle_am_00040,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java new file mode 100755 index 0000000000000000000000000000000000000000..ca1d98b02e7b7160a090a99913c798fe778e96bb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/Nocycle_am_00050.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00050 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 5048) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00050 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00050 A1_00050 = new ThreadRc_00050(); + ThreadRc_00050 A2_00050 = new ThreadRc_00050(); + ThreadRc_00050 A3_00050 = new ThreadRc_00050(); + ThreadRc_00050 A4_00050 = new ThreadRc_00050(); + ThreadRc_00050 A5_00050 = new ThreadRc_00050(); + ThreadRc_00050 A6_00050 = new ThreadRc_00050(); + A1_00050.start(); + A2_00050.start(); + A3_00050.start(); + A4_00050.start(); + A5_00050.start(); + A6_00050.start(); + try { + A1_00050.join(); + A2_00050.join(); + A3_00050.join(); + A4_00050.join(); + A5_00050.join(); + A6_00050.join(); + } catch (InterruptedException e) { + } + if (A1_00050.check() && A2_00050.check() && A3_00050.check() && A4_00050.check() && A5_00050.check() && A6_00050.check()) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/expected.txt b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/test.cfg b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3230e4269f4b9ec2c7ad1320756be1b749e78d91 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0210-rc-function-RC_Thread01-Nocycle_am_00050/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00050) +run(Nocycle_am_00050,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java new file mode 100755 index 0000000000000000000000000000000000000000..40d389e889303baeef1285448715ca4928eb7656 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/Nocycle_am_00060.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00060 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c1_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b2_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 5047) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00060 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00060 A1_00060 = new ThreadRc_00060(); + ThreadRc_00060 A2_00060 = new ThreadRc_00060(); + ThreadRc_00060 A3_00060 = new ThreadRc_00060(); + ThreadRc_00060 A4_00060 = new ThreadRc_00060(); + ThreadRc_00060 A5_00060 = new ThreadRc_00060(); + ThreadRc_00060 A6_00060 = new ThreadRc_00060(); + ThreadRc_00060 A7_00060 = new ThreadRc_00060(); + ThreadRc_00060 A8_00060 = new ThreadRc_00060(); + ThreadRc_00060 A9_00060 = new ThreadRc_00060(); + ThreadRc_00060 A10_00060 = new ThreadRc_00060(); + A1_00060.start(); + A2_00060.start(); + A3_00060.start(); + A4_00060.start(); + A5_00060.start(); + A6_00060.start(); + A7_00060.start(); + A8_00060.start(); + A9_00060.start(); + A10_00060.start(); + try { + A1_00060.join(); + A2_00060.join(); + A3_00060.join(); + A4_00060.join(); + A5_00060.join(); + A6_00060.join(); + A7_00060.join(); + A8_00060.join(); + A9_00060.join(); + A10_00060.join(); + } catch (InterruptedException e) { + } + if (A1_00060.check() && A2_00060.check() && A3_00060.check() && A4_00060.check() && A5_00060.check() && A6_00060.check() && A7_00060.check() && A8_00060.check() && A9_00060.check() && A10_00060.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/expected.txt b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/test.cfg b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9f376e5e67db66a3c38bcddb5b78ade9d0c0ea64 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0211-rc-function-RC_Thread01-Nocycle_am_00060/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00060) +run(Nocycle_am_00060,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java new file mode 100755 index 0000000000000000000000000000000000000000..8e422c30f9031cee859a241cfb237721639d02ac --- /dev/null +++ b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/Nocycle_am_00070.java @@ -0,0 +1,203 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00070 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5045) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00070 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00070 A1_00070 = new ThreadRc_00070(); + ThreadRc_00070 A2_00070 = new ThreadRc_00070(); + ThreadRc_00070 A3_00070 = new ThreadRc_00070(); + ThreadRc_00070 A4_00070 = new ThreadRc_00070(); + ThreadRc_00070 A5_00070 = new ThreadRc_00070(); + ThreadRc_00070 A6_00070 = new ThreadRc_00070(); + A1_00070.start(); + A2_00070.start(); + A3_00070.start(); + A4_00070.start(); + A5_00070.start(); + A6_00070.start(); + try { + A1_00070.join(); + A2_00070.join(); + A3_00070.join(); + A4_00070.join(); + A5_00070.join(); + A6_00070.join(); + } catch (InterruptedException e) { + } + if (A1_00070.check() && A2_00070.check() && A3_00070.check() && A4_00070.check() && A5_00070.check() && A6_00070.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/expected.txt b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/test.cfg b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9ca58824bd51064d868eeb271258a11b960caec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0212-rc-function-RC_Thread01-Nocycle_am_00070/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00070) +run(Nocycle_am_00070,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java new file mode 100755 index 0000000000000000000000000000000000000000..d5fbe4250c271088b55db0a9eb6046744cff6c57 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/Nocycle_am_00080.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00080 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result_Thread1="+result); + if (result == 1406) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00080 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00080 A1_00080 = new ThreadRc_00080(); + ThreadRc_00080 A2_00080 = new ThreadRc_00080(); + ThreadRc_00080 A3_00080 = new ThreadRc_00080(); + ThreadRc_00080 A4_00080 = new ThreadRc_00080(); + ThreadRc_00080 A5_00080 = new ThreadRc_00080(); + ThreadRc_00080 A6_00080 = new ThreadRc_00080(); + A1_00080.start(); + A2_00080.start(); + A3_00080.start(); + A4_00080.start(); + A5_00080.start(); + A6_00080.start(); + try { + A1_00080.join(); + A2_00080.join(); + A3_00080.join(); + A4_00080.join(); + A5_00080.join(); + A6_00080.join(); + } catch (InterruptedException e) { + } + if (A1_00080.check() && A2_00080.check() && A3_00080.check() && A4_00080.check() && A5_00080.check() && A6_00080.check()) + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/expected.txt b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/test.cfg b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2d8097c446e24194799f295262221e917ef658f2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0213-rc-function-RC_Thread01-Nocycle_am_00080/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00080) +run(Nocycle_am_00080,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java new file mode 100755 index 0000000000000000000000000000000000000000..37b0f6a62c4cdfb944972177eb813dc7aed6a2d3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/Nocycle_am_00090.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00090 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2308) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00090 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00090 A1_00090 = new ThreadRc_00090(); + ThreadRc_00090 A2_00090 = new ThreadRc_00090(); + ThreadRc_00090 A3_00090 = new ThreadRc_00090(); + ThreadRc_00090 A4_00090 = new ThreadRc_00090(); + ThreadRc_00090 A5_00090 = new ThreadRc_00090(); + ThreadRc_00090 A6_00090 = new ThreadRc_00090(); + A1_00090.start(); + A2_00090.start(); + A3_00090.start(); + A4_00090.start(); + A5_00090.start(); + A6_00090.start(); + try { + A1_00090.join(); + A2_00090.join(); + A3_00090.join(); + A4_00090.join(); + A5_00090.join(); + A6_00090.join(); + } catch (InterruptedException e) { + } + if (A1_00090.check() && A2_00090.check() && A3_00090.check() && A4_00090.check() && A5_00090.check() && A6_00090.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/expected.txt b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/test.cfg b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f5a0be96d30dcafc9678c636f5aaf8780e78789 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0214-rc-function-RC_Thread01-Nocycle_am_00090/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00090) +run(Nocycle_am_00090,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java new file mode 100755 index 0000000000000000000000000000000000000000..df1619ec3e46f40681ccaccc5ea6f9d10d323454 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/Nocycle_am_00100.java @@ -0,0 +1,249 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00100 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); +// System.out.printf("a=%d\n",a1_main.sum); +// System.out.printf("b=%d\n",a1_main.b1_0.sum); +// System.out.printf("c=%d\n",a1_main.b1_0.c1_0.sum); +// System.out.printf("d=%d\n",a1_main.b1_0.c1_0.d1_0.sum); +// System.out.printf("e=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.sum); +// System.out.printf("f=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum); +// System.out.printf("g=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum); +// System.out.printf("h=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum); +// System.out.printf("i=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum); +// System.out.printf("j=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 11920) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } + } + class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } + } + class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } + } + class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } + } + class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } + } + class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } + } + class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00100 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00100 A1_00100 = new ThreadRc_00100(); + ThreadRc_00100 A2_00100 = new ThreadRc_00100(); + ThreadRc_00100 A3_00100 = new ThreadRc_00100(); + ThreadRc_00100 A4_00100 = new ThreadRc_00100(); + ThreadRc_00100 A5_00100 = new ThreadRc_00100(); + ThreadRc_00100 A6_00100 = new ThreadRc_00100(); + A1_00100.start(); + A2_00100.start(); + A3_00100.start(); + A4_00100.start(); + A5_00100.start(); + A6_00100.start(); + try { + A1_00100.join(); + A2_00100.join(); + A3_00100.join(); + A4_00100.join(); + A5_00100.join(); + A6_00100.join(); + } catch (InterruptedException e) { + } + if (A1_00100.check() && A2_00100.check() && A3_00100.check() && A4_00100.check() && A5_00100.check() && A6_00100.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/expected.txt b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/test.cfg b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f0efa24700061ffcf076ee5d46c04541ce228e1a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0215-rc-function-RC_Thread01-Nocycle_am_00100/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00100) +run(Nocycle_am_00100,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java new file mode 100755 index 0000000000000000000000000000000000000000..2cbc03aa6cf956ffcfdd32b87dc7191180bca1b2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/Nocycle_am_00110.java @@ -0,0 +1,292 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00110 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b3_0.c1_0.sum+a1_main.b4_0.c3_0.sum+a1_main.b1_0.d1_0.sum+a1_main.b3_0.c1_0.d2_0.sum+a1_main.b2_0.c2_0.d3_0.sum+a1_main.b2_0.c2_0.d4_0.sum+a1_main.d5_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 9881) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } + } + class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c2_0.a; + } + } + class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c3_0.a; + } + } + class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d3_0.a + d4_0.a; + } + } + class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00110 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00110 A1_00110 = new ThreadRc_00110(); + ThreadRc_00110 A2_00110 = new ThreadRc_00110(); + ThreadRc_00110 A3_00110 = new ThreadRc_00110(); + ThreadRc_00110 A4_00110 = new ThreadRc_00110(); + ThreadRc_00110 A5_00110 = new ThreadRc_00110(); + ThreadRc_00110 A6_00110 = new ThreadRc_00110(); + A1_00110.start(); + A2_00110.start(); + A3_00110.start(); + A4_00110.start(); + A5_00110.start(); + A6_00110.start(); + try { + A1_00110.join(); + A2_00110.join(); + A3_00110.join(); + A4_00110.join(); + A5_00110.join(); + A6_00110.join(); + } catch (InterruptedException e) { + } + if (A1_00110.check() && A2_00110.check() && A3_00110.check() && A4_00110.check() && A5_00110.check() && A6_00110.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/expected.txt b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/test.cfg b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7ce0854f03d3755c1a16f7bd0706df80d995ff8f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0216-rc-function-RC_Thread01-Nocycle_am_00110/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00110) +run(Nocycle_am_00110,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java new file mode 100755 index 0000000000000000000000000000000000000000..24083edb4b6bd9da23ea1d61958fc509e1bf1581 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/Nocycle_am_00120.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00120 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1007) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00120 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00120 A1_00120 = new ThreadRc_00120(); + ThreadRc_00120 A2_00120 = new ThreadRc_00120(); + ThreadRc_00120 A3_00120 = new ThreadRc_00120(); + ThreadRc_00120 A4_00120 = new ThreadRc_00120(); + ThreadRc_00120 A5_00120 = new ThreadRc_00120(); + ThreadRc_00120 A6_00120 = new ThreadRc_00120(); + A1_00120.start(); + A2_00120.start(); + A3_00120.start(); + A4_00120.start(); + A5_00120.start(); + A6_00120.start(); + try { + A1_00120.join(); + A2_00120.join(); + A3_00120.join(); + A4_00120.join(); + A5_00120.join(); + A6_00120.join(); + } catch (InterruptedException e) { + } + if (A1_00120.check() && A2_00120.check() && A3_00120.check() && A4_00120.check() && A5_00120.check() && A6_00120.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/expected.txt b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/test.cfg b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a828539576d19a7ad670943f41558efc16edb0f9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0217-rc-function-RC_Thread01-Nocycle_am_00120/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00120) +run(Nocycle_am_00120,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java new file mode 100755 index 0000000000000000000000000000000000000000..006cfaef45a66b2e7d654ccd995f5fe06ee87c0d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/Nocycle_am_00130.java @@ -0,0 +1,275 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00130 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a5_main.sum+a6_main.sum+a7_main.sum+a8_main.sum+a9_main.sum+a10_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 3467) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00130 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00130 A1_00130 = new ThreadRc_00130(); + ThreadRc_00130 A2_00130 = new ThreadRc_00130(); + ThreadRc_00130 A3_00130 = new ThreadRc_00130(); + ThreadRc_00130 A4_00130 = new ThreadRc_00130(); + ThreadRc_00130 A5_00130 = new ThreadRc_00130(); + ThreadRc_00130 A6_00130 = new ThreadRc_00130(); + A1_00130.start(); + A2_00130.start(); + A3_00130.start(); + A4_00130.start(); + A5_00130.start(); + A6_00130.start(); + try { + A1_00130.join(); + A2_00130.join(); + A3_00130.join(); + A4_00130.join(); + A5_00130.join(); + A6_00130.join(); + } catch (InterruptedException e) { + } + if (A1_00130.check() && A2_00130.check() && A3_00130.check() && A4_00130.check() && A5_00130.check() && A6_00130.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/expected.txt b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/test.cfg b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c32f88a4cec3e7f01f743902a3ae312b332c1300 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0218-rc-function-RC_Thread01-Nocycle_am_00130/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00130) +run(Nocycle_am_00130,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java new file mode 100755 index 0000000000000000000000000000000000000000..a61a8652a975fcdf5f3ed55156c1bf942dfd4aa3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/Nocycle_am_00140.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00140 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1613) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00140 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00140 A1_00140 = new ThreadRc_00140(); + ThreadRc_00140 A2_00140 = new ThreadRc_00140(); + ThreadRc_00140 A3_00140 = new ThreadRc_00140(); + ThreadRc_00140 A4_00140 = new ThreadRc_00140(); + ThreadRc_00140 A5_00140 = new ThreadRc_00140(); + ThreadRc_00140 A6_00140 = new ThreadRc_00140(); + A1_00140.start(); + A2_00140.start(); + A3_00140.start(); + A4_00140.start(); + A5_00140.start(); + A6_00140.start(); + try { + A1_00140.join(); + A2_00140.join(); + A3_00140.join(); + A4_00140.join(); + A5_00140.join(); + A6_00140.join(); + } catch (InterruptedException e) { + } + if (A1_00140.check() && A2_00140.check() && A3_00140.check() && A4_00140.check() && A5_00140.check() && A6_00140.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/expected.txt b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/test.cfg b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..43d388e04607503f3b66afa2fb12f984156c6305 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0219-rc-function-RC_Thread01-Nocycle_am_00140/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00140) +run(Nocycle_am_00140,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java new file mode 100755 index 0000000000000000000000000000000000000000..5cc1f34024975cbfab7187f77a58d1c7a478076a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/Nocycle_am_00150.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00150 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00150 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00150 A1_00150 = new ThreadRc_00150(); + ThreadRc_00150 A2_00150 = new ThreadRc_00150(); + ThreadRc_00150 A3_00150 = new ThreadRc_00150(); + ThreadRc_00150 A4_00150 = new ThreadRc_00150(); + ThreadRc_00150 A5_00150 = new ThreadRc_00150(); + ThreadRc_00150 A6_00150 = new ThreadRc_00150(); + A1_00150.start(); + A2_00150.start(); + A3_00150.start(); + A4_00150.start(); + A5_00150.start(); + A6_00150.start(); + try { + A1_00150.join(); + A2_00150.join(); + A3_00150.join(); + A4_00150.join(); + A5_00150.join(); + A6_00150.join(); + } catch (InterruptedException e) { + } + if (A1_00150.check() && A2_00150.check() && A3_00150.check() && A4_00150.check() && A5_00150.check() && A6_00150.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/expected.txt b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/test.cfg b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c8cd8300396ddc1c863e871e55b961aead8e509f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0220-rc-function-RC_Thread01-Nocycle_am_00150/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00150) +run(Nocycle_am_00150,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java new file mode 100755 index 0000000000000000000000000000000000000000..87a771127917afadb9609cc7a9ad00162ad488df --- /dev/null +++ b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/Nocycle_am_00160.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00160 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2828) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00160 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00160 A1_00160 = new ThreadRc_00160(); + ThreadRc_00160 A2_00160 = new ThreadRc_00160(); + ThreadRc_00160 A3_00160 = new ThreadRc_00160(); + ThreadRc_00160 A4_00160 = new ThreadRc_00160(); + ThreadRc_00160 A5_00160 = new ThreadRc_00160(); + ThreadRc_00160 A6_00160 = new ThreadRc_00160(); + A1_00160.start(); + A2_00160.start(); + A3_00160.start(); + A4_00160.start(); + A5_00160.start(); + A6_00160.start(); + try { + A1_00160.join(); + A2_00160.join(); + A3_00160.join(); + A4_00160.join(); + A5_00160.join(); + A6_00160.join(); + } catch (InterruptedException e) { + } + if (A1_00160.check() && A2_00160.check() && A3_00160.check() && A4_00160.check() && A5_00160.check() && A6_00160.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/expected.txt b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/test.cfg b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a71ef970c35741aa3a586a7be262995338232a18 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0221-rc-function-RC_Thread01-Nocycle_am_00160/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00160) +run(Nocycle_am_00160,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java new file mode 100755 index 0000000000000000000000000000000000000000..6613f20414c8fedb95273f583f6add03057c7e04 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/Nocycle_am_00170.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00170 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 4046) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00170 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00170 A1_00170 = new ThreadRc_00170(); + ThreadRc_00170 A2_00170 = new ThreadRc_00170(); + ThreadRc_00170 A3_00170 = new ThreadRc_00170(); + ThreadRc_00170 A4_00170 = new ThreadRc_00170(); + ThreadRc_00170 A5_00170 = new ThreadRc_00170(); + ThreadRc_00170 A6_00170 = new ThreadRc_00170(); + A1_00170.start(); + A2_00170.start(); + A3_00170.start(); + A4_00170.start(); + A5_00170.start(); + A6_00170.start(); + try { + A1_00170.join(); + A2_00170.join(); + A3_00170.join(); + A4_00170.join(); + A5_00170.join(); + A6_00170.join(); + } catch (InterruptedException e) { + } + if (A1_00170.check() && A2_00170.check() && A3_00170.check() && A4_00170.check() && A5_00170.check() && A6_00170.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/expected.txt b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/test.cfg b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ea6e1cb71274296fe5b2995f676ca50fd8ae34d2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0222-rc-function-RC_Thread01-Nocycle_am_00170/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00170) +run(Nocycle_am_00170,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java new file mode 100755 index 0000000000000000000000000000000000000000..2cb5802f3230cd712799c466856ef0fd5698f34a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/Nocycle_am_00180.java @@ -0,0 +1,329 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00180 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); +// System.out.printf("a1_main.sum=%d\n",a1_main.sum); +// System.out.printf("a2_main.sum=%d\n",a2_main.sum); +// System.out.printf("a3_main.sum=%d\n",a3_main.sum); +// System.out.printf("a4_main.sum=%d\n",a4_main.sum); +// System.out.printf("a1_main.b1_0.sum=%d\n",a1_main.b1_0.sum); +// System.out.printf("a2_main.b2_0.sum=%d\n",a2_main.b2_0.sum); +// System.out.printf("a4_main.b3_0.sum=%d\n",a4_main.b3_0.sum); +// System.out.printf("a2_main.b2_0.c1_0.sum=%d\n",a2_main.b2_0.c1_0.sum); +// System.out.printf("a3_main.c2_0.sum=%d\n",a3_main.c2_0.sum); +// System.out.printf("a1_main.d1_0.sum=%d\n",a1_main.d1_0.sum); +// System.out.printf("a3_main.c2_0.d2_0.sum=%d\n",a3_main.c2_0.d2_0.sum); +// System.out.printf("a3_main.c2_0.d3_0.sum=%d\n",a3_main.c2_0.d3_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a2_main.b2_0.sum+a4_main.b3_0.sum+a2_main.b2_0.c1_0.sum+a3_main.c2_0.sum+a1_main.d1_0.sum+a3_main.c2_0.d2_0.sum+a3_main.c2_0.d3_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 9260) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00180 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00180 A1_00180 = new ThreadRc_00180(); + ThreadRc_00180 A2_00180 = new ThreadRc_00180(); + ThreadRc_00180 A3_00180 = new ThreadRc_00180(); + ThreadRc_00180 A4_00180 = new ThreadRc_00180(); + ThreadRc_00180 A5_00180 = new ThreadRc_00180(); + ThreadRc_00180 A6_00180 = new ThreadRc_00180(); + A1_00180.start(); + A2_00180.start(); + A3_00180.start(); + A4_00180.start(); + A5_00180.start(); + A6_00180.start(); + try { + A1_00180.join(); + A2_00180.join(); + A3_00180.join(); + A4_00180.join(); + A5_00180.join(); + A6_00180.join(); + } catch (InterruptedException e) { + } + if (A1_00180.check() && A2_00180.check() && A3_00180.check() && A4_00180.check() && A5_00180.check() && A6_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/expected.txt b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/test.cfg b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a118a679647bdc9647f1753840841b9bab729f6d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0223-rc-function-RC_Thread01-Nocycle_am_00180/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00180) +run(Nocycle_am_00180,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java new file mode 100755 index 0000000000000000000000000000000000000000..aef94bb0abd7954a2a87c3185f280bc97a5261a9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/Nocycle_am_00190.java @@ -0,0 +1,2676 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_00010B extends Thread { + private boolean checkout; + public void run() { + Nocycle_am_00010_A1 a1_main = new Nocycle_am_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_am_00010_B1("b1_0"); + a1_main.add(); + a1_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 704) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_am_00010_A1 { + Nocycle_am_00010_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_am_00010_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_A1_"+strObjectName); +// } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_am_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_am_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + // protected void finalize() throws java.lang.Throwable { +// System.out.println("RC-Testing_Destruction_B1_"+strObjectName); +// } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00020B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00020_A1 a1_main = new Nocycle_a_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00020_B2("b2_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1310) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00020_A1 { + Nocycle_a_00020_B1 b1_0; + Nocycle_a_00020_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00030B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00030_A1 a1_main = new Nocycle_a_00030_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00030_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00030_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00030_B3("b3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1919) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00030_A1 { + Nocycle_a_00030_B1 b1_0; + Nocycle_a_00030_B2 b2_0; + Nocycle_a_00030_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00030_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00030_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00030_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00030_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00030_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00040B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00040_A1 a1_main = new Nocycle_a_00040_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00040_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00040_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00040_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00040_B4("b4_0"); + a1_main.b5_0 = new Nocycle_a_00040_B5("b5_0"); + a1_main.b6_0 = new Nocycle_a_00040_B6("b6_0"); + a1_main.b7_0 = new Nocycle_a_00040_B7("b7_0"); + a1_main.b8_0 = new Nocycle_a_00040_B8("b8_0"); + a1_main.b9_0 = new Nocycle_a_00040_B9("b9_0"); + a1_main.b10_0 = new Nocycle_a_00040_B10("b10_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b5_0.add(); + a1_main.b6_0.add(); + a1_main.b7_0.add(); + a1_main.b8_0.add(); + a1_main.b9_0.add(); + a1_main.b10_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b5_0.sum+a1_main.b6_0.sum+a1_main.b7_0.sum+a1_main.b8_0.sum+a1_main.b9_0.sum+a1_main.b10_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b5_0.sum + a1_main.b6_0.sum + a1_main.b7_0.sum + a1_main.b8_0.sum + a1_main.b9_0.sum + a1_main.b10_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 6266) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00040_A1 { + Nocycle_a_00040_B1 b1_0; + Nocycle_a_00040_B2 b2_0; + Nocycle_a_00040_B3 b3_0; + Nocycle_a_00040_B4 b4_0; + Nocycle_a_00040_B5 b5_0; + Nocycle_a_00040_B6 b6_0; + Nocycle_a_00040_B7 b7_0; + Nocycle_a_00040_B8 b8_0; + Nocycle_a_00040_B9 b9_0; + Nocycle_a_00040_B10 b10_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00040_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + b5_0 = null; + b6_0 = null; + b7_0 = null; + b8_0 = null; + b9_0 = null; + b10_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + b5_0.a + b6_0.a + b7_0.a + b8_0.a + b9_0.a + b10_0.a; + } + } + class Nocycle_a_00040_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B5(String strObjectName) { + a = 205; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B5_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B6 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B6(String strObjectName) { + a = 206; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B6_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B7 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B7(String strObjectName) { + a = 207; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B7_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B8 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B8(String strObjectName) { + a = 208; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B8_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B9 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B9(String strObjectName) { + a = 209; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B9_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00040_B10 { + int a; + int sum; + String strObjectName; + Nocycle_a_00040_B10(String strObjectName) { + a = 210; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B10_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00050B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00050_A1 a1_main = new Nocycle_a_00050_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00050_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00050_C1("c1_0"); + a1_main.b1_0.c2_0 = new Nocycle_a_00050_C2("c2_0"); + a1_main.b1_0.c3_0 = new Nocycle_a_00050_C3("c3_0"); + a1_main.b2_0 = new Nocycle_a_00050_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00050_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00050_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c2_0.add(); + a1_main.b1_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c2_0.sum+a1_main.b1_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c2_0.sum + a1_main.b1_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5048) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00050_A1 { + Nocycle_a_00050_B1 b1_0; + Nocycle_a_00050_B2 b2_0; + Nocycle_a_00050_B3 b3_0; + Nocycle_a_00050_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00050_B1 { + Nocycle_a_00050_C1 c1_0; + Nocycle_a_00050_C2 c2_0; + Nocycle_a_00050_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00050_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00050_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00050_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00060B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00060_A1 a1_main = new Nocycle_a_00060_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00060_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00060_B2("b2_0"); + a1_main.b2_0.c1_0 = new Nocycle_a_00060_C1("c1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00060_C2("c2_0"); + a1_main.b2_0.c3_0 = new Nocycle_a_00060_C3("c3_0"); + a1_main.b3_0 = new Nocycle_a_00060_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00060_B4("b4_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c1_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b2_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c1_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b2_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c1_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b2_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5047) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00060_A1 { + Nocycle_a_00060_B1 b1_0; + Nocycle_a_00060_B2 b2_0; + Nocycle_a_00060_B3 b3_0; + Nocycle_a_00060_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00060_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_B2 { + Nocycle_a_00060_C1 c1_0; + Nocycle_a_00060_C2 c2_0; + Nocycle_a_00060_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B2(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00060_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_B4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00060_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00060_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00070B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00070_A1 a1_main = new Nocycle_a_00070_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00070_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00070_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00070_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00070_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_00070_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_00070_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00070_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 5045) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00070_A1 { + Nocycle_a_00070_B1 b1_0; + Nocycle_a_00070_B2 b2_0; + Nocycle_a_00070_B3 b3_0; + Nocycle_a_00070_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_00070_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_B4 { + Nocycle_a_00070_C1 c1_0; + Nocycle_a_00070_C2 c2_0; + Nocycle_a_00070_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00070_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_00070_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00070_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00070_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00080B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00080_A1 a1_main = new Nocycle_a_00080_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00080_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00080_C1("c1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1406) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00080_A1 { + Nocycle_a_00080_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00080_B1 { + Nocycle_a_00080_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00080_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00080_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00080_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00090B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00090_A1 a1_main = new Nocycle_a_00090_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00090_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00090_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00090_D1("d1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2308) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00090_A1 { + Nocycle_a_00090_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00090_B1 { + Nocycle_a_00090_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00090_C1 { + Nocycle_a_00090_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00090_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00090_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00090_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00100B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00100_A1 a1_main = new Nocycle_a_00100_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00100_B1("b1_0"); + a1_main.b1_0.c1_0 = new Nocycle_a_00100_C1("c1_0"); + a1_main.b1_0.c1_0.d1_0 = new Nocycle_a_00100_D1("d1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_00100_E1("e1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_00100_F1("f1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_00100_G1("g1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_00100_H1("h1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_00100_I1("i1_0"); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_00100_J1("j1_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b1_0.c1_0.add(); + a1_main.b1_0.c1_0.d1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); +// System.out.printf("a=%d\n",a1_main.sum); +// System.out.printf("b=%d\n",a1_main.b1_0.sum); +// System.out.printf("c=%d\n",a1_main.b1_0.c1_0.sum); +// System.out.printf("d=%d\n",a1_main.b1_0.c1_0.d1_0.sum); +// System.out.printf("e=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.sum); +// System.out.printf("f=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum); +// System.out.printf("g=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum); +// System.out.printf("h=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum); +// System.out.printf("i=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum); +// System.out.printf("j=%d\n",a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b1_0.c1_0.sum+a1_main.b1_0.c1_0.d1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum+a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b1_0.c1_0.sum + a1_main.b1_0.c1_0.d1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 11920) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00100_A1 { + Nocycle_a_00100_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00100_B1 { + Nocycle_a_00100_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00100_C1 { + Nocycle_a_00100_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00100_D1 { + Nocycle_a_00100_E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } + } + class Nocycle_a_00100_E1 { + Nocycle_a_00100_F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } + } + class Nocycle_a_00100_F1 { + Nocycle_a_00100_G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } + } + class Nocycle_a_00100_G1 { + Nocycle_a_00100_H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } + } + class Nocycle_a_00100_H1 { + Nocycle_a_00100_I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } + } + class Nocycle_a_00100_I1 { + Nocycle_a_00100_J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00100_I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } + } + class Nocycle_a_00100_J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00100_J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00110B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00110_A1 a1_main = new Nocycle_a_00110_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_00110_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00110_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00110_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_00110_B4("b4_0"); + a1_main.b1_0.d1_0 = new Nocycle_a_00110_D1("d1_0"); + a1_main.b2_0.c2_0 = new Nocycle_a_00110_C2("c2_0"); + a1_main.b3_0.c1_0 = new Nocycle_a_00110_C1("c1_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_00110_C3("c3_0"); + a1_main.b3_0.c1_0.d2_0 = new Nocycle_a_00110_D2("d2_0"); + a1_main.b2_0.c2_0.d3_0 = new Nocycle_a_00110_D3("d3_0"); + a1_main.b2_0.c2_0.d4_0 = new Nocycle_a_00110_D4("d4_0"); + a1_main.d5_0 = new Nocycle_a_00110_D5("d5_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b2_0.c2_0.add(); + a1_main.b3_0.c1_0.add(); + a1_main.b4_0.c3_0.add(); + a1_main.b1_0.d1_0.add(); + a1_main.b3_0.c1_0.d2_0.add(); + a1_main.b2_0.c2_0.d3_0.add(); + a1_main.b2_0.c2_0.d4_0.add(); + a1_main.d5_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b2_0.c2_0.sum+a1_main.b3_0.c1_0.sum+a1_main.b4_0.c3_0.sum+a1_main.b1_0.d1_0.sum+a1_main.b3_0.c1_0.d2_0.sum+a1_main.b2_0.c2_0.d3_0.sum+a1_main.b2_0.c2_0.d4_0.sum+a1_main.d5_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b2_0.c2_0.sum + a1_main.b3_0.c1_0.sum + a1_main.b4_0.c3_0.sum + a1_main.b1_0.d1_0.sum + a1_main.b3_0.c1_0.d2_0.sum + a1_main.b2_0.c2_0.d3_0.sum + a1_main.b2_0.c2_0.d4_0.sum + a1_main.d5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 9881) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00110_A1 { + Nocycle_a_00110_B1 b1_0; + Nocycle_a_00110_B2 b2_0; + Nocycle_a_00110_B3 b3_0; + Nocycle_a_00110_B4 b4_0; + Nocycle_a_00110_D5 d5_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + d5_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a + d5_0.a; + } + } + class Nocycle_a_00110_B1 { + Nocycle_a_00110_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00110_B2 { + Nocycle_a_00110_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B2(String strObjectName) { + c2_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c2_0.a; + } + } + class Nocycle_a_00110_B3 { + Nocycle_a_00110_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00110_B4 { + Nocycle_a_00110_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_B4(String strObjectName) { + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c3_0.a; + } + } + class Nocycle_a_00110_C1 { + Nocycle_a_00110_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C1(String strObjectName) { + d2_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_00110_C2 { + Nocycle_a_00110_D3 d3_0; + Nocycle_a_00110_D4 d4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C2(String strObjectName) { + d3_0 = null; + d4_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d3_0.a + d4_0.a; + } + } + class Nocycle_a_00110_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D4 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D4(String strObjectName) { + a = 404; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00110_D5 { + int a; + int sum; + String strObjectName; + Nocycle_a_00110_D5(String strObjectName) { + a = 405; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D5_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00120B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00120_A1 a1_main = new Nocycle_a_00120_A1("a1_main"); + Nocycle_a_00120_A2 a2_main = new Nocycle_a_00120_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00120_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1007) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00120_A1 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00120_A2 { + Nocycle_a_00120_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00120_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00120_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00120_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00130B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00130_A1 a1_main = new Nocycle_a_00130_A1("a1_main"); + Nocycle_a_00130_A2 a2_main = new Nocycle_a_00130_A2("a2_main"); + Nocycle_a_00130_A3 a3_main = new Nocycle_a_00130_A3("a3_main"); + Nocycle_a_00130_A4 a4_main = new Nocycle_a_00130_A4("a4_main"); + Nocycle_a_00130_A5 a5_main = new Nocycle_a_00130_A5("a5_main"); + Nocycle_a_00130_A6 a6_main = new Nocycle_a_00130_A6("a6_main"); + Nocycle_a_00130_A7 a7_main = new Nocycle_a_00130_A7("a7_main"); + Nocycle_a_00130_A8 a8_main = new Nocycle_a_00130_A8("a8_main"); + Nocycle_a_00130_A9 a9_main = new Nocycle_a_00130_A9("a9_main"); + Nocycle_a_00130_A10 a10_main = new Nocycle_a_00130_A10("a10_main"); + a1_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a2_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a3_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a4_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a5_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a6_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a7_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a8_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a9_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a10_main.b1_0 = new Nocycle_a_00130_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a5_main.add(); + a6_main.add(); + a7_main.add(); + a8_main.add(); + a9_main.add(); + a10_main.add(); + a1_main.b1_0.add(); + a2_main.b1_0.add(); + a3_main.b1_0.add(); + a4_main.b1_0.add(); + a5_main.b1_0.add(); + a6_main.b1_0.add(); + a7_main.b1_0.add(); + a8_main.b1_0.add(); + a9_main.b1_0.add(); + a10_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a5_main.sum+a6_main.sum+a7_main.sum+a8_main.sum+a9_main.sum+a10_main.sum+a1_main.b1_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a5_main.sum + a6_main.sum + a7_main.sum + a8_main.sum + a9_main.sum + a10_main.sum + a1_main.b1_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 3467) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00130_A1 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A2 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A3 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A3(String strObjectName) { + b1_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A4 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A4(String strObjectName) { + b1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A5 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A5(String strObjectName) { + b1_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A6 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A6(String strObjectName) { + b1_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A7 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A7(String strObjectName) { + b1_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A8 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A8(String strObjectName) { + b1_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A9 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A9(String strObjectName) { + b1_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_A10 { + Nocycle_a_00130_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00130_A10(String strObjectName) { + b1_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00130_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00130_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00140B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00140_A1 a1_main = new Nocycle_a_00140_A1("a1_main"); + Nocycle_a_00140_A2 a2_main = new Nocycle_a_00140_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00140_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00140_B1("b1_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1613) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00140_A1 { + Nocycle_a_00140_B1 b1_0; + Nocycle_a_00140_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00140_A2 { + Nocycle_a_00140_B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00140_A2(String strObjectName) { + b1_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_00140_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00140_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00140_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00150B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_A2 { + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00160B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00160_A1 a1_main = new Nocycle_a_00160_A1("a1_main"); + Nocycle_a_00160_A2 a2_main = new Nocycle_a_00160_A2("a2_main"); + Nocycle_a_00160_A3 a3_main = new Nocycle_a_00160_A3("a3_main"); + Nocycle_a_00160_A4 a4_main = new Nocycle_a_00160_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a2_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a3_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a4_main.b1_0 = new Nocycle_a_00160_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00160_B2("b2_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 2828) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00160_A1 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A2 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A3 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_A4 { + Nocycle_a_00160_B1 b1_0; + Nocycle_a_00160_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00160_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00160_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00160_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00160_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00170B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00170_A1 a1_main = new Nocycle_a_00170_A1("a1_main"); + Nocycle_a_00170_A2 a2_main = new Nocycle_a_00170_A2("a2_main"); + Nocycle_a_00170_A3 a3_main = new Nocycle_a_00170_A3("a3_main"); + Nocycle_a_00170_A4 a4_main = new Nocycle_a_00170_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a2_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a2_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a3_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a3_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a3_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a4_main.b1_0 = new Nocycle_a_00170_B1("b1_0"); + a4_main.b2_0 = new Nocycle_a_00170_B2("b2_0"); + a4_main.b3_0 = new Nocycle_a_00170_B3("b3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + a2_main.b3_0.add(); + a3_main.b1_0.add(); + a3_main.b2_0.add(); + a3_main.b3_0.add(); + a4_main.b1_0.add(); + a4_main.b2_0.add(); + a4_main.b3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 4046) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00170_A1 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A2 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A3 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A3(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_A4 { + Nocycle_a_00170_B1 b1_0; + Nocycle_a_00170_B2 b2_0; + Nocycle_a_00170_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00170_A4(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_00170_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00170_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00170_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00170_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_00180B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); +// System.out.printf("a1_main.sum=%d\n",a1_main.sum); +// System.out.printf("a2_main.sum=%d\n",a2_main.sum); +// System.out.printf("a3_main.sum=%d\n",a3_main.sum); +// System.out.printf("a4_main.sum=%d\n",a4_main.sum); +// System.out.printf("a1_main.b1_0.sum=%d\n",a1_main.b1_0.sum); +// System.out.printf("a2_main.b2_0.sum=%d\n",a2_main.b2_0.sum); +// System.out.printf("a4_main.b3_0.sum=%d\n",a4_main.b3_0.sum); +// System.out.printf("a2_main.b2_0.c1_0.sum=%d\n",a2_main.b2_0.c1_0.sum); +// System.out.printf("a3_main.c2_0.sum=%d\n",a3_main.c2_0.sum); +// System.out.printf("a1_main.d1_0.sum=%d\n",a1_main.d1_0.sum); +// System.out.printf("a3_main.c2_0.d2_0.sum=%d\n",a3_main.c2_0.d2_0.sum); +// System.out.printf("a3_main.c2_0.d3_0.sum=%d\n",a3_main.c2_0.d3_0.sum); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a3_main.sum+a4_main.sum+a1_main.b1_0.sum+a2_main.b2_0.sum+a4_main.b3_0.sum+a2_main.b2_0.c1_0.sum+a3_main.c2_0.sum+a1_main.d1_0.sum+a3_main.c2_0.d2_0.sum+a3_main.c2_0.d3_0.sum); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 9260) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class Nocycle_a_00180_A3 { + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + Nocycle_a_00180_D1 d1_0; + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_B3 { + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00180_C1 { + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00180_C2 { + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_00190 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00010B A1_00010 = new ThreadRc_00010B(); + ThreadRc_00010B A2_00010 = new ThreadRc_00010B(); + ThreadRc_00020B A1_00020 = new ThreadRc_00020B(); + ThreadRc_00020B A2_00020 = new ThreadRc_00020B(); + ThreadRc_00030B A1_00030 = new ThreadRc_00030B(); + ThreadRc_00030B A2_00030 = new ThreadRc_00030B(); + ThreadRc_00040B A1_00040 = new ThreadRc_00040B(); + ThreadRc_00040B A2_00040 = new ThreadRc_00040B(); + ThreadRc_00050B A1_00050 = new ThreadRc_00050B(); + ThreadRc_00050B A2_00050 = new ThreadRc_00050B(); + ThreadRc_00060B A1_00060 = new ThreadRc_00060B(); + ThreadRc_00060B A2_00060 = new ThreadRc_00060B(); + ThreadRc_00070B A1_00070 = new ThreadRc_00070B(); + ThreadRc_00070B A2_00070 = new ThreadRc_00070B(); + ThreadRc_00080B A1_00080 = new ThreadRc_00080B(); + ThreadRc_00080B A2_00080 = new ThreadRc_00080B(); + ThreadRc_00090B A1_00090 = new ThreadRc_00090B(); + ThreadRc_00090B A2_00090 = new ThreadRc_00090B(); + ThreadRc_00100B A1_00100 = new ThreadRc_00100B(); + ThreadRc_00100B A2_00100 = new ThreadRc_00100B(); + ThreadRc_00110B A1_00110 = new ThreadRc_00110B(); + ThreadRc_00110B A2_00110 = new ThreadRc_00110B(); + ThreadRc_00120B A1_00120 = new ThreadRc_00120B(); + ThreadRc_00120B A2_00120 = new ThreadRc_00120B(); + ThreadRc_00130B A1_00130 = new ThreadRc_00130B(); + ThreadRc_00130B A2_00130 = new ThreadRc_00130B(); + ThreadRc_00140B A1_00140 = new ThreadRc_00140B(); + ThreadRc_00140B A2_00140 = new ThreadRc_00140B(); + ThreadRc_00150B A1_00150 = new ThreadRc_00150B(); + ThreadRc_00150B A2_00150 = new ThreadRc_00150B(); + ThreadRc_00160B A1_00160 = new ThreadRc_00160B(); + ThreadRc_00160B A2_00160 = new ThreadRc_00160B(); + ThreadRc_00170B A1_00170 = new ThreadRc_00170B(); + ThreadRc_00170B A2_00170 = new ThreadRc_00170B(); + ThreadRc_00180B A1_00180 = new ThreadRc_00180B(); + ThreadRc_00180B A2_00180 = new ThreadRc_00180B(); + A1_00010.start(); + A2_00010.start(); + A1_00020.start(); + A2_00020.start(); + A1_00030.start(); + A2_00030.start(); + A1_00040.start(); + A2_00040.start(); + A1_00050.start(); + A2_00050.start(); + A1_00060.start(); + A2_00060.start(); + A1_00070.start(); + A2_00070.start(); + A1_00080.start(); + A2_00080.start(); + A1_00090.start(); + A2_00090.start(); + A1_00100.start(); + A2_00100.start(); + A1_00110.start(); + A2_00110.start(); + A1_00120.start(); + A2_00120.start(); + A1_00130.start(); + A2_00130.start(); + A1_00140.start(); + A2_00140.start(); + A1_00150.start(); + A2_00150.start(); + A1_00160.start(); + A2_00160.start(); + A1_00170.start(); + A2_00170.start(); + A1_00180.start(); + A2_00180.start(); + try { + A1_00010.join(); + A2_00010.join(); + A1_00020.join(); + A2_00020.join(); + A1_00030.join(); + A2_00030.join(); + A1_00040.join(); + A2_00040.join(); + A1_00050.join(); + A2_00050.join(); + A1_00060.join(); + A2_00060.join(); + A1_00070.join(); + A2_00070.join(); + A1_00080.join(); + A2_00080.join(); + A1_00090.join(); + A2_00090.join(); + A1_00100.join(); + A2_00100.join(); + A1_00110.join(); + A2_00110.join(); + A1_00120.join(); + A2_00120.join(); + A1_00130.join(); + A2_00130.join(); + A1_00140.join(); + A2_00140.join(); + A1_00150.join(); + A2_00150.join(); + A1_00160.join(); + A2_00160.join(); + A1_00170.join(); + A2_00170.join(); + A1_00180.join(); + A2_00180.join(); + } catch (InterruptedException e) { + } + if (A1_00010.check() && A2_00010.check() && A1_00020.check() && A2_00020.check() && A1_00030.check() && A2_00030.check() && A1_00040.check() && A2_00040.check() && A1_00050.check() && A2_00050.check() && A1_00060.check() && A2_00060.check() && A1_00070.check() && A2_00070.check() && A1_00080.check() && A2_00080.check() && A1_00090.check() && A2_00090.check() && A1_00100.check() && A2_00100.check() && A1_00110.check() && A2_00110.check() && A1_00120.check() && A2_00120.check() && A1_00130.check() && A2_00130.check() && A1_00140.check() && A2_00140.check() && A1_00150.check() && A2_00150.check() && A1_00160.check() && A2_00160.check() && A1_00170.check() && A2_00170.check() && A1_00180.check() && A2_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/expected.txt b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/test.cfg b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..74ed9c2579c7c29d3e8d4bac12350083828b7567 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0224-rc-function-RC_Thread01-Nocycle_am_00190/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_00190) +run(Nocycle_am_00190,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java new file mode 100755 index 0000000000000000000000000000000000000000..ce2555ca5b0db0b9f48065050491e4d02dff8586 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/Nocycle_am_2_00010.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Nocycle_am_2_00010 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + // System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1939) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_2_00010 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00010 A1_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A2_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A3_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A4_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A5_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + ThreadRc_Nocycle_am_2_00010 A6_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010(); + A1_Nocycle_am_2_00010.start(); + A2_Nocycle_am_2_00010.start(); + A3_Nocycle_am_2_00010.start(); + A4_Nocycle_am_2_00010.start(); + A5_Nocycle_am_2_00010.start(); + A6_Nocycle_am_2_00010.start(); + try { + A1_Nocycle_am_2_00010.join(); + A2_Nocycle_am_2_00010.join(); + A3_Nocycle_am_2_00010.join(); + A4_Nocycle_am_2_00010.join(); + A5_Nocycle_am_2_00010.join(); + A6_Nocycle_am_2_00010.join(); + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00010.check() && A2_Nocycle_am_2_00010.check() && A3_Nocycle_am_2_00010.check() && A4_Nocycle_am_2_00010.check() && A5_Nocycle_am_2_00010.check() && A6_Nocycle_am_2_00010.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/expected.txt b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/test.cfg b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9ed102007307d8ea08bd0969a2602d60f80b8b7f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0225-rc-function-RC_Thread01-Nocycle_am_2_00010/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_2_00010) +run(Nocycle_am_2_00010,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java new file mode 100755 index 0000000000000000000000000000000000000000..691a6842ae652af6d8d00a299727b3b9c2b9f95a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/Nocycle_am_2_00020.java @@ -0,0 +1,640 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Nocycle_am_2_00020 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + int result = result1 + result2 + result3; + if (result == 26225) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } + } + class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } + } + class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } + } + class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } + } + class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } + } + class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } + } + class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_2_00020 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00020 A1_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A2_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A3_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A4_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A5_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + ThreadRc_Nocycle_am_2_00020 A6_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020(); + A1_Nocycle_am_2_00020.start(); + A2_Nocycle_am_2_00020.start(); + A3_Nocycle_am_2_00020.start(); + A4_Nocycle_am_2_00020.start(); + A5_Nocycle_am_2_00020.start(); + A6_Nocycle_am_2_00020.start(); + try { + A1_Nocycle_am_2_00020.join(); + A2_Nocycle_am_2_00020.join(); + A3_Nocycle_am_2_00020.join(); + A4_Nocycle_am_2_00020.join(); + A5_Nocycle_am_2_00020.join(); + A6_Nocycle_am_2_00020.join(); + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00020.check() && A2_Nocycle_am_2_00020.check() && A3_Nocycle_am_2_00020.check() && A4_Nocycle_am_2_00020.check() && A5_Nocycle_am_2_00020.check() && A6_Nocycle_am_2_00020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/expected.txt b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/test.cfg b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9d721c8b0d2967f9402de0f73979816fe5632f17 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0226-rc-function-RC_Thread01-Nocycle_am_2_00020/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_2_00020) +run(Nocycle_am_2_00020,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java new file mode 100755 index 0000000000000000000000000000000000000000..8e79faebd3c44d9f3c7647a9f266b8e90630c0ce --- /dev/null +++ b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/Nocycle_am_2_00030.java @@ -0,0 +1,758 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ThreadRc_Nocycle_am_2_00010B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_2_00010_A1 a1_main = new Nocycle_a_2_00010_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00010_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00010_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00010_B3("b3_0"); + Nocycle_a_2_00010_A2 a2_main = new Nocycle_a_2_00010_A2("a2_main"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a2_main.add(); + // System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum); + int result = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a2_main.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1939) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_2_00010_A1 { + Nocycle_a_2_00010_B1 b1_0; + Nocycle_a_2_00010_B2 b2_0; + Nocycle_a_2_00010_B3 b3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a; + } + } + class Nocycle_a_2_00010_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00010_A2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00010_A2(String strObjectName) { + a = 10; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +class ThreadRc_Nocycle_am_2_00020B extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_2_00020_A1 a1_main = new Nocycle_a_2_00020_A1("a1_main"); + a1_main.b1_0 = new Nocycle_a_2_00020_B1("b1_0"); + a1_main.b2_0 = new Nocycle_a_2_00020_B2("b2_0"); + a1_main.b3_0 = new Nocycle_a_2_00020_B3("b3_0"); + a1_main.b4_0 = new Nocycle_a_2_00020_B4("b4_0"); + a1_main.b4_0.c1_0 = new Nocycle_a_2_00020_C1("c1_0"); + a1_main.b4_0.c2_0 = new Nocycle_a_2_00020_C2("c2_0"); + a1_main.b4_0.c3_0 = new Nocycle_a_2_00020_C3("c3_0"); + a1_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a1_main.b3_0.add(); + a1_main.b4_0.add(); + a1_main.b4_0.c1_0.add(); + a1_main.b4_0.c2_0.add(); + a1_main.b4_0.c3_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum+a1_main.b3_0.sum+a1_main.b4_0.sum+a1_main.b4_0.c1_0.sum+a1_main.b4_0.c2_0.sum+a1_main.b4_0.c3_0.sum); + int result1 = a1_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum + a1_main.b3_0.sum + a1_main.b4_0.sum + a1_main.b4_0.c1_0.sum + a1_main.b4_0.c2_0.sum + a1_main.b4_0.c3_0.sum; + //System.out.println("RC-Testing_Result="+result1); + Nocycle_a_2_00020_2A1 a1_main2 = new Nocycle_a_2_00020_2A1("a1_main2"); + a1_main2.b1_0 = new Nocycle_a_2_00020_2B1("b1_0"); + a1_main2.b1_0.c1_0 = new Nocycle_a_2_00020_2C1("c1_0"); + a1_main2.b1_0.c1_0.d1_0 = new Nocycle_a_2_00020_2D1("d1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0 = new Nocycle_a_2_00020_2E1("e1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0 = new Nocycle_a_2_00020_2F1("f1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0 = new Nocycle_a_2_00020_2G1("g1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0 = new Nocycle_a_2_00020_2H1("h1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0 = new Nocycle_a_2_00020_2I1("i1_0"); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0 = new Nocycle_a_2_00020_2J1("j1_0"); + a1_main2.add(); + a1_main2.b1_0.add(); + a1_main2.b1_0.c1_0.add(); + a1_main2.b1_0.c1_0.d1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.add(); + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.add(); + int result2 = a1_main2.sum + a1_main2.b1_0.sum + a1_main2.b1_0.c1_0.sum + a1_main2.b1_0.c1_0.d1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.sum + a1_main2.b1_0.c1_0.d1_0.e1_0.f1_0.g1_0.h1_0.i1_0.j1_0.sum; + Nocycle_a_2_00020_3A1 a1_main3 = new Nocycle_a_2_00020_3A1("a1_main3"); + Nocycle_a_2_00020_3A2 a2_main = new Nocycle_a_2_00020_3A2("a2_main"); + Nocycle_a_2_00020_3A3 a3_main = new Nocycle_a_2_00020_3A3("a3_main"); + Nocycle_a_2_00020_3A4 a4_main = new Nocycle_a_2_00020_3A4("a4_main"); + a1_main3.b1_0 = new Nocycle_a_2_00020_3B1("b1_0"); + a1_main3.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a1_main3.b1_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a2_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a2_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a2_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0 = new Nocycle_a_2_00020_3B2("b2_0"); + a3_main.b2_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a3_main.b2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.b2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a3_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a3_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a3_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a4_main.b3_0 = new Nocycle_a_2_00020_3B3("b3_0"); + a4_main.b3_0.c1_0 = new Nocycle_a_2_00020_3C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new Nocycle_a_2_00020_3D1("d1_0"); + a4_main.c2_0 = new Nocycle_a_2_00020_3C2("c2_0"); + a4_main.c2_0.d2_0 = new Nocycle_a_2_00020_3D2("d2_0"); + a4_main.c2_0.d3_0 = new Nocycle_a_2_00020_3D3("d3_0"); + a1_main3.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main3.b1_0.add(); + a1_main3.d1_0.add(); + a1_main3.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result3 = a1_main3.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main3.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a2_main.b2_0.c1_0.sum + a3_main.c2_0.sum + a1_main3.d1_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum; + int result = result1 + result2 + result3; + if (result == 26225) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_2_00020_A1 { + Nocycle_a_2_00020_B1 b1_0; + Nocycle_a_2_00020_B2 b2_0; + Nocycle_a_2_00020_B3 b3_0; + Nocycle_a_2_00020_B4 b4_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class Nocycle_a_2_00020_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_B4 { + Nocycle_a_2_00020_C1 c1_0; + Nocycle_a_2_00020_C2 c2_0; + Nocycle_a_2_00020_C3 c3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_B4(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class Nocycle_a_2_00020_C1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_C2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_C3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_2A1 { + Nocycle_a_2_00020_2B1 b1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2A1(String strObjectName) { + b1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a; + } + } + class Nocycle_a_2_00020_2B1 { + Nocycle_a_2_00020_2C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2B1(String strObjectName) { + c1_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_2_00020_2C1 { + Nocycle_a_2_00020_2D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_2_00020_2D1 { + Nocycle_a_2_00020_2E1 e1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2D1(String strObjectName) { + e1_0 = null; + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + e1_0.a; + } + } + class Nocycle_a_2_00020_2E1 { + Nocycle_a_2_00020_2F1 f1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2E1(String strObjectName) { + f1_0 = null; + a = 501; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_E1_"+strObjectName); + } + void add() { + sum = a + f1_0.a; + } + } + class Nocycle_a_2_00020_2F1 { + Nocycle_a_2_00020_2G1 g1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2F1(String strObjectName) { + g1_0 = null; + a = 601; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_F1_"+strObjectName); + } + void add() { + sum = a + g1_0.a; + } + } + class Nocycle_a_2_00020_2G1 { + Nocycle_a_2_00020_2H1 h1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2G1(String strObjectName) { + h1_0 = null; + a = 701; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_G1_"+strObjectName); + } + void add() { + sum = a + h1_0.a; + } + } + class Nocycle_a_2_00020_2H1 { + Nocycle_a_2_00020_2I1 i1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2H1(String strObjectName) { + i1_0 = null; + a = 801; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_H1_"+strObjectName); + } + void add() { + sum = a + i1_0.a; + } + } + class Nocycle_a_2_00020_2I1 { + Nocycle_a_2_00020_2J1 j1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2I1(String strObjectName) { + j1_0 = null; + a = 901; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_I1_"+strObjectName); + } + void add() { + sum = a + j1_0.a; + } + } + class Nocycle_a_2_00020_2J1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_2J1(String strObjectName) { + a = 1001; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_J1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3A1 { + Nocycle_a_2_00020_3B1 b1_0; + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class Nocycle_a_2_00020_3A2 { + Nocycle_a_2_00020_3B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class Nocycle_a_2_00020_3A3 { + Nocycle_a_2_00020_3B2 b2_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class Nocycle_a_2_00020_3A4 { + Nocycle_a_2_00020_3B3 b3_0; + Nocycle_a_2_00020_3C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class Nocycle_a_2_00020_3B1 { + Nocycle_a_2_00020_3D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_2_00020_3B2 { + Nocycle_a_2_00020_3C1 c1_0; + Nocycle_a_2_00020_3D1 d1_0; + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_2_00020_3B3 { + Nocycle_a_2_00020_3C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_2_00020_3C1 { + Nocycle_a_2_00020_3D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_2_00020_3C2 { + Nocycle_a_2_00020_3D2 d2_0; + Nocycle_a_2_00020_3D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_2_00020_3D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_2_00020_3D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_2_00020_3D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class Nocycle_am_2_00030 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Nocycle_am_2_00010B A1_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A2_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A3_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A4_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A5_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00010B A6_Nocycle_am_2_00010 = new ThreadRc_Nocycle_am_2_00010B(); + ThreadRc_Nocycle_am_2_00020B A1_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A2_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A3_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A4_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A5_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + ThreadRc_Nocycle_am_2_00020B A6_Nocycle_am_2_00020 = new ThreadRc_Nocycle_am_2_00020B(); + A1_Nocycle_am_2_00010.start(); + A2_Nocycle_am_2_00010.start(); + A3_Nocycle_am_2_00010.start(); + A4_Nocycle_am_2_00010.start(); + A5_Nocycle_am_2_00010.start(); + A6_Nocycle_am_2_00010.start(); + A1_Nocycle_am_2_00020.start(); + A2_Nocycle_am_2_00020.start(); + A3_Nocycle_am_2_00020.start(); + A4_Nocycle_am_2_00020.start(); + A5_Nocycle_am_2_00020.start(); + A6_Nocycle_am_2_00020.start(); + try { + A1_Nocycle_am_2_00010.join(); + A2_Nocycle_am_2_00010.join(); + A3_Nocycle_am_2_00010.join(); + A4_Nocycle_am_2_00010.join(); + A5_Nocycle_am_2_00010.join(); + A6_Nocycle_am_2_00010.join(); + A1_Nocycle_am_2_00020.join(); + A2_Nocycle_am_2_00020.join(); + A3_Nocycle_am_2_00020.join(); + A4_Nocycle_am_2_00020.join(); + A5_Nocycle_am_2_00020.join(); + A6_Nocycle_am_2_00020.join(); + } catch (InterruptedException e) { + } + if (A1_Nocycle_am_2_00010.check() && A2_Nocycle_am_2_00010.check() && A3_Nocycle_am_2_00010.check() && A4_Nocycle_am_2_00010.check() && A5_Nocycle_am_2_00010.check() && A6_Nocycle_am_2_00010.check() && A1_Nocycle_am_2_00020.check() && A2_Nocycle_am_2_00020.check() && A3_Nocycle_am_2_00020.check() && A4_Nocycle_am_2_00020.check() && A5_Nocycle_am_2_00020.check() && A6_Nocycle_am_2_00020.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/expected.txt b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/test.cfg b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6458ffa0cef0692b8aec50440f38e2bc95f59e1a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0227-rc-function-RC_Thread01-Nocycle_am_2_00030/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Nocycle_am_2_00030) +run(Nocycle_am_2_00030,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java new file mode 100755 index 0000000000000000000000000000000000000000..feef822446b5821a4769036cb1f49678dd68c1a1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/RC_Thread_01.java @@ -0,0 +1,344 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_01_1 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_01_2 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_01_3 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_01_4 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_01_5 extends Thread { + public void run() { + RC_Thread_01 rcth01 = new RC_Thread_01(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_01 { + private volatile static RC_Thread_01_A1 a1_main = null; + private volatile static RC_Thread_01_A2 a2_main = null; + private volatile static RC_Thread_01_A3 a3_main = null; + private volatile static RC_Thread_01_A4 a4_main = null; + RC_Thread_01() { + try { + a1_main = new RC_Thread_01_A1("a1_main"); + a2_main = new RC_Thread_01_A2("a2_main"); + a3_main = new RC_Thread_01_A3("a3_main"); + a4_main = new RC_Thread_01_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_01_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_01_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a2_main.b2_0 = new RC_Thread_01_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a3_main.b2_0 = new RC_Thread_01_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + a3_main.c2_0 = new RC_Thread_01_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + a4_main.b3_0 = new RC_Thread_01_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_01_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_01_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_01_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_01_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_01_D3("d3_0"); + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_01_1 t1=new RC_Thread_01_1(); + RC_Thread_01_2 t2=new RC_Thread_01_2(); + RC_Thread_01_3 t3=new RC_Thread_01_3(); + RC_Thread_01_4 t4=new RC_Thread_01_4(); + RC_Thread_01_5 t5=new RC_Thread_01_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + } catch (InterruptedException e) {} + } + public void setA1null() { + a1_main = null; + } + public void setA2null() { + a2_main = null; + } + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_01_D2("new"); + a3_main = new RC_Thread_01_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + } + } + public void setA3null() { + a3_main = null; + } + public void setA4null() { + a4_main = null; + } + class RC_Thread_01_A1 { + volatile RC_Thread_01_B1 b1_0; + volatile RC_Thread_01_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class RC_Thread_01_A2 { + volatile RC_Thread_01_B2 b2_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class RC_Thread_01_A3 { + volatile RC_Thread_01_B2 b2_0; + volatile RC_Thread_01_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class RC_Thread_01_A4 { + volatile RC_Thread_01_B3 b3_0; + volatile RC_Thread_01_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class RC_Thread_01_B1 { + volatile RC_Thread_01_D2 d2_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class RC_Thread_01_B2 { + volatile RC_Thread_01_C1 c1_0; + volatile RC_Thread_01_D1 d1_0; + volatile RC_Thread_01_D2 d2_0; + volatile RC_Thread_01_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class RC_Thread_01_B3 { + volatile RC_Thread_01_C1 c1_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class RC_Thread_01_C1 { + volatile RC_Thread_01_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class RC_Thread_01_C2 { + volatile RC_Thread_01_D2 d2_0; + volatile RC_Thread_01_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_01_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class RC_Thread_01_D1 { + int a; + int sum; + String strObjectName; + RC_Thread_01_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_01_D2 { + int a; + int sum; + String strObjectName; + RC_Thread_01_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_01_D3 { + int a; + int sum; + String strObjectName; + RC_Thread_01_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/expected.txt b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/test.cfg b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8ad250d9c718088060c80b3a1bba4d361f7ea95f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0228-rc-function-RC_Thread02-RC_Thread_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_01) +run(RC_Thread_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java new file mode 100755 index 0000000000000000000000000000000000000000..ca8384de9fab9eb8e178322770f4d535e981deb1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/RC_Thread_02.java @@ -0,0 +1,240 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_02_1 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_02_2 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_02_3 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_02_4 extends Thread { + public void run() { + RC_Thread_02 rcth01 = new RC_Thread_02("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_02 { + private volatile static RC_Thread_02_A1 a1 = null; + RC_Thread_02(String str) { + try { + a1 = new RC_Thread_02_A1("a1"); + a1.b1_0 = new RC_Thread_02_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_02_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_02_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_02_C3("c3_0"); + a1.b2_0 = new RC_Thread_02_B2("b2_0"); + a1.b3_0 = new RC_Thread_02_B3("b3_0"); + a1.b4_0 = new RC_Thread_02_B4("b4_0"); + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_02_1 t1=new RC_Thread_02_1(); + RC_Thread_02_2 t2=new RC_Thread_02_2(); + RC_Thread_02_3 t3=new RC_Thread_02_3(); + RC_Thread_02_4 t4=new RC_Thread_02_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try{ + t1.join(); + t2.join(); + t3.join(); + t4.join(); + }catch(InterruptedException e){} + } + public void deleteA1() { + a1 = null; + } + public void ModifyB4() { + try{ + a1.b4_0 = new RC_Thread_02_B4("new_b4"); + }catch(NullPointerException e){ + } + } + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + } + } + public void setA1(RC_Thread_02_A1 a1) { + this.a1 = a1; + } + class RC_Thread_02_A1 { + volatile RC_Thread_02_B1 b1_0; + volatile RC_Thread_02_B2 b2_0; + volatile RC_Thread_02_B3 b3_0; + volatile RC_Thread_02_B4 b4_0; + int a; + int sum; + String strObjectName; + RC_Thread_02_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class RC_Thread_02_B1 { + volatile RC_Thread_02_C1 c1_0; + volatile RC_Thread_02_C2 c2_0; + volatile RC_Thread_02_C3 c3_0; + int a; + int sum; + String strObjectName; + RC_Thread_02_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class RC_Thread_02_B2 { + int a; + int sum; + String strObjectName; + RC_Thread_02_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_02_B3 { + int a; + int sum; + String strObjectName; + RC_Thread_02_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_02_B4 { + int a; + int sum; + String strObjectName; + RC_Thread_02_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_02_C1 { + int a; + int sum; + String strObjectName; + RC_Thread_02_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_02_C2 { + int a; + int sum; + String strObjectName; + RC_Thread_02_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_02_C3 { + int a; + int sum; + String strObjectName; + RC_Thread_02_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/expected.txt b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/test.cfg b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a4b330459fd79deb803c2b0f3bdb1b1d820c0c58 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0229-rc-function-RC_Thread02-RC_Thread_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_02) +run(RC_Thread_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java new file mode 100644 index 0000000000000000000000000000000000000000..3908fba98e7d9036eba104a88ba40a1922caa1b1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/RC_Thread_03.java @@ -0,0 +1,323 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RcThread0301 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0302 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0303 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0304 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0305 extends Thread { + public void run() { + RC_Thread_03 rcth01 = new RC_Thread_03(); + try { + rcth01.setA4(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread03GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} +public class RC_Thread_03 { + private static volatile RcThread03A1 a1_main = null; + private static volatile RcThread03A2 a2_main = null; + private static volatile RcThread03A3 a3_main = null; + private static volatile RcThread03A4 a4_main = null; + RC_Thread_03() { + try { + a1_main = new RcThread03A1("a1_main"); + a2_main = new RcThread03A2("a2_main"); + a3_main = new RcThread03A3("a3_main"); + a4_main = new RcThread03A4("a4_main"); + a1_main.b1_0 = new RcThread03B1("b1_0"); + a1_main.d1_0 = new RcThread03D1("d1_0"); + a1_main.b1_0.d2_0 = new RcThread03D2("d2_0"); + a2_main.b2_0 = new RcThread03B2("b2_0"); + a2_main.b2_0.c1_0 = new RcThread03C1("c1_0"); + a2_main.b2_0.d1_0 = new RcThread03D1("d1_0"); + a2_main.b2_0.d2_0 = new RcThread03D2("d2_0"); + a2_main.b2_0.d3_0 = new RcThread03D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0 = new RcThread03B2("b2_0"); + a3_main.b2_0.c1_0 = new RcThread03C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0.d1_0 = new RcThread03D1("d1_0"); + a3_main.b2_0.d2_0 = new RcThread03D2("d2_0"); + a3_main.b2_0.d3_0 = new RcThread03D3("d3_0"); + a3_main.c2_0 = new RcThread03C2("c2_0"); + a3_main.c2_0.d2_0 = new RcThread03D2("d2_0"); + a3_main.c2_0.d3_0 = new RcThread03D3("d3_0"); + a4_main.b3_0 = new RcThread03B3("b3_0"); + a4_main.b3_0.c1_0 = new RcThread03C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RcThread03D1("d1_0"); + a4_main.c2_0 = new RcThread03C2("c2_0"); + a4_main.c2_0.d2_0 = new RcThread03D2("d2_0"); + a4_main.c2_0.d3_0 = new RcThread03D3("d3_0"); + } catch (NullPointerException e) { + // do nothing + } + } + public static void main(String[] args) { + RcThread03GC gc = new RcThread03GC(); + gc.run(); + for(int start = 0; start < 10; start++) { + rcTestcaseMainWrapper(); + } + System.out.println("ExpectResult"); + } + private static void rcTestcaseMainWrapper() { + RcThread0301 t1 = new RcThread0301(); + RcThread0302 t2 = new RcThread0302(); + RcThread0303 t3 = new RcThread0303(); + RcThread0304 t4 = new RcThread0304(); + RcThread0305 t5 = new RcThread0305(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + }catch(InterruptedException e){ + // do nothing + } + } + void setA1null() { + a1_main = null; + } + void setA2null() { + a2_main = null; + } + void setA3() { + try { + a3_main.c2_0.d2_0 = new RcThread03D2("new"); + a3_main = new RcThread03A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + // do nothing + } + } + void setA3null() { + a3_main = null; + } + void setA4() { + try { + a4_main = new RcThread03A4("a4_new"); + } catch (NullPointerException e) { + // do nothing + } + } + class RcThread03A1 { + volatile RcThread03B1 b1_0; + volatile RcThread03D1 d1_0; + int a; + int sum; + String strObjectName; + RcThread03A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03A2 { + volatile RcThread03B2 b2_0; + int a; + int sum; + String strObjectName; + RcThread03A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03A3 { + volatile RcThread03B2 b2_0; + volatile RcThread03C2 c2_0; + int a; + int sum; + String strObjectName; + RcThread03A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03A4 { + volatile RcThread03B3 b3_0; + volatile RcThread03C2 c2_0; + int a; + int sum; + String strObjectName; + RcThread03A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03B1 { + volatile RcThread03D2 d2_0; + int a; + int sum; + String strObjectName; + RcThread03B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03B2 { + volatile RcThread03C1 c1_0; + volatile RcThread03D1 d1_0; + volatile RcThread03D2 d2_0; + volatile RcThread03D3 d3_0; + int a; + int sum; + String strObjectName; + RcThread03B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03B3 { + volatile RcThread03C1 c1_0; + int a; + int sum; + String strObjectName; + RcThread03B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03C1 { + volatile RcThread03D1 d1_0; + int a; + int sum; + String strObjectName; + RcThread03C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03C2 { + volatile RcThread03D2 d2_0; + volatile RcThread03D3 d3_0; + int a; + int sum; + String strObjectName; + RcThread03C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03D1 { + int a; + int sum; + String strObjectName; + RcThread03D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03D2 { + int a; + int sum; + String strObjectName; + RcThread03D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; + } + } + class RcThread03D3 { + int a; + int sum; + String strObjectName; + RcThread03D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/expected.txt b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/test.cfg b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bfb421aaed4e4034a0ecac85b3e6c0c7fccb741f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0230-rc-function-RC_Thread02-RC_Thread_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_03) +run(RC_Thread_03,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java new file mode 100644 index 0000000000000000000000000000000000000000..11d518dceb2ca3dedb414868e6cd600f7f7ec96a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/RC_Thread_04.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RcThread0401 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0402 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0403 extends Thread { + public void run() { + RC_Thread_04 rcth01 = new RC_Thread_04(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread04GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} +public class RC_Thread_04 { + private static volatile RcThread04A1 a1_main = null; + private static volatile RcThread04A4 a4_main = null; + private static volatile RcThread04A5 a5_main = null; + RC_Thread_04() { + try { + RcThread04A1 a1 = new RcThread04A1(); + a1.a2_0 = new RcThread04A2(); + a1.a2_0.a3_0 = new RcThread04A3(); + RcThread04A4 a4 = new RcThread04A4(); + RcThread04A5 a5 = new RcThread04A5(); + a4.a1_0 = a1; + a5.a1_0 = a1; + a1.a2_0.a3_0.a1_0 = a1; + a1_main = a1; + a4_main = a4; + a5_main = a5; + } catch (NullPointerException e) { + // do nothing + } + } + public static void main(String[] args) { + cyclePatternWrapper(); + RcThread04GC gc = new RcThread04GC(); + gc.start(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + private static void cyclePatternWrapper() { + a1_main = new RcThread04A1(); + a1_main.a2_0 = new RcThread04A2(); + a1_main.a2_0.a3_0 = new RcThread04A3(); + a4_main = new RcThread04A4(); + a5_main = new RcThread04A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main = null; + a4_main = null; + a5_main = null; + Runtime.getRuntime().gc(); // 单独构造一次Cycle_B_1_00180环,通过gc学习到环模式 + } + private static void rcTestcaseMainWrapper() { + RcThread0401 t1 = new RcThread0401(); + RcThread0402 t2 = new RcThread0402(); + RcThread0403 t3 = new RcThread0403(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + }catch(InterruptedException e){ + // do nothing + } + } + void setA1null() { + a1_main = null; + } + void setA4null() { + a4_main = null; + } + void setA5null() { + a5_main = null; + } + static class RcThread04A1 { + volatile RcThread04A2 a2_0; + int a; + int sum; + RcThread04A1() { + a2_0 = null; + a = 1; + sum = 0; + } + } + static class RcThread04A2 { + volatile RcThread04A3 a3_0; + int a; + int sum; + RcThread04A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + static class RcThread04A3 { + volatile RcThread04A1 a1_0; + int a; + int sum; + RcThread04A3() { + a1_0 = null; + a = 3; + sum = 0; + } + } + static class RcThread04A4 { + volatile RcThread04A1 a1_0; + int a; + int sum; + RcThread04A4() { + a1_0 = null; + a = 4; + sum = 0; + } + } + static class RcThread04A5 { + volatile RcThread04A1 a1_0; + int a; + int sum; + RcThread04A5() { + a1_0 = null; + a = 5; + sum = 0; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/expected.txt b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/test.cfg b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5bf58680f8641d1ba1e33d869c167689e6beba16 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0231-rc-function-RC_Thread02-RC_Thread_04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_04) +run(RC_Thread_04,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java new file mode 100644 index 0000000000000000000000000000000000000000..a69726f71910d9aaf02d6b6fc27b4ce5ab50aecf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/RC_Thread_05.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RcThread0501 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0502 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0503 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0504 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA1(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0505 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0506 extends Thread { + public void run() { + RC_Thread_05 rcth01 = new RC_Thread_05(); + try { + rcth01.setA3_a(5); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread05GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} +public class RC_Thread_05 { + private static volatile RcThread05A1 a1Main = null; + private static volatile RcThread05A4 a4Main = null; + private static volatile RcThread05A5 a5Main = null; + RC_Thread_05() { + try { + a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + a4Main = new RcThread05A4(); + a5Main = new RcThread05A5(); + a4Main.a1_0 = a1Main; + a5Main.a1_0 = a1Main; + a1Main.a2_0.a3_0.a1_0 = a1Main; + } catch (NullPointerException e) { + // do nothing + } + } + public static void main(String[] args) { + cyclePatternWrapper(); + RcThread05GC gc = new RcThread05GC(); + gc.run(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + private static void cyclePatternWrapper() { + a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + a4Main = new RcThread05A4(); + a5Main = new RcThread05A5(); + a4Main.a1_0 = a1Main; + a5Main.a1_0 = a1Main; + a1Main.a2_0.a3_0.a1_0 = a1Main; + a1Main = null; + a4Main = null; + a5Main = null; + Runtime.getRuntime().gc(); // 单独构造一次Cycle_B_1_00180环,通过gc学习到环模式 + } + private static void rcTestcaseMainWrapper() { + RcThread0501 t1 = new RcThread0501(); + RcThread0502 t2 = new RcThread0502(); + RcThread0503 t3 = new RcThread0503(); + RcThread0504 t4 = new RcThread0504(); + RcThread0505 t5 = new RcThread0505(); + RcThread0506 t6 = new RcThread0506(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + t6.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + }catch(InterruptedException e){ + // do nothing + } + } + void setA1null() { + a1Main = null; + } + void setA4null() { + a4Main = null; + } + void setA5null() { + a5Main = null; + } + void setA1() { + try { + this.a1Main = new RcThread05A1(); + a1Main.a2_0 = new RcThread05A2(); + a1Main.a2_0.a3_0 = new RcThread05A3(); + } catch (NullPointerException e) { + // do nothing + } + } + void checkA3() { + try { + int a = a1Main.a2_0.a3_0.a; + } catch (NullPointerException e) { + // do nothing + } + } + void setA3_a(int a) { + try { + this.a1Main.a2_0.a3_0.a = a; + } catch (NullPointerException e) { } + } + static class RcThread05A1 { + volatile RcThread05A2 a2_0; + int a; + int sum; + RcThread05A1() { + a2_0 = null; + a = 1; + sum = 0; + } + } + static class RcThread05A2 { + volatile RcThread05A3 a3_0; + int a; + int sum; + RcThread05A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + static class RcThread05A3 { + volatile RcThread05A1 a1_0; + int a; + int sum; + RcThread05A3() { + a1_0 = null; + a = 3; + sum = 0; + } + } + static class RcThread05A4 { + volatile RcThread05A1 a1_0; + int a; + int sum; + RcThread05A4() { + a1_0 = null; + a = 4; + sum = 0; + } + } + static class RcThread05A5 { + volatile RcThread05A1 a1_0; + int a; + int sum; + RcThread05A5() { + a1_0 = null; + a = 5; + sum = 0; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/expected.txt b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/test.cfg b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..49c35b615894e835c5b1d65be552abe2b02f8310 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0232-rc-function-RC_Thread02-RC_Thread_05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_05) +run(RC_Thread_05,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java new file mode 100644 index 0000000000000000000000000000000000000000..a7b79d01a8aba797b052b064e906f38d8cedb106 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/RC_Thread_06.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RcThread0601 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0602 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0603 extends Thread { + public void run() { + RC_Thread_06 rcth01 = new RC_Thread_06(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread06GC extends Thread { + public void run() { + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 50); + if (start == 50) { + System.out.println("ExpectResult"); + } + } +} +public class RC_Thread_06 { + private static volatile RcThread06A1 a1Main = null; + private static volatile RcThread06A5 a5Main = null; + RC_Thread_06() { + try { + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + } catch (NullPointerException e) { + // do nothing + } + } + public static void main(String[] args) { + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + RcThread06GC gc = new RcThread06GC(); + gc.run(); + int start = 0; + for (;start < 20; start++) { + rcTestcaseMainWrapper(); + } + if (start == 20) { + System.out.println("ExpectResult"); + } + } + private static void cyclePatternWrapper() { + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + a1Main = null; + a5Main = null; + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a1Main = null; + a1Main = new RcThread06A1(); + a1Main.a2_0 = new RcThread06A2(); + a1Main.a2_0.a3_0 = new RcThread06A3(); + a1Main.a2_0.a3_0.a4_0 = new RcThread06A4(); + a1Main.a2_0.a3_0.a4_0.a1_0 = a1Main; + a5Main = new RcThread06A5(); + a1Main.a2_0.a3_0.a4_0.a6_0 = new RcThread06A6(); + a1Main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5Main; + a5Main.a3_0 = a1Main.a2_0.a3_0; + a1Main.a2_0.a3_0 = null; + a1Main = null; + a5Main = null; //总共三种环类型 + } + private static void rcTestcaseMainWrapper() { + RcThread0601 t1 = new RcThread0601(); + RcThread0602 t2 = new RcThread0602(); + RcThread0603 t3 = new RcThread0603(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e){ + // do nothing + } + } + void setA1null() { + a1Main = null; + } + void setA4null() { + try { + a1Main.a2_0.a3_0.a4_0 = null; + a5Main.a3_0.a4_0 = null; + } catch (NullPointerException e) { } + } + void setA5null() { + a5Main = null; + } + static class RcThread06A1 { + volatile RcThread06A2 a2_0; + volatile RcThread06A4 a4_0; + int a; + int sum; + RcThread06A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + } + static class RcThread06A2 { + volatile RcThread06A3 a3_0; + int a; + int sum; + RcThread06A2() { + a3_0 = null; + a = 2; + sum = 0; + } + } + static class RcThread06A3 { + volatile RcThread06A4 a4_0; + int a; + int sum; + RcThread06A3() { + a4_0 = null; + a = 3; + sum = 0; + } + } + static class RcThread06A4 { + volatile RcThread06A1 a1_0; + volatile RcThread06A6 a6_0; + int a; + int sum; + RcThread06A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + } + static class RcThread06A5 { + volatile RcThread06A3 a3_0; + int a; + int sum; + RcThread06A5() { + a3_0 = null; + a = 5; + sum = 0; + } + } + static class RcThread06A6 { + volatile RcThread06A5 a5_0; + int a; + int sum; + RcThread06A6() { + a5_0 = null; + a = 6; + sum = 0; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/expected.txt b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/test.cfg b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..98579d7b9fbf406921a7ea61fe10a4a5294e1bf0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0233-rc-function-RC_Thread02-RC_Thread_06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_06) +run(RC_Thread_06,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java new file mode 100644 index 0000000000000000000000000000000000000000..4166bc00ce0cd86136364a1777fdcbdf5a10e7e9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/RC_Thread_07.java @@ -0,0 +1,233 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RcThread0701 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.modifyA1(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0702 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.checkA4(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread0703 extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + try { + rcth01.setA5(); + } catch (NullPointerException e) { + // do nothing + } + } +} +class RcThread07GC extends Thread { + public void run() { + RC_Thread_07 rcth01 = new RC_Thread_07(); + int start = 0; + do { + Runtime.getRuntime().gc(); + start++; + } while (start < 20); + } +} +public class RC_Thread_07 { + private static volatile RcThread07A1 a1_main = null; + private static volatile RcThread07A5 a5_main = null; + RC_Thread_07() { + try { + RcThread07A1 a1_1 = new RcThread07A1(); + a1_1.a2_0 = new RcThread07A2(); + a1_1.a2_0.a3_0 = new RcThread07A3(); + a1_1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1_1.a2_0.a3_0.a4_0.a1_0 = a1_1; + RcThread07A5 a5_1 = new RcThread07A5(); + a1_1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1_1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_1; + a5_1.a3_0 = a1_1.a2_0.a3_0; + a1_main = a1_1; + a5_main = a5_1; + } catch (NullPointerException e) { + // do nothing + } + } + public static void main(String[] args) { + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + cyclePatternWrapper(); + Runtime.getRuntime().gc(); + RcThread07GC gc = new RcThread07GC(); + gc.start(); + rcTestcaseMainWrapper(); + rcTestcaseMainWrapper(); + System.out.println("ExpectResult"); + } + private static void cyclePatternWrapper() { + RcThread07A1 a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RcThread07A5 a5 = new RcThread07A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1 = null; + a5 = null; + a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + a1 = null; + a1 = new RcThread07A1(); + a1.a2_0 = new RcThread07A2(); + a1.a2_0.a3_0 = new RcThread07A3(); + a1.a2_0.a3_0.a4_0 = new RcThread07A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + a5 = new RcThread07A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RcThread07A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1.a2_0.a3_0 = null; + a1 = null; + a5 = null; + } + private static void rcTestcaseMainWrapper() { + RcThread0701 t1 = new RcThread0701(); + RcThread0702 t2 = new RcThread0702(); + RcThread0703 t3 = new RcThread0703(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e){ + // do nothing + } + } + void modifyA1() { + a1_main.a2_0.a3_0 = null; + a1_main = null; + } + void checkA4() { + try { + int[] arr = new int[2]; + arr[0] = a5_main.a3_0.a4_0.sum; + arr[1] = a5_main.a3_0.a4_0.a; + } catch (NullPointerException e) { + // do nothing + } + } + void setA5() { + RcThread07A5 a5 = new RcThread07A5(); + a5 = this.a5_main; + a5_main = null; + } + static class RcThread07A1 { + volatile RcThread07A2 a2_0; + volatile RcThread07A4 a4_0; + int a; + int sum; + RcThread07A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RcThread07A2 { + volatile RcThread07A3 a3_0; + int a; + int sum; + RcThread07A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RcThread07A3 { + volatile RcThread07A4 a4_0; + int a; + int sum; + RcThread07A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + static class RcThread07A4 { + volatile RcThread07A1 a1_0; + volatile RcThread07A6 a6_0; + int a; + int sum; + RcThread07A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + static class RcThread07A5 { + volatile RcThread07A3 a3_0; + int a; + int sum; + RcThread07A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RcThread07A6 { + volatile RcThread07A5 a5_0; + int a; + int sum; + RcThread07A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/expected.txt b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/test.cfg b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7e5fbb17f772e6776345fbda14783166067dd13c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0234-rc-function-RC_Thread02-RC_Thread_07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_07) +run(RC_Thread_07,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java new file mode 100755 index 0000000000000000000000000000000000000000..8911b9b73610047a9244a8e353dae85000d98f95 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/RC_Thread_08.java @@ -0,0 +1,234 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_08_1 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_08_2 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_08_3 extends Thread { + public void run() { + RC_Thread_08 rcth01 = new RC_Thread_08(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_08 { + private volatile static RC_Thread_08_A1 a1_main = null; + private volatile static RC_Thread_08_A4 a4_main = null; + private volatile static RC_Thread_08_A6 a6_main = null; + RC_Thread_08() { + try { + RC_Thread_08_A1 a1 = new RC_Thread_08_A1("a1"); + RC_Thread_08_A4 a4 = new RC_Thread_08_A4("a4"); + RC_Thread_08_A6 a6 = new RC_Thread_08_A6("a6"); + a1.a2_0 = new RC_Thread_08_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_08_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_08_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + RC_Thread_08_A1 a1 = new RC_Thread_08_A1("a1"); + RC_Thread_08_A4 a4 = new RC_Thread_08_A4("a4"); + RC_Thread_08_A6 a6 = new RC_Thread_08_A6("a6"); + a1.a2_0 = new RC_Thread_08_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_08_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_08_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_08_1 t_00010= new RC_Thread_08_1(); + RC_Thread_08_2 t_00020= new RC_Thread_08_2(); + RC_Thread_08_3 t_00030= new RC_Thread_08_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + } catch (InterruptedException e) {} + } + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + } + } + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_08_A3("new-a3"); + } catch (NullPointerException e) { + } + } + public void setA3null() { + RC_Thread_08_A3 a3 = new RC_Thread_08_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + } + } + static class RC_Thread_08_A1 { + volatile RC_Thread_08_A2 a2_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_08_A2 { + volatile RC_Thread_08_A3 a3_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_08_A3 { + volatile RC_Thread_08_A1 a1_0; + volatile RC_Thread_08_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + static class RC_Thread_08_A4 { + volatile RC_Thread_08_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + static class RC_Thread_08_A5 { + volatile RC_Thread_08_A6 a6_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + static class RC_Thread_08_A6 { + volatile RC_Thread_08_A1 a1_0; + volatile RC_Thread_08_A3 a3_0; + volatile RC_Thread_08_A4 a4_0; + int a; + int sum; + String strObjectName; + RC_Thread_08_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/expected.txt b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/test.cfg b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..55d09cf3adccb2bc3365f3a3f072b5c0a5c725c6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0235-rc-function-RC_Thread02-RC_Thread_08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_08) +run(RC_Thread_08,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java new file mode 100755 index 0000000000000000000000000000000000000000..26935a9d415c660cb8123e7150743ba7239d8dcf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/RC_Thread_09.java @@ -0,0 +1,345 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_09_1 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_09_2 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_09_3 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_09_4 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_09_5 extends Thread { + public void run() { + RC_Thread_09 rcth01 = new RC_Thread_09(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_09 { + private static RC_Thread_09_A1 a1_main = null; + private static RC_Thread_09_A2 a2_main = null; + private static RC_Thread_09_A3 a3_main = null; + private static RC_Thread_09_A4 a4_main = null; + RC_Thread_09() { + try { + a1_main = new RC_Thread_09_A1("a1_main"); + a2_main = new RC_Thread_09_A2("a2_main"); + a3_main = new RC_Thread_09_A3("a3_main"); + a4_main = new RC_Thread_09_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_09_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_09_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a2_main.b2_0 = new RC_Thread_09_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a3_main.b2_0 = new RC_Thread_09_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + a3_main.c2_0 = new RC_Thread_09_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + a4_main.b3_0 = new RC_Thread_09_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_09_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_09_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_09_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_09_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_09_D3("d3_0"); + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_09_1 t1 = new RC_Thread_09_1(); + RC_Thread_09_2 t2 = new RC_Thread_09_2(); + RC_Thread_09_3 t3 = new RC_Thread_09_3(); + RC_Thread_09_4 t4 = new RC_Thread_09_4(); + RC_Thread_09_5 t5 = new RC_Thread_09_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA2null() { + a2_main = null; + } + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_09_D2("new"); + a3_main = new RC_Thread_09_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + } + } + public void setA3null() { + a3_main = null; + } + public void setA4null() { + a4_main = null; + } + class RC_Thread_09_A1 { + RC_Thread_09_B1 b1_0; + RC_Thread_09_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class RC_Thread_09_A2 { + RC_Thread_09_B2 b2_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class RC_Thread_09_A3 { + RC_Thread_09_B2 b2_0; + RC_Thread_09_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class RC_Thread_09_A4 { + RC_Thread_09_B3 b3_0; + RC_Thread_09_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class RC_Thread_09_B1 { + RC_Thread_09_D2 d2_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class RC_Thread_09_B2 { + RC_Thread_09_C1 c1_0; + RC_Thread_09_D1 d1_0; + RC_Thread_09_D2 d2_0; + RC_Thread_09_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class RC_Thread_09_B3 { + RC_Thread_09_C1 c1_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class RC_Thread_09_C1 { + RC_Thread_09_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class RC_Thread_09_C2 { + RC_Thread_09_D2 d2_0; + RC_Thread_09_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_09_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class RC_Thread_09_D1 { + int a; + int sum; + String strObjectName; + RC_Thread_09_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_09_D2 { + int a; + int sum; + String strObjectName; + RC_Thread_09_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_09_D3 { + int a; + int sum; + String strObjectName; + RC_Thread_09_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/expected.txt b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/test.cfg b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c42d05743de997695c111807375b6dd5c0d5b7c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0236-rc-function-RC_Thread02-RC_Thread_09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_09) +run(RC_Thread_09,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java new file mode 100755 index 0000000000000000000000000000000000000000..f008b7be34802879c4965221ddef86588eadc4d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/RC_Thread_10.java @@ -0,0 +1,241 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_10_1 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_10_2 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_10_3 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_10_4 extends Thread { + public void run() { + RC_Thread_10 rcth01 = new RC_Thread_10("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_10 { + private static RC_Thread_10_A1 a1 = null; + RC_Thread_10(String str) { + try { + a1 = new RC_Thread_10_A1("a1"); + a1.b1_0 = new RC_Thread_10_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_10_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_10_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_10_C3("c3_0"); + a1.b2_0 = new RC_Thread_10_B2("b2_0"); + a1.b3_0 = new RC_Thread_10_B3("b3_0"); + a1.b4_0 = new RC_Thread_10_B4("b4_0"); + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_10_1 t1 = new RC_Thread_10_1(); + RC_Thread_10_2 t2 = new RC_Thread_10_2(); + RC_Thread_10_3 t3 = new RC_Thread_10_3(); + RC_Thread_10_4 t4 = new RC_Thread_10_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + } catch (InterruptedException e) { + } + } + public void deleteA1() { + a1 = null; + } + public void ModifyB4() { + try { + a1.b4_0 = new RC_Thread_10_B4("new_b4"); + } catch (NullPointerException e) { + } + } + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + } + } + public void setA1(RC_Thread_10_A1 a1) { + this.a1 = a1; + } + class RC_Thread_10_A1 { + RC_Thread_10_B1 b1_0; + RC_Thread_10_B2 b2_0; + RC_Thread_10_B3 b3_0; + RC_Thread_10_B4 b4_0; + int a; + int sum; + String strObjectName; + RC_Thread_10_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class RC_Thread_10_B1 { + RC_Thread_10_C1 c1_0; + RC_Thread_10_C2 c2_0; + RC_Thread_10_C3 c3_0; + int a; + int sum; + String strObjectName; + RC_Thread_10_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class RC_Thread_10_B2 { + int a; + int sum; + String strObjectName; + RC_Thread_10_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_10_B3 { + int a; + int sum; + String strObjectName; + RC_Thread_10_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_10_B4 { + int a; + int sum; + String strObjectName; + RC_Thread_10_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_10_C1 { + int a; + int sum; + String strObjectName; + RC_Thread_10_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_10_C2 { + int a; + int sum; + String strObjectName; + RC_Thread_10_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_10_C3 { + int a; + int sum; + String strObjectName; + RC_Thread_10_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/expected.txt b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/test.cfg b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..998cf876eff57f9a79ca5773e6a0f8aba66a5c64 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0237-rc-function-RC_Thread02-RC_Thread_10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_10) +run(RC_Thread_10,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java new file mode 100755 index 0000000000000000000000000000000000000000..4fa65165870720be438f0f7f9e7681a6dc466314 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/RC_Thread_11.java @@ -0,0 +1,348 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_11_1 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_11_2 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA2null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_11_3 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_11_4 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_11_5 extends Thread { + public void run() { + RC_Thread_11 rcth01 = new RC_Thread_11(); + try { + rcth01.setA4(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_11 { + private static RC_Thread_11_A1 a1_main = null; + private static RC_Thread_11_A2 a2_main = null; + private static RC_Thread_11_A3 a3_main = null; + private static RC_Thread_11_A4 a4_main = null; + RC_Thread_11() { + try { + a1_main = new RC_Thread_11_A1("a1_main"); + a2_main = new RC_Thread_11_A2("a2_main"); + a3_main = new RC_Thread_11_A3("a3_main"); + a4_main = new RC_Thread_11_A4("a4_main"); + a1_main.b1_0 = new RC_Thread_11_B1("b1_0"); + a1_main.d1_0 = new RC_Thread_11_D1("d1_0"); + a1_main.b1_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a2_main.b2_0 = new RC_Thread_11_B2("b2_0"); + a2_main.b2_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a2_main.b2_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a2_main.b2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a2_main.b2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a3_main.b2_0 = new RC_Thread_11_B2("b2_0"); + a3_main.b2_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a3_main.b2_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a3_main.b2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a3_main.b2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + a3_main.c2_0 = new RC_Thread_11_C2("c2_0"); + a3_main.c2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a3_main.c2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + a4_main.b3_0 = new RC_Thread_11_B3("b3_0"); + a4_main.b3_0.c1_0 = new RC_Thread_11_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new RC_Thread_11_D1("d1_0"); + a4_main.c2_0 = new RC_Thread_11_C2("c2_0"); + a4_main.c2_0.d2_0 = new RC_Thread_11_D2("d2_0"); + a4_main.c2_0.d3_0 = new RC_Thread_11_D3("d3_0"); + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_11_1 t1 = new RC_Thread_11_1(); + RC_Thread_11_2 t2 = new RC_Thread_11_2(); + RC_Thread_11_3 t3 = new RC_Thread_11_3(); + RC_Thread_11_4 t4 = new RC_Thread_11_4(); + RC_Thread_11_5 t5 = new RC_Thread_11_5(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA2null() { + a2_main = null; + } + public void setA3() { + try { + a3_main.c2_0.d2_0 = new RC_Thread_11_D2("new"); + a3_main = new RC_Thread_11_A3("a3_new"); + a3_main = null; + } catch (NullPointerException e) { + } + } + public void setA3null() { + a3_main = null; + } + public void setA4() { + try { + a4_main = new RC_Thread_11_A4("a4_new"); + } catch (NullPointerException e) { + } + } + class RC_Thread_11_A1 { + RC_Thread_11_B1 b1_0; + RC_Thread_11_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class RC_Thread_11_A2 { + RC_Thread_11_B2 b2_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class RC_Thread_11_A3 { + RC_Thread_11_B2 b2_0; + RC_Thread_11_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class RC_Thread_11_A4 { + RC_Thread_11_B3 b3_0; + RC_Thread_11_C2 c2_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class RC_Thread_11_B1 { + RC_Thread_11_D2 d2_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class RC_Thread_11_B2 { + RC_Thread_11_C1 c1_0; + RC_Thread_11_D1 d1_0; + RC_Thread_11_D2 d2_0; + RC_Thread_11_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class RC_Thread_11_B3 { + RC_Thread_11_C1 c1_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class RC_Thread_11_C1 { + RC_Thread_11_D1 d1_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class RC_Thread_11_C2 { + RC_Thread_11_D2 d2_0; + RC_Thread_11_D3 d3_0; + int a; + int sum; + String strObjectName; + RC_Thread_11_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class RC_Thread_11_D1 { + int a; + int sum; + String strObjectName; + RC_Thread_11_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_11_D2 { + int a; + int sum; + String strObjectName; + RC_Thread_11_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_11_D3 { + int a; + int sum; + String strObjectName; + RC_Thread_11_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/expected.txt b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/test.cfg b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..78d48ddf2984688b43339d45a6cab72d14e5c6dc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0238-rc-function-RC_Thread02-RC_Thread_11/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_11) +run(RC_Thread_11,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java new file mode 100755 index 0000000000000000000000000000000000000000..55c4e2330b68d13bb6cb116d5d6163e0cb36e494 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/RC_Thread_12.java @@ -0,0 +1,174 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_12_1 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_12_2 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_12_3 extends Thread { + public void run() { + RC_Thread_12 rcth01 = new RC_Thread_12(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_12 { + private static RC_Thread_12_A1 a1_main = null; + private static RC_Thread_12_A4 a4_main = null; + private static RC_Thread_12_A5 a5_main = null; + RC_Thread_12() { + try { + a1_main = new RC_Thread_12_A1(); + a1_main.a2_0 = new RC_Thread_12_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_12_A3(); + a4_main = new RC_Thread_12_A4(); + a5_main = new RC_Thread_12_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_12_A1(); + a1_main.a2_0 = new RC_Thread_12_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_12_A3(); + a4_main = new RC_Thread_12_A4(); + a5_main = new RC_Thread_12_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main=null; + a4_main=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_12_1 t1 = new RC_Thread_12_1(); + RC_Thread_12_2 t2 = new RC_Thread_12_2(); + RC_Thread_12_3 t3 = new RC_Thread_12_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + a4_main = null; + } + public void setA5null() { + a5_main = null; + } + static class RC_Thread_12_A1 { + RC_Thread_12_A2 a2_0; + int a; + int sum; + RC_Thread_12_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_12_A2 { + RC_Thread_12_A3 a3_0; + int a; + int sum; + RC_Thread_12_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_12_A3 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + RC_Thread_12_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RC_Thread_12_A4 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + RC_Thread_12_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RC_Thread_12_A5 { + RC_Thread_12_A1 a1_0; + int a; + int sum; + RC_Thread_12_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/expected.txt b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/test.cfg b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3009053340578a112ff0c800a32865f6548fe18f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0239-rc-function-RC_Thread02-RC_Thread_12/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_12) +run(RC_Thread_12,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java new file mode 100755 index 0000000000000000000000000000000000000000..8a7d61d88e67ab5e57c3b53e975d85833cfdfd7f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/RC_Thread_13.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_13_1 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_13_2 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_13_3 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_13_4 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA1(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_13_5 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_13_6 extends Thread { + public void run() { + RC_Thread_13 rcth01 = new RC_Thread_13(); + try { + rcth01.setA3_a(5); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_13 { + private static RC_Thread_13_A1 a1_main = null; + private static RC_Thread_13_A4 a4_main = null; + private static RC_Thread_13_A5 a5_main = null; + RC_Thread_13() { + try { + a1_main = new RC_Thread_13_A1(); + a1_main.a2_0 = new RC_Thread_13_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_13_A3(); + a4_main = new RC_Thread_13_A4(); + a5_main = new RC_Thread_13_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_13_1 t1 = new RC_Thread_13_1(); + RC_Thread_13_2 t2 = new RC_Thread_13_2(); + RC_Thread_13_3 t3 = new RC_Thread_13_3(); + RC_Thread_13_4 t4 = new RC_Thread_13_4(); + RC_Thread_13_5 t5 = new RC_Thread_13_5(); + RC_Thread_13_6 t6 = new RC_Thread_13_6(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + t5.start(); + t6.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + t5.join(); + t6.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + a4_main = null; + } + public void setA5null() { + a5_main = null; + } + public void setA1() { + try { + this.a1_main = new RC_Thread_13_A1(); + a1_main.a2_0 = new RC_Thread_13_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_13_A3(); + } catch (NullPointerException e) { + } + } + public void checkA3() { + try { + int a = a1_main.a2_0.a3_0.a; + } catch (NullPointerException e) { + } + } + public void setA3_a(int a) { + try { + this.a1_main.a2_0.a3_0.a = a; + } catch (NullPointerException e) { + } + } + class RC_Thread_13_A1 { + RC_Thread_13_A2 a2_0; + int a; + int sum; + RC_Thread_13_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class RC_Thread_13_A2 { + RC_Thread_13_A3 a3_0; + int a; + int sum; + RC_Thread_13_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class RC_Thread_13_A3 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + RC_Thread_13_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class RC_Thread_13_A4 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + RC_Thread_13_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class RC_Thread_13_A5 { + RC_Thread_13_A1 a1_0; + int a; + int sum; + RC_Thread_13_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/expected.txt b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/test.cfg b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1712965dde1592914f59e1cc3ec948fb10451c53 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0240-rc-function-RC_Thread02-RC_Thread_13/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_13) +run(RC_Thread_13,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java new file mode 100755 index 0000000000000000000000000000000000000000..63c3b2c31331cd23a08fd3e888f7b072f2a2f7fb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/RC_Thread_14.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_14_1 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +class RC_Thread_14_2 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +class RC_Thread_14_3 extends Thread { + public void run() { + RC_Thread_14 rcth01 = new RC_Thread_14(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +public class RC_Thread_14 { + private static RC_Thread_14_A1 a1_main = null; + private static RC_Thread_14_A5 a5_main = null; + RC_Thread_14() { + try { + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main=null; + a5_main=null; + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a1_main=null; + a1_main = new RC_Thread_14_A1(); + a1_main.a2_0 = new RC_Thread_14_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_14_A3(); + a1_main.a2_0.a3_0.a4_0 = new RC_Thread_14_A4(); + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_14_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_14_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a2_0.a3_0=null; + a1_main=null; + a5_main=null; + //Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_14_1 t1 = new RC_Thread_14_1(); + RC_Thread_14_2 t2 = new RC_Thread_14_2(); + RC_Thread_14_3 t3 = new RC_Thread_14_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + try { + a1_main.a2_0.a3_0.a4_0 = null; + a5_main.a3_0.a4_0 = null; + } catch (NullPointerException e) { + } + } + public void setA5null() { + a5_main = null; + } + static class RC_Thread_14_A1 { + RC_Thread_14_A2 a2_0; + RC_Thread_14_A4 a4_0; + int a; + int sum; + RC_Thread_14_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_14_A2 { + RC_Thread_14_A3 a3_0; + int a; + int sum; + RC_Thread_14_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_14_A3 { + RC_Thread_14_A4 a4_0; + int a; + int sum; + RC_Thread_14_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + static class RC_Thread_14_A4 { + RC_Thread_14_A1 a1_0; + RC_Thread_14_A6 a6_0; + int a; + int sum; + RC_Thread_14_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + static class RC_Thread_14_A5 { + RC_Thread_14_A3 a3_0; + int a; + int sum; + RC_Thread_14_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_14_A6 { + RC_Thread_14_A5 a5_0; + int a; + int sum; + RC_Thread_14_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/expected.txt b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/test.cfg b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fd39795ec6c5a61be58695f3b96776d2a13dcf99 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0241-rc-function-RC_Thread02-RC_Thread_14/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_14) +run(RC_Thread_14,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java new file mode 100755 index 0000000000000000000000000000000000000000..6f5fb7367a1b5c73d9fe2655a99f8e943f8c2fe7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/RC_Thread_15.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_15_1 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.ModifyA1(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_15_2 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.checkA4(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_15_3 extends Thread { + public void run() { + RC_Thread_15 rcth01 = new RC_Thread_15(); + try { + rcth01.setA5(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_15 { + private static RC_Thread_15_A1 a1_main = null; + private static RC_Thread_15_A5 a5_main = null; + RC_Thread_15() { + try { + RC_Thread_15_A1 a1 = new RC_Thread_15_A1(); + a1.a2_0 = new RC_Thread_15_A2(); + a1.a2_0.a3_0 = new RC_Thread_15_A3(); + a1.a2_0.a3_0.a4_0 = new RC_Thread_15_A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_15_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1_main = a1; + a5_main = a5; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + RC_Thread_15_A1 a1 = new RC_Thread_15_A1(); + a1.a2_0 = new RC_Thread_15_A2(); + a1.a2_0.a3_0 = new RC_Thread_15_A3(); + a1.a2_0.a3_0.a4_0 = new RC_Thread_15_A4(); + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_15_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1=null; + a5=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_15_1 t1 = new RC_Thread_15_1(); + RC_Thread_15_2 t2 = new RC_Thread_15_2(); + RC_Thread_15_3 t3 = new RC_Thread_15_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + public void ModifyA1() { + a1_main.a2_0.a3_0 = null; + a1_main = null; + } + public void checkA4() { + try { + int[] arr = new int[2]; + arr[0] = a5_main.a3_0.a4_0.sum; + arr[1] = a5_main.a3_0.a4_0.a; + } catch (NullPointerException e) { + } + } + public void setA5() { + RC_Thread_15_A5 a5 = new RC_Thread_15_A5(); + a5 = this.a5_main; + a5_main = null; + } + static class RC_Thread_15_A1 { + RC_Thread_15_A2 a2_0; + RC_Thread_15_A4 a4_0; + int a; + int sum; + RC_Thread_15_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_15_A2 { + RC_Thread_15_A3 a3_0; + int a; + int sum; + RC_Thread_15_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_15_A3 { + RC_Thread_15_A4 a4_0; + int a; + int sum; + RC_Thread_15_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + static class RC_Thread_15_A4 { + RC_Thread_15_A1 a1_0; + RC_Thread_15_A6 a6_0; + int a; + int sum; + RC_Thread_15_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + static class RC_Thread_15_A5 { + RC_Thread_15_A3 a3_0; + int a; + int sum; + RC_Thread_15_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_15_A6 { + RC_Thread_15_A5 a5_0; + int a; + int sum; + RC_Thread_15_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/expected.txt b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/test.cfg b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..58cab3b4c0140ccd01ab25e0d84fd97f8d7c8566 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0242-rc-function-RC_Thread02-RC_Thread_15/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_15) +run(RC_Thread_15,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java new file mode 100755 index 0000000000000000000000000000000000000000..b158185f79ada6026fa4a4899f9b53b607d257ec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/RC_Thread_16.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_16_1 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_16_2 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_16_3 extends Thread { + public void run() { + RC_Thread_16 rcth01 = new RC_Thread_16(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_16 { + private static RC_Thread_16_A1 a1_main = null; + private static RC_Thread_16_A4 a4_main = null; + private static RC_Thread_16_A6 a6_main = null; + RC_Thread_16() { + try { + RC_Thread_16_A1 a1 = new RC_Thread_16_A1("a1"); + RC_Thread_16_A4 a4 = new RC_Thread_16_A4("a4"); + RC_Thread_16_A6 a6 = new RC_Thread_16_A6("a6"); + a1.a2_0 = new RC_Thread_16_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_16_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_16_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + RC_Thread_16_A1 a1 = new RC_Thread_16_A1("a1"); + RC_Thread_16_A4 a4 = new RC_Thread_16_A4("a4"); + RC_Thread_16_A6 a6 = new RC_Thread_16_A6("a6"); + a1.a2_0 = new RC_Thread_16_A2("a2_0"); + a1.a2_0.a3_0 = new RC_Thread_16_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_16_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_16_1 t_00010 = new RC_Thread_16_1(); + RC_Thread_16_2 t_00020 = new RC_Thread_16_2(); + RC_Thread_16_3 t_00030 = new RC_Thread_16_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + } catch (InterruptedException e) { + } + } + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + } + } + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_16_A3("new-a3"); + } catch (NullPointerException e) { + } + } + public void setA3null() { + RC_Thread_16_A3 a3 = new RC_Thread_16_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + } + } + static class RC_Thread_16_A1 { + RC_Thread_16_A2 a2_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_16_A2 { + RC_Thread_16_A3 a3_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_16_A3 { + RC_Thread_16_A1 a1_0; + RC_Thread_16_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + static class RC_Thread_16_A4 { + RC_Thread_16_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + static class RC_Thread_16_A5 { + RC_Thread_16_A6 a6_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + static class RC_Thread_16_A6 { + RC_Thread_16_A1 a1_0; + RC_Thread_16_A3 a3_0; + RC_Thread_16_A4 a4_0; + int a; + int sum; + String strObjectName; + RC_Thread_16_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/expected.txt b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/test.cfg b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..123968aed3d923db1c9adab7a134968b00adebd3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0243-rc-function-RC_Thread02-RC_Thread_16/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_16) +run(RC_Thread_16,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java new file mode 100755 index 0000000000000000000000000000000000000000..16c19b8d6da5bd6ca7dc46fe016df1e9045f3156 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/RC_Thread_17.java @@ -0,0 +1,178 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_17_1 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_17_2 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_17_3 extends Thread { + public void run() { + RC_Thread_17 rcth01 = new RC_Thread_17(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_17 { + private static RC_Thread_17_A1 a1_main = null; + private static RC_Thread_17_A4 a4_main = null; + private static RC_Thread_17_A5 a5_main = null; + private static RC_Thread_17_A2 a2=null; + RC_Thread_17() { + try { + a1_main = new RC_Thread_17_A1(); + a2 = new RC_Thread_17_A2(); + a1_main.a2_0=a2; + a1_main.a2_0.a3_0 = new RC_Thread_17_A3(); + a4_main = new RC_Thread_17_A4(); + a5_main = new RC_Thread_17_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_17_A1(); + a2 = new RC_Thread_17_A2(); + a1_main.a2_0=a2; + a1_main.a2_0.a3_0 = new RC_Thread_17_A3(); + a4_main = new RC_Thread_17_A4(); + a5_main = new RC_Thread_17_A5(); + a4_main.a1_0 = a1_main; + a5_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main=null; + a4_main=null; + a2=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_17_1 t1 = new RC_Thread_17_1(); + RC_Thread_17_2 t2 = new RC_Thread_17_2(); + RC_Thread_17_3 t3 = new RC_Thread_17_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + a4_main = null; + } + public void setA5null() { + a5_main = null; + } + static class RC_Thread_17_A1 { + RC_Thread_17_A2 a2_0; + int a; + int sum; + RC_Thread_17_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_17_A2 { + RC_Thread_17_A3 a3_0; + int a; + int sum; + RC_Thread_17_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_17_A3 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + RC_Thread_17_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RC_Thread_17_A4 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + RC_Thread_17_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RC_Thread_17_A5 { + RC_Thread_17_A1 a1_0; + int a; + int sum; + RC_Thread_17_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/expected.txt b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/test.cfg b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a436aa5e961830e1d899c496e5161f896aa38870 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0244-rc-function-RC_Thread02-RC_Thread_17/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_17) +run(RC_Thread_17,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java new file mode 100755 index 0000000000000000000000000000000000000000..40035dc0dac89fe2d8ac09bc1fb9bdedcb41a3cb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/RC_Thread_18.java @@ -0,0 +1,238 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_18_1 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_18_2 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_18_3 extends Thread { + public void run() { + RC_Thread_18 rcth01 = new RC_Thread_18(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_18 { + private volatile static RC_Thread_18_A1 a1_main = null; + private volatile static RC_Thread_18_A4 a4_main = null; + private volatile static RC_Thread_18_A6 a6_main = null; + private static RC_Thread_18_A2 a2=null; + RC_Thread_18() { + try { + RC_Thread_18_A1 a1 = new RC_Thread_18_A1("a1"); + RC_Thread_18_A4 a4 = new RC_Thread_18_A4("a4"); + RC_Thread_18_A6 a6 = new RC_Thread_18_A6("a6"); + a2 = new RC_Thread_18_A2("a2_0"); + a1.a2_0=a2; + a1.a2_0.a3_0 = new RC_Thread_18_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_18_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + RC_Thread_18_A1 a1 = new RC_Thread_18_A1("a1"); + RC_Thread_18_A4 a4 = new RC_Thread_18_A4("a4"); + RC_Thread_18_A6 a6 = new RC_Thread_18_A6("a6"); + a2 = new RC_Thread_18_A2("a2_0"); + a1.a2_0=a2; + a1.a2_0.a3_0 = new RC_Thread_18_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RC_Thread_18_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1=null; + a2=null; + a4=null; + a6=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_18_1 t_00010= new RC_Thread_18_1(); + RC_Thread_18_2 t_00020= new RC_Thread_18_2(); + RC_Thread_18_3 t_00030= new RC_Thread_18_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + } catch (InterruptedException e) {} + } + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + } + } + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RC_Thread_18_A3("new-a3"); + } catch (NullPointerException e) { + } + } + public void setA3null() { + RC_Thread_18_A3 a3 = new RC_Thread_18_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + } + } + static class RC_Thread_18_A1 { + volatile RC_Thread_18_A2 a2_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_18_A2 { + volatile RC_Thread_18_A3 a3_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_18_A3 { + volatile RC_Thread_18_A1 a1_0; + volatile RC_Thread_18_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + static class RC_Thread_18_A4 { + volatile RC_Thread_18_A5 a5_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + static class RC_Thread_18_A5 { + volatile RC_Thread_18_A6 a6_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + static class RC_Thread_18_A6 { + volatile RC_Thread_18_A1 a1_0; + volatile RC_Thread_18_A3 a3_0; + volatile RC_Thread_18_A4 a4_0; + int a; + int sum; + String strObjectName; + RC_Thread_18_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/expected.txt b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/test.cfg b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0eaa4eed1cf26f0d23c75af6ef795394bb71ee13 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0245-rc-function-RC_Thread02-RC_Thread_18/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_18) +run(RC_Thread_18,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java new file mode 100755 index 0000000000000000000000000000000000000000..abf28516cf67fcfcd0a4f0bc203a3955e701b1d6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/RC_Thread_19.java @@ -0,0 +1,243 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class RC_Thread_19_1 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.addSum(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_19_2 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.ModifyB4(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_19_3 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.deleteA1(); + } catch (NullPointerException e) { + } + } +} +class RC_Thread_19_4 extends Thread { + public void run() { + RC_Thread_19 rcth01 = new RC_Thread_19("rcth01"); + try { + rcth01.setA1(null); + } catch (NullPointerException e) { + } + } +} +public class RC_Thread_19 { + private static RC_Thread_19_A1 a1 = null; + private volatile static RC_Thread_19_B4 b4; + RC_Thread_19(String str) { + try { + a1 = new RC_Thread_19_A1("a1"); + a1.b1_0 = new RC_Thread_19_B1("b1_0"); + a1.b1_0.c1_0 = new RC_Thread_19_C1("c1_0"); + a1.b1_0.c2_0 = new RC_Thread_19_C2("c2_0"); + a1.b1_0.c3_0 = new RC_Thread_19_C3("c3_0"); + a1.b2_0 = new RC_Thread_19_B2("b2_0"); + a1.b3_0 = new RC_Thread_19_B3("b3_0"); + b4=new RC_Thread_19_B4("b4_0"); + a1.b4_0 =b4; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_19_1 t1 = new RC_Thread_19_1(); + RC_Thread_19_2 t2 = new RC_Thread_19_2(); + RC_Thread_19_3 t3 = new RC_Thread_19_3(); + RC_Thread_19_4 t4 = new RC_Thread_19_4(); + t1.start(); + t2.start(); + t3.start(); + t4.start(); + try { + t1.join(); + t2.join(); + t3.join(); + t4.join(); + } catch (InterruptedException e) { + } + } + public void deleteA1() { + a1 = null; + } + public void ModifyB4() { + try { + a1.b4_0 = new RC_Thread_19_B4("new_b4"); + } catch (NullPointerException e) { + } + } + public void addSum() { + try { + a1.add(); + a1.b1_0.add(); + a1.b2_0.add(); + a1.b3_0.add(); + a1.b4_0.add(); + a1.b1_0.c1_0.add(); + a1.b1_0.c2_0.add(); + a1.b1_0.c3_0.add(); + } catch (NullPointerException e) { + } + } + public void setA1(RC_Thread_19_A1 a1) { + this.a1 = a1; + } + class RC_Thread_19_A1 { + RC_Thread_19_B1 b1_0; + RC_Thread_19_B2 b2_0; + RC_Thread_19_B3 b3_0; + RC_Thread_19_B4 b4_0; + int a; + int sum; + String strObjectName; + RC_Thread_19_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + b3_0 = null; + b4_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a + b3_0.a + b4_0.a; + } + } + class RC_Thread_19_B1 { + RC_Thread_19_C1 c1_0; + RC_Thread_19_C2 c2_0; + RC_Thread_19_C3 c3_0; + int a; + int sum; + String strObjectName; + RC_Thread_19_B1(String strObjectName) { + c1_0 = null; + c2_0 = null; + c3_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + c1_0.a + c2_0.a + c3_0.a; + } + } + class RC_Thread_19_B2 { + int a; + int sum; + String strObjectName; + RC_Thread_19_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_19_B3 { + int a; + int sum; + String strObjectName; + RC_Thread_19_B3(String strObjectName) { + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_19_B4 { + int a; + int sum; + String strObjectName; + RC_Thread_19_B4(String strObjectName) { + a = 204; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B4_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_19_C1 { + int a; + int sum; + String strObjectName; + RC_Thread_19_C1(String strObjectName) { + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_19_C2 { + int a; + int sum; + String strObjectName; + RC_Thread_19_C2(String strObjectName) { + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class RC_Thread_19_C3 { + int a; + int sum; + String strObjectName; + RC_Thread_19_C3(String strObjectName) { + a = 303; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/expected.txt b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/test.cfg b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d194a16ed14672c344381c2e8f8d5754fadd498f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0246-rc-function-RC_Thread02-RC_Thread_19/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_19) +run(RC_Thread_19,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java new file mode 100755 index 0000000000000000000000000000000000000000..d740a84de9cf0cdef22bf343a53c81b40c7810a7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/RC_Thread_20.java @@ -0,0 +1,206 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.Runtime; +class RC_Thread_20_1 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +class RC_Thread_20_2 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +class RC_Thread_20_3 extends Thread { + public void run() { + RC_Thread_20 rcth01 = new RC_Thread_20(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + e.printStackTrace(); + } + } +} +public class RC_Thread_20 { + private static RC_Thread_20_A1 a1_main = null; + private static RC_Thread_20_A5 a5_main = null; + private static RC_Thread_20_A4 a4; + RC_Thread_20() { + try { + RC_Thread_20_A1 a1 = new RC_Thread_20_A1(); + a1.a2_0 = new RC_Thread_20_A2(); + a1.a2_0.a3_0 = new RC_Thread_20_A3(); + RC_Thread_20_A4 a4_temp=new RC_Thread_20_A4(); + a1.a2_0.a3_0.a4_0 = a4_temp; + a1.a2_0.a3_0.a4_0.a1_0 = a1; + RC_Thread_20_A5 a5 = new RC_Thread_20_A5(); + a1.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_20_A6(); + a1.a2_0.a3_0.a4_0.a6_0.a5_0 = a5; + a5.a3_0 = a1.a2_0.a3_0; + a1_main=a1; + a4=a4_temp; + a5_main=a5; + } catch (NullPointerException e) { + } + } + public static void main(String[] args) { + cycle_pattern_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + Runtime.getRuntime().gc(); + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void cycle_pattern_wrapper(){ + a1_main = new RC_Thread_20_A1(); + a1_main.a2_0 = new RC_Thread_20_A2(); + a1_main.a2_0.a3_0 = new RC_Thread_20_A3(); + a4=new RC_Thread_20_A4(); + a1_main.a2_0.a3_0.a4_0 = a4; + a1_main.a2_0.a3_0.a4_0.a1_0 = a1_main; + a5_main = new RC_Thread_20_A5(); + a1_main.a2_0.a3_0.a4_0.a6_0 = new RC_Thread_20_A6(); + a1_main.a2_0.a3_0.a4_0.a6_0.a5_0 = a5_main; + a5_main.a3_0 = a1_main.a2_0.a3_0; + a1_main=null; + a4=null; + a5_main=null; + Runtime.getRuntime().gc(); + } + private static void rc_testcase_main_wrapper() { + RC_Thread_20_1 t1 = new RC_Thread_20_1(); + RC_Thread_20_2 t2 = new RC_Thread_20_2(); + RC_Thread_20_3 t3 = new RC_Thread_20_3(); + t1.start(); + t2.start(); + t3.start(); + try { + t1.join(); + t2.join(); + t3.join(); + } catch (InterruptedException e) { + } + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + try { + a1_main.a2_0.a3_0.a4_0 = null; + a5_main.a3_0.a4_0 = null; + } catch (NullPointerException e) { + } + } + public void setA5null() { + a5_main = null; + } + static class RC_Thread_20_A1 { + RC_Thread_20_A2 a2_0; + RC_Thread_20_A4 a4_0; + int a; + int sum; + RC_Thread_20_A1() { + a2_0 = null; + a4_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RC_Thread_20_A2 { + RC_Thread_20_A3 a3_0; + int a; + int sum; + RC_Thread_20_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_20_A3 { + RC_Thread_20_A4 a4_0; + int a; + int sum; + RC_Thread_20_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + static class RC_Thread_20_A4 { + RC_Thread_20_A1 a1_0; + RC_Thread_20_A6 a6_0; + int a; + int sum; + RC_Thread_20_A4() { + a1_0 = null; + a6_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a + a6_0.a; + } + } + static class RC_Thread_20_A5 { + RC_Thread_20_A3 a3_0; + int a; + int sum; + RC_Thread_20_A5() { + a3_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RC_Thread_20_A6 { + RC_Thread_20_A5 a5_0; + int a; + int sum; + RC_Thread_20_A6() { + a5_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/expected.txt b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/test.cfg b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..32304f9d4b4e02ca96f3d626dd5a678d859feabd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0247-rc-function-RC_Thread02-RC_Thread_20/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Thread_20) +run(RC_Thread_20,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java b/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java new file mode 100755 index 0000000000000000000000000000000000000000..bdbd50831c009e5648010c955e344ea7cbca1728 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/RC_Finalize_02.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class RC_Finalize_02 { + public void finalize() { + System.out.println("ExpectResult"); + } + public static int run(String argv[], PrintStream out) { + return 0; + } + public static void main(String argv[]) { + System.runFinalizersOnExit(true); + RC_Finalize_02 testClass = new RC_Finalize_02(); + } +} // end RC_Finalize_02 diff --git a/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/test.cfg b/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b5773eb3b61fa0e654571bd28d552bc0ca79496 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0248-rc-function-RC_Finalize_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Finalize_02) +run(RC_Finalize_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java new file mode 100755 index 0000000000000000000000000000000000000000..6769f27db96f40a62080dffd39d590871ad7fe23 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/RC_Finalize_03.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +class RC_Finalize_031 { + public void finalize() { + RC_Finalize_03.fo_finalized = true; + RC_Finalize_03.dummy = 1 / RC_Finalize_03.zero; + RC_Finalize_03.fo_exception_occerred = false; + } +} +public class RC_Finalize_03 { + public static boolean fo_finalized; + public static boolean fo_exception_occerred; + public static final long TIMEOUT = 50000; + public static final int zero = 0; + public static int dummy; + public static int run(String argv[], PrintStream out) { + fo_finalized = false; + fo_exception_occerred = true; + RC_Finalize_031 cl1 = new RC_Finalize_031(); + cl1 = null; + long startTime = System.currentTimeMillis(); + while (System.currentTimeMillis() - startTime < TIMEOUT){ + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (!fo_finalized) { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + //out.println("InterruptedException: " + e); + return 2; + } catch(Throwable e) { + //out.println("Throwable: " + e); + return 2; + } + } else { + break; + } + } + if (!fo_finalized) { + //out.println("Ok, RC_Finalize_031 was not finalized during " + TIMEOUT/1000 + "sec"); + return 0; + } + if (fo_exception_occerred) { + return 0; + } else { + //out.println("Failed: expected exception is not thrown"); + } + return 2; + } + public static void main(String argv[]) { + if(run(argv, System.out)==0) + System.out.println("ExpectResult"); + } +} // end RC_Finalize_03 diff --git a/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/expected.txt b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/test.cfg b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dc2fa306b6c1aa4c103661f48c449d9562e50cb6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0249-rc-function-RC_Finalize_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Finalize_03) +run(RC_Finalize_03,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..741f5a560197a20c022d4a7c2742879d2fa1a598 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/Alloc_11_15x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_11_15x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_11_8B=11*8; + private final static int MAX_12_8B=12*8; + private final static int MAX_13_8B=13*8; + private final static int MAX_14_8B=14*8; + private final static int MAX_15_8B=15*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*2/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize11 = alloc_test(MAX_11_8B); + int countSize12 = alloc_test(MAX_12_8B); + int countSize13 = alloc_test(MAX_13_8B); + int countSize14 = alloc_test(MAX_14_8B); + int countSize15 = alloc_test(MAX_15_8B); + //System.out.println(countSize11); + //System.out.println(countSize12); + //System.out.println(countSize13); + //System.out.println(countSize14); + //System.out.println(countSize15); + if (countSize11 == 853 && countSize12 == 788 && countSize13 == 728 && countSize14 == 681 && countSize15 == 639) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/expected.txt b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/test.cfg b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e587efab0519d1e52b24e581869d7b6def7c0d00 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0250-rc-function-ROSAlloc-Alloc_11_15x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_11_15x8B) +run(Alloc_11_15x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..011d0545e153c544a8ce929cbce637b42eb00e25 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/Alloc_128x8B.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_128x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i=i+3) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_128_8B); + //System.out.println(result); + if ( result == 243561) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/expected.txt b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/test.cfg b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8c5f0032cb32ee2b02aaaf0d46bd5d61ce5ab4f3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0251-rc-function-ROSAlloc-Alloc_128x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_128x8B) +run(Alloc_128x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..61f2bb043656cc99ea0825aa052c3746fe087184 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/Alloc_16_20x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_16_20x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_16_8B=16*8; + private final static int MAX_17_8B=17*8; + private final static int MAX_18_8B=18*8; + private final static int MAX_19_8B=19*8; + private final static int MAX_20_8B=20*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*2/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize16 = alloc_test(MAX_16_8B); + int countSize17 = alloc_test(MAX_17_8B); + int countSize18 = alloc_test(MAX_18_8B); + int countSize19 = alloc_test(MAX_19_8B); + int countSize20 = alloc_test(MAX_20_8B); + //System.out.println(countSize16); + //System.out.println(countSize17); + //System.out.println(countSize18); + //System.out.println(countSize19); + //System.out.println(countSize20); + if (countSize16 == 604 && countSize17 == 572 && countSize18 == 542 && countSize19 == 517 && countSize20 == 495) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/expected.txt b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/test.cfg b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1a7650aba3d32585f64baa3714f3acc9c901ffa0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0252-rc-function-ROSAlloc-Alloc_16_20x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_16_20x8B) +run(Alloc_16_20x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6a5af099a51b718894e29419e629ed35466bb87d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/Alloc_192x8B.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_192x8B { + private static final int PAGE_SIZE = 4*1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192*8; + private static ArrayList store; + private static int alloc_test(int slot_type) { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 + 1 - OBJ_HEADSIZE; i <= slot_type - OBJ_HEADSIZE; i = i + 6) { + for (int j = 0; j < (PAGE_SIZE * 1280 / (i + OBJ_HEADSIZE) + 5); j++) { + temp = new byte[i]; + store.add(temp); + } + sum += store.size(); + store = new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_192_8B); + if ( result == 357534) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/expected.txt b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/test.cfg b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a34cacae07273151d32ea8af04d5b04dce6ee260 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0253-rc-function-ROSAlloc-Alloc_192x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_192x8B) +run(Alloc_192x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..2798fa5f727272e3769ca2498514c909247bbfd9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/Alloc_21_25x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_21_25x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_21_8B=21*8; + private final static int MAX_22_8B=22*8; + private final static int MAX_23_8B=23*8; + private final static int MAX_24_8B=24*8; + private final static int MAX_25_8B=25*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*3/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize21 = alloc_test(MAX_21_8B); + int countSize22 = alloc_test(MAX_22_8B); + int countSize23 = alloc_test(MAX_23_8B); + int countSize24 = alloc_test(MAX_24_8B); + int countSize25 = alloc_test(MAX_25_8B); + //System.out.println(countSize21); + //System.out.println(countSize22); + //System.out.println(countSize23); + //System.out.println(countSize24); + //System.out.println(countSize25); + if (countSize21 == 674 && countSize22 == 646 && countSize23 == 621 && countSize24 == 599 && countSize25 == 577) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/expected.txt b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/test.cfg b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7f5e28f4aabcddc94f63bb2e9884d3213915592e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0254-rc-function-ROSAlloc-Alloc_21_25x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_21_25x8B) +run(Alloc_21_25x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..317ffd492c9ec36ff3bb503af3da1e126d9a4d56 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/Alloc_256x8B.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_256x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + for(int i=1024+1-OBJ_HEADSIZE;i<=slot_type-OBJ_HEADSIZE;i=i+256) + { + for(int j=0;j<(PAGE_SIZE*5120/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_256_8B); + //System.out.println(result); + if ( result == 62191) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/expected.txt b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/test.cfg b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f924fa8e2d2f75562bb18c357683533bb6e648ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0255-rc-function-ROSAlloc-Alloc_256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_256x8B) +run(Alloc_256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6f38a15f521c7801fbe32c1190e8251a21318af7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/Alloc_26_30x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_26_30x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_26_8B=26*8; + private final static int MAX_27_8B=27*8; + private final static int MAX_28_8B=28*8; + private final static int MAX_29_8B=29*8; + private final static int MAX_30_8B=30*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*3/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize26 = alloc_test(MAX_26_8B); + int countSize27 = alloc_test(MAX_27_8B); + int countSize28 = alloc_test(MAX_28_8B); + int countSize29 = alloc_test(MAX_29_8B); + int countSize30 = alloc_test(MAX_30_8B); + //System.out.println(countSize26); + //System.out.println(countSize27); + //System.out.println(countSize28); + //System.out.println(countSize29); + //System.out.println(countSize30); + if (countSize26 == 557 && countSize27 == 538 && countSize28 == 522 && countSize29 == 506 && countSize30 == 492) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/expected.txt b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/test.cfg b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60b17339bb8ac5321e0309c730066d20a0b4501e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0256-rc-function-ROSAlloc-Alloc_26_30x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_26_30x8B) +run(Alloc_26_30x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..5deedfcb775ed8638df6f0b36d37aa12d4fafe48 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/Alloc_3_10x8B.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_3_10x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_3_8B=3*8; + private final static int MAX_4_8B=4*8; + private final static int MAX_5_8B=5*8; + private final static int MAX_6_8B=6*8; + private final static int MAX_7_8B=7*8; + private final static int MAX_8_8B=8*8; + private final static int MAX_9_8B=9*8; + private final static int MAX_10_8B=10*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args){ + store=new ArrayList(); + int countSize3 = alloc_test(MAX_3_8B); + int countSize4 = alloc_test(MAX_4_8B); + int countSize5 = alloc_test(MAX_5_8B); + int countSize6 = alloc_test(MAX_6_8B); + int countSize7 = alloc_test(MAX_7_8B); + int countSize8 = alloc_test(MAX_8_8B); + int countSize9 = alloc_test(MAX_9_8B); + int countSize10 = alloc_test(MAX_10_8B); + if(countSize3==4488 && countSize4==1234 && countSize5==978 && countSize6==816 && countSize7==701 && countSize8==620 &&countSize9==556 && countSize10==505 ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/expected.txt b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/test.cfg b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..372e16ee766d8134f67a146f55e6a1b39b5508f3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0257-rc-function-ROSAlloc-Alloc_3_10x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_3_10x8B) +run(Alloc_3_10x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..291fb6e4e3c151a00e588b0d1a12624d14f8303c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/Alloc_31_35x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_31_35x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_31_8B=31*8; + private final static int MAX_32_8B=32*8; + private final static int MAX_33_8B=33*8; + private final static int MAX_34_8B=34*8; + private final static int MAX_35_8B=35*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*4/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize31 = alloc_test(MAX_31_8B); + int countSize32 = alloc_test(MAX_32_8B); + int countSize33 = alloc_test(MAX_33_8B); + int countSize34 = alloc_test(MAX_34_8B); + int countSize35 = alloc_test(MAX_35_8B); + //System.out.println(countSize31); + //System.out.println(countSize32); + //System.out.println(countSize33); + //System.out.println(countSize34); + //System.out.println(countSize35); + if (countSize31 == 612 && countSize32 == 596 && countSize33 == 580 && countSize34 == 564 && countSize35 == 550) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/expected.txt b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/test.cfg b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..32ff89b18cbd6f62654f42cab303050da95c8928 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0258-rc-function-ROSAlloc-Alloc_31_35x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_31_35x8B) +run(Alloc_31_35x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..3022f8ebe8c91c1bcc6b4e3dfd3c8406764f6a61 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/Alloc_36_40x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_36_40x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_36_8B=36*8; + private final static int MAX_37_8B=37*8; + private final static int MAX_38_8B=38*8; + private final static int MAX_39_8B=39*8; + private final static int MAX_40_8B=40*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*4/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize36 = alloc_test(MAX_36_8B); + int countSize37 = alloc_test(MAX_37_8B); + int countSize38 = alloc_test(MAX_38_8B); + int countSize39 = alloc_test(MAX_39_8B); + int countSize40 = alloc_test(MAX_40_8B); + //System.out.println(countSize36); + //System.out.println(countSize37); + //System.out.println(countSize38); + //System.out.println(countSize39); + //System.out.println(countSize40); + if (countSize36 == 537 && countSize37 == 524 && countSize38 == 512 && countSize39 == 501 && countSize40 == 491) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/expected.txt b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/test.cfg b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..aa49b8209af21b3d7eb3a2dda9720b34c3123843 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0259-rc-function-ROSAlloc-Alloc_36_40x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_36_40x8B) +run(Alloc_36_40x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..f42b1b39d38866722b38db2aa604783dc740cfb8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/Alloc_41_45x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_41_45x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_41_8B=41*8; + private final static int MAX_42_8B=42*8; + private final static int MAX_43_8B=43*8; + private final static int MAX_44_8B=44*8; + private final static int MAX_45_8B=45*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*5/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize41 = alloc_test(MAX_41_8B); + int countSize42 = alloc_test(MAX_42_8B); + int countSize43 = alloc_test(MAX_43_8B); + int countSize44 = alloc_test(MAX_44_8B); + int countSize45 = alloc_test(MAX_45_8B); + //System.out.println(countSize41); + //System.out.println(countSize42); + //System.out.println(countSize43); + //System.out.println(countSize44); + //System.out.println(countSize45); + if (countSize41 == 581 && countSize42 == 569 && countSize43 == 557 && countSize44 == 547 && countSize45 == 536) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/expected.txt b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/test.cfg b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f6de369c998a091f29b1287073c4175a2fe20018 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0260-rc-function-ROSAlloc-Alloc_41_45x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_41_45x8B) +run(Alloc_41_45x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..80fc4686154c6735e2bccf6694f55c572d06e2b1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/Alloc_46_50x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_46_50x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_46_8B=46*8; + private final static int MAX_47_8B=47*8; + private final static int MAX_48_8B=48*8; + private final static int MAX_49_8B=49*8; + private final static int MAX_50_8B=50*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*5/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize46 = alloc_test(MAX_46_8B); + int countSize47 = alloc_test(MAX_47_8B); + int countSize48 = alloc_test(MAX_48_8B); + int countSize49 = alloc_test(MAX_49_8B); + int countSize50 = alloc_test(MAX_50_8B); + //System.out.println(countSize46); + //System.out.println(countSize47); + //System.out.println(countSize48); + //System.out.println(countSize49); + //System.out.println(countSize50); + if (countSize46 == 525 && countSize47 == 516 && countSize48 == 507 && countSize49 == 498 && countSize50 == 489) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/expected.txt b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/test.cfg b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f073f19f0b45fce924d612e435acfe25b75e2770 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0261-rc-function-ROSAlloc-Alloc_46_50x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_46_50x8B) +run(Alloc_46_50x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..e7398dc2e379ba1e031057aa8f1278fb0f8bd244 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/Alloc_51_55x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_51_55x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_51_8B=51*8; + private final static int MAX_52_8B=52*8; + private final static int MAX_53_8B=53*8; + private final static int MAX_54_8B=54*8; + private final static int MAX_55_8B=55*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*6/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize51 = alloc_test(MAX_51_8B); + int countSize52 = alloc_test(MAX_52_8B); + int countSize53 = alloc_test(MAX_53_8B); + int countSize54 = alloc_test(MAX_54_8B); + int countSize55 = alloc_test(MAX_55_8B); + //System.out.println(countSize51); + //System.out.println(countSize52); + //System.out.println(countSize53); + //System.out.println(countSize54); + //System.out.println(countSize55); + if (countSize51 == 562 && countSize52 == 553 && countSize53 == 543 && countSize54 == 535 && countSize55 == 526) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/expected.txt b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/test.cfg b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5504474cb1afb68a604e429931bdf55a7ce5cca5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0262-rc-function-ROSAlloc-Alloc_51_55x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_51_55x8B) +run(Alloc_51_55x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..7cee10bfa237fc1d59e9c6c70d2ea657433c83d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/Alloc_56_60x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_56_60x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_56_8B=56*8; + private final static int MAX_57_8B=57*8; + private final static int MAX_58_8B=58*8; + private final static int MAX_59_8B=59*8; + private final static int MAX_60_8B=60*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*6/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize56 = alloc_test(MAX_56_8B); + int countSize57 = alloc_test(MAX_57_8B); + int countSize58 = alloc_test(MAX_58_8B); + int countSize59 = alloc_test(MAX_59_8B); + int countSize60 = alloc_test(MAX_60_8B); + //System.out.println(countSize56); + //System.out.println(countSize57); + //System.out.println(countSize58); + //System.out.println(countSize59); + //System.out.println(countSize60); + if (countSize56 == 518 && countSize57 == 511 && countSize58 == 503 && countSize59 == 496 && countSize60 == 488) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/expected.txt b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/test.cfg b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6debf2e21b938e944f1668f3fdbf2adc3ab176d1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0263-rc-function-ROSAlloc-Alloc_56_60x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_56_60x8B) +run(Alloc_56_60x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ef5c89785fc362e2291c702fb4e22045c5329675 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/Alloc_61_64x8B.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_61_64x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_61_8B=61*8; + private final static int MAX_62_8B=62*8; + private final static int MAX_63_8B=63*8; + private final static int MAX_64_8B=64*8; + private static ArrayList store; + private static int alloc_test(int slot_type){ + store=new ArrayList(); + byte[] temp; + int i; + if(slot_type==24){ + i=1;} + else if(slot_type==1024){ + i=64*8+1-OBJ_HEADSIZE; + }else{ + i=slot_type-2*8+1; + } + for(;i<=slot_type-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*7/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + store=new ArrayList(); + return check_size; + } + public static void main(String[] args) { + store = new ArrayList(); + int countSize61 = alloc_test(MAX_61_8B); + int countSize62 = alloc_test(MAX_62_8B); + int countSize63 = alloc_test(MAX_63_8B); + int countSize64 = alloc_test(MAX_64_8B); + //System.out.println(countSize61); + //System.out.println(countSize62); + //System.out.println(countSize63); + //System.out.println(countSize64); + if (countSize61 == 549 && countSize62 == 542 && countSize63 == 535 && countSize64 == 528 ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/expected.txt b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/test.cfg b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..52d1427d72c5d7874449ea78c00bb79232d73c97 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0264-rc-function-ROSAlloc-Alloc_61_64x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_61_64x8B) +run(Alloc_61_64x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java b/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6650ab6b910a9f8f8e66f23e1e74fbee9e517c43 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/Alloc_B256x8B.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class Alloc_B256x8B { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static ArrayList store; + private static int alloc_test(int slot_type){ + int sum=0; + store=new ArrayList(); + byte[] temp; + for(int i=1024*1024-OBJ_HEADSIZE;i<=slot_type-OBJ_HEADSIZE;i=i+256) + { + for(int j=0;j<(PAGE_SIZE*2560/(i+OBJ_HEADSIZE)+5);j++) + { + temp = new byte[i]; + store.add(temp); + } + sum +=store.size(); + store=new ArrayList(); + } + return sum; + } + public static void main(String[] args) { + store = new ArrayList(); + int result = alloc_test(MAX_B256_8B); + //System.out.println(result); + if ( result == 46939) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/test.cfg b/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5a03e3efe93c6b27b085a1126853dcfc3f08773d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0265-rc-function-ROSAlloc-Alloc_B256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_B256x8B) +run(Alloc_B256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..7b2be9e38623340ccad8fb9e6edfad3fa66a72f9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/Alloc_Thread_128x8B.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_128x8B { + public static void main(String[] args){ + Alloc_Thread_128x8B_01 test1=new Alloc_Thread_128x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/expected.txt b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/test.cfg b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..34a3d61f779bd516f0d56acf2a9e3565f1d582c1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0266-rc-function-ROSAlloc-Alloc_Thread_128x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_128x8B) +run(Alloc_Thread_128x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..475e816c93bd1d10887e8eeb79e4a6872d683d12 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/Alloc_Thread_18x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 743858) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_18x8B { + public static void main(String[] args){ + Alloc_Thread_18x8B_01 test1=new Alloc_Thread_18x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/expected.txt b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/test.cfg b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..524de6d65f856098e2096d7c63a18e0dba87d084 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0267-rc-function-ROSAlloc-Alloc_Thread_18x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_18x8B) +run(Alloc_Thread_18x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..bc456b1c1670f6d6d7af143f20491193b5f9c2c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/Alloc_Thread_192x8B.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_192x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_192x8B { + public static void main(String[] args){ + Alloc_Thread_192x8B_01 test1=new Alloc_Thread_192x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/expected.txt b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/test.cfg b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..94c18c1a3cfccf8cd309927b9c17782cf9a819ff --- /dev/null +++ b/testsuite/java_test/rc_test/RC0268-rc-function-ROSAlloc-Alloc_Thread_192x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_192x8B) +run(Alloc_Thread_192x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..97ac95f02274dbd1f266d02d98276f257d00c862 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/Alloc_Thread2_128x8B_2.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_128x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_128x8B_2 { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Thread2_128x8B_2_01 test1=new Alloc_Thread2_128x8B_2_01(); + test1.start(); + Alloc_Thread2_128x8B_2_01 test2=new Alloc_Thread2_128x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/expected.txt b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ea0bfcefea737af31d6c40ccec238d7400ca0ab7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0269-rc-function-ROSAlloc-Alloc_Thread2_128x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_128x8B_2) +run(Alloc_Thread2_128x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..c18b3eb86df1b3381a08739fe108b2963eff6b9e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/Alloc_Thread2_128x8B.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 348510) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_128x8B { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Thread2_128x8B_01 test1=new Alloc_Thread2_128x8B_01(); + test1.start(); + Alloc_Thread2_128x8B_01 test2=new Alloc_Thread2_128x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/expected.txt b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/test.cfg b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f72885576320e730b59b2459b4ccf4af7a66d35 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0270-rc-function-ROSAlloc-Alloc_Thread2_128x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_128x8B) +run(Alloc_Thread2_128x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..e58ccef1ed33d747055bbbc971d12fe511eca9db --- /dev/null +++ b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/Alloc_Thread2_18x8B.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i+=10) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 89848) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_18x8B { + public static void main(String[] args){ + Alloc_Thread2_18x8B_01 test1=new Alloc_Thread2_18x8B_01(); + test1.start(); + Alloc_Thread2_18x8B_01 test2=new Alloc_Thread2_18x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check() == true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/expected.txt b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/test.cfg b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5d4de423a44d7999d1c5a0b2d91de73caada5ba8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0271-rc-function-ROSAlloc-Alloc_Thread2_18x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_18x8B) +run(Alloc_Thread2_18x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..a456eae7e303fc306dc34d10cbc2ff97e6f722d3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/Alloc_Thread2_192x8B_2.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_192x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_192x8B_2 { + public static void main(String[] args){ + Alloc_Thread2_192x8B_2_01 test1=new Alloc_Thread2_192x8B_2_01(); + test1.start(); + Alloc_Thread2_192x8B_2_01 test2=new Alloc_Thread2_192x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true &&test2.check()==true ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/expected.txt b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b0be5785936225889e566fa8c8ab2444670ff734 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0272-rc-function-ROSAlloc-Alloc_Thread2_192x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_192x8B_2) +run(Alloc_Thread2_192x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..27d51cdf7b49af7c4d87c95d9648f0d1e542b0bf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/Alloc_Thread2_192x8B.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_192x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_192_8B=192*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024-OBJ_HEADSIZE;i<=MAX_192_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 201256) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_192x8B { + public static void main(String[] args){ + Alloc_Thread2_192x8B_01 test1=new Alloc_Thread2_192x8B_01(); + test1.start(); + Alloc_Thread2_192x8B_01 test2=new Alloc_Thread2_192x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true &&test2.check()==true ) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/expected.txt b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/test.cfg b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2167dff4129f421773f47ee0371292051d4aaedd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0273-rc-function-ROSAlloc-Alloc_Thread2_192x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_192x8B) +run(Alloc_Thread2_192x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java b/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..1797a74e922a69f0374d2cced3d0d5a996967be9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/Alloc_Thread2_256x8B_2.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_256x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + try{Thread.sleep(100);}catch(InterruptedException e){} + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+60) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%10000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 214274) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_256x8B_2 { + public static void main(String[] args){ + Alloc_Thread2_256x8B_2_01 test1=new Alloc_Thread2_256x8B_2_01(); + test1.start(); + Alloc_Thread2_256x8B_2_01 test2=new Alloc_Thread2_256x8B_2_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c4896b4d68bba080673abba3316015bd48f873d0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0274-rc-function-ROSAlloc-Alloc_Thread2_256x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_256x8B_2) +run(Alloc_Thread2_256x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..0b794797b8d63ecea45de3faefd6fac74162242f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/Alloc_Thread2_256x8B.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+60) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 214274) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_256x8B { + public static void main(String[] args){ + Alloc_Thread2_256x8B_01 test1=new Alloc_Thread2_256x8B_01(); + test1.start(); + Alloc_Thread2_256x8B_01 test2=new Alloc_Thread2_256x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/expected.txt b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/test.cfg b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..845f0fc8d136705ca019fd87a770e8a427f445af --- /dev/null +++ b/testsuite/java_test/rc_test/RC0275-rc-function-ROSAlloc-Alloc_Thread2_256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_256x8B) +run(Alloc_Thread2_256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ced0e272af690c6969a19f6e9fe5bac579f8a40f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/Alloc_Thread2_30x8B.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 271654) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_30x8B { + public static void main(String[] args){ + Alloc_Thread2_30x8B_01 test1=new Alloc_Thread2_30x8B_01(); + test1.start(); + Alloc_Thread2_30x8B_01 test2=new Alloc_Thread2_30x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true&& test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/expected.txt b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/test.cfg b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9515bbbc66441e5526c0294297273436f3ba7d2a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0276-rc-function-ROSAlloc-Alloc_Thread2_30x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_30x8B) +run(Alloc_Thread2_30x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..11ddadab50adbc20c57309c03e42aa186acf09ed --- /dev/null +++ b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/Alloc_Thread2_40x8B.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 153513) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_40x8B { + public static void main(String[] args){ + Alloc_Thread2_40x8B_01 test1=new Alloc_Thread2_40x8B_01(); + test1.start(); + Alloc_Thread2_40x8B_01 test2=new Alloc_Thread2_40x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/expected.txt b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/test.cfg b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..805e1692c5caaf64bc3e81aee665a26db355365d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0277-rc-function-ROSAlloc-Alloc_Thread2_40x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_40x8B) +run(Alloc_Thread2_40x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..6092649cac2bc90e3d64548b0b0d21c85225ea5c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/Alloc_Thread2_50x8B.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 237701) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_50x8B { + public static void main(String[] args){ + Alloc_Thread2_50x8B_01 test1=new Alloc_Thread2_50x8B_01(); + test1.start(); + Alloc_Thread2_50x8B_01 test2=new Alloc_Thread2_50x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/expected.txt b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/test.cfg b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0c7fbc2d1574cf331875a96097288d3585196dac --- /dev/null +++ b/testsuite/java_test/rc_test/RC0278-rc-function-ROSAlloc-Alloc_Thread2_50x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_50x8B) +run(Alloc_Thread2_50x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..406d656a05d4fed1d992652515e3792020772495 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/Alloc_Thread_256x8B.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_256_8B=256*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=192*8-OBJ_HEADSIZE;i<=MAX_256_8B-OBJ_HEADSIZE;i=i+100) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 142271) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_256x8B { + public static void main(String[] args){ + Alloc_Thread_256x8B_01 test1=new Alloc_Thread_256x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/expected.txt b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/test.cfg b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d7bd95637505f683df9dbd798e4345ec76553c31 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0279-rc-function-ROSAlloc-Alloc_Thread_256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_256x8B) +run(Alloc_Thread_256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..5d06405df076669789fe8ce3308377a98b4b9902 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/Alloc_Thread2_60x8B.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 194350) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_60x8B { + public static void main(String[] args){ + Alloc_Thread2_60x8B_01 test1=new Alloc_Thread2_60x8B_01(); + test1.start(); + Alloc_Thread2_60x8B_01 test2=new Alloc_Thread2_60x8B_01(); + test2.start(); + try{ + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/expected.txt b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/test.cfg b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..82e35dd6cd7f6c0b22a6fd23257df1a11625eb76 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0280-rc-function-ROSAlloc-Alloc_Thread2_60x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_60x8B) +run(Alloc_Thread2_60x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..67d6ce2f15ba8332856e76e7f68353cf4638c2ce --- /dev/null +++ b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/Alloc_Thread2_64x8B.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_64x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_64_8B = 64 * 8; + private static boolean checkout = false; + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 480 - OBJ_HEADSIZE; i <= MAX_64_8B - OBJ_HEADSIZE; i++) { + for (int j = 0; j < (PAGE_SIZE * 128 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + } + } + int checkSize = store.size(); + if (checkSize == 35212) { + checkout = true; + } + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_64x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Thread2_64x8B_01 test1 = new Alloc_Thread2_64x8B_01(); + test1.start(); + Alloc_Thread2_64x8B_01 test2 = new Alloc_Thread2_64x8B_01(); + test2.start(); + try { + test1.join(); + test2.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/expected.txt b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/test.cfg b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a8450f975eeafbbce4114250bd366f30647eacd4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0281-rc-function-ROSAlloc-Alloc_Thread2_64x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_64x8B) +run(Alloc_Thread2_64x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ae224499d966ae69fa4305d477f182b84c253df5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/Alloc_Thread2_B256x8B.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread2_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+1024) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 38167) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread2_B256x8B { + public static void main(String[] args){ + Alloc_Thread2_B256x8B_01 test1=new Alloc_Thread2_B256x8B_01(); + test1.start(); + try{ test1.sleep(1000);} catch(InterruptedException e){} + Alloc_Thread2_B256x8B_01 test2=new Alloc_Thread2_B256x8B_01(); + test2.start(); + try{ test2.sleep(1000);} catch(InterruptedException e){} + try{ + test1.sleep(1000); + test2.sleep(1000); + test1.join(); + test2.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/expected.txt b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/test.cfg b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b4a83850b4c2b9a72b5f0f05212c954adc4f9408 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0282-rc-function-ROSAlloc-Alloc_Thread2_B256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread2_B256x8B) +run(Alloc_Thread2_B256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..b7634c3221aa807bafba6f684d00a3d7fb425faa --- /dev/null +++ b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/Alloc_Thread_30x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 271654) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_30x8B { + public static void main(String[] args){ + Alloc_Thread_30x8B_01 test1=new Alloc_Thread_30x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/expected.txt b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/test.cfg b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bde44c5ef2386b36f250babf89d6b53f0e378531 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0283-rc-function-ROSAlloc-Alloc_Thread_30x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_30x8B) +run(Alloc_Thread_30x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..205ae619d86911a36e23cfb8cbb1fb182b1e0827 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/Alloc_Thread_40x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*128/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 153513) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_40x8B { + public static void main(String[] args){ + Alloc_Thread_40x8B_01 test1=new Alloc_Thread_40x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/expected.txt b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/test.cfg b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cd14673e2b3ae62af68c7c0560c53e9e2336b2c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0284-rc-function-ROSAlloc-Alloc_Thread_40x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_40x8B) +run(Alloc_Thread_40x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..4aead08050ad1186d6c3617247faf8501f60e5c8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/Alloc_Thread_50x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 237701) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_50x8B { + public static void main(String[] args){ + Alloc_Thread_50x8B_01 test1=new Alloc_Thread_50x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/expected.txt b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/test.cfg b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..30edfbbf87efb167af3d74b06c729cfa986d7994 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0285-rc-function-ROSAlloc-Alloc_Thread_50x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_50x8B) +run(Alloc_Thread_50x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..e95e110c40abae7c5cb12703880c694263b4a88a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/Alloc_Thread_60x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*256/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 194350) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_60x8B { + public static void main(String[] args){ + Alloc_Thread_60x8B_01 test1=new Alloc_Thread_60x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/expected.txt b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/test.cfg b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..96ec6794103daab3ba484375ab4d4a29d09f16de --- /dev/null +++ b/testsuite/java_test/rc_test/RC0286-rc-function-ROSAlloc-Alloc_Thread_60x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_60x8B) +run(Alloc_Thread_60x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..be25a74c7f305f64bfa43a4975d34c5cc4482669 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/Alloc_Thread_64x8B.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_64x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_64_8B=64*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=480-OBJ_HEADSIZE;i<=MAX_64_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*512/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 139895) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_64x8B { + public static void main(String[] args){ + Alloc_Thread_64x8B_01 test1=new Alloc_Thread_64x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/expected.txt b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/test.cfg b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d9576a2526e52b8300889bbb2bbf83034cfdf165 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0287-rc-function-ROSAlloc-Alloc_Thread_64x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_64x8B) +run(Alloc_Thread_64x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..00cffdde310938fb9f5fedc2d7298d2916f7564b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/Alloc_Thread_B256x8B.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Thread_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+1024) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 38167) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Thread_B256x8B { + public static void main(String[] args){ + Alloc_Thread_B256x8B_01 test1=new Alloc_Thread_B256x8B_01(); + test1.start(); + try{ + test1.join(); + }catch (InterruptedException e){} + if(test1.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/expected.txt b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/test.cfg b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a30052f044ece0026307b32dedd45377fbac9b4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0288-rc-function-ROSAlloc-Alloc_Thread_B256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Thread_B256x8B) +run(Alloc_Thread_B256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..c2d9279ea6ca63b422aa9851b92045f263636e71 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/Alloc_Threadm_128x8B_2.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_128x8B_2_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + try{Thread.sleep(100);}catch(InterruptedException e){} + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+10) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + if(j%1000==0) + { + try{Thread.sleep(100);}catch(InterruptedException e){} + } + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 28253) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_128x8B_2 { + public static void main(String[] args){ + Alloc_Threadm_128x8B_2_01 test1=new Alloc_Threadm_128x8B_2_01(); + test1.start(); + Alloc_Threadm_128x8B_2_01 test2=new Alloc_Threadm_128x8B_2_01(); + test2.start(); + Alloc_Threadm_128x8B_2_01 test3=new Alloc_Threadm_128x8B_2_01(); + test3.start(); + Alloc_Threadm_128x8B_2_01 test4=new Alloc_Threadm_128x8B_2_01(); + test4.start(); + Alloc_Threadm_128x8B_2_01 test5=new Alloc_Threadm_128x8B_2_01(); + test5.start(); + Alloc_Threadm_128x8B_2_01 test6=new Alloc_Threadm_128x8B_2_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/expected.txt b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..822552e5ed214a941701e9fc2ce976dc09bdc488 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0289-rc-function-ROSAlloc-Alloc_Threadm_128x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_128x8B_2) +run(Alloc_Threadm_128x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..fb458b5be73507ae5efda6994a22c3c1642caa33 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/Alloc_Threadm_128x8B.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_128x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_128_8B=128*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=512-OBJ_HEADSIZE;i<=MAX_128_8B-OBJ_HEADSIZE;i=i+10) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 28253) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_128x8B { + public static void main(String[] args){ + Alloc_Threadm_128x8B_01 test1=new Alloc_Threadm_128x8B_01(); + test1.start(); + Alloc_Threadm_128x8B_01 test2=new Alloc_Threadm_128x8B_01(); + test2.start(); + Alloc_Threadm_128x8B_01 test3=new Alloc_Threadm_128x8B_01(); + test3.start(); + Alloc_Threadm_128x8B_01 test4=new Alloc_Threadm_128x8B_01(); + test4.start(); + Alloc_Threadm_128x8B_01 test5=new Alloc_Threadm_128x8B_01(); + test5.start(); + Alloc_Threadm_128x8B_01 test6=new Alloc_Threadm_128x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/expected.txt b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/test.cfg b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..099a62a673cabadd830d3d9a91ed733a0005ffa0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0290-rc-function-ROSAlloc-Alloc_Threadm_128x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_128x8B) +run(Alloc_Threadm_128x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..e0beb0b1ce3fa50272b43ebafa8f98e115b87051 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/Alloc_Threadm_18x8B.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_18x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_18_8B=18*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=1;i<=MAX_18_8B-OBJ_HEADSIZE;i=i+20) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 54765) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_18x8B { + public static void main(String[] args){ + Alloc_Threadm_18x8B_01 test1=new Alloc_Threadm_18x8B_01(); + test1.start(); + Alloc_Threadm_18x8B_01 test2=new Alloc_Threadm_18x8B_01(); + test2.start(); + Alloc_Threadm_18x8B_01 test3=new Alloc_Threadm_18x8B_01(); + test3.start(); + Alloc_Threadm_18x8B_01 test4=new Alloc_Threadm_18x8B_01(); + test4.start(); + Alloc_Threadm_18x8B_01 test5=new Alloc_Threadm_18x8B_01(); + test5.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + }catch (InterruptedException e){} + if(test1.check()==true && test2.check() == true &&test3.check()==true && test4.check() == true&& test5.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/expected.txt b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/test.cfg b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..58a5579418be6c710bf71f09665736860f81468a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0291-rc-function-ROSAlloc-Alloc_Threadm_18x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_18x8B) +run(Alloc_Threadm_18x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..ac8cae2ee278066d4fdd72f326c2da8cf634367f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/Alloc_Threadm_192x8B_2.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_192x8B_2_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192 * 8; + private static boolean checkout = false; + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + int checkSize = 0; + for (int i = 1024 - OBJ_HEADSIZE; i <= MAX_192_8B - OBJ_HEADSIZE; i = i + 100) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + if (j % 1000 == 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + } + temp = new byte[i]; + store.add(temp); + checkSize += store.size(); + store = new ArrayList(); + } + } + if (checkSize == 10117) { + checkout = true; + } + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_192x8B_2 { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_192x8B_2_01 test1 = new Alloc_Threadm_192x8B_2_01(); + test1.start(); + Alloc_Threadm_192x8B_2_01 test2 = new Alloc_Threadm_192x8B_2_01(); + test2.start(); + Alloc_Threadm_192x8B_2_01 test3 = new Alloc_Threadm_192x8B_2_01(); + test3.start(); + Alloc_Threadm_192x8B_2_01 test4 = new Alloc_Threadm_192x8B_2_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() == true && test2.check() == true && test3.check() == true && test4.check() == true) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/expected.txt b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..28eff5d5d05b4bc2b210774bb85599c5cf49a8fc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0292-rc-function-ROSAlloc-Alloc_Threadm_192x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_192x8B_2) +run(Alloc_Threadm_192x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java new file mode 100644 index 0000000000000000000000000000000000000000..7ab5273a2beb3f8ab68bb2b343e4995d2b299ef6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/Alloc_Threadm_192x8B.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_192x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_192_8B = 192 * 8; + private static boolean checkout = false; + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + int checkSize = 0; + for (int i = 1024 - OBJ_HEADSIZE; i <= MAX_192_8B - OBJ_HEADSIZE; i = i + 100) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + checkSize++; + store = new ArrayList(); + } + } + if (checkSize == 10117) { + checkout = true; + } + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_192x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_192x8B_01 test1 = new Alloc_Threadm_192x8B_01(); + test1.start(); + Alloc_Threadm_192x8B_01 test2 = new Alloc_Threadm_192x8B_01(); + test2.start(); + Alloc_Threadm_192x8B_01 test3 = new Alloc_Threadm_192x8B_01(); + test3.start(); + Alloc_Threadm_192x8B_01 test4 = new Alloc_Threadm_192x8B_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/expected.txt b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/test.cfg b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..054727c9ee65806f93a298aa53b77a1b582a2170 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0293-rc-function-ROSAlloc-Alloc_Threadm_192x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_192x8B) +run(Alloc_Threadm_192x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java new file mode 100755 index 0000000000000000000000000000000000000000..f9c01b66976a142fc8880b385c3a2ed755ab954b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/Alloc_Threadm_256x8B_2.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_256x8B_2_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_256_8B = 256 * 8; + private static boolean checkOut = false; + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + int check_size = 0; + for (int i = 192 * 8 - OBJ_HEADSIZE; i <= MAX_256_8B - OBJ_HEADSIZE; i = i + 800) { + for (int j = 0; j < (PAGE_SIZE * 1024 / (i + OBJ_HEADSIZE) + 10); j++) { + if (j % 1000 == 0) { + try { + Thread.sleep(100); + } catch (InterruptedException e) { + // do nothing + } + } + temp = new byte[i]; + store.add(temp); + check_size++; + store = new ArrayList(); + } + } + if (check_size == 2740) { + checkOut = true; + } + } + public boolean check() { + return checkOut; + } +} +public class Alloc_Threadm_256x8B_2 { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_256x8B_2_01 test1 = new Alloc_Threadm_256x8B_2_01(); + test1.start(); + Alloc_Threadm_256x8B_2_01 test2 = new Alloc_Threadm_256x8B_2_01(); + test2.start(); + Alloc_Threadm_256x8B_2_01 test3 = new Alloc_Threadm_256x8B_2_01(); + test3.start(); + Alloc_Threadm_256x8B_2_01 test4 = new Alloc_Threadm_256x8B_2_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/expected.txt b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/test.cfg b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ee52d7175e53bc01a7c55328ab02dbc45d66e79b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0294-rc-function-ROSAlloc-Alloc_Threadm_256x8B_2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_256x8B_2) +run(Alloc_Threadm_256x8B_2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..b50d40044adbcd950abedc2ae1672363e5ed19c0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/Alloc_Threadm_256x8B.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_256x8B_01 extends Thread { + private static final int PAGE_SIZE = 4 * 1024; + private static final int OBJ_HEADSIZE = 8; + private static final int MAX_256_8B = 256 * 8; + private static boolean checkOut = false; + public void run() { + ArrayList store = new ArrayList(); + byte[] temp; + int checkSize = 0; + for (int i = 192 * 8 - OBJ_HEADSIZE; i <= MAX_256_8B - OBJ_HEADSIZE; i = i + 800) { + for (int j = 0; j < (PAGE_SIZE * 512 / (i + OBJ_HEADSIZE) + 10); j++) { + temp = new byte[i]; + store.add(temp); + checkSize++; + store = new ArrayList(); + } + } + if (checkSize == 1375) { + checkOut = true; + } + } + public boolean check() { + return checkOut; + } +} +public class Alloc_Threadm_256x8B { + public static void main(String[] args) { + Runtime.getRuntime().gc(); + Alloc_Threadm_256x8B_01 test1 = new Alloc_Threadm_256x8B_01(); + test1.start(); + Alloc_Threadm_256x8B_01 test2 = new Alloc_Threadm_256x8B_01(); + test2.start(); + Alloc_Threadm_256x8B_01 test3 = new Alloc_Threadm_256x8B_01(); + test3.start(); + Alloc_Threadm_256x8B_01 test4 = new Alloc_Threadm_256x8B_01(); + test4.start(); + try { + test1.join(); + test2.join(); + test3.join(); + test4.join(); + } catch (InterruptedException e) { + // do nothing + } + if (test1.check() && test2.check() && test3.check() && test4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("Error"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/expected.txt b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/test.cfg b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b63cb01878bcc00a9760e9430866914cffc2ef60 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0295-rc-function-ROSAlloc-Alloc_Threadm_256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_256x8B) +run(Alloc_Threadm_256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ea65e22c48a0a8e448e3c439ca3e10592964554c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/Alloc_Threadm_30x8B.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_30x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_30_8B=30*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=144-OBJ_HEADSIZE;i<=MAX_30_8B-OBJ_HEADSIZE;i=i+5) + { + for(int j=0;j<(PAGE_SIZE*64/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 28217) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_30x8B { + public static void main(String[] args){ + Alloc_Threadm_30x8B_01 test1=new Alloc_Threadm_30x8B_01(); + test1.start(); + Alloc_Threadm_30x8B_01 test2=new Alloc_Threadm_30x8B_01(); + test2.start(); + Alloc_Threadm_30x8B_01 test3=new Alloc_Threadm_30x8B_01(); + test3.start(); + Alloc_Threadm_30x8B_01 test4=new Alloc_Threadm_30x8B_01(); + test4.start(); + Alloc_Threadm_30x8B_01 test5=new Alloc_Threadm_30x8B_01(); + test5.start(); + Alloc_Threadm_30x8B_01 test6=new Alloc_Threadm_30x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&& test2.check()==true&&test3.check()==true&& test4.check()==true&&test5.check()==true&& test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/expected.txt b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/test.cfg b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5a498c81fae4e16d17f050c7067800b9eefbb432 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0296-rc-function-ROSAlloc-Alloc_Threadm_30x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_30x8B) +run(Alloc_Threadm_30x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..cab97b94f5d444ae7b22484f8fe589055762c17c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/Alloc_Threadm_40x8B.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_40x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_40_8B=40*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=240-OBJ_HEADSIZE;i<=MAX_40_8B-OBJ_HEADSIZE;i+=4) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 29915) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_40x8B { + public static void main(String[] args){ + Alloc_Threadm_40x8B_01 test1=new Alloc_Threadm_40x8B_01(); + test1.start(); + Alloc_Threadm_40x8B_01 test2=new Alloc_Threadm_40x8B_01(); + test2.start(); + Alloc_Threadm_40x8B_01 test3=new Alloc_Threadm_40x8B_01(); + test3.start(); + Alloc_Threadm_40x8B_01 test4=new Alloc_Threadm_40x8B_01(); + test4.start(); + Alloc_Threadm_40x8B_01 test5=new Alloc_Threadm_40x8B_01(); + test5.start(); + Alloc_Threadm_40x8B_01 test6=new Alloc_Threadm_40x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/expected.txt b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/test.cfg b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f4278b6030e042c126434e3e6cf0d16d4f05760c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0297-rc-function-ROSAlloc-Alloc_Threadm_40x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_40x8B) +run(Alloc_Threadm_40x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..665acc792677e2f622f526b3872f14a5c171db0c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/Alloc_Threadm_50x8B.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_50x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_50_8B=50*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=320-OBJ_HEADSIZE;i<=MAX_50_8B-OBJ_HEADSIZE;i=i+5) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 18816) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_50x8B { + public static void main(String[] args){ + Alloc_Threadm_50x8B_01 test1=new Alloc_Threadm_50x8B_01(); + test1.start(); + Alloc_Threadm_50x8B_01 test2=new Alloc_Threadm_50x8B_01(); + test2.start(); + Alloc_Threadm_50x8B_01 test3=new Alloc_Threadm_50x8B_01(); + test3.start(); + Alloc_Threadm_50x8B_01 test4=new Alloc_Threadm_50x8B_01(); + test4.start(); + Alloc_Threadm_50x8B_01 test5=new Alloc_Threadm_50x8B_01(); + test5.start(); + Alloc_Threadm_50x8B_01 test6=new Alloc_Threadm_50x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/expected.txt b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/test.cfg b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09ee5dd9d47ff4d21fb4d25f25c36d12bf87b91f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0298-rc-function-ROSAlloc-Alloc_Threadm_50x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_50x8B) +run(Alloc_Threadm_50x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..18c983c385358cb0c0baced246cabfd4caee4404 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/Alloc_Threadm_60x8B.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_60x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_60_8B=60*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=400-OBJ_HEADSIZE;i<=MAX_60_8B-OBJ_HEADSIZE;i+=3) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 24509) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_60x8B { + public static void main(String[] args){ + Runtime.getRuntime().gc(); + Alloc_Threadm_60x8B_01 test1=new Alloc_Threadm_60x8B_01(); + test1.start(); + Alloc_Threadm_60x8B_01 test2=new Alloc_Threadm_60x8B_01(); + test2.start(); + Alloc_Threadm_60x8B_01 test3=new Alloc_Threadm_60x8B_01(); + test3.start(); + Alloc_Threadm_60x8B_01 test4=new Alloc_Threadm_60x8B_01(); + test4.start(); + Alloc_Threadm_60x8B_01 test5=new Alloc_Threadm_60x8B_01(); + test5.start(); + Alloc_Threadm_60x8B_01 test6=new Alloc_Threadm_60x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/expected.txt b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/test.cfg b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..95a620ad49a4aa3ab8401448f97b240e39593d3a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0299-rc-function-ROSAlloc-Alloc_Threadm_60x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_60x8B) +run(Alloc_Threadm_60x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..79f413277366aa7b49f183f061c6d45fa57a40bb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/Alloc_Threadm_64x8B.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_64x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_64_8B=64*8; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + for(int i=480-OBJ_HEADSIZE;i<=MAX_64_8B-OBJ_HEADSIZE;i++) + { + for(int j=0;j<(PAGE_SIZE*96/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + } + } + int check_size=store.size(); + //System.out.println(check_size); + if(check_size == 26487) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_64x8B { + public static void main(String[] args){ + Alloc_Threadm_64x8B_01 test1=new Alloc_Threadm_64x8B_01(); + test1.start(); + Alloc_Threadm_64x8B_01 test2=new Alloc_Threadm_64x8B_01(); + test2.start(); + Alloc_Threadm_64x8B_01 test3=new Alloc_Threadm_64x8B_01(); + test3.start(); + Alloc_Threadm_64x8B_01 test4=new Alloc_Threadm_64x8B_01(); + test4.start(); + Alloc_Threadm_64x8B_01 test5=new Alloc_Threadm_64x8B_01(); + test5.start(); + Alloc_Threadm_64x8B_01 test6=new Alloc_Threadm_64x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/expected.txt b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/test.cfg b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4a31b80b5d8f8163d778d634171e5dd35317e873 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0300-rc-function-ROSAlloc-Alloc_Threadm_64x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_64x8B) +run(Alloc_Threadm_64x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java new file mode 100755 index 0000000000000000000000000000000000000000..ec7b019e153e4ff12e7f908772b2eb3e1c392bf5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/Alloc_Threadm_B256x8B.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +class Alloc_Threadm_B256x8B_01 extends Thread { + private final static int PAGE_SIZE=4*1024; + private final static int OBJ_HEADSIZE = 8; + private final static int MAX_B256_8B=2*1024*1024; + private static boolean checkout=false; + public void run() { + ArrayList store=new ArrayList(); + byte[] temp; + int check_size=0; + for(int i=1024*1024-OBJ_HEADSIZE;i<=MAX_B256_8B-OBJ_HEADSIZE;i=i+15120) + { + for(int j=0;j<(PAGE_SIZE*10240/(i+OBJ_HEADSIZE)+10);j++) + { + temp = new byte[i]; + store.add(temp); + check_size +=store.size(); + store=new ArrayList(); + } + } + //System.out.println(check_size); + if(check_size == 2612) + checkout=true; + } + public boolean check() { + return checkout; + } +} +public class Alloc_Threadm_B256x8B { + public static void main(String[] args){ + Alloc_Threadm_B256x8B_01 test1=new Alloc_Threadm_B256x8B_01(); + test1.start(); + try{ test1.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test2=new Alloc_Threadm_B256x8B_01(); + test2.start(); + try{ test2.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test3=new Alloc_Threadm_B256x8B_01(); + test3.start(); + try{ test3.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test4=new Alloc_Threadm_B256x8B_01(); + test4.start(); + try{ test4.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test5=new Alloc_Threadm_B256x8B_01(); + test5.start(); + try{ test5.sleep(1000);} catch(InterruptedException e){} + Alloc_Threadm_B256x8B_01 test6=new Alloc_Threadm_B256x8B_01(); + test6.start(); + try{ + test1.join(); + test2.join(); + test3.join(); + test4.join(); + test5.join(); + test6.join(); + }catch (InterruptedException e){} + if(test1.check()==true&&test2.check()==true && test3.check()==true&&test4.check()==true && test5.check()==true&&test6.check()==true) + System.out.println("ExpectResult"); + else + System.out.println("Error"); + } +} diff --git a/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/expected.txt b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/test.cfg b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f057c503d25705b58c864c621f36e042cd0399ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0301-rc-function-ROSAlloc-Alloc_Threadm_B256x8B/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Alloc_Threadm_B256x8B) +run(Alloc_Threadm_B256x8B,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..2394cffdfe92277b5d9ede1b662277421032c9e7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/PhantomRefTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class PhantomRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setPhantomReference() { + rp = new PhantomReference(new Object(), rq); + if (rp.get() != null) { + a++; + } + } + public static void main(String [] args) throws Exception { + Reference r; + setPhantomReference(); + Thread.sleep(2000); + while ((r = rq.poll())!=null) { + if (!r.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + a++; + } + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/expected.txt b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/test.cfg b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..44fb681340954579828b8134859ed1b0022888f5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0302-rc-function-Ref-PhantomRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(PhantomRefTest) +run(PhantomRefTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..72ea20b6e240c33b71c39f425a1b88c7604aa236 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/SoftRefTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class SoftRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + SoftReference sr = new SoftReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) {} + } + } + } + public static void main(String [] args) throws Exception { + Reference r; + setSoftReference(); + new Thread(new TriggerRP()).start(); + Thread.sleep(3000); + if (rp.get() != null) { + a++; + } + while ((r = rq.poll())!=null) { + if(!r.getClass().toString().equals("class java.lang.ref.SoftReference")) { + a++; + } + } + if (a == 101) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/expected.txt b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/test.cfg b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3d1f6aa3db27e895bfecddbfb51306296b5e8008 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0303-rc-function-Ref-SoftRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest) +run(SoftRefTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java b/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..556b2ef76a3737341c617cd80860bf515f5291c1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/WeakRefTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class WeakRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) {} + } + } + } + public static void main(String [] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Thread.sleep(3000); + if (rp.get() != null) { + a++; + } + while ((r = rq.poll())!=null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + a++; + } + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/test.cfg b/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0fc378f32a214ff86ad4d550fd1a825009ff42d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0304-rc-function-Ref-WeakRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(WeakRefTest) +run(WeakRefTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java new file mode 100755 index 0000000000000000000000000000000000000000..5f334be738a727735236562cbfebd904d8c5b1f8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/RC_newObjectIassign_01.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +public class RC_newObjectIassign_01 { + final static String STR = "MapleTest"; + static int check = 0; + String[] strArray; + static String str1; + volatile String str2; + private RC_newObjectIassign_01(){ + strArray=new String[10]; + str1="MapleTest"; + str2="FigoTest"; + } + private RC_newObjectIassign_01(String str){ + str1=str; + str2=str; + } + private RC_newObjectIassign_01(String[] str){ + strArray=str; + } + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 5){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"a","b","c"}; + RC_newObjectIassign_01 rctest=new RC_newObjectIassign_01(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + rctest.str1="firstTimeTestStr1"; + rctest.str2="firstTimeTestStr2"; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="firstTimeTestStr1" && rctest.str2== "firstTimeTestStr2") + check +=1; + rctest = new RC_newObjectIassign_01("secondTimeTest"); + if(Arrays.equals(rctest.strArray,null) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest.strArray = arrayStr; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest=new RC_newObjectIassign_01(); + if(rctest.strArray.length == 10 && rctest.str1 =="MapleTest" && rctest.str2== "FigoTest") + check +=1; + } +} diff --git a/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/expected.txt b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/test.cfg b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..feb1c2d18c0bbc295cf5f74816aabbedd2877e2c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0309-rc-function-Optimization-RC_newObjectIassign_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_newObjectIassign_01) +run(RC_newObjectIassign_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java new file mode 100755 index 0000000000000000000000000000000000000000..f246e37d03de547d3c88f1da6727cb0ac30465ef --- /dev/null +++ b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/RC_newObjectIassign_02.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +class Base{ + String[] strArray; + volatile String str2; +} +public class RC_newObjectIassign_02 extends Base{ + final static String STR = "MapleTest"; + static int check = 0; + static String str1; + private RC_newObjectIassign_02(){ + strArray=new String[10]; + str1="MapleTest"; + str2="FigoTest"; + } + private RC_newObjectIassign_02(String str){ + str1=str; + str2=str; + } + private RC_newObjectIassign_02(String[] str){ + strArray=str; + } + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 5){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"a","b","c"}; + RC_newObjectIassign_02 rctest=new RC_newObjectIassign_02(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + rctest.str1="firstTimeTestStr1"; + rctest.str2="firstTimeTestStr2"; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="firstTimeTestStr1" && rctest.str2== "firstTimeTestStr2") + check +=1; + rctest = new RC_newObjectIassign_02("secondTimeTest"); + if(Arrays.equals(rctest.strArray,null) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest.strArray = arrayStr; + if(Arrays.equals(rctest.strArray,example) && rctest.str1 =="secondTimeTest" && rctest.str2== "secondTimeTest") + check +=1; + rctest=new RC_newObjectIassign_02(); + if(rctest.strArray.length == 10 && rctest.str1 =="MapleTest" && rctest.str2== "FigoTest") + check +=1; + } +} diff --git a/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/expected.txt b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/test.cfg b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..71b8ee34a67ddb4702ec6dbda5f913961faec044 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0310-rc-function-Optimization-RC_newObjectIassign_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_newObjectIassign_02) +run(RC_newObjectIassign_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java new file mode 100755 index 0000000000000000000000000000000000000000..858e576c99ae8d9e2bbcd664eef18c23de1a5962 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/RC_newObjectToField.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +public class RC_newObjectToField { + final static String STR = "MapleTest"; + static int check = 0; + volatile static String[] strArray; + static String str1; + volatile String str2; + private RC_newObjectToField(){ + strArray=new String[10]; + str1=new String("str1")+"MapleTest"; + str2="FigoTest"; + } + private RC_newObjectToField(String str){ + str1=new String("str1")+str; + str2=new String("str2")+str; + } + private RC_newObjectToField(String[] str){ + Arrays.sort(str); + Arrays.toString(str); + new Object(); + new String("Just Test"); + Arrays.binarySearch(str,"d"); + strArray=new String[10]; + strArray=str; + } + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 3){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] example = {"a","b","c"}; + String[] arrayStr = {"c","a","b"}; + RC_newObjectToField rctest=new RC_newObjectToField(arrayStr); + if(Arrays.equals(rctest.strArray,example) && rctest.str1 ==null && rctest.str2== null) + check +=1; + rctest = new RC_newObjectToField("secondTimeTest"); + if(Arrays.equals(rctest.strArray,example) && rctest.str1.equals("str1secondTimeTest") && rctest.str2.equals( "str2secondTimeTest")) + check +=1; + rctest=new RC_newObjectToField(); + if(rctest.strArray.length == 10 && rctest.str1.equals("str1MapleTest") && rctest.str2== "FigoTest") + check +=1; + } +} diff --git a/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/expected.txt b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/test.cfg b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a5e035104f614e815c678e2013e9f8b76b04625 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0311-rc-function-Optimization-RC_newObjectToField/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_newObjectToField) +run(RC_newObjectToField,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java new file mode 100755 index 0000000000000000000000000000000000000000..79e90757b19f7d9b32a1811a93b59a2a81d35212 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/RC_newObjectToField_02.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +public class RC_newObjectToField_02 { + final static String STR = "MapleTest"; + static int check = 0; + volatile static String[] strArray; + int[] intArray; + static String str1; + volatile String str2; + private RC_newObjectToField_02() throws ArithmeticException{ + strArray=new String[10]; + str1=new String("str1")+"MapleTest"; + str2="FigoTest"; + intArray = new int[]{1/0}; + } + private RC_newObjectToField_02(String str) throws StringIndexOutOfBoundsException{ + str1=(new String("str1")+str).substring(-1,-2); + str2=new String("str2")+str; + } + private RC_newObjectToField_02(String[] str) throws ArrayIndexOutOfBoundsException{ + Arrays.sort(str); + Arrays.toString(str); + new Object(); + new String("Just Test"); + Arrays.binarySearch(str,"d"); + intArray=new int[10]; + strArray=new String[1]; + strArray[2]=new String("IndexOutBounds"); + } + public static void main(String[] args){ + for(int i =1; i<=100 ; i++){ + test_new_objct_assign(); + if(check != 3){ + System.out.println("ErrorResult"); + break; + }else{ + check=0; + str1=null; + } + } + System.out.println("ExpectResult"); + } + private static void test_new_objct_assign(){ + String[] arrayStr = {"c","a","b"}; + try{ + RC_newObjectToField_02 rctest=new RC_newObjectToField_02(arrayStr); + }catch(ArrayIndexOutOfBoundsException a) { + check += 1; + } + try{ + RC_newObjectToField_02 rctest = new RC_newObjectToField_02("secondTimeTest");} + catch(StringIndexOutOfBoundsException s){ + check +=1; + } + try{ + RC_newObjectToField_02 rctest=new RC_newObjectToField_02();} + catch(ArithmeticException a){ + check +=1; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/expected.txt b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/test.cfg b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f528293abce633a0b59e4136551e5b9678b1590a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0312-rc-function-Optimization-RC_newObjectToField_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_newObjectToField_02) +run(RC_newObjectToField_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java new file mode 100755 index 0000000000000000000000000000000000000000..8fd579314541da306ac959481252aee3127e4e1f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/RC_staticInput.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class RC_staticInput { + static int []test= {10,20,30,40}; + public static void main(String [] args) { + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + test(4,test); + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void test(int first, int[] second) { + int [] xyz = {23,24,25,26}; + test = xyz; + if(second.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/expected.txt b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..309f6d50570536aa5ec2bd6eba765f9c8fa03b0f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/expected.txt @@ -0,0 +1,3 @@ +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/test.cfg b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f477354f3ca8db7feb7b5dea5ef1a8766e2475da --- /dev/null +++ b/testsuite/java_test/rc_test/RC0313-rc-function-Optimization-RC_staticInput/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_staticInput) +run(RC_staticInput,EXPECTNUM=3) diff --git a/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java new file mode 100755 index 0000000000000000000000000000000000000000..15cebf163e14281a573b76183b0de095c12b6086 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/RC_staticInput_02.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class RC_staticInput_02 { + static int []test= {10,20,30,40}; + public static void main(String [] args) { + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + test(4,test); + if(test.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void test(int first, int[] second) { + int [] xyz = {23,24,25,26}; + modify(xyz); + if(second.length==4) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } + public static void modify(int[] temp){ + test=temp; + } +} diff --git a/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/expected.txt b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..309f6d50570536aa5ec2bd6eba765f9c8fa03b0f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/expected.txt @@ -0,0 +1,3 @@ +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/test.cfg b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d15b7898f43586f2e3d812b958806153801badd2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0314-rc-function-Optimization-RC_staticInput_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_staticInput_02) +run(RC_staticInput_02,EXPECTNUM=3) diff --git a/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java new file mode 100755 index 0000000000000000000000000000000000000000..c631778cb0bb49af4e1318ae51ffc141530dd68d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/Memory_normalTestCase1.java @@ -0,0 +1,547 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase1 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int ALLOC_4K = 4 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase1() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase1_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + System.out.println("ExpectResult"); + } + public static void main(String[] args) { + testCase1(); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/expected.txt b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/test.cfg b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46a1a9dcbc51553128643a1f73caa5b7b89d8051 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0315-rc-Memory-normalTestCase1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase1) +run(Memory_normalTestCase1,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java new file mode 100755 index 0000000000000000000000000000000000000000..c003b37637fc341bab8c200c89ce33df6408281c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/Memory_normalTestCase2.java @@ -0,0 +1,555 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase2 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase2() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1, DEFAULT_REPEAT_TIMES, remain), "testCase2_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase2(); + Runtime.getRuntime().gc(); + testCase2(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/expected.txt b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/test.cfg b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..625bab53cdf95d7e157f96b982cf73ae45ce81c0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0316-rc-Memory-normalTestCase2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase2) +run(Memory_normalTestCase2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java new file mode 100755 index 0000000000000000000000000000000000000000..7dd46f205e2e0780e133804ecd9e0eb193193c09 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/Memory_normalTestCase3.java @@ -0,0 +1,548 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.Random; +import java.util.List; +import java.util.ArrayList; +import java.util.Set; +import java.util.HashSet; +public class Memory_normalTestCase3 { + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int MAX_SLOT_NUM = 62; + private static final int DEFAULT_THREAD_NUM = 80; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static boolean running = true; + private static List> allThreadReference = new ArrayList>(); + private static boolean rest = false; + private static int restTime = 5000; + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + public static void wrapper() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_2K, slot, allThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, allThreadReference, i, MemAlloc.SAVE_HALF, false, + 1, DEFAULT_REPEAT_TIMES, remain), "testCase3_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + public static void main(String[] args) { + wrapper(); + Runtime.getRuntime().gc(); + wrapper(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte[] unit; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public abstract static class MemAllocMethod { + protected long mAllocSize; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + private final Cleaner cleaner; + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); +// public static ArrayList refAndWeakRefAndCleanerFActiveObjList +// = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, + MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/expected.txt b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/test.cfg b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e110889d3e9b393da44f055caf073b9588ba2be1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0317-rc-Memory-normalTestCase3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase3) +run(Memory_normalTestCase3,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java new file mode 100755 index 0000000000000000000000000000000000000000..df0a530930e57ae25cd0f0ac1fc0fa573f6f8d7e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/Memory_normalTestCase4.java @@ -0,0 +1,556 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase4 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase4() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int slot = 0; + for (int i = 0; i < MAX_SLOT_NUM; i++) { + slot = i % MAX_SLOT_NUM; + Runnable remain = new MemAlloc(ALLOC_2K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, true, 1); + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_HALF_RAMDOM, false, 1, DEFAULT_REPEAT_TIMES, remain), "testCase4_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase4(); + Runtime.getRuntime().gc(); + testCase4(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/expected.txt b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/test.cfg b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5d64d11546688f3efdd7ee44704c27fb23d5b1c9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0318-rc-Memory-normalTestCase4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase4) +run(Memory_normalTestCase4,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java new file mode 100755 index 0000000000000000000000000000000000000000..9032cdf7bb1dfbd3fbef48c0d41e2fc6570dff5d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/Memory_normalTestCase5.java @@ -0,0 +1,558 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase5 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if(s ==null) + return; + if(s.isAlive()){ + synchronized (list){ + list.remove(s); + } + } + } + } + } + public static void testCase5() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + int average = ALLOC_4K / DEFAULT_THREAD_NUM; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K + Math.max(getSlotSize(slot), average), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase5_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args){ + testCase5(); + Runtime.getRuntime().gc(); + testCase5(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit{ + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit{ + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable{ + public byte unit[]; + public TestCleaner(byte unit[]){ + this.unit = unit; + } + public void run(){ + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit{ + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit{ + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + public void run(){ + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit{ + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + public void run(){ + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive{ + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit{ + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + public void run(){ + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM){ + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit{ + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this,new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable{ + public byte[] unit; + public TestCleaner(byte[] unit){ + this.unit = unit; + } + public void run(){ + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx+1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER){ + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if(curNum < 3){ + return new AllocUnitwithCleaner(alloc_size); + } + if(curNum < 4){ + return new AllocUnitWithWeakRefrence(alloc_size); + } + if(curNum < 5){ + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if(curNum < 6){ + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if(curNum < 7){ + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if(curNum < 8){ + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if(curNum < 2){ + return new AllocUnitWithWeakRefrence(alloc_size); + } + if(curNum < 3){ + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if(ret != null){ + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/expected.txt b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/test.cfg b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..68661142e4a912a86e73de7935babe236c33ebed --- /dev/null +++ b/testsuite/java_test/rc_test/RC0319-rc-Memory-normalTestCase5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase5) +run(Memory_normalTestCase5,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java new file mode 100755 index 0000000000000000000000000000000000000000..d389b6dd99d4837a2716de0c09feff5c777ce606 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/Memory_normalTestCase6.java @@ -0,0 +1,562 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase6 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase6() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + t = new Thread(new MemAlloc(ALLOC_4K, (int) (Math.random() * MAX_SLOT_NUM), mAllThreadReference, 0, 1, false, 1, DEFAULT_THREAD_NUM), "testCase6_" + (1)); + list.add(t); + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 1; i < DEFAULT_THREAD_NUM + 1; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K - getSlotSize(slot), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase6_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase6(); + Runtime.getRuntime().gc(); + testCase6(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/expected.txt b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/test.cfg b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..866de1ef11ef55b54f8e7d282787b2b29c351529 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0320-rc-Memory-normalTestCase6/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase6) +run(Memory_normalTestCase6,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java new file mode 100755 index 0000000000000000000000000000000000000000..538225a42f1f386da5ca79e12ea1def50f9271d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/Memory_normalTestCase6_1.java @@ -0,0 +1,562 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase6_1 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase6_1() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + t = new Thread(new MemAlloc(ALLOC_4K, (int) (Math.random() * MAX_SLOT_NUM), mAllThreadReference, 0, 1, false, 1, DEFAULT_THREAD_NUM), "testCase6_1_" + (1)); + list.add(t); + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 1; i < DEFAULT_THREAD_NUM + 1; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase6_1_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase6_1(); + Runtime.getRuntime().gc(); + testCase6_1(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/expected.txt b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/test.cfg b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7db7c343088b44863396dc28e9679636679256dd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0321-rc-Memory-normalTestCase6_1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase6_1) +run(Memory_normalTestCase6_1,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java new file mode 100755 index 0000000000000000000000000000000000000000..efe09a2ef1e039c45a6ccaaba882fa43a326c98c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/Memory_normalTestCase7.java @@ -0,0 +1,558 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +//import java.lang.ref.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase7 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase7() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K + getSlotSize(slot), slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase7_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase7(); + Runtime.getRuntime().gc(); + testCase7(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/expected.txt b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/test.cfg b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f978fc6ebfc4bec4fa4ff2f1b86a2305ba4713a2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0322-rc-Memory-normalTestCase7/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase7) +run(Memory_normalTestCase7,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java new file mode 100755 index 0000000000000000000000000000000000000000..e35b925ce86898e5603e9124571175e2eba7c8a6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/Memory_normalTestCase8.java @@ -0,0 +1,552 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase8 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase8() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_8K + ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase8_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase8(); + Runtime.getRuntime().gc(); + testCase8(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/expected.txt b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/test.cfg b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..82eee5ac9461da6fbf104e971f30b6c775c90f31 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0323-rc-Memory-normalTestCase8/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase8) +run(Memory_normalTestCase8,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java new file mode 100755 index 0000000000000000000000000000000000000000..4c0f143ad90b6f2888eb7d053e53a4a7a5302fdf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/Memory_normalTestCase9.java @@ -0,0 +1,541 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.*; +public class Memory_normalTestCase9 { + static final int MAX_SLOT_NUM = 62; + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int DEFAULT_THREAD_NUM = 80; + private static final int ALLOC_12K = 12 * 1024; + static boolean running = true; + static List> allThreadReference = new ArrayList>(); + private static boolean rest = false; + private static int restTime = 5000; + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + private static void testCase9() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_12K, slot, allThreadReference, i, MemAlloc.SAVE_ALL, + false, 1), "testCase9_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + public static void main(String[] args) { + testCase9(); + Runtime.getRuntime().gc(); + testCase9(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte[] unit; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + private final Cleaner cleaner; + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, + MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/expected.txt b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/test.cfg b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b121e97faf3763be070167aea94785fc9f02b5f2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0324-rc-Memory-normalTestCase9/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase9) +run(Memory_normalTestCase9,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java new file mode 100755 index 0000000000000000000000000000000000000000..8eeb6092cc910ce52c312f3a5578b199848e2b24 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/Memory_normalTestCase10.java @@ -0,0 +1,552 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase10 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase10() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_16K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase10_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase10(); + Runtime.getRuntime().gc(); + testCase10(); + System.out.println("ExpectResult"); + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/expected.txt b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/test.cfg b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..42742e7b7fa333dcb28d9478f3398a392c3aeed5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0325-rc-Memory-normalTestCase10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase10) +run(Memory_normalTestCase10,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java new file mode 100755 index 0000000000000000000000000000000000000000..59173a83d70cf480265474943c2c21a5da8866c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/Memory_normalTestCase11.java @@ -0,0 +1,598 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase11 { + private static final int DEFAULT_THREAD_NUM = 80; + private static final int MAX_SLOT_NUM = 62; + private static boolean rest = false; + private static int restTime = 5000; + private static boolean running = true; + private static final int ALLOC_4K = 4 * 1024; + private static final int MAX_REALIVE_OBJ_NUM = 1000; + private static List> allThreadReference = new ArrayList>(); + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + private static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted during trySleep", e); + } + } + private static boolean tryRest() { + if (rest) { + trySleep(restTime); + return true; + } + return false; + } + private static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + private static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + throw new RuntimeException("Thread interrupted while joining", e); + } + } + } + private static void testCase11() { + resetTestEnvirment(allThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, allThreadReference, i, MemAlloc.SAVE_ALL, + false, 1), "testCase11_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(allThreadReference, i, false), "testCase11_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(allThreadReference); + } + public static void main(String[] args) { + testCase11(); + Runtime.getRuntime().gc(); + testCase11(); + System.out.println("ExpectResult"); + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!running) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte []unit; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public abstract static class MemAllocMethod { + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte []unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + private TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + public static final int PAGE_SIZE = 4016; + public static final int PAGE_HEADSIZE = 80; + public static final int OBJ_MAX_SIZE = 1008; + public static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + private int mRepeatTimes = 1; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, + Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, + boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes,Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, + callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, + repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, + int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!running) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + continue; + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/expected.txt b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/test.cfg b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..45920ba2791bf34a8cab8a40d250688bdcba2a61 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0326-rc-Memory-normalTestCase11/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase11) +run(Memory_normalTestCase11,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java new file mode 100755 index 0000000000000000000000000000000000000000..7c34025610ee07c98a76ec55e54aa1ec8d162e95 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/Memory_normalTestCase12.java @@ -0,0 +1,620 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase12 { + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase11() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + t = new Thread(new MemAlloc(ALLOC_4K, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1), "testCase11_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase11_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void testCase12() { + for (int i = 0; i < 3; i++) { + testCase11(); + } + } + public static void main(String[] args) { + testCase12(); + Runtime.getRuntime().gc(); + testCase12(); + System.out.println("ExpectResult"); + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/expected.txt b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/test.cfg b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..daf4824742920cf26e2abf9f71ea93c0d0aeaf24 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0327-rc-Memory-normalTestCase12/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase12) +run(Memory_normalTestCase12,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java new file mode 100755 index 0000000000000000000000000000000000000000..f2edda2b99e15abdf7bdbc951a6e9d7d8f42cf8e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/Memory_normalTestCase15.java @@ -0,0 +1,890 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase15 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase15() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 11, ENUM_RANGE.ENUM_RANGE_BOTH, 11, 0, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 11, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase15_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase15_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase15(); + Runtime.getRuntime().gc(); + testCase15(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/expected.txt b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/test.cfg b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c3bce22d986cf09581b4266ff79780070a5138ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0330-rc-Memory-normalTestCase15/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase15) +run(Memory_normalTestCase15,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java new file mode 100755 index 0000000000000000000000000000000000000000..b327aee14cf4ec4c42456c9213c753ff3f8a8af1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/Memory_normalTestCase16.java @@ -0,0 +1,890 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase16 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase16() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 11, ENUM_RANGE.ENUM_RANGE_BOTH, 11, 80, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 11, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase16_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + list.clear(); + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + t = new Thread(new FreeReference(mAllThreadReference, i, false), "testCase16_free_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + resetTestEnvirment(mAllThreadReference); + } + public static void main(String[] args) { + testCase16(); + Runtime.getRuntime().gc(); + testCase16(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/expected.txt b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/test.cfg b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..158fbec5ee02357e4069d978621068ecf0b0fc65 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0331-rc-Memory-normalTestCase16/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase16) +run(Memory_normalTestCase16,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java new file mode 100755 index 0000000000000000000000000000000000000000..0a29b86f815127e16bf035db3efe802194e2adb9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/Memory_normalTestCase17.java @@ -0,0 +1,880 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase17 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase17() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_4K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 0, false); + t = new Thread(new MemAlloc(ALLOC_4K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase17_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase17(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/expected.txt b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/test.cfg b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2312047691f1c66e00f62cda8a4303ed7b3364d4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0332-rc-Memory-normalTestCase17/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase17) +run(Memory_normalTestCase17,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java new file mode 100755 index 0000000000000000000000000000000000000000..dca1cd0514ab001f935523673b5b6f03bee224a0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/Memory_normalTestCase18.java @@ -0,0 +1,882 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase18 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase18() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_4K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 0, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_4K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase18_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase18(); + Runtime.getRuntime().gc(); + testCase18(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/expected.txt b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/test.cfg b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3be083a3d5b8ae1c9d672d56a1ccf6b4f45dcaa9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0333-rc-Memory-normalTestCase18/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase18) +run(Memory_normalTestCase18,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java new file mode 100755 index 0000000000000000000000000000000000000000..fd5779d656f0f5ef20960d9c83f1a2712fb37641 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/Memory_normalTestCase19.java @@ -0,0 +1,880 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase19 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase19() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < 2 * DEFAULT_THREAD_NUM; i++) { + int slot = i % MAX_SLOT_NUM; + RandomAllocMethod allocMethod = new RandomAllocMethod(ALLOC_8K * 6, ENUM_RANGE.ENUM_RANGE_ALL, 6, 80, Math.random() > 0.5d); + t = new Thread(new MemAlloc(ALLOC_8K * 6, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, false, 1, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase19_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase19(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/expected.txt b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/test.cfg b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ec46e6aea535b901f9a333f18b4bf6f73b1fd9c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0334-rc-Memory-normalTestCase19/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase19) +run(Memory_normalTestCase19,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java new file mode 100755 index 0000000000000000000000000000000000000000..a456d95365b10bbb5dd381f29e2ecf5730742163 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/Memory_normalTestCase22.java @@ -0,0 +1,891 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase22 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_THREAD_NUM_HALF = DEFAULT_THREAD_NUM / 2; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase22() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + RandomAllocMethod allocMethod = new RandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i % DEFAULT_THREAD_NUM_HALF, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase22_alloc_" + (i + 1)); + list.add(t); + } + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + RandomAllocMethod allocMethod = new RandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i % DEFAULT_THREAD_NUM_HALF, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase22_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase22(); + Runtime.getRuntime().gc(); + testCase22(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/expected.txt b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/test.cfg b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fc777d05efe152f5caf4b062587c53fff14ebbd8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0335-rc-Memory-normalTestCase22/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase22) +run(Memory_normalTestCase22,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java new file mode 100755 index 0000000000000000000000000000000000000000..ae2cd37367dfa4198288af23cc28d2576d399633 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/Memory_normalTestCase23.java @@ -0,0 +1,939 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase23 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_THREAD_NUM_HALF = DEFAULT_THREAD_NUM / 2; + public static final int MAX_REALIVE_OBJ_NUM = 1000; + static List> mAllThreadReference = new ArrayList>(); + static AllocUnit[] mLocks = new AllocUnit[DEFAULT_THREAD_NUM]; + private static int getSlotSize(int slot) { + return MemAlloc.idx_to_size(slot); + } + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + private static Set getRandomIndex(List arrayToFree, int freeNum) { + HashSet result = new HashSet(); + if (arrayToFree == null) { + return result; + } + randomSet(0, arrayToFree.size(), freeNum >= arrayToFree.size() ? arrayToFree.size() : freeNum, result); + return result; + } + private static void randomSet(int min, int max, int n, HashSet set) { + if (n > (max - min + 1) || max < min) { + return; + } + for (int i = 0; i < n; i++) { + int num = (int) (Math.random() * (max - min)) + min; + set.add(num); + } + int setSize = set.size(); + if (setSize < n) { + randomSet(min, max, n - setSize, set); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + private static boolean tryRest() { + if (mRest) { + trySleep(mRestTime); + return true; + } + return false; + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void testCase23() { + resetTestEnvirment(mAllThreadReference); + ArrayList list = new ArrayList(); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM; i++) { + int slot = new Random().nextInt(MAX_SLOT_NUM); + int size = new Random().nextInt(ALLOC_12K) + ALLOC_4K; + MemAllocMethod allocMethod = new ContinueRandomAllocMethod(size, ENUM_RANGE.ENUM_RANGE_ALL, 6, (int) Math.random() * 100, Math.random() > 0.5d, 100, 400, 0, false); + t = new Thread(new MemAlloc(size, slot, mAllThreadReference, i, MemAlloc.SAVE_ALL, true, 1000, DEFAULT_REPEAT_TIMES, null, allocMethod), "testCase23_alloc_" + (i + 1)); + list.add(t); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void main(String[] args) { + testCase23(); + Runtime.getRuntime().gc(); + testCase23(); + System.out.println("ExpectResult"); + } + public static int makesureprop(int prop) { + if (prop > 100 || prop <= 0) { + prop = 100; + } + return prop; + } + public static ArrayList choose_idx(int min, int max, int chosen, boolean random) { + if (min > max) { + return null; + } + ArrayList ret = new ArrayList(); + if (!random) { + int grow = (max - min + chosen) / chosen; + for (int i = min; i < max; i = i + grow) { + Integer a = Integer.valueOf(i); + ret.add(a); + } + } else { + Random rand = new Random(); + for (int i = 0; i < chosen; i++) { + int randNumber = rand.nextInt(max - min) + min; + Integer rdn = Integer.valueOf(randNumber); + ret.add(rdn); + } + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + public static ArrayList alloc_choose_prop(ArrayList purpose, ArrayList other, int prop, long size, int diff, boolean isStress) { + prop = makesureprop(prop); + ArrayList array = new ArrayList(); + long size_alloc = 0; + int n_p = prop / 10, n_o = (100 - prop) / 10; + boolean no_alloc = true; + while (size_alloc < size) { + for (int i = 0; i < n_p; i++) { + Iterator it1 = purpose.iterator(); + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + for (int i = 0; i < n_o; i++) { + Iterator it2 = other.iterator(); + while (it2.hasNext()) { + int a = (it2.next()).intValue(); + size_alloc = size_alloc + idx_to_size(a); + ArrayList temp_array = alloc_byte_idx(idx_to_size(a), a, diff, isStress); + array.addAll(temp_array); + no_alloc = false; + } + if (size_alloc > size) { + return array; + } + } + if (no_alloc) + return array; + } + return array; + } + public static ArrayList alloc_choose_idx(long size, ENUM_RANGE range, int chosen, int prop, boolean random, boolean isStress) { + ArrayList purpose = new ArrayList(); + ArrayList other = new ArrayList(); + ArrayList largeobj_list = new ArrayList(); + ArrayList array = new ArrayList(); + boolean has_small = false, has_large = false; + if (!random) { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, GLOBAL_MIN_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX + 1, chosen, random)); + largeobj_list.add(LARGE_PAGE_SIZE); + largeobj_list.add(8 * LARGE_PAGE_SIZE); + has_small = true; + has_large = true; + break; + default: + break; + } + } else { + switch (range) { + case ENUM_RANGE_LOCAL: + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_GLOBAL: + purpose.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_BOTH: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + has_small = true; + break; + case ENUM_RANGE_LARGEOBJ: + Random rand = new Random(); + int largenum = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum; i++) { + int randNumber = rand.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + break; + case ENUM_RANGE_ALL: + chosen = chosen / 2; + purpose.addAll(choose_idx(LOCAL_MIN_IDX, LOCAL_MAX_IDX, chosen, random)); + other.addAll(choose_idx(GLOBAL_MIN_IDX, GLOBAL_MAX_IDX, chosen, random)); + Random rand2 = new Random(); + int largenum2 = LARGEOBJ_CHOSEN_NUM; + for (int i = 0; i < largenum2; i++) { + int randNumber = rand2.nextInt(32) + 1; + largeobj_list.add(randNumber * LARGE_PAGE_SIZE); + } + has_large = true; + has_small = true; + break; + default: + } + } + if (has_small) { + array.addAll(alloc_choose_prop(purpose, other, prop, size, 0, isStress)); + } + if (has_large) { + array.addAll(alloc_list_large(LARGEOBJ_ALLOC_SIZE, largeobj_list, 50, isStress)); + } + return array; + } + public static ArrayList alloc_list_large(long bytesize, ArrayList alloc_list, int prop, boolean isStress) { + ArrayList array = new ArrayList(); + long size_allocated = 0; + prop = makesureprop(prop); + int n_p = prop / 10, n_o = (100 - prop) / 10; + while (size_allocated < bytesize) { + Iterator it1 = alloc_list.iterator(); + boolean first = true; + int loopn = n_p; + while (it1.hasNext()) { + int a = (it1.next()).intValue(); + if (first) { + loopn = n_p; + first = false; + } else { + loopn = n_o; + first = true; + } + for (int i = 0; i < loopn; i++) { + size_allocated = size_allocated + a; + ArrayList temp_array = alloc_byte_large(a, a, 0, isStress); + array.addAll(temp_array); + if (size_allocated > bytesize) { + return array; + } + } + } + } + return array; + } + public static ArrayList alloc_byte_large(long bytesize, int alloc_size, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (alloc_size <= OBJ_MAX_SIZE) { + return null; + } + long size = 0; + if ((bytesize + diff * alloc_size) <= 0) { + return null; + } + bytesize = bytesize + diff * alloc_size; + while (size < bytesize) { + size = size + alloc_size; + array.add(MemAlloc.AllocOneUnit(alloc_size, isStress)); + } + return array; + } + public static class RandomAllocMethod extends MemAllocMethod { + public RandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + } + @Override + public List alloc(boolean isStress) { + List ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + } + static class FreeReference implements Runnable { + private List> mAllReference = null; + private int mThreadIdx = 0; + private boolean mLoop = false; + private boolean mSync = false; + public FreeReference(List> reference, int threadIdx, boolean loop, boolean sync) { + mAllReference = reference; + mThreadIdx = threadIdx; + mLoop = loop; + mSync = sync; + } + public FreeReference(List> reference, int threadIdx, boolean loop) { + this(reference, threadIdx, loop, false); + } + private void release() { + if (mSync) { + synchronized (mAllReference) { + releaseOperate(); + } + } else { + releaseOperate(); + } + } + private void releaseOperate() { + if (mAllReference == null) { + return; + } + if (mThreadIdx >= mAllReference.size()) { + return; + } + List cur = mAllReference.get(mThreadIdx); + mAllReference.set(mThreadIdx, null); + if (cur != null) { + cur.clear(); + } + } + @Override + public void run() { + if (!mLoop) { + release(); + return; + } + while (mLoop) { + if (!mRunning) { + break; + } + release(); + trySleep(1); + } + } + } + public static class ContinueRandomAllocMethod extends MemAllocMethod { + private long mSleep; + private long mTotalTimes; + private long mTimes = 0; + private boolean mFreeImmediately; + public ContinueRandomAllocMethod(long size, ENUM_RANGE range, int chosen, int prop, boolean random, long sleep, long totalTimes, int times, boolean freeImmediately) { + mAllocSize = size; + mRange = range; + mChosen = chosen; + mProp = prop; + mRandorm = random; + mSleep = sleep; + mTotalTimes = totalTimes; + mTimes = times; + mFreeImmediately = freeImmediately; + } + @Override + public List alloc(boolean isStress) { + List ret = null; + List tmp = null; + if (mTotalTimes == 0 && mTimes == 0) { + ret = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + return ret; + } + long elipseTime = 0; + boolean find = false; + ret = new ArrayList(); + while (elipseTime < mTotalTimes) { + long now = System.currentTimeMillis(); + tmp = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + if (!mFreeImmediately && tmp != null) { + ret.addAll(tmp); + } else { + tmp = null; + } + find = true; + trySleep(mSleep); + elipseTime += System.currentTimeMillis() - now; + } + if (!find) { + int time = 0; + while (time < mTotalTimes) { + tmp = alloc_choose_idx(mAllocSize, mRange, mChosen, mProp, mRandorm, isStress); + if (!mFreeImmediately && tmp != null) { + ret.addAll(tmp); + } else { + tmp = null; + } + time++; + trySleep(mSleep); + } + } + return ret; + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static enum ENUM_RANGE { + ENUM_RANGE_NONE, ENUM_RANGE_LOCAL, ENUM_RANGE_GLOBAL, ENUM_RANGE_BOTH, ENUM_RANGE_LARGEOBJ, ENUM_RANGE_ALL + } + public static abstract class MemAllocMethod { + protected long mAllocSize; + protected ENUM_RANGE mRange; + protected int mChosen = 0; + protected int mProp = 0; + protected boolean mRandorm; + public abstract List alloc(boolean isStress); + } + public static class AllocUnitWithFinalizeSleep extends AllocUnit { + public AllocUnitWithFinalizeSleep(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + trySleep(1000); + } + } + public static class AllocUnitWithSoftReference extends AllocUnit { + private Reference refArray; + public AllocUnitWithSoftReference(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithFinalize extends AllocUnit { + public AllocUnitWithFinalize(int arrayLength) { + super(arrayLength); + } + @Override + public void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitCycleMaster extends AllocUnit { + @SuppressWarnings("unused") + private AllocUnitCycleSlave slave = null; + public AllocUnitCycleMaster(int arrayLength) { + super(arrayLength); + slave = new AllocUnitCycleSlave(arrayLength, this); + } + } + public static class AllocUnitCycleSlave extends AllocUnit { + private AllocUnitCycleMaster master = null; + public AllocUnitCycleSlave(int arrayLength, AllocUnitCycleMaster master) { + super(arrayLength); + this.master = master; + } + } + public static class AllocUnitwithCleaner extends AllocUnit { + public AllocUnitwithCleaner(int arrayLength) { + super(arrayLength); + this.cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private final Cleaner cleaner; + private static class TestCleaner implements Runnable { + public byte unit[]; + public TestCleaner(byte unit[]) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + public static class AllocUnitWithWeakRefrence extends AllocUnit { + public WeakReference weakIntArray; + public AllocUnitWithWeakRefrence(int arrayLength) { + super(arrayLength); + weakIntArray = new WeakReference(new byte[arrayLength]); + } + } + public static class AllocUnitWithRefAndCleanerF extends AllocUnit { + private Reference refArray; + private Cleaner cleaner; + public AllocUnitWithRefAndCleanerF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithWeakRefAndCleanerF extends AllocUnit { + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithWeakRefAndCleanerF(int arrayLength) { + super(arrayLength); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class ReAlive { + public static ArrayList cleanerList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + public static ArrayList refAndWeakRefAndCleanerFActiveObjList + = new ArrayList(MAX_REALIVE_OBJ_NUM); + } + public static class AllocUnitWithRefAndWeakRefAndCleanerActiveObjF extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + if (ReAlive.cleanerList.size() > MAX_REALIVE_OBJ_NUM) { + ReAlive.cleanerList.clear(); + } else { + ReAlive.cleanerList.add(this); + } + this.unit = null; + } + } + @Override + protected void finalize() throws Throwable { + unit = null; + } + } + public static class AllocUnitWithRefAndWeakRefAndCleanerFActiveObj extends AllocUnit { + private Reference refArray; + private WeakReference weakRefArray; + private Cleaner cleaner; + public AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(int arrayLength) { + super(arrayLength); + refArray = new SoftReference(new byte[arrayLength]); + weakRefArray = new WeakReference(new byte[arrayLength]); + cleaner = Cleaner.create(this, new TestCleaner(new byte[arrayLength])); + } + private static class TestCleaner implements Runnable { + public byte[] unit; + public TestCleaner(byte[] unit) { + this.unit = unit; + } + public void run() { + this.unit = null; + } + } + } + static class MemAlloc implements Runnable { + int mAllocSize = 4 * 1024; + int mSaveNum = -1; + boolean mFreeImmediately = false; + int mSlot = 0; + int mSleepTime = 5; + List> mSaveTo = null; + int mSaveIndex = 0; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + public static final int SAVE_ALL = -1; + public static final int SAVE_HALF = -2; + public static final int SAVE_HALF_RAMDOM = -3; + public static final int SAVE_HALF_MINUS = -4; + private int mRepeatTimes = 1; + public static volatile int totalAllocedNum = 0; + public static boolean TEST_OOM_FINALIZER = false; + private Runnable mCallBackAfterFree = null; + private MemAllocMethod mAllocMethod = null; + private boolean mIsStress; + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + mIsStress = isStress; + mAllocSize = allocSize; + mFreeImmediately = freeImmediately; + mSaveNum = saveNum; + mSlot = slot; + mSleepTime = sleepTime; + mSaveTo = saveTo; + mSaveIndex = saveIndex; + mRepeatTimes = repeatTimes; + mCallBackAfterFree = callBackAfterFree; + mAllocMethod = allMethod; + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree, MemAllocMethod allMethod) { + this(false, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + /** + * saveNum:0, no obj will be reference by gloal, -1:all will be + * reference. + **/ + public MemAlloc(int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes, Runnable callBackAfterFree) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, callBackAfterFree, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime, int repeatTimes) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, repeatTimes, null); + } + public MemAlloc(boolean isStress, int allocSize, int slot, List> saveTo, int saveIndex, int saveNum, boolean freeImmediately, int sleepTime) { + this(isStress, allocSize, slot, saveTo, saveIndex, saveNum, freeImmediately, sleepTime, 1); + } + private List merge(List src1, List src2) { + if (src1 == null && src2 == null) { + return null; + } + List list = new ArrayList(); + if (src1 != null) { + list.addAll(src1); + src1.clear(); + } + if (src2 != null) { + list.addAll(src2); + src2.clear(); + } + return list; + } + public static long pagesize_to_allocsize(long size_) { + long ret = 0; + int pagenum = 0; + if (size_ > (PAGE_SIZE + PAGE_HEADSIZE)) { + pagenum = (int) (size_ / (PAGE_SIZE + PAGE_HEADSIZE)); + size_ = size_ - pagenum * (PAGE_SIZE + PAGE_HEADSIZE); + } + if (size_ < PAGE_SIZE) { + ret = pagenum * PAGE_SIZE + size_; + } else { + ret = pagenum * PAGE_SIZE + PAGE_SIZE; + } + return ret; + } + public static int idx_to_size(int idx) { + int ret = 0; + if (idx < 0 || idx > GLOBAL_MAX_IDX) { + return 112; + } + if (idx < GLOBAL_MAX_IDX) { + ret = (idx + 1) * 8 + OBJ_HEADSIZE; + } else { + // idx equals GLOBAL_MAX_IDX + ret = OBJ_MAX_SIZE + OBJ_HEADSIZE; + } + return ret; + } + public static AllocUnit AllocOneUnit(int alloc_size, boolean isStress) { + if (TEST_OOM_FINALIZER) { + return new AllocUnitWithFinalizeSleep(alloc_size); + } + int curNum; + totalAllocedNum++; + curNum = totalAllocedNum % 100; + if (!isStress) { + if (curNum < 1) { + return new AllocUnitWithFinalize(alloc_size); + } + if (curNum < 2) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 3) { + return new AllocUnitwithCleaner(alloc_size); + } + if (curNum < 4) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 5) { + return new AllocUnitWithRefAndCleanerF(alloc_size); + } + if (curNum < 6) { + return new AllocUnitWithWeakRefAndCleanerF(alloc_size); + } + if (curNum < 7) { + return new AllocUnitWithRefAndWeakRefAndCleanerActiveObjF(alloc_size); + } + if (curNum < 8) { + return new AllocUnitWithRefAndWeakRefAndCleanerFActiveObj(alloc_size); + } + } else { + if (curNum < 1) { + return new AllocUnitCycleMaster(alloc_size); + } + if (curNum < 2) { + return new AllocUnitWithWeakRefrence(alloc_size); + } + if (curNum < 3) { + return new AllocUnitWithSoftReference(alloc_size); + } + } + return new AllocUnit(alloc_size); + } + public static ArrayList alloc_byte_idx(long bytesize, int idx, int diff, boolean isStress) { + ArrayList array = new ArrayList(); + if (idx < LOCAL_MIN_IDX || idx > GLOBAL_MAX_IDX) { + return null; + } + bytesize = pagesize_to_allocsize(bytesize); + int size_ = idx_to_size(idx); + if (size_ <= 0) { + return null; + } + int sizenum = (int) (bytesize / size_); + if (sizenum == 0) { + return null; + } + if (diff >= 0 || (sizenum + diff) > 0) { + sizenum = sizenum + diff; + } + for (int j = 0; j < sizenum; j++) { + array.add(MemAlloc.AllocOneUnit(size_, isStress)); + } + return array; + } + @Override + public void run() { + for (int j = 0; j < mRepeatTimes || mRepeatTimes < 0; j++) { + if (!mRunning) { + break; + } + tryRest(); + List ret = null; + if (mAllocMethod == null) { + ret = alloc_byte_idx(mAllocSize, mSlot, 0, mIsStress); + } else { + ret = mAllocMethod.alloc(mIsStress); + } + if (ret == null) { + // Log.e(TAG, + // "Fatal error happen when alloc memory: alloc size: "+mAllocSize+" slot:"+mSlot); + continue; + } else { + // Log.e(TAG, + // "alloc memory sucessfull: alloc size: "+mAllocSize+" slot:"+mSlot); + } + trySleep(mSleepTime); + if (mFreeImmediately) { + if (ret != null) { + ret.clear(); + ret = null; + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + continue; + } + if (mSaveTo != null && mSaveNum != 0) { + if (mSaveNum == SAVE_ALL && mSaveIndex < mSaveTo.size()) { + } else if (mSaveNum == SAVE_HALF && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_MINUS && mSaveIndex < mSaveTo.size() && ret != null) { + int half = ret.size() / 2 - 1; + half = half < 0 ? 0 : half; + for (int i = ret.size() - 1; i > half; i--) { + ret.remove(i); + } + } else if (mSaveNum == SAVE_HALF_RAMDOM && mSaveIndex < mSaveTo.size() && ret != null) { + Set free = getRandomIndex(ret, ret.size() / 2 + 1); + for (Integer index : free) { + ret.set(index, null); + } + } else if (ret != null) { + int i = ret.size() > mSaveNum ? mSaveNum : ret.size(); + for (i = ret.size() - 1; i > 0; i--) { + ret.remove(i); + } + } + if (mCallBackAfterFree != null) { + mCallBackAfterFree.run(); + } + synchronized (mSaveTo) { + mSaveTo.set(mSaveIndex, ret); + } + } + trySleep(mSleepTime); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/expected.txt b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/test.cfg b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c88e404b1d9bad5d7e14e6306f15b5f12838d8ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0336-rc-Memory-normalTestCase23/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase23) +run(Memory_normalTestCase23,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java new file mode 100755 index 0000000000000000000000000000000000000000..ee6cdbeee2c944c5e77f98a7a7be5001f7b1b2df --- /dev/null +++ b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/Memory_normalTestCase27.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.*; +public class Memory_normalTestCase27 { + static final int PAGE_SIZE = 4016; + static final int PAGE_HEADSIZE = 80; + static final int OBJ_MAX_SIZE = 1008; + static final int OBJ_HEADSIZE = 16; + private static final int DEFAULT_THREAD_NUM = 80; + static final int MAX_SLOT_NUM = 62; + private static boolean mRest = false; + private static int mRestTime = 5000; + static boolean mRunning = true; + static final int LOCAL_MAX_IDX = 15; + public static final int LOCAL_MIN_IDX = 0; + public static final int GLOBAL_MAX_IDX = 62; + static final int GLOBAL_MIN_IDX = 16; + static final int LARGE_PAGE_SIZE = 4096; + static final int LARGEOBJ_CHOSEN_NUM = 2; + static final int LARGEOBJ_ALLOC_SIZE = 128 * LARGE_PAGE_SIZE; + private static final int DEFAULT_REPEAT_TIMES = 1; + private static final int ALLOC_16K = 16 * 1024; + private static final int ALLOC_12K = 12 * 1024; + private static final int ALLOC_8K = 8 * 1024; + private static final int ALLOC_4K = 4 * 1024; + private static final int ALLOC_2K = 2 * 1024; + private static final int DEFAULT_STRESS_THREAD_NUM = 60; + private static final int DEFAULT_STRESS_THREAD_NUM_HALF = DEFAULT_STRESS_THREAD_NUM / 2; + private static ArrayList mThreadList = new ArrayList(); + public static void testCase27() { + RCWeakProxyTest.RCWeakProxyTestEntry(); + } + public static void main(String[] args) { + testCase27(); + System.out.println("ExpectResult"); + } +} +class RCWeakProxyTest { + static class A { + Object o; + } + static class ThreadRunning extends Thread { + HashMap map; + Hashtable table; + ThreadRunning(HashMap m, Hashtable t) { + super("testCase_RCWeakProxy"); + map = m; + table = t; + } + int foo() { + return map.values().size(); + } + public void run() { + for (int i = 0; i < 500; i++) { + /* + * Collection c = map.values(); if (c == null) { + * System.out.println("error"); return; } int x = c.size(); + */ + + + int x = foo(); + if (x == 100) { + } else { + A a = new A(); + a = new A(); + } + /* + * int y = table.values().size(); if (y == 100) { + * System.out.println("bla"); } + */ + + + } + } + } + public static void RCWeakProxyTestEntry() { + HashMap map = new HashMap(); + map.put("key1", "value1"); + Hashtable table = new Hashtable(); + table.put("key1", "value1"); + int num_thread = 2; + ThreadRunning t[] = new ThreadRunning[num_thread]; + for (int i = 0; i < num_thread; i++) { + t[i] = new ThreadRunning(map, table); + t[i].start(); + } + try { + for (int i = 0; i < num_thread; i++) { + t[i].join(); + } + } catch (Exception e) { + } + } +} diff --git a/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/expected.txt b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/test.cfg b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2b99d97f193935f99fe43864aea37b3095e4d14c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0337-rc-Memory-normalTestCase27/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase27) +run(Memory_normalTestCase27,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java new file mode 100755 index 0000000000000000000000000000000000000000..c5471185baddbdb02619960e3f1837891fd9e130 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/Memory_normalTestCase28.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Random; +import java.util.Set; +public class Memory_normalTestCase28 { + private static final int DEFAULT_THREAD_NUM = 80; + public static final int LOCAL_MIN_IDX = 0; + private static final int DEFAULT_STRESS_THREAD_NUM = 60; + private static final String MODULE_NAME_MEMT = "MemAllocTest"; + static List> mAllStressThreadReference = new ArrayList>(); + private static ArrayList mThreadList = new ArrayList(); + private static void resetTestEnvirment(List> referenceList) { + int size = 0; + synchronized (referenceList) { + size = referenceList.size(); + } + for (; size < 2 * DEFAULT_THREAD_NUM; size++) { + synchronized (referenceList) { + referenceList.add(null); + } + } + int i = 0; + synchronized (referenceList) { + for (List all : referenceList) { + if (all != null) { + all.clear(); + } + referenceList.set(i++, null); + } + } + } + public static void main(String[] args) { + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + Runtime.getRuntime().gc(); + testCase28(); + System.out.println("ExpectResult"); + } + public static void testCase28() { + ArrayList list = new ArrayList(); + resetTestEnvirment(mAllStressThreadReference); + Thread t = null; + for (int i = 0; i < DEFAULT_THREAD_NUM / 8; i++) { + t = new Thread(new Runnable() { + @Override + public void run() { + for (int j = 0; j < 50; j++) { + NativeTestFunc nativeTestFunc = new NativeTestFunc(); + nativeTestFunc.testNativeWeakDelete(nativeTestFunc); + System.runFinalization(); + } + } + }, MODULE_NAME_MEMT + "_testCase28_weak_" + i); + list.add(t); + } + for (int i = 0; i < DEFAULT_THREAD_NUM / 8; i++) { + t = new Thread(new Runnable() { + @Override + public void run() { + for (int j = 0; j < 50; j++) { + NativeTestFunc nativeTestFunc = new NativeTestFunc(); + nativeTestFunc.testNativeGlobalDelete(nativeTestFunc); + System.runFinalization(); + } + } + }, MODULE_NAME_MEMT + "_testCase28_global_" + i); + list.add(t); + } + mThreadList.addAll(list); + startAllThread(list); + waitAllThreadFinish(list); + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + if (s == null) + return; + if (s.isAlive()) { + synchronized (list) { + list.remove(s); + } + } + } + } + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } +} +class NativeTestFunc { + static { + // System.loadLibrary("StressTestNative"); + } + public native void testNativeAttach(); + public native void testNativeWeakDelete(Object input); + public native void testNativeGlobalDelete(Object input); +} diff --git a/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/expected.txt b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/test.cfg b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9ab03166d30d22a9463d2f4c011b422d40bd07cb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0338-rc-Memory-normalTestCase28/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_normalTestCase28) +run(Memory_normalTestCase28,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java b/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..4b0221a5a6c7a9f73457bbedc61ba2db98fd8856 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/Ref_Processor_Cycle_All_Weak_Ref.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Cycle_All_Weak_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static int allSum; + public static void main(String[] args) { + checkCount = 0; + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + test_01(); + if (allSum == 20) { + checkCount++; + System.out.println("sum is wrong"); + } + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkCount: " + checkCount); + } + } + } + private static void test_01() { + Cycle_A cycleA = new Cycle_A(); + cycleA.cyb = new Cycle_B(); + cycleA.cyb.cyc = new Cycle_C(); + cycleA.cyb.cyc.cyd = new Cycle_D(); + cycleA.cyb.cyc.cyd.cya = cycleA; + allSum = cycleA.sum + cycleA.cyb.sum + cycleA.cyb.cyc.sum + cycleA.cyb.cyc.cyd.sum; + sleep(2000); + if ((cycleA.wr.get() != null) || (cycleA.cyb.sr.get() != null) || (cycleA.cyb.cyc.pr.get() != null) + || (cycleA.cyb.cyc.cyd.str.get() != null)) { + checkCount++; + } + cycleA = null; + sleep(2000); + if (cycleA != null && cycleA.cyb != null && cycleA.cyb.cyc != null && cycleA.cyb.cyc.cyd != null + && cycleA.cyb.cyc.cyd.cya != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " [test_01]a1 has not free"); + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} +class Cycle_A { + Reference wr; + Cycle_B cyb; + int aNum; + int sum; + static StringBuffer stringBufferA = new StringBuffer("ref_processor_cycle_A"); + Cycle_A() { + stringBufferA = new StringBuffer("ref_processor_cycle_A"); + wr = new WeakReference<>(stringBufferA); + if (wr.get() == null) { + assert false; + } + stringBufferA = null; + cyb = null; + aNum = 1; + } + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_B { + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + static StringBuffer stringBufferB = new StringBuffer("ref_processor_cycle_B"); + Cycle_B() { + stringBufferB = new StringBuffer("ref_processor_cycle_B"); + sr = new WeakReference<>(stringBufferB); + if (sr.get() == null) { + assert false; + } + stringBufferB = null; + cyc = null; + bNum = 2; + } + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer stringBufferC = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + Cycle_C() { + stringBufferC = new StringBuffer("ref_processor_cycle_C"); + pr = new WeakReference<>(stringBufferC); + if (pr.get() == null) { + assert false; + } + stringBufferC = null; + cyd = null; + cNum = 3; + } + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_D { + Reference str; + Cycle_A cya; + StringBuffer stringBufferD = new StringBuffer("ref_processor_cycle_D"); + int dNum; + int sum; + Cycle_D() { + stringBufferD = new StringBuffer("ref_processor_cycle_D"); + str = new WeakReference(stringBufferD); + stringBufferD = null; + cya = null; + dNum = 4; + } + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} diff --git a/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/test.cfg b/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..060648525e7fb3a3ae41a6383e6bbc93b242b517 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0339-rc-rp-cycle_all_weak/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Cycle_All_Weak_Ref) +run(Ref_Processor_Cycle_All_Weak_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java b/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..1401d5f831a92ad0bf10704e612011b46903f5d8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/Ref_Processor_Cycle_Weak_Strong_Ref.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Cycle_Weak_Strong_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static int allSum; + public static void main(String[] args) { + checkCount = 0; + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + test_01(); + if (allSum == 20) { + checkCount++; + System.out.println("sum is wrong"); + } + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkCount: " + checkCount); + } + } + } + private static void test_01() { + Cycle_A cycleA = new Cycle_A(); + cycleA.cyb = new Cycle_B(); + cycleA.cyb.cyc = new Cycle_C(); + cycleA.cyb.cyc.cyd = new Cycle_D(); + cycleA.cyb.cyc.cyd.cya = cycleA; + allSum = cycleA.sum + cycleA.cyb.sum + cycleA.cyb.cyc.sum + cycleA.cyb.cyc.cyd.sum; + sleep(2000); + if ((cycleA.wr.get() != null) || (cycleA.cyb.sr.get() != null) || (cycleA.cyb.cyc.pr.get() != null) + || (cycleA.cyb.cyc.cyd.string == null)) { + checkCount++; + } + cycleA = null; + sleep(2000); + if (cycleA != null && cycleA.cyb != null && cycleA.cyb.cyc != null && cycleA.cyb.cyc.cyd != null + && cycleA.cyb.cyc.cyd.cya != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " [test_01]a1 has not free"); + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} +class Cycle_A { + Reference wr; + Cycle_B cyb; + int aNum; + int sum; + static StringBuffer stringBufferA = new StringBuffer("ref_processor_cycle_A"); + Cycle_A() { + stringBufferA = new StringBuffer("ref_processor_cycle_A"); + wr = new WeakReference<>(stringBufferA); + if (wr.get() == null) { + assert false; + } + stringBufferA = null; + cyb = null; + aNum = 1; + } + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_B { + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + static StringBuffer stringBufferB = new StringBuffer("ref_processor_cycle_B"); + Cycle_B() { + stringBufferB = new StringBuffer("ref_processor_cycle_B"); + sr = new WeakReference<>(stringBufferB); + if (sr.get() == null) { + assert false; + } + stringBufferB = null; + cyc = null; + bNum = 2; + } + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer stringBufferC = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + Cycle_C() { + stringBufferC = new StringBuffer("ref_processor_cycle_C"); + pr = new WeakReference<>(stringBufferC); + if (pr.get() == null) { + assert false; + } + stringBufferC = null; + cyd = null; + cNum = 3; + } + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_D { + String string; + Cycle_A cya; + int dNum; + int sum; + Cycle_D() { + string = new String("ref_processor_cycle_D"); + cya = null; + dNum = 4; + } + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} diff --git a/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/test.cfg b/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9a994331964c03139ffd51cb2ccafd8873b83dca --- /dev/null +++ b/testsuite/java_test/rc_test/RC0340-rc-rp-cycle_weak_strong/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Cycle_Weak_Strong_Ref) +run(Ref_Processor_Cycle_Weak_Strong_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java b/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..1207da6cde6a6000c9032b652919659bbf492bbc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/Ref_Processor_Mutator_Ref.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Mutator_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq, srq, prq; + static StringBuffer stringBuffer1 = new StringBuffer("weak"); + static StringBuffer stringBuffer2 = new StringBuffer("soft"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("error,check_count: " + check_count); + } + } + private static void test() { + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + sleep(2000); + if (wr.get() != null) { + check_count++; + } + if (sr.get() != null) { + check_count++; + } + } + Reference wrqPoll, srqPoll, prqPoll; + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "prq.poll()"); + } + } + } + public static void test_01() { + wrq = new ReferenceQueue(); + srq = new ReferenceQueue(); + prq = new ReferenceQueue(); + stringBuffer1 = new StringBuffer("weak"); + stringBuffer2 = new StringBuffer("soft"); + stringBuffer3 = new StringBuffer("phantom"); + wr = new WeakReference(stringBuffer1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in wr"); + } + sr = new WeakReference(stringBuffer2, srq); + if (sr.get() == null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in sr"); + } + pr = new PhantomReference(stringBuffer3, prq); + if (pr.get() != null) { + check_count++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ----------------------" + + "check_count: " + check_count); + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in pr"); + } + stringBuffer1 = null; + stringBuffer2 = null; + stringBuffer3 = null; + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/test.cfg b/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f8ac850936777f9a95492ff1bd746270abc2d4ac --- /dev/null +++ b/testsuite/java_test/rc_test/RC0341-rc-rp-mutator/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Mutator_Ref) +run(Ref_Processor_Mutator_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java b/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java new file mode 100755 index 0000000000000000000000000000000000000000..1fd6c4406c8c8c678818c2db480b7c6597a7a139 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/Ref_Processor_Weak_Ref_Boundary.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Weak_Ref_Boundary { + static int checkCount = 0; + static final int TEST_NUM = 1; + static WeakReference wr[] = new WeakReference[14]; + static WeakReference sr[] = new WeakReference[14]; + static PhantomReference pr[] = new PhantomReference[14]; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + Runtime.getRuntime().gc(); + test(); + //Result judgment + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult,checkNum: " + checkCount); + } + } + private static void test() { + //test01: 14 mix weak references + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + } + sleep(1000); + } + public static void setSoftRef(int times) { + stringBuffer1 = new StringBuffer("soft"); + for (int i = 0; i < times; i++) { + sr[i] = new WeakReference(stringBuffer1, srq); + if (sr[i].get() == null) { + System.out.println(" ---------------error in sr of test01"); + checkCount++; + } + } + stringBuffer1 = null; + } + public static void setWeakRef(int times) { + stringBuffer2 = new StringBuffer("Weak"); + for (int i = 0; i < times; i++) { + wr[i] = new WeakReference(stringBuffer2, wrq); + if (wr[i].get() == null) { + System.out.println(" ---------------error in wr of test01"); + checkCount++; + } + } + stringBuffer2 = null; + } + public static void setPhantomRef(int times) { + stringBuffer3 = new StringBuffer("phantom"); + for (int i = 0; i < times; i++) { + pr[i] = new PhantomReference(stringBuffer3, prq); + if (pr[i].get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ---------------" + + "error in pr of test01"); + checkCount++; + } + } + stringBuffer3 = null; + } + public static void test_01() { + /* 14 mix weak references*/ + + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(4); + checkWeakRq("weak", 4); + setPhantomRef(5); + checkPhantomRq("phantom"); + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(5); + checkWeakRq("weak", 5); + setPhantomRef(5); + checkPhantomRq("phantom"); + setSoftRef(5); + checkSoftRq("soft", 5); + setWeakRef(6); + checkWeakRq("weak", 6); + setPhantomRef(5); + checkPhantomRq("phantom"); + } + public static void checkSoftRq(String funName, int times) { + Reference srqPoll; + sleep(2000); + if (sr != null) { + for (int i = 0; i < times; i++) { + if (sr[i].get() != null) { + checkCount++; + System.out.println(" ErrorResult in sr " + funName); + } + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + } + public static void checkWeakRq(String funName, int times) { + Reference wrqPoll; + sleep(2000); + for (int i = 0; i < times; i++) { + if (wr[i].get() != null) { + checkCount++; + System.out.println(" ErrorResult in wr " + funName + "times:" + i); + } + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + } + public static void checkPhantomRq(String funName) { + Reference prqPoll; + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + checkCount++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/test.cfg b/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d63667212adfed59bca56962b1471e68dc250e77 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0342-rc-rp-weak_ref_boundary/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Weak_Ref_Boundary) +run(Ref_Processor_Weak_Ref_Boundary,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java b/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..ff757c0405a4e08d0122dba297126041bca0470e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/Ref_Processor_Wcb_Test_Ref.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class Ref_Processor_Wcb_Test_Ref { + static int checkCount = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + if (checkCount == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("errorResult ---- checkcount: " + checkCount); + } + } + private static void test() { + // test: if WCB == 0, return object value + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + sleep(1000); + } + // test: if WCB == 1, return null + checkRet("test step 2"); + // test: check change WCB 1 to 0 + } + private static void test_01() { + /*if WCB == 0, return object value except PhantomReference*/ + stringBuffer1 = new StringBuffer("soft"); + stringBuffer2 = new StringBuffer("weak"); + stringBuffer3 = new StringBuffer("phantom"); + wr = new WeakReference(stringBuffer2, wrq); + if (wr.get() == null) { + checkCount++; + } + sr = new WeakReference(stringBuffer1, srq); + if (sr.get() == null) { + checkCount++; + } + pr = new PhantomReference(stringBuffer3, prq); + if (pr.get() != null) { + checkCount++; + } + stringBuffer2 = null; + stringBuffer1 = null; + stringBuffer3 = null; + } + private static void checkRet(String funName) { + sleep(2000); + Reference wrqPoll, srqPoll, prqPoll; + if (sr.get() != null) { + checkCount++; + } + if (wr.get() != null) { + checkCount++; + } + if (pr.get() != null) { + checkCount++; + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + checkCount++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + checkCount++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/test.cfg b/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..10c3f05e76a14b6f3df17a55470971362b8f1335 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0343-rc-rp-wcb_test_ref/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Wcb_Test_Ref) +run(Ref_Processor_Wcb_Test_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java b/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..32eb0bf5d2e71ddec7ff277a1e326055c737b38e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/Ref_Processor_Aged_Ref.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Aged_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static final int AGED_NUM = 3; + static WeakReference sr[] = new WeakReference[AGED_NUM + 1]; + static WeakReference wr[] = new WeakReference[AGED_NUM + 1]; + static PhantomReference pr[] = new PhantomReference[AGED_NUM + 1]; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("WeakReference"); + static StringBuffer obj2 = new StringBuffer("WeakReference"); + static StringBuffer obj3 = new StringBuffer("PhantomReference"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check_count : " + check_count); + } + } + public static void test() { + for (int i = 0; i < TEST_NUM; i++) { + // Threshold for Ref object == age - 1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM - 1); + checkRef(AGED_NUM - 1); + // Threshold for Ref object == age + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM); + checkRef(AGED_NUM); + // Threshold for Ref object == age + 1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM + 1); + checkRef(AGED_NUM + 1); + // Has entered the Aged Ref queue + // The number of processing == X-1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM - 1); + checkRef(AGED_NUM - 1); + //the number of processing == X + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM); + checkRef(AGED_NUM); + //the number of processing == X+1 + obj1 = new StringBuffer("WeakReference"); + obj2 = new StringBuffer("WeakReference"); + obj3 = new StringBuffer("PhantomReference"); + setRef(AGED_NUM + 1); + checkRef(AGED_NUM + 1); + } + } + public static void setRef(int repeat_time) { + /*Threshold for Ref object == age - 1*/ + for (int i = 0; i < repeat_time; i++) { + sr[i] = new WeakReference(obj1, srq); + if (sr[i].get() == null) { + check_count++; + System.out.println("sr in setRef " + i + "repeat_time:" + repeat_time); + } + wr[i] = new WeakReference(obj2, wrq); + if (wr[i].get() == null) { + check_count++; + System.out.println("wr in setRef " + i + "repeat_time:" + repeat_time); + } + pr[i] = new PhantomReference(obj3, prq); + if (pr[i].get() != null) { + check_count++; + System.out.println("pr in setRef"); + } + } + obj1 = null; + obj2 = null; + obj3 = null; + } + public static void checkRef(int repeat_time) { + sleep(2000); + for (int i = 0; i < repeat_time; i++) { + if (sr[i].get() != null) { + check_count++; + } + if (wr[i].get() != null) { + check_count++; + } + Reference wrqPoll, srqPoll, prqPoll; + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/test.cfg b/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b2c94f7b477f25935833cd14c0ddd9f0b05fed01 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0344-rc-rp-test_aged_ref/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Aged_Ref) +run(Ref_Processor_Aged_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java b/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..91778bfa778bd5d56e554ba7514987a3cc773585 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/Ref_Processor_Single_Or_More_Weak_Ref.java @@ -0,0 +1,179 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Single_Or_More_Weak_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static Reference wr, sr, pr; + static ReferenceQueue wrq, srq, prq; + static StringBuffer obj_1 = new StringBuffer("hello"); + static StringBuffer obj_2 = new StringBuffer("kitty"); + static StringBuffer obj_3 = new StringBuffer("mikey"); + static StringBuffer obj4 = new StringBuffer("WeakReference"); + static StringBuffer obj5 = new StringBuffer("WeakReference"); + static StringBuffer obj6 = new StringBuffer("PhantomReference"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + if (check_count == 0) + System.out.println("ExpectResult"); + else { + System.out.println("ErrorResult, check_count:" + check_count); + } + } + private static void test() { + Reference wrqPoll, srqPoll, prqPoll; + for (int i = 0; i < TEST_NUM; i++) { + weakRef(); + sleep(2000); + if (wr.get() != null) { + check_count++; + System.out.println(" ErrorResult in weakRef step1"); + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll() step2"); + } + } + } + // check WeakReference + for (int i = 0; i < TEST_NUM; i++) { + softRef(); + sleep(2000); + if (sr.get() != null) { + check_count++; + System.out.println(" ErrorResult in softRef step2"); + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + } + // check PhantomReference + for (int i = 0; i < TEST_NUM; i++) { + phantomRef(); + sleep(2000); + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + // more than one reference + for (int i = 0; i < TEST_NUM; i++) { + mixRef(); + sleep(2000); + if (wr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:weakRef"); + } + if (sr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:softRef"); + } + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult in mixRef step2:phantomRef"); + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println(" ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println(" ErrorResult in prq.poll()"); + } + } + } + } + private static void weakRef() { + wrq = new ReferenceQueue(); + obj_1 = new StringBuffer("hello"); + wr = new WeakReference(obj_1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(" ErrorResult in weakRef step1"); + } + obj_1 = null; + } + private static void softRef() { + srq = new ReferenceQueue(); + obj_2 = new StringBuffer("kitty"); + sr = new WeakReference(obj_2, srq); + if (sr.get() == null) { + check_count++; + System.out.println(" ErrorResult in softRef step1"); + } + obj_2 = null; + } + private static void phantomRef() { + obj_3 = new StringBuffer("mikey"); + prq = new ReferenceQueue(); + pr = new PhantomReference(obj_3, prq); + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult in phantomRef step1"); + } + obj_3 = null; + } + private static void mixRef() { + wrq = new ReferenceQueue(); + srq = new ReferenceQueue(); + prq = new ReferenceQueue(); + obj4 = new StringBuffer("WeakReference"); + obj5 = new StringBuffer("WeakReference"); + obj6 = new StringBuffer("PhantomReference"); + wr = new WeakReference(obj4, wrq); + if (wr.get() == null) { + check_count++; + System.out.println(" ErrorResult of wr in mixRef step1"); + } + sr = new WeakReference(obj5, srq); + if (sr.get() == null) { + check_count++; + System.out.println(" ErrorResult of sr in mixRef step2"); + } + pr = new PhantomReference(obj6, prq); + if (pr.get() != null) { + check_count++; + System.out.println(" ErrorResult of pr in mixRef step3"); + } + obj4 = null; + obj5 = null; + obj6 = null; + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/test.cfg b/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d2db9e2223b1466662d8e4f2675e649f8d575ecb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0345-rc-rp-single_or_more/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Single_Or_More_Weak_Ref) +run(Ref_Processor_Single_Or_More_Weak_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java b/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java new file mode 100755 index 0000000000000000000000000000000000000000..3a29a0a586cf11bc1be7c31a8dbbd6349ee641a5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/Ref_Processor_Strong_And_Weak_Ref.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class Ref_Processor_Strong_And_Weak_Ref { + static int check_count = 0; + static final int TEST_NUM = 1; + static String rf = new String("test"); + static Reference wr, sr, pr; + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("weak"); + static StringBuffer obj2 = new StringBuffer("soft"); + static StringBuffer obj3 = new StringBuffer("phantom"); + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + if (check_count == 0){ + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult check_count : " + check_count); + } + } + private static void test() { + // strong and weak reference, first free strong, next free weak + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + } + checkRq("test_01_02"); + } + private static void test_01() { + /* strong and weak reference, first free strong, next free weak*/ + + obj1 = new StringBuffer("weak"); + obj2 = new StringBuffer("soft"); + obj3 = new StringBuffer("phantom"); + wr = new WeakReference(obj1, wrq); + if (wr.get() == null) { + check_count++; + System.out.println("error in test01---------------wr"); + } + sr = new WeakReference(obj2, srq); + if (sr.get() == null) { + check_count++; + System.out.println("error in test01----------------sr"); + } + pr = new PhantomReference(obj3, prq); + if (pr.get() != null) { + check_count++; + System.out.println("error in test01----------------pr"); + } + obj1 = null; + obj2 = null; + obj3 = null; + if (rf == null) { + check_count++; + System.out.println("error in test01-----------rf"); + } + } + private static void checkRq(String funName) { + Reference wrqPoll, srqPoll, prqPoll; + sleep(2000); + if (wr.get() != null) { + System.out.println("error in checkRq---------------wr"); + check_count++; + } + if (sr.get() != null) { + System.out.println("error in checkRq--------------sr"); + check_count++; + } + if (rf == null || (!rf.equals("test"))) { + System.out.println("error in checkRq---------------rf"); + check_count++; + } + while ((wrqPoll = wrq.poll()) != null) { + if (!wrqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println("ErrorResult in wrq.poll()"); + } + } + while ((srqPoll = srq.poll()) != null) { + if (!srqPoll.getClass().toString().equals("class java.lang.ref.WeakReference")) { + check_count++; + System.out.println("ErrorResult in srq.poll()"); + } + } + while ((prqPoll = prq.poll()) != null) { + if (!prqPoll.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + check_count++; + System.out.println("ErrorResult in prq.poll()"); + } + } + } + private static void sleep(int sleepNum) { + try { + Thread.sleep(sleepNum); + } catch (InterruptedException e) { + System.out.println("sleep was Interrupted"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/test.cfg b/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..755722bd105ef9e5204ff399e82006c2e40763bf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0346-rc-rp-strong_and_weak/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ref_Processor_Strong_And_Weak_Ref) +run(Ref_Processor_Strong_And_Weak_Ref,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java b/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java new file mode 100755 index 0000000000000000000000000000000000000000..08accef63fd1cbe8b477bdf656c1c8f3a41f0bc4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/SimulThreadInRef.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class SimulThreadInRef { + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + } + static void test() { + int soft, weak, phantom; + soft = testExecuteSoft(); + Runtime.getRuntime().gc(); + soft = testExecuteSoft(); + weak = testExecuteWeak(); + Runtime.getRuntime().gc(); + weak = testExecuteWeak(); + phantom = testExecutePhantom(); + Runtime.getRuntime().gc(); + phantom = testExecutePhantom(); + testExecuteOther(); + Runtime.getRuntime().gc(); + if ((soft == 0) && (weak == 0) && (phantom == 0)) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + static int testExecuteSoft() { + MultiRef multiRef = new MultiRef(); + ThreadTestSoftRef threadTestSoftRef = new ThreadTestSoftRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestSoftRef.run(); + } + return threadTestSoftRef.count1; + } + static int testExecuteWeak() { + MultiRef multiRef = new MultiRef(); + ThreadTestWeakRef threadTestWeakRef = new ThreadTestWeakRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestWeakRef.run(); + } + return threadTestWeakRef.count2; + } + static int testExecutePhantom() { + MultiRef multiRef = new MultiRef(); + ThreadTestPhantomRef threadTestPhantomRef = new ThreadTestPhantomRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestPhantomRef.run(); + } + return threadTestPhantomRef.count3; + } + static void testExecuteOther() { + MultiRef multiRef = new MultiRef(); + ThreadTestOtherRef threadTestOtherRef = new ThreadTestOtherRef(multiRef); + int N = 1; + for (int i = 0; i < N; i++) { + threadTestOtherRef.run(); + } + } +} +class MultiRef { + static Reference sr, wr, pr, osr; + static StringBuffer obj1 = new StringBuffer("Soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("Phantom"); + ReferenceQueue srq = new ReferenceQueue(); + ReferenceQueue wrq = new ReferenceQueue(); + ReferenceQueue prq = new ReferenceQueue(); + static int srValue, wrValue, prValue; + void setSoftRef() { + obj1 = new StringBuffer("Soft"); + sr = new WeakReference(obj1, srq); + if (sr.get() == null) { + srValue++; + } + obj1 = null; + } + void setWeakRef() { + obj2 = new StringBuffer("weak"); + wr = new WeakReference(obj2, wrq); + if (wr.get() == null) { + wrValue++; + } + obj2 = null; + } + void setPhantomRef() { + obj3 = new StringBuffer("Phantom"); + pr = new PhantomReference(obj3, prq); + if (pr.get() != null) { + prValue++; + } + obj3 = null; + } + void setOtherSoftRef() { + osr = new WeakReference(new Object()); + } + int freeSoftRef() throws InterruptedException { + Reference r1; + setSoftRef(); + Thread.sleep(2000); + if (sr.get() != null) { + srValue++; + System.out.println("error in soft"); + } + while ((r1 = srq.poll()) != null) { + if (!r1.getClass().toString().equals("class java.lang.ref.WeakReference")) { + srValue++; + } + } + return srValue; + } + int freeWeakRef() throws InterruptedException { + Reference r2; + setWeakRef(); + Thread.sleep(2000); + if (wr.get() != null) { + wrValue++; + System.out.println("error in weak"); + } + while ((r2 = wrq.poll()) != null) { + if (!r2.getClass().toString().equals("class java.lang.ref.WeakReference")) { + wrValue++; + } + } + return wrValue; + } + int freePhantomRef() throws InterruptedException { + Reference r1; + setPhantomRef(); + Thread.sleep(2000); + while ((r1 = prq.poll()) != null) { + if (!r1.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + prValue++; + } + } + return prValue; + } +} +// 线程1,设置软引用 +class ThreadTestSoftRef implements Runnable { + MultiRef multiRef; + int count1; + public ThreadTestSoftRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + @Override + public void run() { + try { + count1 = multiRef.freeSoftRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} +// 线程2,设置弱引用 +class ThreadTestWeakRef implements Runnable { + MultiRef multiRef; + int count2; + public ThreadTestWeakRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + @Override + public void run() { + try { + count2 = multiRef.freeWeakRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} +// 线程3,设置虚引用 +class ThreadTestPhantomRef implements Runnable { + MultiRef multiRef; + int count3; + public ThreadTestPhantomRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + @Override + public void run() { + try { + count3 = multiRef.freePhantomRef(); + } catch (Exception e) { + e.printStackTrace(); + } + } +} +// 线程4,设置其他引用 +class ThreadTestOtherRef implements Runnable { + MultiRef multiRef; + public ThreadTestOtherRef(MultiRef multiRef) { + this.multiRef = multiRef; + } + @Override + public void run() { + multiRef.setOtherSoftRef(); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/test.cfg b/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a87dfd925fae53e228494790a1565e039414ed24 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0347-rc-rp-simulthread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SimulThreadInRef) +run(SimulThreadInRef,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java b/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d76ba86ed9883070ecf438355b9efe58b97825ca --- /dev/null +++ b/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/DeadReferenceTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class DeadReferenceTest { + static int TEST_NUM = 1; + static int judgeNum = 0; + static Reference weakRp; + static ReferenceQueue rq = new ReferenceQueue(); + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + deadReferenceTest(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void setWeakRef() { + weakRp = new WeakReference(null, rq); + } + static void deadReferenceTest() throws InterruptedException { + Reference reference; + setWeakRef(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + if (weakRp.get() != null) { + judgeNum++; + } + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + judgeNum++; + } + } + } +} +class ThreadRf implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/test.cfg b/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..68d5773f531f32c008378f1abdc0374517fbd7ad --- /dev/null +++ b/testsuite/java_test/rc_test/RC0348-rc-rp-simpleweakref_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(DeadReferenceTest) +run(DeadReferenceTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java b/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..64c3762488cd7a70f689621e8e6a4cbf5bd8206d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/IsCleanerInDeadCycle.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +public class IsCleanerInDeadCycle { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerInDeadCycle(); + Runtime.getRuntime().gc(); + isCleanerInDeadCycle(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void isCleanerInDeadCycle() throws InterruptedException { + judgeNum = 0; + Cycle_BDec_00010_A1_Cleaner cycleBA1 = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + System.gc(); + boolean result = cycleA.setCleanerCycle(cycleBA1); + cycleBA1.cycleBA2 = null; + cycleBA1 = null; + if (result == true) { + Thread.sleep(2000); + if (cycleBA1.cleaner == null || cycleBA1.cycleBA2.cleaner == null) { + } else { + judgeNum++; + } + } else { + judgeNum++; + } + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + Cycle_BDec_00010_A2_Cleaner cycleBA2; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBA2, null); + cycleBA2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBA2.num; + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBA1Cleaner; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBA1Cleaner, null); + cycleBA1Cleaner = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBA1Cleaner.num; + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBDA 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + cycleBDA.add(); + cycleBDA.cycleBA2.add(); + int nSum = cycleBDA.sum + cycleBDA.cycleBA2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.cycleBA2 = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1Cleaner.cycleBA2.cycleBA1Cleaner = cycleBDA1Cleaner; + boolean ret; + ret = ModifyCleanerA1(cycleBDA1Cleaner); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1Cleaner.cleaner == null && cycleBDA1Cleaner.cycleBA2.cleaner == null + && cycleBDA1Cleaner != null && cycleBDA1Cleaner.cycleBA2 != null) { + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/test.cfg b/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..11b599f11d9573cc74727c278ca09f40c882226c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0349-rc-rp-simpleweakref_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerInDeadCycle) +run(IsCleanerInDeadCycle,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java b/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..3b162bad617bf9b05ae25024cc7355c7b221a017 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java @@ -0,0 +1,395 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.*; +public class IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Throwable { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + Runtime.getRuntime().gc(); + isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("error,judgeNum:" + judgeNum); + } + } + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA1); + Runtime.getRuntime().gc(); + return result; + } + static void isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB() throws Throwable { + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleBDA1Cleaner); + if (result == true) { + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + cycleBDA1Cleaner = null; + if (result == true) { + if (cycleBDA1Cleaner.clearSoftReference() == true) { + if (cycleBDA1Cleaner.clearWeakReference() == true) { + if (cycleBDA1Cleaner.clearFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearNoFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearFinalizeCleaner() == true) { + if (cycleBDA1Cleaner.clearNoFinalizeCleaner() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner--------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " " + + "ErrorResult in clearFinalizeCleaner------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " " + + "ErrorResult in clearNoFinalizePhantomReference---------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference-----------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult " + + "in clearWeakReference------------------" + + "isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "clearSoftReference-----------------isCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ErrorResult in " + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA2Cleaner.num; + } + /** + * 设置软引用,clear and enqueue + */ + + + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + static void setSoftReference() { + stringBuffer1 = new StringBuffer("soft"); + srp = new WeakReference(stringBuffer1, srq); + if (srp.get() == null) { + value++; + } + stringBuffer1 = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRf()).start(); + System.gc(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用, clear and enqueue + */ + + + static void setWeakReference() { + stringBuffer2 = new StringBuffer("weak"); + wrp = new WeakReference(stringBuffer2, wrq); + if (wrp.get() == null) { + value++; + } + stringBuffer2 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRf()).start(); + System.gc(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + + + static void setPhantomReference() { + stringBuffer3 = new StringBuffer("phantom"); + prp = new PhantomReference(stringBuffer3, prq); + if (prp.get() != null) { + value++; + } + stringBuffer3 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws Throwable { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + /** + * 设置cleaner, 没有Referent finalized,clear and enqueue + */ + + + static void setCleaner() { + Cleaner crp = null; + String str = new String("test"); + crp.create(str, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + } + } + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置cleaner, 经过Referent finalized,clear and enqueue + */ + + + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用, Cleaner即为空 + new Thread(new ThreadRf()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleB 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.add(); + cycleB.cycleBDA2Cleaner.add(); + int nSum = cycleB.sum + cycleB.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1Cleaner.cycleBDA2Cleaner.cycleBD = cycleBDA1Cleaner; + boolean ret; + ret = ModifyCleanerA1(cycleBDA1Cleaner); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1Cleaner.cleaner == null && cycleBDA1Cleaner.cycleBDA2Cleaner.cleaner == null + && cycleBDA1Cleaner != null && cycleBDA1Cleaner.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBD; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBD, null); + cycleBD = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBD.num; + } +} +class RC_Finalize { + static int value = 0; + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } +} +class ThreadRf implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/test.cfg b/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..adf16fe56eb1cbe424644256c262a7e1f601fcb6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0350-rc-rp-simpleweakref_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB) +run(IsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java b/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java new file mode 100755 index 0000000000000000000000000000000000000000..3b68bc4e2553c025491f3e040723519bf9621d09 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/IsCleanerNotInDeadCycleFreeRef.java @@ -0,0 +1,131 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.*; +public class IsCleanerNotInDeadCycleFreeRef { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleFreeRef(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleFreeRef(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void isCleanerNotInDeadCycleFreeRef() throws InterruptedException { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + System.gc(); + boolean result = cycleA.setCleanerCycle(cycleBDA1Cleaner); + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + if (result == true) { + Thread.sleep(2000); + if ((cycleBDA1Cleaner.cleaner == null) || (cycleBDA1Cleaner.cycleBDA2Cleaner.cleaner == null) + || (cycleBDA1Cleaner != null)) { + while ((cleaner = (Cleaner) cycleBDA1Cleaner.rq.poll()) != null) { + if (!cleaner.getClass().toString().equals("class sun.misc.Cleaner")) { + judgeNum++; + } + } + } else { + judgeNum++; + } + } else { + judgeNum++; + } + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA2Cleaner.num; + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBDA1, null); + cycleBDA1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA1.num; + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBD 传入的是带有Referent的类实例 + * @return 传入的是带有Referent的类实例 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBD) { + cycleBD.add(); + cycleBD.cycleBDA2Cleaner.add(); + int nSum = cycleBD.sum + cycleBD.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Cleaner的环 + * + * @param cycleB + * @return + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleB.cycleBDA2Cleaner.cycleBDA1 = cycleB; + boolean ret; + ret = ModifyCleanerA1(cycleB); + // 环正确,且reference都没释放 + if (ret == true && cycleB.cleaner == null && cycleB.cycleBDA2Cleaner.cleaner == null && cycleB != null + && cycleB.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/test.cfg b/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e48dc2cab7a36863a4663bbd9661560309f10d02 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0351-rc-rp-simpleweakref_04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerNotInDeadCycleFreeRef) +run(IsCleanerNotInDeadCycleFreeRef,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java b/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..0e08a9e7c78125adbae295258b63b78b4726a89f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB.java @@ -0,0 +1,431 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.io.PrintStream; +import java.lang.ref.*; +public class IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void isCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB() throws Exception { + SetReferentNull setReferentNull = new SetReferentNull(); + setReferentNull.run(); + IsCleanerNotInDeadCycleNotFreeRefFailSetWCB isCleanerNotInDeadCycleNotFreeRefFailSetWCB = + new IsCleanerNotInDeadCycleNotFreeRefFailSetWCB(); + isCleanerNotInDeadCycleNotFreeRefFailSetWCB.run(); + if (isCleanerNotInDeadCycleNotFreeRefFailSetWCB.check == false) { + judgeNum++; + } + } +} +class SetReferentNull implements Runnable { + Cycle_BDec_00010_A1_Cleaner a1_cleaner; + Cycle_BDec_00010_A2_Cleaner a2_cleaner; + @Override + public void run() { + a2_cleaner = null; + a1_cleaner = null; + } +} +class IsCleanerNotInDeadCycleNotFreeRefFailSetWCB implements Runnable { + boolean check; + @Override + public void run() { + check = isCleanerNotInDeadCycleNotFreeRefFailSetWCB(); + } + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA); + Runtime.getRuntime().gc(); + return result; + } + public boolean isCleanerNotInDeadCycleNotFreeRefFailSetWCB() { + Cycle_BDec_00010_A1_Cleaner cycleB = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleB); + if (result == true) { + try { + if (result == true) { + if (cycleB.clearSoftReference() == true) { + if (cycleB.clearWeakReference() == true) { + if (cycleB.clearFinalizePhantomReference() == true) { + if (cycleB.clearNoFinalizePhantomReference() == true) { + if (cycleB.clearFinalizeCleaner() == true) { + if (cycleB.clearNoFinalizeCleaner() == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizeCleaner"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in NotIsCleanerNotInDeadCycleNotFreeRef"); + return false; + } + } catch (Exception e) { + return false; + } + } else { + return false; + } + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleBDA1Cleaner 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner) { + cycleBDA1Cleaner.add(); + cycleBDA1Cleaner.cycleBDA2Cleaner.add(); + int nsum = cycleBDA1Cleaner.sum + cycleBDA1Cleaner.cycleBDA2Cleaner.sum; + if (nsum == 6) return true; + else return false; + } + /** + * 设置一个带Cleaner的环 + * + * @param cycleBDA1 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA1) { + cycleBDA1.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBDA1.cycleBDA2Cleaner.cycleBD = cycleBDA1; + boolean ret; + ret = ModifyCleanerA1(cycleBDA1); + // 环正确,且reference都没释放 + if (ret == true && cycleBDA1.cleaner == null && cycleBDA1.cycleBDA2Cleaner.cleaner == null + && cycleBDA1 != null && cycleBDA1.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBD; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBD, null); + cycleBD = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBD.num; + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA2Cleaner.num; + } + /** + * 设置软引用,clear and enqueue + */ + + + static Reference srp, wrp, prp, crp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer stringBuffer1 = new StringBuffer("soft"); + static StringBuffer stringBuffer2 = new StringBuffer("weak"); + static StringBuffer stringBuffer3 = new StringBuffer("phantom"); + static void setSoftReference() { + stringBuffer1 = new StringBuffer("soft"); + srp = new WeakReference(stringBuffer1, srq); + if (srp.get() == null) { + value++; + } + stringBuffer1 = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " --------------------" + + "srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用, clear and enqueue + */ + + + static void setWeakReference() { + stringBuffer2 = new StringBuffer("weak"); + wrp = new WeakReference(stringBuffer2, wrq); + if (wrp.get() == null) { + value++; + } + stringBuffer2 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + + + static void setPhantomReference() { + stringBuffer3 = new StringBuffer("phantom"); + prp = new PhantomReference(stringBuffer3, prq); + if (prp.get() != null) { + value++; + } + stringBuffer3 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + /** + * 设置虚引用,经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + /** + * 设置cleaner,没有Referent finalized,clear and enqueue + */ + + + static void setCleaner() { + Cleaner crp = null; + StringBuffer stringBuffer = new StringBuffer("test"); + crp.create(stringBuffer, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + } + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置cleaner,经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用,Cleaner即为空 + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class RC_Finalize { + static int value = 0; + static void rcFinalize() throws InterruptedException { + RC_Finalize rc_finalize = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + public static int run(String argv[], PrintStream out) { + return 0; + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/test.cfg b/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..227c9dac32941ef1c9ac18c6ee04695761230f37 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0352-rc-rp-simpleweakref_05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB) +run(IsCleanerNotInDeadCycleNotFreeRefFailSetWCBSetAtomicWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java b/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..a5006d45d0a64cbcc516493e34b6c5f32b3e9b03 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/IsCleanerNotInDeadCycleNotFreeRefSetWCB.java @@ -0,0 +1,393 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.*; +public class IsCleanerNotInDeadCycleNotFreeRefSetWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotFreeRefSetWCB(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotFreeRefSetWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static boolean resultSetCycle(Cycle_BDec_00010_A1_Cleaner cycleBDA) { + InCycle cycleA = new InCycle(); + boolean result = cycleA.setCleanerCycle(cycleBDA); + Runtime.getRuntime().gc(); + return result; + } + static void isCleanerNotInDeadCycleNotFreeRefSetWCB() throws InterruptedException { + Cycle_BDec_00010_A1_Cleaner cycleBDA1Cleaner = new Cycle_BDec_00010_A1_Cleaner(); + boolean result = resultSetCycle(cycleBDA1Cleaner); + cycleBDA1Cleaner.cycleBDA2Cleaner = null; + if (result == true) { + if (cycleBDA1Cleaner.clearSoftReference() == true) { + if (cycleBDA1Cleaner.clearWeakReference() == true) { + if (cycleBDA1Cleaner.clearFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearNoFinalizePhantomReference() == true) { + if (cycleBDA1Cleaner.clearFinalizeCleaner() == true) { + if (cycleBDA1Cleaner.clearNoFinalizeCleaner() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizeCleaner------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizeCleaner------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference------------isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference------------isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB------------" + + "isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + Cycle_BDec_00010_A1_Cleaner cycleBDA1; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cycleBDA1, null); + cycleBDA1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA1.num; + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cycleBDA2Cleaner; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cycleBDA2Cleaner, null); + cycleBDA2Cleaner = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cycleBDA2Cleaner.num; + } + /** + * 设置软引用,clear and enqueue + */ + + + static Reference srp, wrp, prp, crp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static ReferenceQueue crq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("soft"); + static StringBuffer obj1 = new StringBuffer("weak"); + static StringBuffer obj2 = new StringBuffer("phantom"); + static void setSoftReference() { + obj = new StringBuffer("soft"); + srp = new WeakReference(obj, srq); + if (srp.get() == null) { + value++; + } + obj = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用,clear and enqueue + */ + + + static void setWeakReference() { + obj1 = new StringBuffer("weak"); + wrp = new WeakReference(obj1, wrq); + if (wrp.get() == null) { + value++; + } + obj1 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 没有Referent finalized,clear and enqueue + */ + + + static void setPhantomReference() { + prp = new PhantomReference(obj2, prq); + if (prp.get() != null) { + value++; + } + obj2 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } + /** + * 设置cleaner, 没有Referent finalized,clear and enqueue + */ + + + static void setCleaner() { + Cleaner crp = null; + StringBuffer str = new StringBuffer("test"); + crp.create(str, null); + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + } + } + static boolean clearNoFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + setCleaner(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = crq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + /** + * 设置cleaner, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizeCleaner() throws InterruptedException { + Reference reference; + value = 100; + int finalValue = finalSet(); + Runtime.getRuntime().gc(); + if (finalValue == 200) { + value = value + 100; + } + setCleaner(); + // 初次调用, Cleaner即为空 + try { + if (crp.get() != null) { + value++; + } + } catch (NullPointerException e) { + e.printStackTrace(); + } + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.Cleaner")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cycleB 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cycleB) { + cycleB.add(); + cycleB.cycleBDA2Cleaner.add(); + int nSum = cycleB.sum + cycleB.cycleBDA2Cleaner.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Cleaner的环 + * + * @param cycleBD 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cycleBD) { + cycleBD.cycleBDA2Cleaner = new Cycle_BDec_00010_A2_Cleaner(); + cycleBD.cycleBDA2Cleaner.cycleBDA1 = cycleBD; + boolean ret; + ret = ModifyCleanerA1(cycleBD); + //环正确,且reference都没释放 + if (ret == true && cycleBD.cleaner == null && cycleBD.cycleBDA2Cleaner.cleaner == null + && cycleBD != null && cycleBD.cycleBDA2Cleaner != null) { + return true; + } else { + return false; + } + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} +class RC_Finalize { + static int value = 0; + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/test.cfg b/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..05ea334034ab24daf0d078e97c94f9b4683fc4ee --- /dev/null +++ b/testsuite/java_test/rc_test/RC0353-rc-rp-simpleweakref_06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerNotInDeadCycleNotFreeRefSetWCB) +run(IsCleanerNotInDeadCycleNotFreeRefSetWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java b/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java new file mode 100755 index 0000000000000000000000000000000000000000..444a048b1a75e3cd329a02b1b730219baefb9284 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/IsCleanerNotInDeadCycleNotSetWCBFailAtomic.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.*; +public class IsCleanerNotInDeadCycleNotSetWCBFailAtomic { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + isCleanerNotInDeadCycleNotSetWCBFailAtomic(); + Runtime.getRuntime().gc(); + isCleanerNotInDeadCycleNotSetWCBFailAtomic(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void isCleanerNotInDeadCycleNotSetWCBFailAtomic() throws InterruptedException { + Cycle_BDec_00010_A1_Cleaner cleanerClass1 = new Cycle_BDec_00010_A1_Cleaner(); + InCycle cycleA = new InCycle(); + cycleA.setCleanerCycle(cleanerClass1); + System.gc(); + boolean result = cycleA.setCleanerCycle(cleanerClass1); + if (result == false) { + judgeNum++; + } + } +} +class Cycle_BDec_00010_A1_Cleaner { + static Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2_Cleaner cleanerClass2; + int num; + int sum; + static int value; + Cycle_BDec_00010_A1_Cleaner() { + cleaner.create(cleanerClass2, null); + cleanerClass2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + cleanerClass2.num; + } +} +class Cycle_BDec_00010_A2_Cleaner { + Cleaner cleaner; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1_Cleaner cleanerClass1; + int num; + int sum; + static int value; + Cycle_BDec_00010_A2_Cleaner() { + cleaner.create(cleanerClass1, null); + cleanerClass1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + cleanerClass1.num; + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param cleaner 传入的是带有Referent的类实例 + * @return 返回布尔值,判断运算的结果正确 + */ + + + public static boolean ModifyCleanerA1(Cycle_BDec_00010_A1_Cleaner cleaner) { + cleaner.add(); + cleaner.cleanerClass2.add(); + int nSum = cleaner.sum + cleaner.cleanerClass2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Cleaner的环 + * + * @param cleaner 传入的是带有Referent的类实例 + * @return 返回布尔值,判断reference没释放 + */ + + + public static boolean setCleanerCycle(Cycle_BDec_00010_A1_Cleaner cleaner) { + cleaner.cleanerClass2 = new Cycle_BDec_00010_A2_Cleaner(); + cleaner.cleanerClass2.cleanerClass1 = cleaner; + boolean ret; + ret = ModifyCleanerA1(cleaner); + System.gc(); + ret = ModifyCleanerA1(cleaner); + // 环正确,且reference都没释放 + if (ret == true && cleaner.cleaner == null && cleaner.cleanerClass2.cleaner == null && cleaner != null + && cleaner.cleanerClass2 != null) { + return true; + } else { + return false; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/test.cfg b/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cdb6df07bce4958e22d39b1913b33b1d5b5affbe --- /dev/null +++ b/testsuite/java_test/rc_test/RC0354-rc-rp-simpleweakref_07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(IsCleanerNotInDeadCycleNotSetWCBFailAtomic) +run(IsCleanerNotInDeadCycleNotSetWCBFailAtomic,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java b/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java new file mode 100755 index 0000000000000000000000000000000000000000..017ce4cfde664c00ceaa23314bab26f95b222c87 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.*; +public class NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotInDeadCycleNotSetWCBFailAtomic(); + Runtime.getRuntime().gc(); + notIsCleanerNotInDeadCycleNotSetWCBFailAtomic(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void notIsCleanerNotInDeadCycleNotSetWCBFailAtomic() throws InterruptedException { + Cycle_BDec_00010_A1 cycleMember = new Cycle_BDec_00010_A1(); + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycleMember); + System.gc(); + boolean result = cycleA.setCycle(cycleMember); + if (result == false) { + judgeNum++; + } + } +} +class Cycle_BDec_00010_A1 { + Reference memberRef1; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A1() { + obj = new StringBuffer("weak"); + memberRef1 = new WeakReference(obj, rq); + if (memberRef1.get() == null) { + assert false; + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + partner2.num; + } +} +class Cycle_BDec_00010_A2 { + Reference memberRef2; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A2() { + obj = new StringBuffer("weak"); + memberRef2 = new WeakReference(obj, rq); + if (memberRef2.get() == null) { + assert false; + } + obj = null; + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + partner1.num; + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + if (ret == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/test.cfg b/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a53aa7b37b120cca48acac4b82c0ca8a811e7000 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0355-rc-rp-simpleweakref_08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic) +run(NotIsCleanerNotInDeadCycleNotSetWCBFailAtomic,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java b/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..da5eafc3476d4d810f043469720ca52a6413379e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/NotIsCleanerNotInDeadCycleNotFreeRefSetWCB.java @@ -0,0 +1,349 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.ref.*; +public class NotIsCleanerNotInDeadCycleNotFreeRefSetWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotInDeadCycleNotFreeRefSetWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static boolean resultSetCycle(Cycle_BDec_00010_A1 a1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(a1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(a1); + return result; + } + static void notIsCleanerNotInDeadCycleNotFreeRefSetWCB() throws InterruptedException { + Cycle_BDec_00010_A1 cycleA = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(cycleA); + cycleA.partner2 = null; + if (result == true) { + if (cycleA.clearSoftReference() == true) { + if (cycleA.clearWeakReference() == true) { + if (cycleA.clearFinalizePhantomReference() == true) { + if (cycleA.clearNoFinalizePhantomReference() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference--------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference---------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference-------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB---------------------" + + "NotIsCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A1() throws InterruptedException { + obj = new StringBuffer("weak"); + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + System.out.println("error in a1Ref.get"); + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + partner2.num; + } + /** + * 设置软引用, clear and enqueue + */ + + + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("obj"); + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference ref; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + value++; + } + while ((ref = srq.poll()) != null) { + if (!ref.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用, clear and enqueue + */ + + + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 没有Referent finalized, clear and enqueue. + */ + + + static void setPhantomReference() { + obj3 = new StringBuffer("obj"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A2() throws InterruptedException { + obj = new StringBuffer("weak"); + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + obj = null; + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + partner1.num; + } +} +class RC_Finalize { + static int value = 0; + static void rc_Finalize() throws InterruptedException { + RC_Finalize a = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + public static int run(String argv[], PrintStream out) { + return 0; + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (Exception e) { + e.printStackTrace(); + } + } + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + refInstance.obj = null; + refInstance.partner2.obj = null; + Thread.sleep(2000); + boolean ret; + ret = ModifyA1(refInstance); + if (ret == true) { + if (refInstance.a1Ref.get() == null) { + if (refInstance.partner2.a2Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0 == null || a1_0.a2_0 == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a2Ref.get() == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() == null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/test.cfg b/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8aebef23635e1128818272779d941fb33580a6ec --- /dev/null +++ b/testsuite/java_test/rc_test/RC0356-rc-rp-simpleweakref_09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NotIsCleanerNotInDeadCycleNotFreeRefSetWCB) +run(NotIsCleanerNotInDeadCycleNotFreeRefSetWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java b/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..21c2d63e0991658f7c17cff2959cef49790d06a5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB.java @@ -0,0 +1,375 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.ref.*; +public class NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB(); + Runtime.getRuntime().gc(); + notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void notIsCleanerNotFreeRefFailSetWCBSetAtomicWCB() throws Exception { + SetReferentNull setReferentNull = new SetReferentNull(); + setReferentNull.run(); + NotIsCleanerNotInDeadCycleNotFreeRef notIsCleanerNotInDeadCycleNotFreeRef = new + NotIsCleanerNotInDeadCycleNotFreeRef(); + notIsCleanerNotInDeadCycleNotFreeRef.run(); + if (notIsCleanerNotInDeadCycleNotFreeRef.check == false) { + judgeNum++; + } + } +} +class SetReferentNull implements Runnable { + Cycle_BDec_00010_A1 cycle1; + Cycle_BDec_00010_A2 cycle2; + @Override + public void run() { + cycle2 = null; + cycle1 = null; + } +} +class NotIsCleanerNotInDeadCycleNotFreeRef implements Runnable { + boolean check; + @Override + public void run() { + try { + check = notIsCleanerNotInDeadCycleNotFreeRef(); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + static boolean resultSetCycle(Cycle_BDec_00010_A1 cycle1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycle1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(cycle1); + return result; + } + boolean notIsCleanerNotInDeadCycleNotFreeRef() throws InterruptedException { + Cycle_BDec_00010_A1 a1 = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(a1); + try { + if (result == true) { + if (a1.clearSoftReference() == true) { + if (a1.clearWeakReference() == true) { + if (a1.clearFinalizePhantomReference() == true) { + if (a1.clearNoFinalizePhantomReference() == true) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in NotIsCleanerNotInDeadCycleNotFreeRef"); + return false; + } + } catch (Exception e) { + return false; + } + } +} +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A2() { + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + partner1.num; + } +} +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A1() { + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + assert false; + } + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + partner2.num; + } + /** + * 设置软引用, clear and enqueue + */ + + + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("phantom"); + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用,clear and enqueue + */ + + + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + //释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用,没有Referent finalized,clear and enqueue + */ + + + static void setPhantomReference() { + obj3 = new StringBuffer("phantom"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true:正确;false:错误 + */ + + + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + refInstance.obj = null; + refInstance.partner2.obj = null; + Thread.sleep(2000); + if (ret == true) { + if (refInstance.a1Ref.get() == null && refInstance.partner2.a2Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0==null||a1_0.a2_0==nulll"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() != null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} +class RC_Finalize { + static int value = 0; + static void rc_Finalize() throws InterruptedException { + RC_Finalize a = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + public static int run(String argv[], PrintStream out) { + return 0; + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/test.cfg b/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7d0717aadafc6e0e2ae5e0521634034a875dee70 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0357-rc-rp-simpleweakref_10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB) +run(NotIsCleanerNotFreeRefFailSetWCBSetAtomicWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java b/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java new file mode 100755 index 0000000000000000000000000000000000000000..827382d438c0b0bafa7b41dad14d6397c331af2a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB.java @@ -0,0 +1,348 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.lang.ref.*; +public class NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB { + static int TEST_NUM = 1; + static int judgeNum = 0; + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + Runtime.getRuntime().gc(); + notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static boolean resultSetCycle(Cycle_BDec_00010_A1 cycle1) throws InterruptedException { + InCycle cycleA = new InCycle(); + cycleA.setCycle(cycle1); + Runtime.getRuntime().gc(); + boolean result = cycleA.setCycle(cycle1); + return result; + } + static void notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB() throws InterruptedException { + Cycle_BDec_00010_A1 cycle1 = new Cycle_BDec_00010_A1(); + boolean result = resultSetCycle(cycle1); + if (result == true) { + cycle1.partner2 = null; + cycle1 = null; + if (cycle1.clearSoftReference() == true) { + if (cycle1.clearWeakReference() == true) { + if (cycle1.clearFinalizePhantomReference() == true) { + if (cycle1.clearNoFinalizePhantomReference() == true) { + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearNoFinalizePhantomReference--------------" + + "notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearFinalizePhantomReference-------------" + + "notIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearWeakReference"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in clearSoftReference"); + } + } else { + judgeNum++; + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " ErrorResult in isCleanerNotInDeadCycleNotFreeRefSetWCB"); + } + } +} +class Cycle_BDec_00010_A1 { + Reference a1Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A2 partner2; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A1() { + obj = new StringBuffer("weak"); + a1Ref = new WeakReference(obj, rq); + if (a1Ref.get() == null) { + assert false; + } + obj = null; + partner2 = null; + num = 1; + sum = 0; + value = 100; + } + void add() { + sum = num + partner2.num; + } + /** + * 设置软引用,clear and enqueue + */ + + + static Reference srp, wrp, prp; + static ReferenceQueue srq = new ReferenceQueue(); + static ReferenceQueue wrq = new ReferenceQueue(); + static ReferenceQueue prq = new ReferenceQueue(); + static StringBuffer obj1 = new StringBuffer("soft"); + static StringBuffer obj2 = new StringBuffer("weak"); + static StringBuffer obj3 = new StringBuffer("phantom"); + static void setSoftReference() { + obj1 = new StringBuffer("soft"); + srp = new WeakReference(obj1, srq); + if (srp.get() == null) { + value++; + } + obj1 = null; + } + static boolean clearSoftReference() throws InterruptedException { + int value = 100; + Reference r; + setSoftReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + //释放,应该为空 + if (srp.get() != null) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.get():" + srp.get()); + value++; + } + while ((r = srq.poll()) != null) { + if (!r.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " --------------------srp.while"); + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置弱引用,clear and enqueue + */ + + + static void setWeakReference() { + obj2 = new StringBuffer("weak"); + wrp = new WeakReference(obj2, wrq); + if (wrp.get() == null) { + value++; + } + obj2 = null; + } + static boolean clearWeakReference() throws InterruptedException { + value = 100; + Reference reference; + setWeakReference(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + // 释放,应该为空 + if (wrp.get() != null) { + value++; + } + while ((reference = wrq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + /** + * 设置虚引用, 没有Referent finalized, clear and enqueue + */ + + + static void setPhantomReference() { + obj3 = new StringBuffer("phantom"); + prp = new PhantomReference(obj3, prq); + if (prp.get() != null) { + value++; + } + obj3 = null; + } + static boolean clearNoFinalizePhantomReference() throws InterruptedException { + value = 100; + Reference reference; + setPhantomReference(); + Thread.sleep(2000); + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 100) { + return true; + } else { + return false; + } + } + static int finalSet() { + RC_Finalize testClass1 = new RC_Finalize(); + System.runFinalization(); + return testClass1.value; + } + /** + * 设置虚引用, 经过Referent finalized,clear and enqueue + */ + + + static boolean clearFinalizePhantomReference() throws InterruptedException { + value = 100; + int valueFinal = finalSet(); + Runtime.getRuntime().gc(); + valueFinal = finalSet(); + Reference reference; + setPhantomReference(); + Thread.sleep(5000); + if (valueFinal == 200) { + value = value + 100; + } + while ((reference = prq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.PhantomReference")) { + value++; + } + } + if (value == 200) { + return true; + } else { + return false; + } + } +} +class Cycle_BDec_00010_A2 { + Reference a2Ref; + static ReferenceQueue rq = new ReferenceQueue(); + Cycle_BDec_00010_A1 partner1; + int num; + int sum; + static int value; + static StringBuffer obj = new StringBuffer("weak"); + Cycle_BDec_00010_A2() { + obj = new StringBuffer("weak"); + a2Ref = new WeakReference(obj, rq); + if (a2Ref.get() == null) { + assert false; + } + obj = null; + partner1 = null; + num = 2; + sum = 0; + value = 100; + } + void add() { + sum = num + partner1.num; + } +} +class InCycle { + /** + * 确认环是正确的 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true: 正确;false:错误 + */ + + + public static boolean ModifyA1(Cycle_BDec_00010_A1 refInstance) { + refInstance.add(); + refInstance.partner2.add(); + int nSum = refInstance.sum + refInstance.partner2.sum; + if (nSum == 6) { + return true; + } else { + return false; + } + } + /** + * 设置一个带Referent的环 + * + * @param refInstance 传入的是带有Referent的类实例 + * @return true: 正确;false:错误 + */ + + + public static boolean setCycle(Cycle_BDec_00010_A1 refInstance) throws InterruptedException { + refInstance.partner2 = new Cycle_BDec_00010_A2(); + if (refInstance.partner2.a2Ref.get() == null) { + return false; + } + refInstance.partner2.partner1 = refInstance; + boolean ret; + ret = ModifyA1(refInstance); + if (ret == true) { + Thread.sleep(2000); + if (refInstance.a1Ref.get() == null) { + if (refInstance != null && refInstance.partner2 != null) { + return true; + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0==null||a1_0.a2_0==nulll"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + + " a1_0.a1Ref.get() != null"); + return false; + } + } else { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " ret != true"); + return false; + } + } +} +class RC_Finalize { + static int value = 0; + static void rc_Finalize() throws InterruptedException { + RC_Finalize rc = new RC_Finalize(); + Thread.sleep(2000); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + value = 200; + } + public static int run(String argv[], PrintStream out) { + return 0; + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/test.cfg b/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e9c77123e00c97473f9335d9a9e17804afcf281b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0358-rc-rp-simpleweakref_11/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB) +run(NotIsCleanerInDeadCycleNotFreeRefFailSetWCBFailAtomicWCB,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java b/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java new file mode 100755 index 0000000000000000000000000000000000000000..fefe5e0c882632d126971fc4cc3f4dc0706817a0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/NotIsCleanerFreeRef.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class NotIsCleanerFreeRef { + static int TEST_NUM = 1; + static int judgeNum = 0; + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("soft"); + static void setSoftRef() { + obj = new StringBuffer("soft"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + judgeNum++; + } + obj = null; + } + public static void main(String[] args) throws Exception { + judgeNum = 0; + for (int i = 0; i < TEST_NUM; i++) { + notIsCleanerFreeRef(); + Runtime.getRuntime().gc(); + notIsCleanerFreeRef(); + } + if (judgeNum == 0) { + System.out.println("ExpectResult"); + } + } + static void notIsCleanerFreeRef() throws InterruptedException { + Reference ref; + setSoftRef(); + new Thread(new ThreadRef()).start(); + Thread.sleep(2000); + if (rp.get() != null) { + judgeNum++; + } + while ((ref = rq.poll()) != null) { + if (!ref.getClass().toString().equals("class java.lang.ref.WeakReference")) { + judgeNum++; + } + } + } +} +class ThreadRef implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(100); + } catch (InterruptedException e) { + System.out.println(" sleep was Interrupted"); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/test.cfg b/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3a2a038918bc65109a29d54c806af7922adfff3f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0359-rc-rp-simpleweakref_12/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NotIsCleanerFreeRef) +run(NotIsCleanerFreeRef,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java b/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java new file mode 100755 index 0000000000000000000000000000000000000000..d0a42d919a95ddd9d5afb05d62b392bf110a7cbd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/BackupTracingAndRefPro.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class BackupTracingAndRefPro { + static int NUM = 2; + public static void main(String[] args) { + runRefPro(); + Runtime.getRuntime().gc(); + runRefPro(); + runBackupTracing(); + Runtime.getRuntime().gc(); + runBackupTracing(); + System.out.println("ExpectResult"); + } + static void runRefPro() { + ThreadRefPro threadRefPro = new ThreadRefPro(); + for (int i = 0; i < NUM; i++) { + threadRefPro.run(); + } + } + static void runBackupTracing() { + ThreadBackupTracing threadBackupTracing = new ThreadBackupTracing(); + for (int i = 0; i < NUM; i++) { + threadBackupTracing.run(); + } + } +} +class ThreadBackupTracing implements Runnable { + int result = 0; + void versify() { + ReferenceOperation ref = new ReferenceOperation(); + ref.referenceOperation = ref; + ref.add(); + result = ref.sum; + } + @Override + public void run() { + versify(); + if (result != 20) { + System.out.println("error result ==" + result); + } + } +} +class ReferenceOperation { + ReferenceOperation referenceOperation; + int num; + int sum; + ReferenceOperation() { + referenceOperation = null; + num = 10; + sum = 0; + } + void add() { + sum = num + referenceOperation.num; + } +} +class ThreadRefPro implements Runnable { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("weak"); + static void setWeakRef() { + obj = new StringBuffer("weak"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + System.out.println("error"); + } + obj = null; + } + @Override + public void run() { + Reference reference; + setWeakRef(); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (rp.get() != null) { + System.out.println("error in rp.get()"); + } + while ((reference = rq.poll()) != null) { + if (!reference.getClass().toString().equals("class java.lang.ref.WeakReference")) { + System.out.println("error in rq"); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/test.cfg b/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..285b2cd5af01b5cda07e5a2adbd2a2378414f26d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0360-rc-Memory-leaktestsupplycase-01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(BackupTracingAndRefPro) +run(BackupTracingAndRefPro,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java b/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java new file mode 100755 index 0000000000000000000000000000000000000000..c495115c2b8db73e335abdc5f442a0c2c495ddb8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/FinalizerRef.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class FinalizerRef { + static int NUM = 1; + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + System.out.println("ExpectResult"); + } + public static void test() { + SetWeakRef setWeakRef = new SetWeakRef(); + setWeakRef.setWeakRef(); + ThreadWeakRef_01 threadWeakRef_01 = new ThreadWeakRef_01(); + ThreadWeakRef_02 threadWeakRef_02 = new ThreadWeakRef_02(); + ThreadWeakRef_03 threadWeakRef_03 = new ThreadWeakRef_03(); + ThreadWeakRef_04 threadWeakRef_04 = new ThreadWeakRef_04(); + ThreadWeakRef_05 threadWeakRef_05 = new ThreadWeakRef_05(); + for (int i = 0; i < NUM; i++) { + threadWeakRef_01.run(); + threadWeakRef_02.run(); + threadWeakRef_03.run(); + threadWeakRef_04.run(); + threadWeakRef_05.run(); + } + } +} +class SetWeakRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer obj = new StringBuffer("weak"); + static void setWeakRef() { + obj = new StringBuffer("weak"); + rp = new WeakReference(obj, rq); + if (rp.get() == null) { + System.out.println("error"); + } + obj = null; + } +} +class ThreadWeakRef_01 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_01 threadWeakRef_01 = new ThreadWeakRef_01(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} +class ThreadWeakRef_02 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_02 threadWeakRef_02 = new ThreadWeakRef_02(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} +class ThreadWeakRef_03 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_03 threadWeakRef_03 = new ThreadWeakRef_03(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} +class ThreadWeakRef_04 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_04 threadWeakRef_04 = new ThreadWeakRef_04(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} +class ThreadWeakRef_05 implements Runnable { + @Override + public void run() { + System.gc(); + ThreadWeakRef_05 threadWeakRef_05 = new ThreadWeakRef_05(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/test.cfg b/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1eab09494274bf27ead1ba3ba5c385e24129a3ab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0361-rc-Memory-leaktestsupplycase-02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerRef) +run(FinalizerRef,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java b/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java new file mode 100755 index 0000000000000000000000000000000000000000..a0017326bad5acf89f5ee5ca9200c2de4dac994c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/FinalizerTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class FinalizerTest extends Object { + static int finalizeNum = 10; + static Reference rp[] = new Reference[finalizeNum]; + static ReferenceQueue rq = new ReferenceQueue(); + static int checkNum = 0; + static StringBuffer stringBuffer; + static FinalizerTest finalizerTest = null; + static void newFinalizeObject() throws InterruptedException { + stringBuffer = new StringBuffer("weak"); + for (int i = 0; i < finalizeNum; i++) { + rp[i] = new WeakReference(stringBuffer, rq); + if (rp[i].get() == null) { + checkNum--; + } + } + stringBuffer = null; + } + protected void finalize() throws Throwable { + super.finalize(); + checkNum++; + } + static void newFinalizeTest() throws InterruptedException { + for (int i = 0; i < finalizeNum; i++) { + FinalizerTest finalizerTest = new FinalizerTest(); + finalizerTest.newFinalizeObject(); + } + finalizerTest = null; + } + static void finalizeTest() throws InterruptedException { + newFinalizeTest(); + Thread.sleep(2000); + System.gc(); + System.runFinalization(); + for (int i = 0; i < finalizeNum; i++) { + if (rp[i].get() != null) { + checkNum--; + } + } + } + public static void main(String[] args) throws InterruptedException { + finalizeTest(); + Runtime.getRuntime().gc(); + finalizeTest(); + if (checkNum == (finalizeNum * 2)) { + System.out.println("ExpectResult"); + } else { + System.out.println("checkNum = " + checkNum); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/test.cfg b/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e1400c7623c278932f20dff19daadf9943f1e9d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0362-rc-Memory-leaktestsupplycase-03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerTest) +run(FinalizerTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java b/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java new file mode 100755 index 0000000000000000000000000000000000000000..2df9d632aef1713d7a00ef41157123bf8ff4ce1f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/FrequentGCAndFinalize.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class FrequentGCAndFinalize { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int num = 10; + static StringBuffer stringBuffer = new StringBuffer("weak"); + static void setWeakRef() { + stringBuffer = new StringBuffer("weak"); + rp = new WeakReference(stringBuffer, rq); + if (rp.get() == null) { + System.out.println("error"); + } + stringBuffer = null; + } + static void executeThreadGC() { + ThreadGC threadGC = new ThreadGC(); + for (int i = 0; i < num; i++) { + threadGC.run(); + } + } + static void executeThreadFinalize() { + ThreadFinalize threadFinalize = new ThreadFinalize(); + for (int i = 0; i < num; i++) { + threadFinalize.run(); + } + } + public static void main(String[] args) { + setWeakRef(); + executeThreadFinalize(); + executeThreadGC(); + executeThreadFinalize(); + System.out.println("ExpectResult"); + } +} +class ThreadGC implements Runnable { + @Override + public void run() { + Runtime.getRuntime().gc(); + } +} +class ThreadFinalize implements Runnable { + @Override + public void run() { + ThreadFinalize threadFinalize = new ThreadFinalize(); + System.runFinalization(); + } + protected void finalize() throws Throwable { + super.finalize(); + } +} diff --git a/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/test.cfg b/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ce4790ac01e5d8ff1f699e5f47a24270f8190fdb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0363-rc-Memory-leaktestsupplycase-04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FrequentGCAndFinalize) +run(FrequentGCAndFinalize,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java b/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java new file mode 100755 index 0000000000000000000000000000000000000000..e9f9d38ac086bb596a63423b11d5eda70cc98c59 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/RaceInLoadAndWriteWeakRef.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class RaceInLoadAndWriteWeakRef { + static int NUM = 100; + public static void main(String[] args) { + test(); + Runtime.getRuntime().gc(); + test(); + System.out.println("ExpectResult"); + } + static void test(){ + SetWeakRef setWeakRef = new SetWeakRef(); + setWeakRef.setWeakRef(); + ThreadLoadWeakRef threadLoadWeakRef = new ThreadLoadWeakRef(setWeakRef); + ThreadWriteWeakRef threadWriteWeakRef = new ThreadWriteWeakRef(setWeakRef); + for (int i = 0; i < NUM; i++) { + threadLoadWeakRef.run(); + Runtime.getRuntime().gc(); + threadLoadWeakRef.run(); + Runtime.getRuntime().gc(); + threadLoadWeakRef.run(); + threadWriteWeakRef.run(); + Runtime.getRuntime().gc(); + threadWriteWeakRef.run(); + } + } +} +class SetWeakRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer stringBuffer = new StringBuffer("Weak"); + static void setWeakRef() { + stringBuffer = new StringBuffer("Weak"); + rp = new WeakReference(stringBuffer, rq); + if (rp.get() == null) { + System.out.println("error"); + } + stringBuffer = null; + } +} +class ThreadLoadWeakRef implements Runnable { + SetWeakRef setWeakRef; + public ThreadLoadWeakRef(SetWeakRef setWeakRef) { + this.setWeakRef = setWeakRef; + } + static Reference rp_load; + @Override + public void run() { + rp_load = setWeakRef.rp; + } +} +class ThreadWriteWeakRef implements Runnable { + SetWeakRef setWeakRef; + public ThreadWriteWeakRef(SetWeakRef setWeakRef) { + this.setWeakRef = setWeakRef; + } + static WeakReference rp_write; + @Override + public void run() { + setWeakRef.rp = rp_write; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/test.cfg b/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2547607f87eabb5fd4e7097c48e6cc3bff60fa3c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0364-rc-Memory-leaktestsupplycase-05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RaceInLoadAndWriteWeakRef) +run(RaceInLoadAndWriteWeakRef,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java b/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java new file mode 100755 index 0000000000000000000000000000000000000000..72aa37e23b72b1c68178eeb5a8ebd3f2ae12a7b0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/WeakAndCleanerRef.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class WeakAndCleanerRef { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static StringBuffer stringBuffer = new StringBuffer("test"); + static void addWeakAndCleanerRef() { + rp = new WeakReference(stringBuffer, rq); + } + public static void main(String[] args) throws InterruptedException { + ThreadCleaner threadCleaner = new ThreadCleaner(); + Cleaner cleaner = Cleaner.create(stringBuffer, threadCleaner); + addWeakAndCleanerRef(); + stringBuffer = null; + cleaner.clean(); + Thread.sleep(2000); + addWeakAndCleanerRef(); + if (rp.get() == null) { + System.out.println("ExpectResult"); + } + } +} +class ThreadCleaner implements Runnable { + @Override + public void run() { + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/test.cfg b/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..bcacd543eed703cdbfe6dcdd69b1c135ae9fb511 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0365-rc-Memory-leaktestsupplycase-06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(WeakAndCleanerRef) +run(WeakAndCleanerRef,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java new file mode 100755 index 0000000000000000000000000000000000000000..2cba7e06acbccb0e78d3f7a9244c7a296b9c5be1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/RC_Array_01.java @@ -0,0 +1,391 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_001{ + //Parent interface + volatile int[] base1; + int[][] base2; + int[][] base21; + int[][][] base3; +} +public class RC_Array_01 extends Base_001{ + static int check_count = 0; + static int[] arr1 = {10,20,30,40}; + static int[][] arr2 = {{10,20,30,40},{40,50},{60}}; + static int[][] arr21 = {{40,50,60,30},{70,80},{90}}; + static int[][][] arr3 = {arr2,arr21}; + private RC_Array_01(){ + base1 = new int[]{10,20,30,40}; + base2 = new int[][]{{10,20,30,40},{40,50},{60}}; + base21 = new int[][]{{40,50,60,30},{70,80},{90}}; + base3 = new int[][][]{{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + } + private RC_Array_01(int[] intar){ + base1 = intar; + } + private RC_Array_01(int[][] intarr){ + base2 = intarr; + } + private RC_Array_01(int[][][] intarrr){ + base3 = intarrr; + } + private RC_Array_01(int[] intar, int[][] intarr, int[][][] intarrr){ + base1 = intar; + base2 = intarr; + base3 = intarrr; + } + public static void main(String [] args) { + final int[] TEST1 = {10,20,30,40}; + final int[][] TEST2 = {TEST1,{40,50},{60}}; + final int[][] TEST21 = {{40,50,60,30},{70,80},{90}}; + final int[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_01_test01 function return value to the parameter third and judged. + //RC_Array_01_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_01 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_01_test02(); + //Get an array object by returning a function call + int[] getarr1 = RC_Array_get01(); + int[][] getarr2 = RC_Array_get02(); + int[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, int[] second, int[][] third, int[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + int [] xyz = {23,24,25,26}; + int[][] xyz2 = {{23,24,25,26},{23,24},{23}}; + int[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, int[] second, int[][] third, int[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + int [] xyz = {23,24,25,26}; + int[][] xyz2 = {{23,24,25,26},{23,24},{23}}; + int[][][] xyz3 = {xyz2,xyz2}; + second = (int[]) change(second,xyz); + third = (int[][])change(third,xyz2); + four = (int[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(int[][] third) { + //The test03 interface is called, and the RC_Array_01_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_01_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static int[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static int[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static int[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static int[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + int [] value1 = {23,24,25,26}; + RC_Array_01 rctest=new RC_Array_01(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new int[] {88,10,02,11}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static int[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + int[][] value2 = {{23,24,25,26},{23,24},{23}}; + RC_Array_01 rctest=new RC_Array_01(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new int[][] {{88,10,02,11},{10,92},{16}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static int[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + int[][][] value3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + RC_Array_01 rctest=new RC_Array_01(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new int[][][]{{{88,10,02,11},{10,92},{12}},{{88,10,02,11},{10,92},{16}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static int[][] RC_Array_01_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to the newly created + // object field, and judge the result + int [] value1 = {23,24,25,26}; + int[][] value2 = {{23,24,25,26},{23,24},{23}}; + int[][][] value3 = {value2,value2}; + RC_Array_01 rctest=new RC_Array_01(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new int[] {88,10,02,11}; + rctest.base2 = new int[][] {{88,10,02,11},{10,92},{16}}; + rctest.base21 = new int[][] {{88,10,02,11},{10,92},{12}}; + rctest.base3 = new int[][][]{{{88,10,02,11},{10,92},{12}},{{88,10,02,11},{10,92},{16}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test01"); + return rctest.base21; + } + private static int[] RC_Array_final01() + { + final int [] VALUE1 = {23,24,25,26}; + return VALUE1; + } + private static int[][] RC_Array_final02() + { + final int[][] VALUE2 = {{23,24,25,26},{23,24},{23}}; + return VALUE2; + } + private static int[][][] RC_Array_final03() + { + final int[][][] VALUE3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + return VALUE3; + } + private static int[][] RC_Array_01_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_01 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final int [] VALUE1 = RC_Array_final01(); + final int[][] VALUE2 = RC_Array_final02(); + final int[][][] VALUE3 = RC_Array_final03(); + RC_Array_01 rctest=new RC_Array_01(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_01_test02_2"); + return VALUE2; + } + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + int [] value1 = RC_Array_final01(); + int[][] value2 = RC_Array_final02(); + int[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getInt(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 23; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setInt(value1,5,10); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getInt(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getInt(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getInt(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //NumberFormatException + try{ + Integer i = new Integer(10); + Array.setInt(value1,0,i.decode("abc")); + }catch (NumberFormatException e) + { + check++; + } + //ClassCastException + RC_Array_01 rc1 = new RC_Array_01(); + try{ + Base_001 bs1 = new Base_001(); + rc1 = (RC_Array_01)bs1; + rc1.base1[0] = 123; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 123) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getInt(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getInt(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getInt(value3,1); + }catch (NullPointerException e){ + check++; + } + if (check == 19) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/expected.txt b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/test.cfg b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..66383cfdaef85f0bd7a6edcd49ed685486d90064 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0366-rc-ArrayOptimization-RC_Array_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_01) +run(RC_Array_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java new file mode 100755 index 0000000000000000000000000000000000000000..3dc6d90325f54531ff289e5073924fb166334193 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/RC_Array_02.java @@ -0,0 +1,402 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.util.regex.PatternSyntaxException; +class Base_002{ + //Parent interface + volatile String[] base1; + String[][] base2; + String[][] base21; + String[][][] base3; +} +public class RC_Array_02 extends Base_002{ + static int check_count = 0; + static String[] arr1 = {"10","20","30","40"}; + static String[][] arr2 = {{"10","20","30","40"},{"40","50"},{"60"}}; + static String[][] arr21 = {{"40","50","60","30"},{"70","80"},{"90"}}; + static String[][][] arr3 = {arr2,arr21}; + //literial type data + static String literial_v = "abc"; + static String[] arstr1 = {literial_v,literial_v,literial_v,literial_v}; + static String[][] arstr2 = {{"abc","abc","abc","abc"},{"abc","abc"},{literial_v}}; + static String[][][] arstr3 = {arstr2,arstr2}; + private RC_Array_02(){ + base1 = new String[]{"10","20","30","40"}; + base2 = new String[][]{{"10","20","30","40"},{"40","50"},{"60"}}; + base21 = new String[][]{{"40","50","60","30"},{"70","80"},{"90"}}; + base3 = new String[][][]{{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + } + private RC_Array_02(String[] Stringar){ + base1 = Stringar; + } + private RC_Array_02(String[][] Stringarr){ + base2 = Stringarr; + } + private RC_Array_02(String[][][] Stringarrr){ + base3 = Stringarrr; + } + private RC_Array_02(String[] Stringar, String[][] Stringarr, String[][][] Stringarrr){ + base1 = Stringar; + base2 = Stringarr; + base3 = Stringarrr; + } + public static void main(String [] args) { + final String[] TEST1 = {"10","20","30","40"}; + final String[][] TEST2 = {TEST1,{"40","50"},{"60"}}; + final String[][] TEST21 = {{"40","50","60","30"},{"70","80"},{"90"}}; + final String[][][] TEST3 = {TEST2,TEST21}; + //literial type data + final String literial_v = "abc"; + final String[] arstrr1 = {literial_v,literial_v,literial_v,literial_v}; + final String[][] arstrr2 = {{"abc","abc","abc","abc"},{"abc","abc"},{literial_v}}; + final String[][][] arstrr3 = {arstrr2,arstrr2}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult String step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + test01(4,arstr1,arstr2,arstr3); + test01(4,arstrr1,arstrr2,arstrr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + test02(4,arstr1,arstr2,arstr3); + test02(4,arstrr1,arstrr2,arstrr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2 + && arstrr1.length == 4 && arstrr2.length == 3 && arstrr3.length == 2 + && arstr1.length == 4 && arstr2.length == 3 && arstr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_02_test01 function return value to the parameter third and judged. + //RC_Array_02_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_02() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_02_test02(); + //Get an array object by returning a function call + String[] getarr1 = RC_Array_get01(); + String[][] getarr2 = RC_Array_get02(); + String[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 28) + System.out.println("ExpectResult"); + } + private static void test01(int first, String[] second, String[][] third, String[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + String [] xyz = {"23","24","25","26"}; + String[][] xyz2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, String[] second, String[][] third, String[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + String [] xyz = {"23","24","25","26"}; + String[][] xyz2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] xyz3 = {xyz2,xyz2}; + second = (String[]) change(second,xyz); + third = (String[][])change(third,xyz2); + four = (String[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(String[][] third) { + //The test03 interface is called, and the RC_Array_02_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_02_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static String[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static String[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static String[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static String[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + String [] value1 = {"23","24","25","26"}; + RC_Array_02 rctest=new RC_Array_02(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new String[] {"88","10","02","11"}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static String[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + String[][] value2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + RC_Array_02 rctest=new RC_Array_02(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new String[][] {{"88","10","02","11"},{"10","92"},{"16"}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static String[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + String[][][] value3 = {{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + RC_Array_02 rctest=new RC_Array_02(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new String[][][]{{{"88","10","02","11"},{"10","92"},{"12"}},{{"88","10","02","11"},{"10","92"},{"16"}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static String[][] RC_Array_02_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_02, and assign a value to the newly created + // object field, and judge the result + String [] value1 = {"23","24","25","26"}; + String[][] value2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + String[][][] value3 = {value2,value2}; + RC_Array_02 rctest=new RC_Array_02(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new String[] {"88","10","02","11"}; + rctest.base2 = new String[][] {{"88","10","02","11"},{"10","92"},{"16"}}; + rctest.base21 = new String[][] {{"88","10","02","11"},{"10","92"},{"12"}}; + rctest.base3 = new String[][][]{{{"88","10","02","11"},{"10","92"},{"12"}},{{"88","10","02","11"},{"10","92"},{"16"}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test01"); + return rctest.base21; + } + private static String[] RC_Array_final01() + { + final String [] VALUE1 = {"23","24","25","26"}; + return VALUE1; + } + private static String[][] RC_Array_final02() + { + final String[][] VALUE2 = {{"23","24","25","26"},{"23","24"},{"23"}}; + return VALUE2; + } + private static String[][][] RC_Array_final03() + { + final String[][][] VALUE3 = {{{"10","20","30","40"},{"40","50"},{"60"}},{{"40","50","60","30"},{"70","80"},{"90"}}}; + return VALUE3; + } + private static String[][] RC_Array_02_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_02 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final String [] VALUE1 = RC_Array_final01(); + final String[][] VALUE2 = RC_Array_final02(); + final String[][][] VALUE3 = RC_Array_final03(); + RC_Array_02 rctest=new RC_Array_02(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_02_test02_2"); + return VALUE2; + } + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + String [] value1 = RC_Array_final01(); + String[][] value2 = RC_Array_final02(); + String[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.get(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.set(value1,5,"10"); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.get(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IndexOutOfBoundsException + try { + char[] ch1 = {'h','x','c','t'}; + Array.set(RC_Array_final03()[0][0],0,String.valueOf(ch1, 5, 2)); + }catch (IndexOutOfBoundsException e){ + check++; + } + //ClassCastException + RC_Array_02 rc1 = new RC_Array_02(); + try{ + Base_002 bs1 = new Base_002(); + rc1 = (RC_Array_02)bs1; + rc1.base1[0] = "kitty"; + }catch (ClassCastException e) + { + if (rc1.base1[0] != "kitty") + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.get(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.get(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 17) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/expected.txt b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/test.cfg b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e69083dcd4fa87ab1b13c2717b89e97f19d11be0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0367-rc-ArrayOptimization-RC_Array_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_02) +run(RC_Array_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java new file mode 100755 index 0000000000000000000000000000000000000000..feabd65521f64572d6bf1cd05eccdf8f8e7bd831 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/RC_Array_03.java @@ -0,0 +1,384 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_003{ + //Parent interface + volatile char[] base1; + char[][] base2; + char[][] base21; + char[][][] base3; +} +public class RC_Array_03 extends Base_003{ + static int check_count = 0; + static char[] arr1 = {'a','b','c','d'}; + static char[][] arr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static char[][] arr21 = {{'h','i','j','k'},{'l','m'},{'n'}}; + static char[][][] arr3 = {arr2,arr21}; + private RC_Array_03(){ + base1 = new char[]{'a','b','c','d'}; + base2 = new char[][]{{'a','b','c','d'},{'e','f'},{'g'}}; + base21 = new char[][]{{'h','i','j','k'},{'l','m'},{'n'}}; + base3 = new char[][][]{{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + } + private RC_Array_03(char[] charar){ + base1 = charar; + } + private RC_Array_03(char[][] chararr){ + base2 = chararr; + } + private RC_Array_03(char[][][] chararrr){ + base3 = chararrr; + } + private RC_Array_03(char[] charar, char[][] chararr, char[][][] chararrr){ + base1 = charar; + base2 = chararr; + base3 = chararrr; + } + public static void main(String[] args) { + final char[] TEST1 = {'1','2','3','4'}; + final char[][] TEST2 = {TEST1,{'4','5'},{'6'}}; + final char[][] TEST21 = {{'4','5','6','3'},{'7','8'},{'9'}}; + final char[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult char step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_03_test01 function return value to the parameter third and judged. + //RC_Array_03_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_03() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_03_test02(); + //Get an array object by returning a function call + char[] getarr1 = RC_Array_get01(); + char[][] getarr2 = RC_Array_get02(); + char[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + Boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, char[] second, char[][] third, char[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + char [] xyz = {'h','x','w','g'}; + char[][] xyz2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, char[] second, char[][] third, char[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + char [] xyz = {'h','x','w','g'}; + char[][] xyz2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] xyz3 = {xyz2,xyz2}; + second = (char[]) change(second,xyz); + third = (char[][])change(third,xyz2); + four = (char[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(char[][] third) { + //The test03 interface is called, and the RC_Array_03_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_03_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static char[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static char[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static char[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static char[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + char [] value1 = {'h','x','w','g'}; + RC_Array_03 rctest=new RC_Array_03(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new char[] {'8','0','2','3'}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static char[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + char[][] value2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + RC_Array_03 rctest=new RC_Array_03(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new char[][] {{'8','0','2','3'},{'w','g'},{'q'}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static char[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + char[][][] value3 = {{{'1','2','3','4'},{'4','5'},{'6'}},{{'4','5','6','3'},{'7','8'},{'9'}}}; + RC_Array_03 rctest=new RC_Array_03(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new char[][][]{{{'w','a','n','g'},{'s','u'},{'n'}},{{'w','a','n','g'},{'w','g'},{'q'}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static char[][] RC_Array_03_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_03, and assign a value to the newly created + // object field, and judge the result + char [] value1 = {'h','x','w','g'}; + char[][] value2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + char[][][] value3 = {value2,value2}; + RC_Array_03 rctest=new RC_Array_03(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new char[] {'w','a','n','g'}; + rctest.base2 = new char[][] {{'w','a','n','g'},{'w','g'},{'q'}}; + rctest.base21 = new char[][] {{'w','a','n','g'},{'s','u'},{'n'}}; + rctest.base3 = new char[][][]{{{'w','a','n','g'},{'s','u'},{'n'}},{{'w','a','n','g'},{'w','g'},{'q'}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test01"); + return rctest.base21; + } + private static char[] RC_Array_final01() + { + final char [] VALUE1 = {'h','x','w','g'}; + return VALUE1; + } + private static char[][] RC_Array_final02() + { + final char[][] VALUE2 = {{'h','x','w','g'},{'w','g'},{'q'}}; + return VALUE2; + } + private static char[][][] RC_Array_final03() + { + final char[][][] VALUE3 = {{{'1','2','3','4'},{'4','5'},{'6'}},{{'4','5','6','3'},{'7','8'},{'9'}}}; + return VALUE3; + } + private static char[][] RC_Array_03_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_03 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final char [] VALUE1 = RC_Array_final01(); + final char[][] VALUE2 = RC_Array_final02(); + final char[][][] VALUE3 = RC_Array_final03(); + RC_Array_03 rctest=new RC_Array_03(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_03_test02_2"); + return VALUE2; + } + private static Boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + char[] value1 = RC_Array_final01(); + char[][] value2 = RC_Array_final02(); + char[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getChar(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 'e'; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setChar(value1,5,'1'); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getChar(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getChar(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getChar(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_03 rc1 = new RC_Array_03(); + try{ + Base_003 bs1 = new Base_003(); + rc1 = (RC_Array_03)bs1; + rc1.base1[0] = 'p'; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 'p') + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getChar(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getChar(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getChar(value3,1); + }catch (NullPointerException e){ + check++; + } + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/expected.txt b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/test.cfg b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d1bcb307305f56738497c60177a94db00869cdd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0368-rc-ArrayOptimization-RC_Array_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_03) +run(RC_Array_03,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java new file mode 100755 index 0000000000000000000000000000000000000000..afcc5e845f65dc24d0bc367f4a2d4815bafba8b9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/RC_Array_04.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_004{ + //Parent interface + volatile boolean[] base1; + boolean[][] base2; + boolean[][] base21; + boolean[][][] base3; +} +public class RC_Array_04 extends Base_004{ + static int check_count = 0; + static boolean[] arr1 = {true,false,false,true}; + static boolean[][] arr2 = {{true,false,false,true},{false,false},{true,true}}; + static boolean[][] arr21 = {{false,true,false,true},{true,false},{false,true}}; + static boolean[][][] arr3 = {arr2,arr21}; + private RC_Array_04(){ + base1 = new boolean[]{true,true,true,true}; + base2 = new boolean[][]{{true,true,true,true},{false,false},{true,true}}; + base21 = new boolean[][]{{false,true,true,true},{false,true},{true,true}}; + base3 = new boolean[][][]{{{true,true,true,true},{false,false},{true,true}},{{false,true,true,true},{false,true},{true,true}}}; + } + private RC_Array_04(boolean[] booleanar){ + base1 = booleanar; + } + private RC_Array_04(boolean[][] booleanarr){ + base2 = booleanarr; + } + private RC_Array_04(boolean[][][] booleanarrr){ + base3 = booleanarrr; + } + private RC_Array_04(boolean[] booleanar, boolean[][] booleanarr, boolean[][][] booleanarrr){ + base1 = booleanar; + base2 = booleanarr; + base3 = booleanarrr; + } + public static void main(String[] args) { + final boolean[] TEST1 = {true,true,true,true}; + final boolean[][] TEST2 = {TEST1,{false,false},{true,true}}; + final boolean[][] TEST21 = {{false,true,true,true},{false,true},{true,true}}; + final boolean[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult boolean step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_04_test01 function return value to the parameter third and judged. + //RC_Array_04_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_04() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_04_test02(); + //Get an array object by returning a function call + boolean[] getarr1 = RC_Array_get01(); + boolean[][] getarr2 = RC_Array_get02(); + boolean[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, boolean[] second, boolean[][] third, boolean[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + boolean [] xyz = {false,true,false,true}; + boolean[][] xyz2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, boolean[] second, boolean[][] third, boolean[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + boolean [] xyz = {false,true,false,true}; + boolean[][] xyz2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] xyz3 = {xyz2,xyz2}; + second = (boolean[]) change(second,xyz); + third = (boolean[][])change(third,xyz2); + four = (boolean[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(boolean[][] third) { + //The test03 interface is called, and the RC_Array_04_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_04_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static boolean[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static boolean[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static boolean[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static boolean[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + boolean [] value1 = {false,false,false,false}; + RC_Array_04 rctest=new RC_Array_04(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new boolean[] {true,true,true,true}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static boolean[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + boolean[][] value2 = {{true,true,true,true},{false,false},{true}}; + RC_Array_04 rctest=new RC_Array_04(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new boolean[][] {{false,false,false,false},{false,false},{true}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static boolean[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + boolean[][][] value3 = {{{true,true,true,true},{false,false},{true}},{{false,false,false,false},{false,false},{true}}}; + RC_Array_04 rctest=new RC_Array_04(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new boolean[][][]{{{false,false,false,false},{false,false},{true}},{{true,true,true,true},{false,false},{true}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static boolean[][] RC_Array_04_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_04, and assign a value to the newly created + // object field, and judge the result + boolean [] value1 = {true,true,true,true}; + boolean[][] value2 = {{true,true,true,true},{false,false},{true}}; + boolean[][][] value3 = {value2,value2}; + RC_Array_04 rctest=new RC_Array_04(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new boolean[] {false,false,false,false}; + rctest.base2 = new boolean[][] {{false,false,false,false},{false,false},{true}}; + rctest.base21 = new boolean[][] {{false,true,true,false},{false,false},{true}}; + rctest.base3 = new boolean[][][]{{{false,false,false,false},{false,false},{true}},{{false,true,true,false},{false,false},{true}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test01"); + return rctest.base21; + } + private static boolean[] RC_Array_final01() + { + final boolean[] VALUE1 = {true,true,true,true}; + return VALUE1; + } + private static boolean[][] RC_Array_final02() + { + final boolean[][] VALUE2 = {{false,false,false,false},{false,false},{true}}; + return VALUE2; + } + private static boolean[][][] RC_Array_final03() + { + final boolean[][][] VALUE3 = {{{false,true,true,false},{false,false},{true}},{{false,false,false,false},{false,false},{true}}}; + return VALUE3; + } + private static boolean[][] RC_Array_04_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_04 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final boolean[] VALUE1 = RC_Array_final01(); + final boolean[][] VALUE2 = RC_Array_final02(); + final boolean[][][] VALUE3 = RC_Array_final03(); + RC_Array_04 rctest=new RC_Array_04(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_04_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + boolean[] value1 = RC_Array_final01(); + boolean[][] value2 = RC_Array_final02(); + boolean[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getBoolean(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = false; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setBoolean(value1,5,true); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getBoolean(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getBoolean(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_04 rc1 = new RC_Array_04(); + try{ + Base_004 bs1 = new Base_004(); + rc1 = (RC_Array_04)bs1; + rc1.base1[0] = false; + }catch (ClassCastException e) + { + if (rc1.base1[0] != false) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getBoolean(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getBoolean(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/expected.txt b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/test.cfg b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6b71531f307ceb61e972f217a1ae580e9748d1cb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0369-rc-ArrayOptimization-RC_Array_04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_04) +run(RC_Array_04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java new file mode 100755 index 0000000000000000000000000000000000000000..51331fb8c8b2656711447ba009f7ee491b4eaf70 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/RC_Array_05.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_005{ + //Parent interface + volatile byte[] base1; + byte[][] base2; + byte[][] base21; + byte[][][] base3; +} +public class RC_Array_05 extends Base_005{ + static int check_count = 0; + static byte[] arr1 = {1,2,3,4}; + static byte[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static byte[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static byte[][][] arr3 = {arr2,arr21}; + private RC_Array_05(){ + base1 = new byte[]{1,2,3,4}; + base2 = new byte[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new byte[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new byte[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + private RC_Array_05(byte[] bytear){ + base1 = bytear; + } + private RC_Array_05(byte[][] bytearr){ + base2 = bytearr; + } + private RC_Array_05(byte[][][] bytearrr){ + base3 = bytearrr; + } + private RC_Array_05(byte[] bytear, byte[][] bytearr, byte[][][] bytearrr){ + base1 = bytear; + base2 = bytearr; + base3 = bytearrr; + } + public static void main(String[] args) { + final byte[] TEST1 = {1,2,3,4}; + final byte[][] TEST2 = {TEST1,{5,6},{7,8}}; + final byte[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final byte[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult byte step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_05_test01 function return value to the parameter third and judged. + //RC_Array_05_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_05() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_05_test02(); + //Get an array object by returning a function call + byte[] getarr1 = RC_Array_get01(); + byte[][] getarr2 = RC_Array_get02(); + byte[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, byte[] second, byte[][] third, byte[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + byte [] xyz = {8,8,1,0}; + byte[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, byte[] second, byte[][] third, byte[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + byte [] xyz = {8,8,1,0}; + byte[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] xyz3 = {xyz2,xyz2}; + second = (byte[]) change(second,xyz); + third = (byte[][])change(third,xyz2); + four = (byte[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(byte[][] third) { + //The test03 interface is called, and the RC_Array_05_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_05_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static byte[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static byte[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static byte[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static byte[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + byte [] value1 = {9,2,8,8}; + RC_Array_05 rctest=new RC_Array_05(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new byte[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static byte[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + byte[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_05 rctest=new RC_Array_05(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new byte[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static byte[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + byte[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_05 rctest=new RC_Array_05(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new byte[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static byte[][] RC_Array_05_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_05, and assign a value to the newly created + // object field, and judge the result + byte [] value1 = {1,2,3,4}; + byte[][] value2 = {{1,2,3,4},{1,1},{0}}; + byte[][][] value3 = {value2,value2}; + RC_Array_05 rctest=new RC_Array_05(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new byte[] {9,2,8,8}; + rctest.base2 = new byte[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new byte[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new byte[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test01"); + return rctest.base21; + } + private static byte[] RC_Array_final01() + { + final byte[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static byte[][] RC_Array_final02() + { + final byte[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static byte[][][] RC_Array_final03() + { + final byte[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static byte[][] RC_Array_05_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_05 () no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final byte[] VALUE1 = RC_Array_final01(); + final byte[][] VALUE2 = RC_Array_final02(); + final byte[][][] VALUE3 = RC_Array_final03(); + RC_Array_05 rctest=new RC_Array_05(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_05_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + byte[] value1 = RC_Array_final01(); + byte[][] value2 = RC_Array_final02(); + byte[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getByte(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 'h'; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setByte(value1,5,(byte)0x19); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getByte(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getByte(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getByte(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_05 rc1 = new RC_Array_05(); + try{ + Base_005 bs1 = new Base_005(); + rc1 = (RC_Array_05)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getByte(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getByte(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getByte(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/expected.txt b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/test.cfg b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d4c027b1ccc363335919e6962cfd5195360c2717 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0370-rc-ArrayOptimization-RC_Array_05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_05) +run(RC_Array_05,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java new file mode 100755 index 0000000000000000000000000000000000000000..a706d35f58e70cebd12cdead59acd276e55d557f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/RC_Array_06.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_006{ + //Parent interface + volatile short[] base1; + short[][] base2; + short[][] base21; + short[][][] base3; +} +public class RC_Array_06 extends Base_006{ + static int check_count = 0; + static short[] arr1 = {1,2,3,4}; + static short[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static short[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static short[][][] arr3 = {arr2,arr21}; + private RC_Array_06(){ + base1 = new short[]{1,2,3,4}; + base2 = new short[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new short[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new short[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + private RC_Array_06(short[] shortar){ + base1 = shortar; + } + private RC_Array_06(short[][] shortarr){ + base2 = shortarr; + } + private RC_Array_06(short[][][] shortarrr){ + base3 = shortarrr; + } + private RC_Array_06(short[] shortar, short[][] shortarr, short[][][] shortarrr){ + base1 = shortar; + base2 = shortarr; + base3 = shortarrr; + } + public static void main(String[] args) { + final short[] TEST1 = {1,2,3,4}; + final short[][] TEST2 = {TEST1,{5,6},{7,8}}; + final short[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final short[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult short step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_06_test01 function return value to the parameter third and judged. + //RC_Array_06_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_06() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_06_test02(); + //Get an array object by returning a function call + short[] getarr1 = RC_Array_get01(); + short[][] getarr2 = RC_Array_get02(); + short[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, short[] second, short[][] third, short[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + short [] xyz = {8,8,1,0}; + short[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + short[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, short[] second, short[][] third, short[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + short [] xyz = {8,8,1,0}; + short[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + short[][][] xyz3 = {xyz2,xyz2}; + second = (short[]) change(second,xyz); + third = (short[][])change(third,xyz2); + four = (short[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(short[][] third) { + //The test03 interface is called, and the RC_Array_06_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_06_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static short[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static short[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static short[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static short[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + short [] value1 = {9,2,8,8}; + RC_Array_06 rctest=new RC_Array_06(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new short[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static short[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + short[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_06 rctest=new RC_Array_06(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new short[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static short[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + short[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_06 rctest=new RC_Array_06(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new short[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static short[][] RC_Array_06_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_06, and assign a value to the newly created + // object field, and judge the result + short [] value1 = {1,2,3,4}; + short[][] value2 = {{1,2,3,4},{1,1},{0}}; + short[][][] value3 = {value2,value2}; + RC_Array_06 rctest=new RC_Array_06(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new short[] {9,2,8,8}; + rctest.base2 = new short[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new short[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new short[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test01"); + return rctest.base21; + } + private static short[] RC_Array_final01() + { + final short[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static short[][] RC_Array_final02() + { + final short[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static short[][][] RC_Array_final03() + { + final short[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static short[][] RC_Array_06_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_06() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final short[] VALUE1 = RC_Array_final01(); + final short[][] VALUE2 = RC_Array_final02(); + final short[][][] VALUE3 = RC_Array_final03(); + RC_Array_06 rctest=new RC_Array_06(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_06_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + short[] value1 = RC_Array_final01(); + short[][] value2 = RC_Array_final02(); + short[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getShort(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 88; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setShort(value1,5,(short)12); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getShort(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getShort(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getShort(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_06 rc1 = new RC_Array_06(); + try{ + Base_006 bs1 = new Base_006(); + rc1 = (RC_Array_06)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getShort(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getShort(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getShort(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/expected.txt b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/test.cfg b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d4a64754c2d17d87a1933a86ef32ee9dd4196907 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0371-rc-ArrayOptimization-RC_Array_06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_06) +run(RC_Array_06,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java new file mode 100755 index 0000000000000000000000000000000000000000..3f2789b4e119afab811875eff794acf17a4b83ff --- /dev/null +++ b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/RC_Array_07.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_007{ + //Parent interface + volatile long[] base1; + long[][] base2; + long[][] base21; + long[][][] base3; +} +public class RC_Array_07 extends Base_007{ + static int check_count = 0; + static long[] arr1 = {1,2,3,4}; + static long[][] arr2 = {{1,2,3,4},{5,6},{7,8}}; + static long[][] arr21 = {{4,5,6,7},{8,9},{10,11}}; + static long[][][] arr3 = {arr2,arr21}; + private RC_Array_07(){ + base1 = new long[]{1,2,3,4}; + base2 = new long[][]{{1,2,3,4},{5,6},{7,8}}; + base21 = new long[][]{{4,5,6,7},{8,9},{10,11}}; + base3 = new long[][][]{{{1,2,3,4},{5,6},{7,8}},{{4,5,6,7},{8,9},{10,11}}}; + } + private RC_Array_07(long[] longar){ + base1 = longar; + } + private RC_Array_07(long[][] longarr){ + base2 = longarr; + } + private RC_Array_07(long[][][] longarrr){ + base3 = longarrr; + } + private RC_Array_07(long[] longar, long[][] longarr, long[][][] longarrr){ + base1 = longar; + base2 = longarr; + base3 = longarrr; + } + public static void main(String[] args) { + final long[] TEST1 = {1,2,3,4}; + final long[][] TEST2 = {TEST1,{5,6},{7,8}}; + final long[][] TEST21 = {{4,5,6,7},{8,9},{10,11}}; + final long[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult long step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_07_test01 function return value to the parameter third and judged. + //RC_Array_07_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_07() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_07_test02(); + //Get an array object by returning a function call + long[] getarr1 = RC_Array_get01(); + long[][] getarr2 = RC_Array_get02(); + long[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, long[] second, long[][] third, long[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + long [] xyz = {8,8,1,0}; + long[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + long[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, long[] second, long[][] third, long[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + long [] xyz = {8,8,1,0}; + long[][] xyz2 = {{1,2,3,4},{1,1},{0}}; + long[][][] xyz3 = {xyz2,xyz2}; + second = (long[]) change(second,xyz); + third = (long[][])change(third,xyz2); + four = (long[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(long[][] third) { + //The test03 interface is called, and the RC_Array_07_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_07_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static long[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static long[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static long[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static long[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + long [] value1 = {9,2,8,8}; + RC_Array_07 rctest=new RC_Array_07(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new long[] {1,2,3,4}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static long[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + long[][] value2 = {{1,2,3,4},{1,1},{0}}; + RC_Array_07 rctest=new RC_Array_07(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new long[][] {{9,2,8,8},{1,1},{0}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static long[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + long[][][] value3 = {{{1,2,3,4},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + RC_Array_07 rctest=new RC_Array_07(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new long[][][]{{{9,2,8,8},{1,1},{0}},{{1,2,3,4},{1,1},{0}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static long[][] RC_Array_07_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_07, and assign a value to the newly created + // object field, and judge the result + long [] value1 = {1,2,3,4}; + long[][] value2 = {{1,2,3,4},{1,1},{0}}; + long[][][] value3 = {value2,value2}; + RC_Array_07 rctest=new RC_Array_07(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new long[] {9,2,8,8}; + rctest.base2 = new long[][] {{9,2,8,8},{1,1},{0}}; + rctest.base21 = new long[][] {{6,6,6,5},{1,1},{0}}; + rctest.base3 = new long[][][]{{{9,2,8,8},{1,1},{0}},{{6,6,6,5},{1,1},{0}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test01"); + return rctest.base21; + } + private static long[] RC_Array_final01() + { + final long[] VALUE1 = {1,2,3,4}; + return VALUE1; + } + private static long[][] RC_Array_final02() + { + final long[][] VALUE2 = {{9,2,8,8},{1,1},{0}}; + return VALUE2; + } + private static long[][][] RC_Array_final03() + { + final long[][][] VALUE3 = {{{6,6,6,5},{1,1},{0}},{{9,2,8,8},{1,1},{0}}}; + return VALUE3; + } + private static long[][] RC_Array_07_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_07() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final long[] VALUE1 = RC_Array_final01(); + final long[][] VALUE2 = RC_Array_final02(); + final long[][][] VALUE3 = RC_Array_final03(); + RC_Array_07 rctest=new RC_Array_07(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_07_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + long[] value1 = RC_Array_final01(); + long[][] value2 = RC_Array_final02(); + long[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getLong(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 92; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setLong(value1,5,(long)12); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getLong(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getLong(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getLong(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_07 rc1 = new RC_Array_07(); + try{ + Base_007 bs1 = new Base_007(); + rc1 = (RC_Array_07)bs1; + rc1.base1[0] = 8; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getLong(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getLong(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getLong(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/expected.txt b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/test.cfg b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a1d66c633bfc3e20186b34319ab8d51057b66577 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0372-rc-ArrayOptimization-RC_Array_07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_07) +run(RC_Array_07,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java new file mode 100755 index 0000000000000000000000000000000000000000..ed8020e6325d977811834d8b45daed732b99632f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/RC_Array_08.java @@ -0,0 +1,385 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_008{ + //Parent interface + volatile float[] base1; + float[][] base2; + float[][] base21; + float[][][] base3; +} +public class RC_Array_08 extends Base_008{ + static int check_count = 0; + static float[] arr1 = {1.1f,2.2f,3.3f,4.4f}; + static float[][] arr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + static float[][] arr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + static float[][][] arr3 = {arr2,arr21}; + private RC_Array_08(){ + base1 = new float[]{1.1f,2.2f,3.3f,4.4f}; + base2 = new float[][]{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + base21 = new float[][]{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + base3 = new float[][][]{{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}}; + } + private RC_Array_08(float[] floatar){ + base1 = floatar; + } + private RC_Array_08(float[][] floatarr){ + base2 = floatarr; + } + private RC_Array_08(float[][][] floatarrr){ + base3 = floatarrr; + } + private RC_Array_08(float[] floatar, float[][] floatarr, float[][][] floatarrr){ + base1 = floatar; + base2 = floatarr; + base3 = floatarrr; + } + public static void main(String[] args) { + final float[] TEST1 = {1.1f,2.2f,3.3f,4.4f}; + final float[][] TEST2 = {TEST1,{5.5f,6.6f},{7.7f,8.8f}}; + final float[][] TEST21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + final float[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult float step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_08_test01 function return value to the parameter third and judged. + //RC_Array_08_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_08() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_08_test02(); + //Get an array object by returning a function call + float[] getarr1 = RC_Array_get01(); + float[][] getarr2 = RC_Array_get02(); + float[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, float[] second, float[][] third, float[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + float [] xyz = {8.5f,8.3f,1.2f,0.5f}; + float[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, float[] second, float[][] third, float[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + float [] xyz = {8.5f,8.3f,1.2f,0.5f}; + float[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] xyz3 = {xyz2,xyz2}; + second = (float[]) change(second,xyz); + third = (float[][])change(third,xyz2); + four = (float[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(float[][] third) { + //The test03 interface is called, and the RC_Array_08_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_08_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static float[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static float[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static float[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static float[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + float [] value1 = {9.2f,2.2f,8.8f,8.8f}; + RC_Array_08 rctest=new RC_Array_08(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new float[] {1.1f,2.2f,3.3f,4.4f}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static float[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + float[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + RC_Array_08 rctest=new RC_Array_08(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new float[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static float[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + float[][][] value3 = {{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + RC_Array_08 rctest=new RC_Array_08(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new float[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static float[][] RC_Array_08_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_08, and assign a value to the newly created + // object field, and judge the result + float [] value1 = {1.1f,2.2f,3.3f,4.4f}; + float[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + float[][][] value3 = {value2,value2}; + RC_Array_08 rctest=new RC_Array_08(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new float[] {9.2f,2.2f,8.8f,8.8f}; + rctest.base2 = new float[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + rctest.base21 = new float[][] {{6,6,6,5},{1.3f,1.1f},{0.5f}}; + rctest.base3 = new float[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{6,6,6,5},{1.3f,1.1f},{0.5f}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test01"); + return rctest.base21; + } + private static float[] RC_Array_final01() + { + final float[] VALUE1 = {1.1f,2.2f,3.3f,4.4f}; + return VALUE1; + } + private static float[][] RC_Array_final02() + { + final float[][] VALUE2 = {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + return VALUE2; + } + private static float[][][] RC_Array_final03() + { + final float[][][] VALUE3 = {{{6.4f,6.1f,6.3f,5.5f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + return VALUE3; + } + private static float[][] RC_Array_08_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_08() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final float[] VALUE1 = RC_Array_final01(); + final float[][] VALUE2 = RC_Array_final02(); + final float[][][] VALUE3 = RC_Array_final03(); + RC_Array_08 rctest=new RC_Array_08(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_08_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + float[] value1 = RC_Array_final01(); + float[][] value2 = RC_Array_final02(); + float[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getFloat(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 88.10f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setFloat(value1,5,12.5f); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final01(),5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final02()[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getFloat(RC_Array_final03()[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getFloat(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getFloat(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_08 rc1 = new RC_Array_08(); + try{ + Base_008 bs1 = new Base_008(); + rc1 = (RC_Array_08)bs1; + rc1.base1[0] = 8.9f; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8.9f) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getFloat(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getFloat(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getFloat(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 18) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/expected.txt b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/test.cfg b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..750a4c1ff0f6b83288ea46acafe2749eb646cf63 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0373-rc-ArrayOptimization-RC_Array_08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_08) +run(RC_Array_08,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java new file mode 100755 index 0000000000000000000000000000000000000000..cc80daf76c1d38f32d580d8eacb29a624d6056ea --- /dev/null +++ b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/RC_Array_09.java @@ -0,0 +1,370 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +class Base_009{ + //Parent interface + volatile double[] base1; + double[][] base2; + double[][] base21; + double[][][] base3; +} +public class RC_Array_09 extends Base_009{ + static int check_count = 0; + static double[] arr1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] arr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + static double[][] arr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + static double[][][] arr3 = {arr2,arr21}; + private RC_Array_09(){ + base1 = new double[]{1.1f,2.2f,3.3f,4.4f}; + base2 = new double[][]{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + base21 = new double[][]{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + base3 = new double[][][]{{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}}; + } + private RC_Array_09(double[] doublear){ + base1 = doublear; + } + private RC_Array_09(double[][] doublearr){ + base2 = doublearr; + } + private RC_Array_09(double[][][] doublearrr){ + base3 = doublearrr; + } + private RC_Array_09(double[] doublear, double[][] doublearr, double[][][] doublearrr){ + base1 = doublear; + base2 = doublearr; + base3 = doublearrr; + } + public static void main(String[] args) { + final double[] TEST1 = {1.1f,2.2f,3.3f,4.4f}; + final double[][] TEST2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f,8.8f}}; + final double[][] TEST21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f,11.10f}}; + final double[][][] TEST3 = {TEST2,TEST21}; + //Initialization check + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult double step1"); + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + test01(4,TEST1,TEST2,TEST3); + test01(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step2"); + //test02 interface call, call function change to modify the parameter value and judge + test02(4,TEST1,TEST2,TEST3); + test02(4,arr1,arr2,arr3); + if(TEST1.length == 4 && TEST2.length == 3 && TEST3.length == 2 + && arr1.length == 4 && arr2.length == 3 && arr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step3"); + //The test03 interface call, call the RC_Array_09_test01 function return value to the parameter third and judged. + //RC_Array_09_test01,return 2D array,Call the multi-parameter constructor of RC_Array_01, and assign a value to + //the newly created object field, and judge the result + test03(TEST2); + test03(arr2); + if(TEST2.length == 3 && arr2.length == 3) + check_count++; + else + System.out.println("ErrorResult in step4"); + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_09() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + //Test points: inheritance, constructor, return function call, constant, variable, do not receive return value + RC_Array_09_test02(); + //Get an array object by returning a function call + double[] getarr1 = RC_Array_get01(); + double[][] getarr2 = RC_Array_get02(); + double[][][] getarr3 = RC_Array_get03(); + if(getarr1.length == 4 && getarr2.length == 3 && getarr3.length == 2) + check_count++; + else + System.out.println("ErrorResult in step5"); + //Exception testing + boolean ret = RC_Array_Exception(); + if (ret == true) + check_count++; + else + System.out.println("RC_Array_Exception ErrorResult"); + //Result judgment + //System.out.println(check_count); + if(check_count == 24) + System.out.println("ExpectResult"); + } + private static void test01(int first, double[] second, double[][] third, double[][][] four) { + //test01 interface call, internal initialization array, do not modify the parameter value, only judge + double [] xyz = {8.5f,8.3f,1.2f,0.5f}; + double[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] xyz3 = {xyz2,xyz2}; + if(second.length == 4 && third.length == 3 && four.length == 2 + && xyz.length == 4 && xyz2.length == 3 && xyz3.length == 2) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private static void test02(int first, double[] second, double[][] third, double[][][] four) { + //test02 interface call, call function change to modify the parameter value and judge + double [] xyz = {8.5f,8.3f,1.2f,0.5f}; + double[][] xyz2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] xyz3 = {xyz2,xyz2}; + second = (double[]) change(second,xyz); + third = (double[][])change(third,xyz2); + four = (double[][][]) change(four,xyz3); + if(second.length == 4 && third.length == 3 && four.length == 2) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03(double[][] third) { + //The test03 interface is called, and the RC_Array_09_test01 function call is assigned as the return value to + // the parameter third and judged. + third = RC_Array_09_test01(); + if(third.length == 3) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static double[] RC_Array_get01() + { + //Call the 1D array returned by RC_Array_set01 + return RC_Array_set01(); + } + private static double[][] RC_Array_get02() + { + //Call the 2D array returned by RC_Array_set02 + return RC_Array_set02(); + } + private static double[][][] RC_Array_get03() + { + //Call the 3D array returned by RC_Array_set03 + return RC_Array_set03(); + } + private static double[] RC_Array_set01() + { + //return 1D array,Call the constructor of the 1D array parameter of RC_Array_set01, and assign a value to the + // field of the newly created object, and judge the result + double [] value1 = {9.2f,2.2f,8.8f,8.8f}; + RC_Array_09 rctest=new RC_Array_09(value1); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new double[] {1.1f,2.2f,3.3f,4.4f}; + if(rctest.base1.length == 4) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set01"); + return rctest.base1; + } + private static double[][] RC_Array_set02() + { + //return 2D array,Call the constructor of the 2D array parameter of RC_Array_set02, and assign a + // value to the domain of the newly created object, and judge the result + double[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + RC_Array_09 rctest=new RC_Array_09(value2); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,null) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base2 = new double[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + if(rctest.base2.length == 3) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set02"); + return rctest.base2; + } + private static double[][][] RC_Array_set03() + { + //return 3D array,Call the constructor of the 3D array parameter of RC_Array_set03, and assign a value to the + // field of the newly created object, and judge the result + double[][][] value3 = {{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + RC_Array_09 rctest=new RC_Array_09(value3); + if(Arrays.equals(rctest.base1,null) && Arrays.equals(rctest.base2,null) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base3 = new double[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}}; + if(rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_set03"); + return rctest.base3; + } + private static double[][] RC_Array_09_test01() + { + //return 2D array,Call the multi-parameter constructor of RC_Array_09, and assign a value to the newly created + // object field, and judge the result + double [] value1 = {1.1f,2.2f,3.3f,4.4f}; + double[][] value2 = {{1.1f,2.2f,3.3f,4.4f},{1.3f,1.1f},{0.5f}}; + double[][][] value3 = {value2,value2}; + RC_Array_09 rctest=new RC_Array_09(value1,value2,value3); + if(Arrays.equals(rctest.base1,value1) && Arrays.equals(rctest.base2,value2) + && Arrays.equals(rctest.base3,value3) && Arrays.equals(rctest.base21,null)) + check_count++; + rctest.base1 = new double[] {9.2f,2.2f,8.8f,8.8f}; + rctest.base2 = new double[][] {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + rctest.base21 = new double[][] {{6,6,6,5},{1.3f,1.1f},{0.5f}}; + rctest.base3 = new double[][][]{{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}},{{6,6,6,5},{1.3f,1.1f},{0.5f}}}; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test01"); + return rctest.base21; + } + private static double[] RC_Array_final01() + { + final double[] VALUE1 = {1.1f,2.2f,3.3f,4.4f}; + return VALUE1; + } + private static double[][] RC_Array_final02() + { + final double[][] VALUE2 = {{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}; + return VALUE2; + } + private static double[][][] RC_Array_final03() + { + final double[][][] VALUE3 = {{{6.4f,6.1f,6.3f,5.5f},{1.3f,1.1f},{0.5f}},{{9.2f,2.2f,8.8f,8.8f},{1.3f,1.1f},{0.5f}}}; + return VALUE3; + } + private static double[][] RC_Array_09_test02() + { + //The calling function returns a constant value as the assignment of the constant of this function. + //Call RC_Array_09() no argument construction method, initialize the variable of the parent class, and assign + // a value to the domain of the newly created object, and judge the result + final double[] VALUE1 = RC_Array_final01(); + final double[][] VALUE2 = RC_Array_final02(); + final double[][][] VALUE3 = RC_Array_final03(); + RC_Array_09 rctest=new RC_Array_09(); + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test02"); + rctest.base1 = VALUE1; + rctest.base2 = VALUE2; + rctest.base21 = VALUE2; + rctest.base3 = VALUE3; + if(rctest.base1.length == 4 && rctest.base2.length == 3 && rctest.base21.length == 3 && rctest.base3.length == 2) + check_count++; + else + System.out.println("ErrorResult in RC_Array_09_test02_2"); + return VALUE2; + } + private static boolean RC_Array_Exception() + { + //Exception test,exclude NullPointerException,ArrayIndexOutOfBoundsException and so on + int check = 0; + double[] value1 = RC_Array_final01(); + double[][] value2 = RC_Array_final02(); + double[][][] value3 = RC_Array_final03(); + //Is the value as expect after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——1"); + //ArrayIndexOutOfBoundsException + try { + Array.getDouble(value1,5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value1[5] = 10.16f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.setDouble(value1,5,12.5f); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value2[5],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value2[0],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value3[0][3],0); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + Array.getDouble(value3[0][1],5); + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getDouble(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //ClassCastException + RC_Array_09 rc1 = new RC_Array_09(); + try{ + Base_009 bs1 = new Base_009(); + rc1 = (RC_Array_09)bs1; + rc1.base1[0] = 8.9f; + }catch (ClassCastException e) + { + if (rc1.base1[0] != 8.9f) + check++; + } + //Whether the judgment value is normal after Exception + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in RC_Array_Exception——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getDouble(value1,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getDouble(value2,1); + }catch (NullPointerException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (NullPointerException e){ + check++; + } + //System.out.println(check); + if (check == 15) + return true; + else + return false; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/expected.txt b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/test.cfg b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dd02a63623b76eec8bca767b732ce4c9a48752e1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0374-rc-ArrayOptimization-RC_Array_09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_09) +run(RC_Array_09,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java new file mode 100755 index 0000000000000000000000000000000000000000..1485c414157a824413f02c9d50688c33f5bec11a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/RC_Array_10.java @@ -0,0 +1,381 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.Arrays; +public class RC_Array_10 { + static int check_count = 0; + //Nine definitions:int、string、char、boolean、byte、short、long、float、double + static int[] intr1 = {10,20,30,40}; + static int[][] intr2 = {{10,20,30,40},{40,50},{60}}; + static int[][] intr21 = {{40,50,60,30},{70,80},{90}}; + static int[][][] intr3 = {{{10,20,30,40},{40,50},{60}},{{40,50,60,30},{70,80},{90}}}; + static String[] strr1 = {"hello","test","for","array"}; + static String[][] strr2 = {{"hello","test","for","array"},{"2018","11"},{"26"}}; + static String[][] strr21 = {{"huawei","test","for","array"},{"2018","11"},{"26"}}; + static String[][][] strr3 = {{{"hello","test","for","array"},{"2018","11"},{"26"}},{{"huawei","test","for","array"},{"2018","11"},{"26"}}}; + static char[] charr1 = {'a','b','c','d'}; + static char[][] charr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static char[][] charr21 = {{'h','i','j','k'},{'l','m'},{'n'}}; + static char[][][] charr3 = {{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + static boolean[] boolr1 = {true,false,false,true}; + static boolean[][] boolr2 = {{true,false,false,true},{false,false},{true}}; + static boolean[][] boolr21 = {{false,true,false,true},{true,false},{false}}; + static boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{false}}}; + static byte[] byter1 = {1,2,3,4}; + static byte[][] byter2 = {{1,2,3,4},{5,6},{7}}; + static byte[][] byter21 = {{4,5,6,7},{8,9},{10}}; + static byte[][][] byter3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static short[] shortr1 = {1,2,3,4}; + static short[][] shortr2 = {{1,2,3,4},{5,6},{7}}; + static short[][] shortr21 = {{4,5,6,7},{8,9},{10}}; + static short[][][] shortr3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static long[] longr1 = {1,2,3,4}; + static long[][] longr2 = {{1,2,3,4},{5,6},{7}}; + static long[][] longr21 = {{4,5,6,7},{8,9},{10}}; + static long[][][] longr3 = {{{1,2,3,4},{5,6},{7}},{{4,5,6,7},{8,9},{10}}}; + static float[] floatr1 = {1.1f,2.2f,3.3f,4.4f}; + static float[][] floatr2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static float[][] floatr21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}; + static float[][][] floatr3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + static double[] doubler1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static double[][] doubler21 = {{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}; + static double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + public static void main(String [] args) { + //Initialization check + check("initialization"); + //Copy scene1:One, two, three-dimensional array type cyclic assignment + test01(); + check("test01"); + //Copy scene2:One, two, three-dimensional array type System.arraycopy () assignment + test02(); + check("test02"); + //Copy scene3:One, two, three-dimensional array type Arrays.copyOf() assignment + test03(); + check("test03"); + //Copy scene4:One, two, three-dimensional array type Arrays.copyOfRange() assignment + test04(); + check("test04"); + //Copy scene5:One, two, three-dimensional array type clone() assignment + test05(); + check("test05"); + //Result judgment + //System.out.println(check_count); + if(check_count == 11) + System.out.println("ExpectResult"); + } + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled*/ + if(intr1.length == 4 && intr2.length == 3 && intr21.length == 3 && intr3.length == 2 + && strr1.length == 4 && strr2.length == 3 && strr21.length == 3 && strr3.length == 2 + && charr1.length == 4 && charr2.length == 3 && charr21.length == 3 && charr3.length == 2 + && boolr1.length == 4 && boolr2.length == 3 && boolr21.length == 3 && boolr3.length == 2 + && byter1.length == 4 && byter2.length == 3 && byter21.length == 3 && byter3.length == 2 + && shortr1.length == 4 && shortr2.length == 3 && shortr21.length == 3 && shortr3.length == 2 + && longr1.length == 4 && longr2.length == 3 && longr21.length == 3 && longr3.length == 2 + && floatr1.length == 4 && floatr2.length == 3 && floatr21.length == 3 && floatr3.length == 2 + && doubler1.length == 4 && doubler2.length == 3 && doubler21.length == 3 && doubler3.length == 2) + check_count++; + else + System.out.println("ErrorResult in check: " + test_method); + } + private static void test01() { + /*test01:One, two, three-dimensional array type cyclic assignment*/ + int [] tmp_int1 = new int[4]; + int [][] tmp_int2 = new int [3][4]; + int [][][] tmp_int3 = new int [2][3][4]; + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + char [] tmp_char1 = new char[4]; + char [][] tmp_char2 = new char [3][4]; + char [][][] tmp_char3 = new char [2][3][4]; + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + byte [] tmp_byte1 = new byte[4]; + byte [][] tmp_byte2 = new byte [3][4]; + byte [][][] tmp_byte3 = new byte [2][3][4]; + short [] tmp_short1 = new short[4]; + short [][] tmp_short2 = new short [3][4]; + short [][][] tmp_short3 = new short [2][3][4]; + long [] tmp_long1 = new long[4]; + long [][] tmp_long2 = new long [3][4]; + long [][][] tmp_long3 = new long [2][3][4]; + float [] tmp_float1 = new float[4]; + float [][] tmp_float2 = new float [3][4]; + float [][][] tmp_float3 = new float [2][3][4]; + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + //1D array + for (int i = 0; i < intr1.length; i++) { + tmp_int1[i] = intr1[i]; + tmp_String1[i] = strr1[i]; + tmp_char1[i] = charr1[i]; + tmp_boolean1[i] = boolr1[i]; + tmp_byte1[i] = byter1[i]; + tmp_short1[i] = shortr1[i]; + tmp_long1[i] = longr1[i]; + tmp_float1[i] = floatr1[i]; + tmp_double1[i] = doubler1[i]; + } + //2D array + for (int i = 0; i < intr2.length; i++) + for(int j = 0; j < intr2[i].length; j++) + { + tmp_int2[i][j] = intr2[i][j]; + tmp_String2[i][j] = strr2[i][j]; + tmp_char2[i][j] = charr2[i][j]; + tmp_boolean2[i][j] = boolr2[i][j]; + tmp_byte2[i][j] = byter2[i][j]; + tmp_short2[i][j] = shortr2[i][j]; + tmp_long2[i][j] = longr2[i][j]; + tmp_float2[i][j] = floatr2[i][j]; + tmp_double2[i][j] = doubler2[i][j]; + } + //3D array + for (int i = 0; i < intr3.length; i++) + for(int j = 0; j < intr3[i].length; j++) + for(int k = 0; k < intr3[i][j].length; k++) + { + tmp_int3[i][j][k] = intr3[i][j][k]; + tmp_String3[i][j][k] = strr3[i][j][k]; + tmp_char3[i][j][k] = charr3[i][j][k]; + tmp_boolean3[i][j][k] = boolr3[i][j][k]; + tmp_byte3[i][j][k] = byter3[i][j][k]; + tmp_short3[i][j][k] = shortr3[i][j][k]; + tmp_long3[i][j][k] = longr3[i][j][k]; + tmp_float3[i][j][k] = floatr3[i][j][k]; + tmp_double3[i][j][k] = doubler3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static void test02() { + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + int [] tmp_int1 = new int[4]; + int [][] tmp_int2 = new int [3][4]; + int [][][] tmp_int3 = new int [2][3][4]; + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + char [] tmp_char1 = new char[4]; + char [][] tmp_char2 = new char [3][4]; + char [][][] tmp_char3 = new char [2][3][4]; + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + byte [] tmp_byte1 = new byte[4]; + byte [][] tmp_byte2 = new byte [3][4]; + byte [][][] tmp_byte3 = new byte [2][3][4]; + short [] tmp_short1 = new short[4]; + short [][] tmp_short2 = new short [3][4]; + short [][][] tmp_short3 = new short [2][3][4]; + long [] tmp_long1 = new long[4]; + long [][] tmp_long2 = new long [3][4]; + long [][][] tmp_long3 = new long [2][3][4]; + float [] tmp_float1 = new float[4]; + float [][] tmp_float2 = new float [3][4]; + float [][][] tmp_float3 = new float [2][3][4]; + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + System.arraycopy(intr1,0,tmp_int1,0,intr1.length); + System.arraycopy(intr2,0,tmp_int2,0,intr2.length); + System.arraycopy(intr3,0,tmp_int3,0,intr3.length); + System.arraycopy(strr1,0,tmp_String1,0,strr1.length); + System.arraycopy(strr2,0,tmp_String2,0,strr2.length); + System.arraycopy(strr3,0,tmp_String3,0,strr3.length); + System.arraycopy(charr1,0,tmp_char1,0,charr1.length); + System.arraycopy(charr2,0,tmp_char2,0,charr2.length); + System.arraycopy(charr3,0,tmp_char3,0,charr3.length); + System.arraycopy(boolr1,0,tmp_boolean1,0,boolr1.length); + System.arraycopy(boolr2,0,tmp_boolean2,0,boolr2.length); + System.arraycopy(boolr3,0,tmp_boolean3,0,boolr3.length); + System.arraycopy(byter1,0,tmp_byte1,0,byter1.length); + System.arraycopy(byter2,0,tmp_byte2,0,byter2.length); + System.arraycopy(byter3,0,tmp_byte3,0,byter3.length); + System.arraycopy(shortr1,0,tmp_short1,0,shortr1.length); + System.arraycopy(shortr2,0,tmp_short2,0,shortr2.length); + System.arraycopy(shortr3,0,tmp_short3,0,shortr3.length); + System.arraycopy(longr1,0,tmp_long1,0,longr1.length); + System.arraycopy(longr2,0,tmp_long2,0,longr2.length); + System.arraycopy(longr3,0,tmp_long3,0,longr3.length); + System.arraycopy(floatr1,0,tmp_float1,0,floatr1.length); + System.arraycopy(floatr2,0,tmp_float2,0,floatr2.length); + System.arraycopy(floatr3,0,tmp_float3,0,floatr3.length); + System.arraycopy(doubler1,0,tmp_double1,0,doubler1.length); + System.arraycopy(doubler2,0,tmp_double2,0,doubler2.length); + System.arraycopy(doubler3,0,tmp_double3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private static void test03() + { + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + int [] tmp_int1 = Arrays.copyOf(intr1,intr1.length); + int [][] tmp_int2 = Arrays.copyOf(intr2,intr2.length); + int [][][] tmp_int3 = Arrays.copyOf(intr3,intr3.length); + String [] tmp_String1 = Arrays.copyOf(strr1,strr1.length); + String [][] tmp_String2 = Arrays.copyOf(strr2,strr2.length); + String [][][] tmp_String3 = Arrays.copyOf(strr3,strr3.length); + char [] tmp_char1 = Arrays.copyOf(charr1,charr1.length); + char [][] tmp_char2 = Arrays.copyOf(charr2,charr2.length); + char [][][] tmp_char3 = Arrays.copyOf(charr3,charr3.length); + boolean [] tmp_boolean1 = Arrays.copyOf(boolr1,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOf(boolr2,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOf(boolr3,boolr3.length); + byte [] tmp_byte1 = Arrays.copyOf(byter1,byter1.length); + byte [][] tmp_byte2 = Arrays.copyOf(byter2,byter2.length); + byte [][][] tmp_byte3 = Arrays.copyOf(byter3,byter3.length); + short [] tmp_short1 = Arrays.copyOf(shortr1,shortr1.length); + short [][] tmp_short2 = Arrays.copyOf(shortr2,shortr2.length); + short [][][] tmp_short3 = Arrays.copyOf(shortr3,shortr3.length); + long [] tmp_long1 = Arrays.copyOf(longr1,longr1.length); + long [][] tmp_long2 = Arrays.copyOf(longr2,longr2.length); + long [][][] tmp_long3 = Arrays.copyOf(longr3,longr3.length); + float [] tmp_float1 = Arrays.copyOf(floatr1,floatr1.length); + float [][] tmp_float2 = Arrays.copyOf(floatr2,floatr2.length); + float [][][] tmp_float3 = Arrays.copyOf(floatr3,floatr3.length); + double [] tmp_double1 = Arrays.copyOf(doubler1,doubler1.length); + double [][] tmp_double2 = Arrays.copyOf(doubler2,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOf(doubler3,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test03"); + } + private static void test04() + { + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + int [] tmp_int1 = Arrays.copyOfRange(intr1,0,intr1.length); + int [][] tmp_int2 = Arrays.copyOfRange(intr2,0,intr2.length); + int [][][] tmp_int3 = Arrays.copyOfRange(intr3,0,intr3.length); + String [] tmp_String1 = Arrays.copyOfRange(strr1,0,strr1.length); + String [][] tmp_String2 = Arrays.copyOfRange(strr2,0,strr2.length); + String [][][] tmp_String3 = Arrays.copyOfRange(strr3,0,strr3.length); + char [] tmp_char1 = Arrays.copyOfRange(charr1,0,charr1.length); + char [][] tmp_char2 = Arrays.copyOfRange(charr2,0,charr2.length); + char [][][] tmp_char3 = Arrays.copyOfRange(charr3,0,charr3.length); + boolean [] tmp_boolean1 = Arrays.copyOfRange(boolr1,0,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOfRange(boolr2,0,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOfRange(boolr3,0,boolr3.length); + byte [] tmp_byte1 = Arrays.copyOfRange(byter1,0,byter1.length); + byte [][] tmp_byte2 = Arrays.copyOfRange(byter2,0,byter2.length); + byte [][][] tmp_byte3 = Arrays.copyOfRange(byter3,0,byter3.length); + short [] tmp_short1 = Arrays.copyOfRange(shortr1,0,shortr1.length); + short [][] tmp_short2 = Arrays.copyOfRange(shortr2,0,shortr2.length); + short [][][] tmp_short3 = Arrays.copyOfRange(shortr3,0,shortr3.length); + long [] tmp_long1 = Arrays.copyOfRange(longr1,0,longr1.length); + long [][] tmp_long2 = Arrays.copyOfRange(longr2,0,longr2.length); + long [][][] tmp_long3 = Arrays.copyOfRange(longr3,0,longr3.length); + float [] tmp_float1 = Arrays.copyOfRange(floatr1,0,floatr1.length); + float [][] tmp_float2 = Arrays.copyOfRange(floatr2,0,floatr2.length); + float [][][] tmp_float3 = Arrays.copyOfRange(floatr3,0,floatr3.length); + double [] tmp_double1 = Arrays.copyOfRange(doubler1,0,doubler1.length); + double [][] tmp_double2 = Arrays.copyOfRange(doubler2,0,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOfRange(doubler3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test04"); + } + private static void test05() + { + /*test05:One, two, three-dimensional array type clone() assignment*/ + int [] tmp_int1 = intr1.clone(); + int [][] tmp_int2 = intr2.clone(); + int [][][] tmp_int3 = intr3.clone(); + String [] tmp_String1 = strr1.clone(); + String [][] tmp_String2 = strr2.clone(); + String [][][] tmp_String3 = strr3.clone(); + char [] tmp_char1 = charr1.clone(); + char [][] tmp_char2 = charr2.clone(); + char [][][] tmp_char3 = charr3.clone(); + boolean [] tmp_boolean1 = boolr1.clone(); + boolean [][] tmp_boolean2 = boolr2.clone(); + boolean [][][] tmp_boolean3 = boolr3.clone(); + byte [] tmp_byte1 = byter1.clone(); + byte [][] tmp_byte2 = byter2.clone(); + byte [][][] tmp_byte3 = byter3.clone(); + short [] tmp_short1 = shortr1.clone(); + short [][] tmp_short2 = shortr2.clone(); + short [][][] tmp_short3 = shortr3.clone(); + long [] tmp_long1 = longr1.clone(); + long [][] tmp_long2 = longr2.clone(); + long [][][] tmp_long3 = longr3.clone(); + float [] tmp_float1 = floatr1.clone(); + float [][] tmp_float2 = floatr2.clone(); + float [][][] tmp_float3 = floatr3.clone(); + double [] tmp_double1 = doubler1.clone(); + double [][] tmp_double2 = doubler2.clone(); + double [][][] tmp_double3 = doubler3.clone(); + //Compare the last value of the array correctly + if(tmp_int1[3] == 40 && tmp_int2[2][0] == 60 && tmp_int3[1][2][0] == 90 + && tmp_String1[3] == "array" && tmp_String2[2][0] == "26" && tmp_String3[1][2][0]== "26" + && tmp_char1[3] == 'd' && tmp_char2[2][0]== 'g' && tmp_char3[1][2][0] == 'n' + && tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false + && tmp_byte1[3] == (byte)4 && tmp_byte2[2][0] == (byte)7 && tmp_byte3[1][2][0] == (byte)10 + && tmp_short1[3] == (short)4 && tmp_short2[2][0] == (short)7 && tmp_short3[1][2][0] == (short)10 + && tmp_long1[3] == (long)4 && tmp_long2[2][0] == (long)7 && tmp_long3[1][2][0] == (long)10 + && tmp_float1[3] == 4.4f && tmp_float2[2][0] == 7.7f && tmp_float3[1][2][0] == 10.3f + && tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + check_count++; + else + System.out.println("ErrorResult in test05"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/expected.txt b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/test.cfg b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..966d5b51e5835f76588a53bbb8c0596d80ae1c4e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0375-rc-ArrayOptimization-RC_Array_10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_10) +run(RC_Array_10,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java new file mode 100755 index 0000000000000000000000000000000000000000..d939f93e518fd1ddbf4770b655c11d583f7ce1f0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/RC_Array_11.java @@ -0,0 +1,347 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; +public class RC_Array_11 { + static int check_count = 0; + Thread sb = new Thread(); + String[] str_base1; + String[][] str_base2; + String[][][] str_base3; + static String[] strr1 = {"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"}; + static String[][] strr2 = {{"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}; + static String[][][] strr3 = {{{"'h''e''l''l''o'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''6'"}}}; + private static synchronized void intCheckCount() { + check_count++; + } + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private String[] RC_Array_final01() + { + final String [] VALUE1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + return VALUE1; + } + private String[][] RC_Array_final02() + { + final String[][] VALUE2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + return VALUE2; + } + private String[][][] RC_Array_final03() + { + final String[][][] VALUE3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + return VALUE3; + } + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(strr1.length == 4 && strr2.length == 3 && strr3.length == 2) + intCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_11().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + //1D array + for (int i = 0; i < strr1.length; i++) { + tmp_String1[i] = strr1[i]; + } + //2D array + for (int i = 0; i < strr2.length; i++) + for(int j = 0; j < strr2[i].length; j++) + { + tmp_String2[i][j] = strr2[i][j]; + } + //3D array + for (int i = 0; i < strr3.length; i++) + for(int j = 0; j < strr3[i].length; j++) + for(int k = 0; k < strr3[i][j].length; k++) + { + tmp_String3[i][j][k] = strr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + String [] tmp_String1 = new String[4]; + String [][] tmp_String2 = new String [3][4]; + String [][][] tmp_String3 = new String [2][3][4]; + System.arraycopy(strr1,0,tmp_String1,0,strr1.length); + System.arraycopy(strr2,0,tmp_String2,0,strr2.length); + System.arraycopy(strr3,0,tmp_String3,0,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + String [] tmp_String1 = Arrays.copyOf(strr1,strr1.length); + String [][] tmp_String2 = Arrays.copyOf(strr2,strr2.length); + String [][][] tmp_String3 = Arrays.copyOf(strr3,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + String [] tmp_String1 = Arrays.copyOfRange(strr1,0,strr1.length); + String [][] tmp_String2 = Arrays.copyOfRange(strr2,0,strr2.length); + String [][][] tmp_String3 = Arrays.copyOfRange(strr3,0,strr3.length); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + String [] tmp_String1 = strr1.clone(); + String [][] tmp_String2 = strr2.clone(); + String [][][] tmp_String3 = strr3.clone(); + //Compare the last value of the array correctly + if(tmp_String1[3] == "'a''r''r''a''y'" && tmp_String2[2][0] == "'2''6'" && tmp_String3[1][2][0]== "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(String[] arr_str1, String[][] arr_str2, String[][][] arr_str3) + { + String[] tmp_String1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + String[][] tmp_String2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + String[][][] tmp_String3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + //Check the values defined in the function + if(tmp_String1[3] == "'h''a''l''l''y'" && tmp_String2[2][0] == "'2''7'" && tmp_String3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_str1[3]== "'a''r''r''a''y'" && arr_str2[2][0] == "'2''6'" && arr_str3[1][2][0] == "'2''6'") + intCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(strr1, strr2, strr3); + } + } + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private void method07(String[] arr_str1, String[][] arr_str2, String[][][] arr_str3) { + String[] strr1 = {"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}; + String[][] strr2 = {{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"},{"'2''7'"}}; + String[][][] strr3 = {{{"'h''h''l''l''o'","'t''e''s''t'","'f''o''r'","'h''a''l''l''y'"}, {"'2''0''1''8'","'1''1'"}, {"'2''7'"}}, + {{"'h''u''a''w''e''i'","'t''e''s''t'","'f''o''r'","'a''r''r''a''y'"},{"'2''0''1''8'","'1''1'"},{"'2''7'"}}}; + arr_str1 = (String[]) change(arr_str1,strr1); + arr_str2 = (String[][])change(arr_str2,strr2); + arr_str3 = (String[][][]) change(arr_str3,strr3); + //Check the values defined in the function + if(strr1[3] == "'h''a''l''l''y'" && strr2[2][0] == "'2''7'" && strr3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_str1[3]== "'h''a''l''l''y'" && arr_str2[2][0] == "'2''7'" && arr_str3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(strr1,strr2,strr3); + } + } + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final String [] VALUE1 = RC_Array_final01(); + final String[][] VALUE2 = RC_Array_final02(); + final String[][][] VALUE3 = RC_Array_final03(); + RC_Array_11 rctest = new RC_Array_11(); + rctest.str_base1 = VALUE1; + rctest.str_base2 = VALUE2; + rctest.str_base3 = VALUE3; + //Check the values defined in the function + if(VALUE1[3] == "'h''a''l''l''y'" && VALUE2[2][0] == "'2''7'" && VALUE3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.str_base1[3]== "'h''a''l''l''y'" && rctest.str_base2[2][0] == "'2''7'" && rctest.str_base3[1][2][0] == "'2''7'") + intCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + } + public void run() + { + method08(); + } + } + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + String [] value1 = RC_Array_final01(); + String[][] value2 = RC_Array_final02(); + String[][][] value3 = RC_Array_final03(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //ArrayIndexOutOfBoundsException + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value3, 1); + } catch (NullPointerException e) { + check++; + } + //System.out.println(check); + if (check == 8) + intCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/expected.txt b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/test.cfg b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7b92e38935c8d3a7b3347648eb3afe129613934d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0376-rc-ArrayOptimization-RC_Array_11/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_11) +run(RC_Array_11,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java new file mode 100755 index 0000000000000000000000000000000000000000..df00386468d60f54a70aa9065f29b61b5a56c4d7 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/RC_Array_12.java @@ -0,0 +1,343 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; +public class RC_Array_12 { + static int check_count = 0; + Thread sb = new Thread(); + Object[] obj_base1; + Object[][] obj_base2; + Object[][][] obj_base3; + static Object[] objr1 = {'a','b','c','d'}; + static Object[][] objr2 = {{'a','b','c','d'},{'e','f'},{'g'}}; + static Object[][][] objr3 = {{{'a','b','c','d'},{'e','f'},{'g'}},{{'h','i','j','k'},{'l','m'},{'n'}}}; + private static synchronized void incCheckCount() { + check_count++; + } + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private Object[] RC_Array_final04() + { + final Object [] VALUE4 = {'b','s','d','g'}; + return VALUE4; + } + private Object[][] RC_Array_final05() + { + final Object[][] VALUE5 = {{'b','s','d','g'},{'e','f'},{'s'}}; + return VALUE5; + } + private Object[][][] RC_Array_final06() + { + final Object[][][] VALUE6 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + return VALUE6; + } + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(objr1.length == 4 && objr2.length == 3 && objr3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_12().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + Object [] tmp_obj1 = new Object[4]; + Object [][] tmp_obj2 = new Object [3][4]; + Object [][][] tmp_obj3 = new Object [2][3][4]; + //1D array + for (int i = 0; i < objr1.length; i++) { + tmp_obj1[i] = objr1[i]; + } + //2D array + for (int i = 0; i < objr2.length; i++) + for(int j = 0; j < objr2[i].length; j++) + { + tmp_obj2[i][j] = objr2[i][j]; + } + //3D array + for (int i = 0; i < objr3.length; i++) + for(int j = 0; j < objr3[i].length; j++) + for(int k = 0; k < objr3[i][j].length; k++) + { + tmp_obj3[i][j][k] = objr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + Object [] tmp_obj1 = new Object[4]; + Object [][] tmp_obj2 = new Object [3][4]; + Object [][][] tmp_obj3 = new Object [2][3][4]; + System.arraycopy(objr1,0,tmp_obj1,0,objr1.length); + System.arraycopy(objr2,0,tmp_obj2,0,objr2.length); + System.arraycopy(objr3,0,tmp_obj3,0,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + Object [] tmp_obj1 = Arrays.copyOf(objr1,objr1.length); + Object [][] tmp_obj2 = Arrays.copyOf(objr2,objr2.length); + Object [][][] tmp_obj3 = Arrays.copyOf(objr3,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + Object [] tmp_obj1 = Arrays.copyOfRange(objr1,0,objr1.length); + Object [][] tmp_obj2 = Arrays.copyOfRange(objr2,0,objr2.length); + Object [][][] tmp_obj3 = Arrays.copyOfRange(objr3,0,objr3.length); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + Object [] tmp_obj1 = objr1.clone(); + Object [][] tmp_obj2 = objr2.clone(); + Object [][][] tmp_obj3 = objr3.clone(); + //Compare the last value of the array correctly + if(tmp_obj1[3] == (Object)'d' && tmp_obj2[2][0] == (Object)'g' && tmp_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(Object[] arr_obj1, Object[][] arr_obj2, Object[][][] arr_obj3) + { + Object[] tmp_obj1 = {'b','s','d','g'}; + Object[][] tmp_obj2 = {{'b','s','d','g'},{'e','f'},{'s'}}; + Object[][][] tmp_obj3 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + //Check the values defined in the function + if(tmp_obj1[3] == (Object)'g' && tmp_obj2[2][0] == (Object)'s' && tmp_obj3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_obj1[3] == (Object)'d' && arr_obj2[2][0] == (Object)'g' && arr_obj3[1][2][0] == (Object)'n') + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(objr1,objr2,objr3); + } + } + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private void method07(Object[] arr_obj1, Object[][] arr_obj2, Object[][][] arr_obj3) { + Object[] objr1 = {'b','s','d','g'}; + Object[][] objr2 = {{'b','s','d','g'},{'e','f'},{'s'}}; + Object[][][] objr3 = {{{'b','s','d','g'},{'e','f'},{'s'}},{{'h','i','j','k'},{'l','m'},{'a'}}}; + arr_obj1 = (Object[]) change(arr_obj1,objr1); + arr_obj2 = (Object[][])change(arr_obj2,objr2); + arr_obj3 = (Object[][][]) change(arr_obj3,objr3); + //Check the values defined in the function + if(objr1[3] == (Object)'g' && objr2[2][0] == (Object)'s' && objr3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_obj1[3] == (Object)'g' && arr_obj2[2][0] == (Object)'s' && arr_obj3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(objr1,objr2,objr3); + } + } + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final Object [] VALUE4 = RC_Array_final04(); + final Object[][] VALUE5 = RC_Array_final05(); + final Object[][][] VALUE6 = RC_Array_final06(); + RC_Array_12 rctest = new RC_Array_12(); + rctest.obj_base1 = VALUE4; + rctest.obj_base2 = VALUE5; + rctest.obj_base3 = VALUE6; + //Check the values defined in the function + if(VALUE4[3] == (Object)'g' && VALUE5[2][0] == (Object)'s' && VALUE6[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.obj_base1[3] == (Object)'g' && rctest.obj_base2[2][0] == (Object)'s' && rctest.obj_base3[1][2][0] == (Object)'a') + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + } + public void run() + { + method08(); + } + } + private class test09 implements Runnable{ + /*Exception test*/ + private void method09(){ + int check = 0; + Object [] value1 = RC_Array_final04(); + Object[][] value2 = RC_Array_final05(); + Object[][][] value3 = RC_Array_final06(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //ArrayIndexOutOfBoundsException + try { + value1[5] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = "error"; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.get(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.get(value3, 1); + } catch (NullPointerException e) { + check++; + } + //System.out.println(check); + if (check == 8) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/expected.txt b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/test.cfg b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7c8708bc11e6607d9fb2c3b738516d31a03f70d9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0377-rc-ArrayOptimization-RC_Array_12/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_12) +run(RC_Array_12,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java new file mode 100755 index 0000000000000000000000000000000000000000..7bb3c35fb85edcc33ca53092dd627496d3f6356a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/RC_Array_13.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; +public class RC_Array_13 { + static int check_count = 0; + Thread sb = new Thread(); + boolean[] bool_base1; + boolean[][] bool_base2; + boolean[][][] bool_base3; + static boolean[] boolr1 = {true,false,false,true}; + static boolean[][] boolr2 = {{true,false,false,true},{false,false},{true}}; + static boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{false}}}; + private static synchronized void incCheckCount() { + check_count++; + } + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private boolean[] RC_Array_final07() + { + final boolean [] VALUE7 = {true,false,false,false}; + return VALUE7; + } + private boolean[][] RC_Array_final08() + { + final boolean[][] VALUE8 = {{true,false,false,true},{false,false},{false}}; + return VALUE8; + } + private boolean[][][] RC_Array_final09() + { + final boolean[][][] VALUE9 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + return VALUE9; + } + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(boolr1.length == 4 && boolr2.length == 3 && boolr3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + check("End"); + //Result judgment + if(check_count == 14) + result = "ExpectResult"; + return result; + } + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_13().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + //1D array + for (int i = 0; i < boolr1.length; i++) { + tmp_boolean1[i] = boolr1[i]; + } + //2D array + for (int i = 0; i < boolr2.length; i++) + for(int j = 0; j < boolr2[i].length; j++) + { + tmp_boolean2[i][j] = boolr2[i][j]; + } + //3D array + for (int i = 0; i < boolr3.length; i++) + for(int j = 0; j < boolr3[i].length; j++) + for(int k = 0; k < boolr3[i][j].length; k++) + { + tmp_boolean3[i][j][k] = boolr3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) { + incCheckCount(); + } + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + boolean [] tmp_boolean1 = new boolean[4]; + boolean [][] tmp_boolean2 = new boolean [3][4]; + boolean [][][] tmp_boolean3 = new boolean [2][3][4]; + System.arraycopy(boolr1,0,tmp_boolean1,0,boolr1.length); + System.arraycopy(boolr2,0,tmp_boolean2,0,boolr2.length); + System.arraycopy(boolr3,0,tmp_boolean3,0,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + boolean [] tmp_boolean1 = Arrays.copyOf(boolr1,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOf(boolr2,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOf(boolr3,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + boolean [] tmp_boolean1 = Arrays.copyOfRange(boolr1,0,boolr1.length); + boolean [][] tmp_boolean2 = Arrays.copyOfRange(boolr2,0,boolr2.length); + boolean [][][] tmp_boolean3 = Arrays.copyOfRange(boolr3,0,boolr3.length); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + boolean [] tmp_boolean1 = boolr1.clone(); + boolean [][] tmp_boolean2 = boolr2.clone(); + boolean [][][] tmp_boolean3 = boolr3.clone(); + //Compare the last value of the array correctly + if(tmp_boolean1[3] == true && tmp_boolean2[2][0] == true && tmp_boolean3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(boolean[] arr_bool1, boolean[][] arr_bool2, boolean[][][] arr_bool3) + { + boolean[] tmp_boolean1 = {true,false,false,false}; + boolean[][] tmp_boolean2 = {{true,false,false,true},{false,false},{false}}; + boolean[][][] tmp_boolean3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + //Check the values defined in the function + if(tmp_boolean1[3] == false && tmp_boolean2[2][0] == false && tmp_boolean3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_bool1[3] == true && arr_bool2[2][0] == true && arr_bool3[1][2][0] == false) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(boolr1, boolr2, boolr3); + } + } + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private void method07(boolean[] arr_bool1, boolean[][] arr_bool2,boolean[][][] arr_bool3) { + boolean[] boolr1 = {true,false,false,false}; + boolean[][] boolr2 = {{true,false,false,true},{false,false},{false}}; + boolean[][][] boolr3 = {{{true,false,false,true},{false,false},{true}},{{false,true,false,true},{true,false},{true}}}; + arr_bool1 = (boolean[]) change(arr_bool1,boolr1); + arr_bool2 = (boolean[][])change(arr_bool2,boolr2); + arr_bool3 = (boolean[][][]) change(arr_bool3,boolr3); + //Check the values defined in the function + if(boolr1[3] == false && boolr2[2][0] == false && boolr3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_bool1[3] == false && arr_bool2[2][0] == false && arr_bool3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(boolr1,boolr2,boolr3); + } + } + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final boolean [] VALUE7 = RC_Array_final07(); + final boolean[][] VALUE8 = RC_Array_final08(); + final boolean[][][] VALUE9 = RC_Array_final09(); + RC_Array_13 rctest = new RC_Array_13(); + rctest.bool_base1 = VALUE7; + rctest.bool_base2 = VALUE8; + rctest.bool_base3 = VALUE9; + //Check the values defined in the function + if(VALUE7[3] == false && VALUE8[2][0] == false && VALUE9[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.bool_base1[3] == false && rctest.bool_base2[2][0] == false && rctest.bool_base3[1][2][0] == true) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + } + public void run() + { + method08(); + } + } + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + boolean [] value1 = RC_Array_final07(); + boolean[][] value2 = RC_Array_final08(); + boolean[][][] value3 = RC_Array_final09(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //ArrayIndexOutOfBoundsException + try { + value1[5] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = true; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getBoolean(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getBoolean(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getBoolean(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getBoolean(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getBoolean(value3, 1); + } catch (NullPointerException e) { + check++; + } + //System.out.println(check); + if (check == 10) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/expected.txt b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/test.cfg b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5dbfcb924598c617afad1b764a9877e0eb40ddbb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0378-rc-ArrayOptimization-RC_Array_13/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_13) +run(RC_Array_13,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java new file mode 100755 index 0000000000000000000000000000000000000000..ac91e776bb0a7d8e5b517204cbd1c641e70803db --- /dev/null +++ b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/RC_Array_14.java @@ -0,0 +1,354 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +import java.util.Arrays; +import java.io.PrintStream; +public class RC_Array_14 { + static int check_count = 0; + Thread sb = new Thread(); + double[] double_base1; + double[][] double_base2; + double[][][] double_base3; + static double[] doubler1 = {1.1f,2.2f,3.3f,4.4f}; + static double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}}; + static double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.3f}}}; + private static synchronized void incCheckCount() { + check_count++; + } + /*The calling function returns a constant value as the assignment of the constant of this function.*/ + private double[] RC_Array_final10() + { + final double [] VALUE7 = {1.1f,2.2f,3.3f,4.8f}; + return VALUE7; + } + private double[][] RC_Array_final11() + { + final double[][] VALUE8 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + return VALUE8; + } + private double[][][] RC_Array_final12() + { + final double[][][] VALUE9 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + return VALUE9; + } + private static void check(String test_method) + { + /*Public function: Check if the length of the assignment source array is as expected to determine whether the resource is recycled.*/ + if(doubler1.length == 4 && doubler2.length == 3 && doubler3.length == 2) + incCheckCount(); + else + System.out.println("ErrorResult in check: " + test_method); + } + public String run(String argv[],PrintStream out) throws InterruptedException { + String result = "Error"; /*STATUS_FAILED*/ + //Initialization check + check("initialization"); + //Scene test + Thread t1 = new Thread(new test01()); + Thread t2 = new Thread(new test02()); + Thread t3 = new Thread(new test03()); + Thread t4 = new Thread(new test04()); + Thread t5 = new Thread(new test05()); + Thread t6 = new Thread(new test06()); + Thread t7 = new Thread(new test07()); + Thread t8 = new Thread(new test08()); + Thread t9 = new Thread(new test09()); + //Copy scene multithreading + t1.start();t2.start();t3.start();t4.start();t5.start(); + t1.join();t2.join();t3.join();t4.join();t5.join(); + //Other scene + t6.start();t7.start();t8.start(); + t6.join();t7.join();t8.join(); + //Exception scene + t9.start(); + t9.join(); + check("End"); + //Result judgment + //System.out.println(check_count); + if(check_count == 14) + result = "ExpectResult"; + return result; + } + public static void main(String argv[]) { + try { + System.out.println(new RC_Array_14().run(argv, System.out)); + }catch (Exception e) + { + System.out.println(e); + } + } + private class test01 implements Runnable{ + /*test01:One, two, three-dimensional array type cyclic assignment*/ + private void method01() { + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + //1D array + for (int i = 0; i < doubler1.length; i++) { + tmp_double1[i] = doubler1[i]; + } + //2D array + for (int i = 0; i < doubler2.length; i++) + for(int j = 0; j < doubler2[i].length; j++) + { + tmp_double2[i][j] = doubler2[i][j]; + } + //3D array + for (int i = 0; i < doubler3.length; i++) + for(int j = 0; j < doubler3[i].length; j++) + for(int k = 0; k < doubler3[i][j].length; k++) + { + tmp_double3[i][j][k] = doubler3[i][j][k]; + } + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test01"); + } + public void run() + { + method01(); + } + } + private class test02 implements Runnable{ + /*test02:One, two, three-dimensional array type System.arraycopy () assignment*/ + private void method02() { + double [] tmp_double1 = new double[4]; + double [][] tmp_double2 = new double [3][4]; + double [][][] tmp_double3 = new double [2][3][4]; + System.arraycopy(doubler1,0,tmp_double1,0,doubler1.length); + System.arraycopy(doubler2,0,tmp_double2,0,doubler2.length); + System.arraycopy(doubler3,0,tmp_double3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test02"); + } + public void run() + { + method02(); + } + } + private class test03 implements Runnable{ + /*test03:One, two, three-dimensional array type Arrays.copyOf() assignment*/ + private void method03() + { + double [] tmp_double1 = Arrays.copyOf(doubler1,doubler1.length); + double [][] tmp_double2 = Arrays.copyOf(doubler2,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOf(doubler3,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test03"); + } + public void run() + { + method03(); + } + } + private class test04 implements Runnable{ + /*test04:One, two, three-dimensional array type Arrays.copyOfRange() assignment*/ + private void method04() + { + double [] tmp_double1 = Arrays.copyOfRange(doubler1,0,doubler1.length); + double [][] tmp_double2 = Arrays.copyOfRange(doubler2,0,doubler2.length); + double [][][] tmp_double3 = Arrays.copyOfRange(doubler3,0,doubler3.length); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test04"); + } + public void run() + { + method04(); + } + } + private class test05 implements Runnable{ + /*test05:One, two, three-dimensional array type clone() assignment*/ + private void method05() + { + double [] tmp_double1 = doubler1.clone(); + double [][] tmp_double2 = doubler2.clone(); + double [][][] tmp_double3 = doubler3.clone(); + //Compare the last value of the array correctly + if(tmp_double1[3] == (double) 4.4f && tmp_double2[2][0] == (double)7.7f && tmp_double3[1][2][0] == (double)10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test05"); + } + public void run() + { + method05(); + } + } + private class test06 implements Runnable{ + /*test06Interface call, internal initialization array, do not modify parameter values, only judge*/ + private void method06(double[] arr_dou1, double[][] arr_dou2, double[][][] arr_dou3) + { + double[] tmp_double1 = {1.1f,2.2f,3.3f,4.8f}; + double[][] tmp_double2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + double[][][] tmp_double3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + //Check the values defined in the function + if(tmp_double1[3] == 4.8f && tmp_double2[2][0] == 2.7f && tmp_double3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step1"); + //Check unmodified parameter values + if(arr_dou1[3] == 4.4f && arr_dou2[2][0] == 7.7f && arr_dou3[1][2][0] == 10.3f) + incCheckCount(); + else + System.out.println("ErrorResult in test06 step2"); + } + public void run() + { + method06(doubler1, doubler2, doubler3); + } + } + private class test07 implements Runnable{ + /*test07 Interface call, call function change to modify the parameter value and judge*/ + private Object change(Object temp1, Object temp2){ + temp1 = temp2; + return temp1; + } + private void method07(double[] arr_dou1, double[][] arr_dou2, double[][][] arr_dou3) { + double[] doubler1 = {1.1f,2.2f,3.3f,4.8f}; + double[][] doubler2 = {{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{2.7f}}; + double[][][] doubler3 = {{{1.1f,2.2f,3.3f,4.4f},{5.5f,6.6f},{7.7f}},{{4.1f,5.1f,6.1f,7.1f},{8.1f,9.1f},{10.9f}}}; + arr_dou1 = (double[]) change(arr_dou1,doubler1); + arr_dou2 = (double[][])change(arr_dou2,doubler2); + arr_dou3 = (double[][][]) change(arr_dou3,doubler3); + //Check the values defined in the function + if(doubler1[3] == 4.8f && doubler2[2][0] == 2.7f && doubler3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step1"); + //Check the modified parameter values + if(arr_dou1[3] == 4.8f && arr_dou2[2][0] == 2.7f && arr_dou3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test07 step2"); + } + public void run() + { + method07(doubler1,doubler2,doubler3); + } + } + private class test08 implements Runnable{ + /*Call the no-argument constructor, initialize the variables of the parent class, and assign values to the + fields of the newly created object, and judge the result*/ + private void method08() { + final double [] VALUE10 = RC_Array_final10(); + final double[][] VALUE11 = RC_Array_final11(); + final double[][][] VALUE12 = RC_Array_final12(); + RC_Array_14 rctest = new RC_Array_14(); + rctest.double_base1 = VALUE10; + rctest.double_base2 = VALUE11; + rctest.double_base3 = VALUE12; + //Check the values defined in the function + if(VALUE10[3] == 4.8f && VALUE11[2][0] == 2.7f && VALUE12[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step1"); + //Check the modified parameter values + if(rctest.double_base1[3] == 4.8f && rctest.double_base2[2][0] == 2.7f && rctest.double_base3[1][2][0] == 10.9f) + incCheckCount(); + else + System.out.println("ErrorResult in test08 step2"); + } + public void run() + { + method08(); + } + } + private class test09 implements Runnable{ + /*Exception test*/ + private synchronized void method09(){ + int check = 0; + double [] value1 = RC_Array_final10(); + double[][] value2 = RC_Array_final11(); + double[][][] value3 = RC_Array_final12(); + //Is the value judged after the assignment? + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //ArrayIndexOutOfBoundsException + try { + value1[5] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value2[5][0] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + try { + value3[3][3][0] = 4.8f; + }catch (ArrayIndexOutOfBoundsException e){ + check++; + } + //IllegalArgumentException + try { + Array.getDouble(value2,1); + }catch (IllegalArgumentException e){ + check++; + } + try { + Array.getDouble(value3,1); + }catch (IllegalArgumentException e){ + check++; + } + //Whether the judgment value is normal after the abnormality + if(value1.length == 4 && value2.length == 3 && value3.length == 2) + check++; + else + System.out.println("ErrorResult in test09——2"); + //NullPointerException + value1 = null; + value2 = null; + value3 = null; + try { + Array.getDouble(value1, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getDouble(value2, 1); + } catch (NullPointerException e) { + check++; + } + try { + Array.getDouble(value3, 1); + } catch (NullPointerException e) { + check++; + } + //System.out.println(check); + if (check == 10) + incCheckCount(); + else + System.out.println("End: ErrorResult in test09"); + } + public void run() + { + method09(); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/expected.txt b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/test.cfg b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5c4ac6157b2a14d1662c7b75f1a94db78180e8ca --- /dev/null +++ b/testsuite/java_test/rc_test/RC0379-rc-ArrayOptimization-RC_Array_14/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RC_Array_14) +run(RC_Array_14,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java b/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..909dec00de29d76e831e2862ea81c51623b769f5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/RCWeakRefTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} +public class RCWeakRefTest { + public static void main(String[] args) { + new Test_A().test(); + } +} diff --git a/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/test.cfg b/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..61daf9ad0a1fa7c3a0a314bc69953be93e51eaaa --- /dev/null +++ b/testsuite/java_test/rc_test/RC0380-rc-Annotation-RCWeakRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCWeakRefTest) +run(RCWeakRefTest,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java b/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..668962f0564526de3fa022b780e687cfe13c7c70 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/RCWeakRefTest2.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import com.huawei.ark.annotation.Weak; +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} +class Test_A { + @Weak + Test_B bb; + @Weak + volatile Test_B bv; + public void test() { + foo(); + new Thread(new TriggerRef()).start(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); //expect to be null + } + try { + bv.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); //expect to be null + } + } + private void foo() { + //bb = new Test_B(); + try { + Field m = Test_A.class.getDeclaredField("bb"); + Test_B b1 = new Test_B(); + m.set(this, b1); + Field m1 = Test_A.class.getDeclaredField("bv"); + m1.set(this, b1); + Test_B temp1 = (Test_B) m.get(this); + if (temp1 != b1) { + System.out.println("error 1"); + } + Test_B temp2 = (Test_B) m1.get(this); + if (temp2 != b1) { + System.out.println("error 1"); + } + } catch (Exception e) { + System.out.println(e); + } + } + class TriggerRef implements Runnable { + public void run() { + for (int i = 0; i < 100; i++) { + WeakReference ref = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } +} +public class RCWeakRefTest2 { + public static void main(String[] args) { + new Test_A().test(); + } +} diff --git a/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/test.cfg b/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fd5c7fa4ea95d0a10421dcd46881a6ec5e1f9c63 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0381-rc-Annotation-RCWeakRefTest2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCWeakRefTest2) +run(RCWeakRefTest2,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java b/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java new file mode 100755 index 0000000000000000000000000000000000000000..198f4810c9fc1e20e5f36fba913d98ec356876f3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/RCWeakRefTest4.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +class Cycle_B_1_00010_A1 { + @Weak + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class RCWeakRefTest4 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/test.cfg b/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f2b7c995abd8c71e54533a4e65fd25463dad727d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0383-rc-Annotation-RCWeakRefTest4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCWeakRefTest4) +run(RCWeakRefTest4,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java b/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..45838020a06e7e2cd995aa0dea5e3f194a82b832 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/RCWeakRefThreadTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_Bm_1_00010 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00010_A1 a1_0 = new Cycle_B_1_00010_A1(); + a1_0.a1_0 = a1_0; + a1_0.add(); + int nsum = a1_0.sum; + if (nsum == 246) + checkout = true; + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00010_A1 { + @Weak + Cycle_B_1_00010_A1 a1_0; + int a; + int sum; + Cycle_B_1_00010_A1() { + a1_0 = null; + a = 123; + sum = 0; + } + void add() { + sum = a1_0.a + this.a; + } + } +} +public class RCWeakRefThreadTest { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00010 A1_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A2_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A3_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A4_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A5_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + ThreadRc_Cycle_Bm_1_00010 A6_Cycle_Bm_1_00010 = new ThreadRc_Cycle_Bm_1_00010(); + A1_Cycle_Bm_1_00010.start(); + A2_Cycle_Bm_1_00010.start(); + A3_Cycle_Bm_1_00010.start(); + A4_Cycle_Bm_1_00010.start(); + A5_Cycle_Bm_1_00010.start(); + A6_Cycle_Bm_1_00010.start(); + try { + A1_Cycle_Bm_1_00010.join(); + A2_Cycle_Bm_1_00010.join(); + A3_Cycle_Bm_1_00010.join(); + A4_Cycle_Bm_1_00010.join(); + A5_Cycle_Bm_1_00010.join(); + A6_Cycle_Bm_1_00010.join(); + } catch (InterruptedException e) { + // do nothing + } + if (A1_Cycle_Bm_1_00010.check() && A2_Cycle_Bm_1_00010.check() && A3_Cycle_Bm_1_00010.check() && A4_Cycle_Bm_1_00010.check() && A5_Cycle_Bm_1_00010.check() && A6_Cycle_Bm_1_00010.check()) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/test.cfg b/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7ed64bf9ecaaa1c17d9460dd573ccffc226d0c22 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0384-rc-Annotation-RCWeakRefThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCWeakRefThreadTest) +run(RCWeakRefThreadTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java b/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d33af7035a5b97af662c9586bdab9fedb413f15e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/RCUnownedRefTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import com.huawei.ark.annotation.Unowned; +class Test_B { + @Unowned + Test_A aa; + // add volatile will crash + // static Test_A a1; + protected void finalize() { + System.out.println("ExpectResult"); + } +} +class Test_A { + Test_B bb; + public void test() { + setReferences(); + System.runFinalization(); + } + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} +public class RCUnownedRefTest { + public static void main(String[] args) { + new Test_A().test(); + } +} diff --git a/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/test.cfg b/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0e910e709f2dbd50349eda2b2f0318012420cf0a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0385-rc-Annotation-RCUnownedRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefTest) +run(RCUnownedRefTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java b/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..a71b1d5527ab75193dd6c50264365cc9931e4600 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/RCUnownedRefTest2.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +class Test_B { + @Unowned + Test_B bself; + protected void run() { + System.out.println("ExpectResult"); + } +} +class Test_A { + Test_B bb; + Test_B bb2; + public void test() { + foo(); + bb.bself.run(); + bb2.bself.run(); + } + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + bb.bself = bb; + bb2.bself = bb; + } +} +public class RCUnownedRefTest2 { + public static void main(String[] args) { + new Test_A().test(); + } +} diff --git a/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/test.cfg b/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c955e6c777f2d4d0c5f9adb1b2f0332c35980959 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0386-rc-Annotation-RCUnownedRefTest2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefTest2) +run(RCUnownedRefTest2,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java b/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..823762dc0772ffa92ac8efa07811a45fb92eeb66 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/RCUnownedRefUnCycle.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + @Unowned + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00150_A2 { + @Unowned + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } +} +class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class RCUnownedRefUnCycle { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a1_main.b2_0 = a2_main.b2_0; + a2_main.b1_0 = a1_main.b1_0; + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + if (result == 1815) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/test.cfg b/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..093db9437323e6a5028973e1312e79d4cb341b28 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0387-rc-Annotation-RCUnownedRefUnCycle/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefUnCycle) +run(RCUnownedRefUnCycle,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java b/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..cced9ab7f3b2b55c250e02f15b2abe6eb0d7e87e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/RCUnownedRefUncycleThread.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +class ThreadRc_00150 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00150_A1 a1_main = new Nocycle_a_00150_A1("a1_main"); + Nocycle_a_00150_A2 a2_main = new Nocycle_a_00150_A2("a2_main"); + a1_main.b1_0 = new Nocycle_a_00150_B1("b1_0"); + a2_main.b2_0 = new Nocycle_a_00150_B2("b2_0"); + a2_main.b1_0 = a1_main.b1_0; + a1_main.b2_0 = a2_main.b2_0; + a1_main.add(); + a2_main.add(); + a1_main.b1_0.add(); + a1_main.b2_0.add(); + a2_main.b1_0.add(); + a2_main.b2_0.add(); +// System.out.printf("RC-Testing_Result=%d\n",a1_main.sum+a2_main.sum+a1_main.b1_0.sum+a1_main.b2_0.sum); + int result = a1_main.sum + a2_main.sum + a1_main.b1_0.sum + a1_main.b2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1815) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Nocycle_a_00150_A1 { + Nocycle_a_00150_B1 b1_0; + @Unowned + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A1(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_A2 { + @Unowned + Nocycle_a_00150_B1 b1_0; + Nocycle_a_00150_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00150_A2(String strObjectName) { + b1_0 = null; + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b1_0.a + b2_0.a; + } + } + class Nocycle_a_00150_B1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B1(String strObjectName) { + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00150_B2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00150_B2(String strObjectName) { + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class RCUnownedRefUncycleThread { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00150 A1_00150 = new ThreadRc_00150(); + ThreadRc_00150 A2_00150 = new ThreadRc_00150(); + ThreadRc_00150 A3_00150 = new ThreadRc_00150(); + ThreadRc_00150 A4_00150 = new ThreadRc_00150(); + ThreadRc_00150 A5_00150 = new ThreadRc_00150(); + ThreadRc_00150 A6_00150 = new ThreadRc_00150(); + A1_00150.start(); + A2_00150.start(); + A3_00150.start(); + A4_00150.start(); + A5_00150.start(); + A6_00150.start(); + try { + A1_00150.join(); + A2_00150.join(); + A3_00150.join(); + A4_00150.join(); + A5_00150.join(); + A6_00150.join(); + } catch (InterruptedException e) { + } + if (A1_00150.check() && A2_00150.check() && A3_00150.check() && A4_00150.check() && A5_00150.check() && A6_00150.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/test.cfg b/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ee2c09dd244d241793e19edd5d575e14b83a81cb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0389-rc-Annotation-RCUnownedRefUncycleThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefUncycleThread) +run(RCUnownedRefUncycleThread,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java b/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java new file mode 100755 index 0000000000000000000000000000000000000000..df35c6aa3a20ebd5b243bb12fd59a04f50d6aed2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/RCAnnotationThread02.java @@ -0,0 +1,161 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; +class RCAnnotationThread02_1 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA1null(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread02_2 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA4null(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread02_3 extends Thread { + public void run() { + RCAnnotationThread02 rcth01 = new RCAnnotationThread02(); + try { + rcth01.setA5null(); + } catch (NullPointerException e) { + } + } +} +public class RCAnnotationThread02 { + private volatile static RCAnnotationThread02_A1 a1_main = null; + private volatile static RCAnnotationThread02_A4 a4_main = null; + private volatile static RCAnnotationThread02_A5 a5_main = null; + RCAnnotationThread02() { + synchronized (this) { + try { + RCAnnotationThread02_A1 a1 = new RCAnnotationThread02_A1(); + a1.a2_0 = new RCAnnotationThread02_A2(); + a1.a2_0.a3_0 = new RCAnnotationThread02_A3(); + RCAnnotationThread02_A4 a4 = new RCAnnotationThread02_A4(); + RCAnnotationThread02_A5 a5 = new RCAnnotationThread02_A5(); + a4.a1_0 = a1; + a5.a1_0 = a1; + a1.a2_0.a3_0.a1_0 = a1; + a1_main = a1; + a4_main = a4; + a5_main = a5; + } catch (NullPointerException e) { + } + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RCAnnotationThread02_1 t1=new RCAnnotationThread02_1(); + RCAnnotationThread02_2 t2=new RCAnnotationThread02_2(); + RCAnnotationThread02_3 t3=new RCAnnotationThread02_3(); + t1.start(); + t2.start(); + t3.start(); + try{ + t1.join(); + t2.join(); + t3.join(); + }catch(InterruptedException e){} + } + public void setA1null() { + a1_main = null; + } + public void setA4null() { + a4_main = null; + } + public void setA5null() { + a5_main = null; + } + static class RCAnnotationThread02_A1 { + volatile RCAnnotationThread02_A2 a2_0; + int a; + int sum; + RCAnnotationThread02_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + static class RCAnnotationThread02_A2 { + volatile RCAnnotationThread02_A3 a3_0; + int a; + int sum; + RCAnnotationThread02_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + static class RCAnnotationThread02_A3 { + @Weak + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + RCAnnotationThread02_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RCAnnotationThread02_A4 { + @Unowned + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + RCAnnotationThread02_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + static class RCAnnotationThread02_A5 { + @Unowned + volatile RCAnnotationThread02_A1 a1_0; + int a; + int sum; + RCAnnotationThread02_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/test.cfg b/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..17e88286a6d96d7268b20f30e85c87df57a61892 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0392-rc-Annotation-RCAnnotationThread02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationThread02) +run(RCAnnotationThread02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java b/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java new file mode 100755 index 0000000000000000000000000000000000000000..3583ff1cde59b5d75b7917fd80295716ede0fa0b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/RCAnnotationThread04.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; +class RCAnnotationThread04_1 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread04_2 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread04_3 extends Thread { + public void run() { + RCAnnotationThread04 rcth01 = new RCAnnotationThread04(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +public class RCAnnotationThread04 { + private volatile static RCAnnotationThread04_A1 a1_main = null; + private volatile static RCAnnotationThread04_A4 a4_main = null; + private volatile static RCAnnotationThread04_A6 a6_main = null; + RCAnnotationThread04() { + synchronized (this) { + try { + RCAnnotationThread04_A1 a1 = new RCAnnotationThread04_A1("a1"); + RCAnnotationThread04_A4 a4 = new RCAnnotationThread04_A4("a4"); + RCAnnotationThread04_A6 a6 = new RCAnnotationThread04_A6("a6"); + a1.a2_0 = new RCAnnotationThread04_A2("a2_0"); + a1.a2_0.a3_0 = new RCAnnotationThread04_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RCAnnotationThread04_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RCAnnotationThread04_1 t_00010= new RCAnnotationThread04_1(); + RCAnnotationThread04_2 t_00020= new RCAnnotationThread04_2(); + RCAnnotationThread04_3 t_00030= new RCAnnotationThread04_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + } catch (InterruptedException e) {} + } + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + } + } + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RCAnnotationThread04_A3("new-a3"); + } catch (NullPointerException e) { + } + } + public void setA3null() { + RCAnnotationThread04_A3 a3 = new RCAnnotationThread04_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + } + } + static class RCAnnotationThread04_A1 { + volatile RCAnnotationThread04_A2 a2_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + static class RCAnnotationThread04_A2 { + volatile RCAnnotationThread04_A3 a3_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + static class RCAnnotationThread04_A3 { + @Weak + volatile RCAnnotationThread04_A1 a1_0; + volatile RCAnnotationThread04_A5 a5_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + static class RCAnnotationThread04_A4 { + volatile RCAnnotationThread04_A5 a5_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + static class RCAnnotationThread04_A5 { + @Unowned + volatile RCAnnotationThread04_A6 a6_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + static class RCAnnotationThread04_A6 { + @Unowned + volatile RCAnnotationThread04_A1 a1_0; + @Unowned + volatile RCAnnotationThread04_A3 a3_0; + @Unowned + volatile RCAnnotationThread04_A4 a4_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread04_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/test.cfg b/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ec84fde154daf03df94d86c987b684f7b1763652 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0394-rc-Annotation-RCAnnotationThread04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationThread04) +run(RCAnnotationThread04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java b/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java new file mode 100755 index 0000000000000000000000000000000000000000..cd07bba65d2d9432deee08897b7ca5ba0e0c08a1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/RCAnnotationThread05.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Weak; +import com.huawei.ark.annotation.Unowned; +class RCAnnotationThread05_1 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.ModifyA3(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread05_2 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.checkA3(); + } catch (NullPointerException e) { + } + } +} +class RCAnnotationThread05_3 extends Thread { + public void run() { + RCAnnotationThread05 rcth01 = new RCAnnotationThread05(); + try { + rcth01.setA3null(); + } catch (NullPointerException e) { + } + } +} +public class RCAnnotationThread05 { + private volatile static RCAnnotationThread05_A1 a1_main = null; + private volatile static RCAnnotationThread05_A4 a4_main = null; + private volatile static RCAnnotationThread05_A6 a6_main = null; + private static RCAnnotationThread05_A2 a2=null; + RCAnnotationThread05() { + synchronized (this) { + try { + RCAnnotationThread05_A1 a1 = new RCAnnotationThread05_A1("a1"); + RCAnnotationThread05_A4 a4 = new RCAnnotationThread05_A4("a4"); + RCAnnotationThread05_A6 a6 = new RCAnnotationThread05_A6("a6"); + a2 = new RCAnnotationThread05_A2("a2_0"); + a1.a2_0 = a2; + a1.a2_0.a3_0 = new RCAnnotationThread05_A3("a3_0"); + a1.a2_0.a3_0.a1_0 = a1; + a1.a2_0.a3_0.a5_0 = new RCAnnotationThread05_A5("a5_0"); + a1.a2_0.a3_0.a5_0.a6_0 = a6; + a6.a1_0 = a1; + a6.a3_0 = a1.a2_0.a3_0; + a4.a5_0 = a1.a2_0.a3_0.a5_0; + a6.a4_0 = a4; + a1_main = a1; + a4_main = a4; + a6_main = a6; + } catch (NullPointerException e) { + } + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + System.out.println("ExpectResult"); + } + private static void rc_testcase_main_wrapper() { + RCAnnotationThread05_1 t_00010= new RCAnnotationThread05_1(); + RCAnnotationThread05_2 t_00020= new RCAnnotationThread05_2(); + RCAnnotationThread05_3 t_00030= new RCAnnotationThread05_3(); + t_00010.start(); + t_00020.start(); + t_00030.start(); + try { + t_00010.join(); + t_00020.join(); + t_00030.join(); + } catch (InterruptedException e) {} + } + public void checkA3() { + int[] arr = new int[2]; + try { + arr[0] = a1_main.a2_0.a3_0.a; + arr[1] = a1_main.a2_0.a3_0.sum; + } catch (NullPointerException e) { + } + } + public void ModifyA3() { + try { + a1_main.a2_0.a3_0 = new RCAnnotationThread05_A3("new-a3"); + } catch (NullPointerException e) { + } + } + public void setA3null() { + RCAnnotationThread05_A3 a3 = new RCAnnotationThread05_A3("test"); + try { + a3 = this.a1_main.a2_0.a3_0; + this.a1_main.a2_0.a3_0 = null; + } catch (NullPointerException e) { + } + } + static class RCAnnotationThread05_A1 { + volatile RCAnnotationThread05_A2 a2_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + static class RCAnnotationThread05_A2 { + volatile RCAnnotationThread05_A3 a3_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A2(String strObjectName) { + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } + static class RCAnnotationThread05_A3 { + @Weak + volatile RCAnnotationThread05_A1 a1_0; + volatile RCAnnotationThread05_A5 a5_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a; + } + } + static class RCAnnotationThread05_A4 { + @Unowned + volatile RCAnnotationThread05_A5 a5_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A4(String strObjectName) { + a5_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a5_0.a; + } + } + static class RCAnnotationThread05_A5 { + @Unowned + volatile RCAnnotationThread05_A6 a6_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + static class RCAnnotationThread05_A6 { + @Unowned + volatile RCAnnotationThread05_A1 a1_0; + @Unowned + volatile RCAnnotationThread05_A3 a3_0; + @Unowned + volatile RCAnnotationThread05_A4 a4_0; + int a; + int sum; + String strObjectName; + RCAnnotationThread05_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a4_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a + a4_0.a; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/test.cfg b/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..83a3e86251c573299d18953a911099cb8ec12b56 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0395-rc-Annotation-RCAnnotationThread05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationThread05) +run(RCAnnotationThread05,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java b/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..9b6b4a7d7b3c81281e57710adb6aae05296c20b5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/RCAnnotationOneCycle.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_1_00180_A3 { + @Weak + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00180_A4 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_1_00180_A5 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +public class RCAnnotationOneCycle { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/test.cfg b/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d1c76976156550a155ae795d69993bcee32dfd4a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0396-rc-Annotation-RCAnnotationOneCycle/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationOneCycle) +run(RCAnnotationOneCycle,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java b/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..b44fef504c1c3368cec489b7d5c0e81226074d00 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/RCAnnotationOneCycleThread.java @@ -0,0 +1,141 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_Bm_1_00180 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_1_00180_A1 a1_0 = new Cycle_B_1_00180_A1(); + a1_0.a2_0 = new Cycle_B_1_00180_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_1_00180_A3(); + Cycle_B_1_00180_A4 a4_0 = new Cycle_B_1_00180_A4(); + Cycle_B_1_00180_A5 a5_0 = new Cycle_B_1_00180_A5(); + a4_0.a1_0 = a1_0; + a5_0.a1_0 = a1_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a5_0.sum); + //System.out.println(nsum); + if (nsum == 23) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_1_00180_A1 { + Cycle_B_1_00180_A2 a2_0; + int a; + int sum; + Cycle_B_1_00180_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_1_00180_A2 { + Cycle_B_1_00180_A3 a3_0; + int a; + int sum; + Cycle_B_1_00180_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_1_00180_A3 { + @Weak + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A3() { + a1_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A4 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A4() { + a1_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_1_00180_A5 { + @Unowned + Cycle_B_1_00180_A1 a1_0; + int a; + int sum; + Cycle_B_1_00180_A5() { + a1_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } +} +public class RCAnnotationOneCycleThread { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_1_00180 A1_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A2_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A3_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A4_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A5_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + ThreadRc_Cycle_Bm_1_00180 A6_Cycle_Bm_1_00180 = new ThreadRc_Cycle_Bm_1_00180(); + A1_Cycle_Bm_1_00180.start(); + A2_Cycle_Bm_1_00180.start(); + A3_Cycle_Bm_1_00180.start(); + A4_Cycle_Bm_1_00180.start(); + A5_Cycle_Bm_1_00180.start(); + A6_Cycle_Bm_1_00180.start(); + try { + A1_Cycle_Bm_1_00180.join(); + A2_Cycle_Bm_1_00180.join(); + A3_Cycle_Bm_1_00180.join(); + A4_Cycle_Bm_1_00180.join(); + A5_Cycle_Bm_1_00180.join(); + A6_Cycle_Bm_1_00180.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_1_00180.check() && A2_Cycle_Bm_1_00180.check() && A3_Cycle_Bm_1_00180.check() && A4_Cycle_Bm_1_00180.check() && A5_Cycle_Bm_1_00180.check() && A6_Cycle_Bm_1_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/test.cfg b/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a4b077f84e0d309a430cff6d3cdaf803e81848dd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0397-rc-Annotation-RCAnnotationOneCycleThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationOneCycleThread) +run(RCAnnotationOneCycleThread,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java b/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..dbba1a4020081e91c42af2e7ac566b2a9ecd272a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/RCAnnotationTwoCycle.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00080_A3 { + @Weak + Cycle_B_2_00080_A1 a1_0; + @Unowned + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_B_2_00080_A4 { + @Unowned + Cycle_B_2_00080_A3 a3_0; + @Unowned + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00080_A5 { + @Unowned + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +public class RCAnnotationTwoCycle { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a1_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a1_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/test.cfg b/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8a89babeb24f86ba9241d851d4b006f3ff2d791b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0398-rc-Annotation-RCAnnotationTwoCycle/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationTwoCycle) +run(RCAnnotationTwoCycle,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java b/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java new file mode 100755 index 0000000000000000000000000000000000000000..3cd57f18bc03a0bac597adc105ad0cf2aa46734a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/RCAnnotationTwoCycle2.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } +} +class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } +} +class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_B_2_00230_A6 { + @Weak + Cycle_B_2_00230_A1 a1_0; + @Unowned + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a10_0.a; + } +} +class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } +} +class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_B_2_00230_A7 { + @Unowned + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } +} +class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + void add() { + sum = a + a8_0.a; + } +} +public class RCAnnotationTwoCycle2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + //System.out.println(nsum); + if (nsum == 97) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/test.cfg b/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..478633c640a6873dc4f4dff673ec12e0f733a206 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0399-rc-Annotation-RCAnnotationTwoCycle2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationTwoCycle2) +run(RCAnnotationTwoCycle2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java b/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..d28c0d241e52a8e87f45bf92f13bdf1995a1f414 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/RCAnnotationTwoCycleThread.java @@ -0,0 +1,154 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_Bm_2_00080 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00080_A1 a1_0 = new Cycle_B_2_00080_A1(); + a1_0.a2_0 = new Cycle_B_2_00080_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00080_A3(); + Cycle_B_2_00080_A4 a4_0 = new Cycle_B_2_00080_A4(); + a4_0.a2_0 = a1_0.a2_0; + a1_0.a2_0.a3_0.a1_0 = a1_0; + a4_0.a3_0 = a1_0.a2_0.a3_0; + a1_0.a5_0 = new Cycle_B_2_00080_A5(); + a1_0.a2_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0 = a1_0.a5_0; + a4_0.a3_0.a5_0.a4_0 = a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a4_0.add(); + a1_0.a5_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a4_0.sum + a1_0.a5_0.sum); + //System.out.println(nsum); + if (nsum == 28) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00080_A1 { + Cycle_B_2_00080_A2 a2_0; + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A1() { + a2_0 = null; + a5_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00080_A2 { + Cycle_B_2_00080_A3 a3_0; + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A2() { + a3_0 = null; + a4_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A3 { + @Weak + Cycle_B_2_00080_A1 a1_0; + @Unowned + Cycle_B_2_00080_A5 a5_0; + int a; + int sum; + Cycle_B_2_00080_A3() { + a1_0 = null; + a5_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_B_2_00080_A4 { + @Unowned + Cycle_B_2_00080_A3 a3_0; + @Unowned + Cycle_B_2_00080_A2 a2_0; + int a; + int sum; + Cycle_B_2_00080_A4() { + a3_0 = null; + a2_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00080_A5 { + @Unowned + Cycle_B_2_00080_A4 a4_0; + int a; + int sum; + Cycle_B_2_00080_A5() { + a4_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } +} +public class RCAnnotationTwoCycleThread { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00080 A1_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A2_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A3_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A4_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A5_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + ThreadRc_Cycle_Bm_2_00080 A6_Cycle_Bm_2_00080 = new ThreadRc_Cycle_Bm_2_00080(); + A1_Cycle_Bm_2_00080.start(); + A2_Cycle_Bm_2_00080.start(); + A3_Cycle_Bm_2_00080.start(); + A4_Cycle_Bm_2_00080.start(); + A5_Cycle_Bm_2_00080.start(); + A6_Cycle_Bm_2_00080.start(); + try { + A1_Cycle_Bm_2_00080.join(); + A2_Cycle_Bm_2_00080.join(); + A3_Cycle_Bm_2_00080.join(); + A4_Cycle_Bm_2_00080.join(); + A5_Cycle_Bm_2_00080.join(); + A6_Cycle_Bm_2_00080.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00080.check() && A2_Cycle_Bm_2_00080.check() && A3_Cycle_Bm_2_00080.check() && A4_Cycle_Bm_2_00080.check() && A5_Cycle_Bm_2_00080.check() && A6_Cycle_Bm_2_00080.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/test.cfg b/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f0a10efa0358a1502b93fb83a5ceeddfcd26a5f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0400-rc-Annotation-RCAnnotationTwoCycleThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationTwoCycleThread) +run(RCAnnotationTwoCycleThread,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java b/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..26e0e4c47344ccd09e68d7b72fa3d75fdef27907 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/RCAnnotationTwoCycleThread2.java @@ -0,0 +1,215 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_Bm_2_00230 extends Thread { + private boolean checkout; + public void run() { + Cycle_B_2_00230_A1 a1_0 = new Cycle_B_2_00230_A1(); + a1_0.a2_0 = new Cycle_B_2_00230_A2(); + a1_0.a2_0.a3_0 = new Cycle_B_2_00230_A3(); + a1_0.a2_0.a3_0.a4_0 = new Cycle_B_2_00230_A4(); + a1_0.a2_0.a3_0.a4_0.a5_0 = new Cycle_B_2_00230_A5(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0 = new Cycle_B_2_00230_A6(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a1_0 = a1_0; + Cycle_B_2_00230_A10 a10_0 = new Cycle_B_2_00230_A10(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.a10_0 = a10_0; + a10_0.a8_0 = new Cycle_B_2_00230_A8(); + a10_0.a8_0.a9_0 = new Cycle_B_2_00230_A9(); + a10_0.a8_0.a9_0.a7_0 = new Cycle_B_2_00230_A7(); + a10_0.a8_0.a9_0.a7_0.a4_0 = a1_0.a2_0.a3_0.a4_0; + a1_0.add(); + a1_0.a2_0.add(); + a1_0.a2_0.a3_0.add(); + a1_0.a2_0.a3_0.a4_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.add(); + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.add(); + a10_0.a8_0.add(); + a10_0.a8_0.a9_0.add(); + a10_0.a8_0.a9_0.a7_0.add(); + int nsum = (a1_0.sum + a1_0.a2_0.sum + a1_0.a2_0.a3_0.sum + a1_0.a2_0.a3_0.a4_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.sum + a1_0.a2_0.a3_0.a4_0.a5_0.a6_0.sum + a10_0.a8_0.sum + a10_0.a8_0.a9_0.sum + a10_0.a8_0.a9_0.a7_0.sum); + if (nsum == 97) + checkout = true; + } + public boolean check() { + return checkout; + } + class Cycle_B_2_00230_A1 { + Cycle_B_2_00230_A2 a2_0; + int a; + int sum; + Cycle_B_2_00230_A1() { + a2_0 = null; + a = 1; + sum = 0; + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_B_2_00230_A2 { + Cycle_B_2_00230_A3 a3_0; + int a; + int sum; + Cycle_B_2_00230_A2() { + a3_0 = null; + a = 2; + sum = 0; + } + void add() { + sum = a + a3_0.a; + } + } + class Cycle_B_2_00230_A3 { + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A3() { + a4_0 = null; + a = 3; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A4 { + Cycle_B_2_00230_A5 a5_0; + int a; + int sum; + Cycle_B_2_00230_A4() { + a5_0 = null; + a = 4; + sum = 0; + } + void add() { + sum = a + a5_0.a; + } + } + class Cycle_B_2_00230_A5 { + Cycle_B_2_00230_A6 a6_0; + int a; + int sum; + Cycle_B_2_00230_A5() { + a6_0 = null; + a = 5; + sum = 0; + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_B_2_00230_A6 { + @Weak + Cycle_B_2_00230_A1 a1_0; + @Unowned + Cycle_B_2_00230_A10 a10_0; + int a; + int sum; + Cycle_B_2_00230_A6() { + a1_0 = null; + a10_0 = null; + a = 6; + sum = 0; + } + void add() { + sum = a + a1_0.a + a10_0.a; + } + } + class Cycle_B_2_00230_A8 { + Cycle_B_2_00230_A9 a9_0; + int a; + int sum; + Cycle_B_2_00230_A8() { + a9_0 = null; + a = 7; + sum = 0; + } + void add() { + sum = a + a9_0.a; + } + } + class Cycle_B_2_00230_A9 { + Cycle_B_2_00230_A7 a7_0; + int a; + int sum; + Cycle_B_2_00230_A9() { + a7_0 = null; + a = 8; + sum = 0; + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_B_2_00230_A7 { + @Unowned + Cycle_B_2_00230_A4 a4_0; + int a; + int sum; + Cycle_B_2_00230_A7() { + a4_0 = null; + a = 9; + sum = 0; + } + void add() { + sum = a + a4_0.a; + } + } + class Cycle_B_2_00230_A10 { + Cycle_B_2_00230_A8 a8_0; + int a; + int sum; + Cycle_B_2_00230_A10() { + a8_0 = null; + a = 10; + sum = 0; + } + void add() { + sum = a + a8_0.a; + } + } +} +public class RCAnnotationTwoCycleThread2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_Bm_2_00230 A1_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A2_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A3_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A4_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A5_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + ThreadRc_Cycle_Bm_2_00230 A6_Cycle_Bm_2_00230 = new ThreadRc_Cycle_Bm_2_00230(); + A1_Cycle_Bm_2_00230.start(); + A2_Cycle_Bm_2_00230.start(); + A3_Cycle_Bm_2_00230.start(); + A4_Cycle_Bm_2_00230.start(); + A5_Cycle_Bm_2_00230.start(); + A6_Cycle_Bm_2_00230.start(); + try { + A1_Cycle_Bm_2_00230.join(); + A2_Cycle_Bm_2_00230.join(); + A3_Cycle_Bm_2_00230.join(); + A4_Cycle_Bm_2_00230.join(); + A5_Cycle_Bm_2_00230.join(); + A6_Cycle_Bm_2_00230.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_Bm_2_00230.check() && A2_Cycle_Bm_2_00230.check() && A3_Cycle_Bm_2_00230.check() && A4_Cycle_Bm_2_00230.check() && A5_Cycle_Bm_2_00230.check() && A6_Cycle_Bm_2_00230.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/test.cfg b/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b9118e18bc06ee9d21c4323bbd1390729ccacfbd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0401-rc-Annotation-RCAnnotationTwoCycleThread2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationTwoCycleThread2) +run(RCAnnotationTwoCycleThread2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java b/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java new file mode 100755 index 0000000000000000000000000000000000000000..262e7a78a66d96a50d5e35a0966bbdcb3fc029de --- /dev/null +++ b/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/RCAnnotationMultiCycle.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } +} +class Cycle_a_00280_A2 { + @Weak + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00280_A3 { + @Weak + Cycle_a_00280_A1 a1_0; + @Weak + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } +} +class Cycle_a_00280_A5 { + @Unowned + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00280_A6 { + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } +} +public class RCAnnotationMultiCycle { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + if (result == 1443) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/test.cfg b/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..19be30532693c172971a6a9636ac9a658b2ad51d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0402-rc-Annotation-RCAnnotationMultiCycle/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationMultiCycle) +run(RCAnnotationMultiCycle,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java b/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java new file mode 100755 index 0000000000000000000000000000000000000000..e1193455ba8bcea4504da9355c7e86eb2aa9b7ba --- /dev/null +++ b/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/RCAnnotationMultiCycle2.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + @Unowned + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } +} +class Cycle_a_00370_A3 { + @Weak + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } +} +class Cycle_a_00370_A4 { + @Unowned + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } +} +class Cycle_a_00370_A5 { + @Unowned + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } +} +class Cycle_a_00370_A6 { + @Unowned + Cycle_a_00370_A1 a1_0; + @Unowned + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } +} +class Cycle_a_00370_A7 { + @Unowned + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } +} +class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } +} +class Cycle_a_00370_A9 { + @Unowned + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } +} +class Cycle_a_00370_A10 { + @Unowned + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } +} +public class RCAnnotationMultiCycle2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum +a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.sum + a1_main.a2_0.a3_0.a10_0.sum; + if (result == 2623) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/test.cfg b/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..242c634b798bf4af7b9746ff7efa84ff8f3adb1e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0403-rc-Annotation-RCAnnotationMultiCycle2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationMultiCycle2) +run(RCAnnotationMultiCycle2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java b/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java new file mode 100755 index 0000000000000000000000000000000000000000..76a1a5327c9e691157fe92e4228437115a5aa59a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/RCAnnotationMultiCycleThread.java @@ -0,0 +1,170 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_am_00280 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00280_A1 a1_main = new Cycle_a_00280_A1("a1_main"); + Cycle_a_00280_A6 a6_main = new Cycle_a_00280_A6("a6_main"); + a1_main.a2_0 = new Cycle_a_00280_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new Cycle_a_00280_A3("a3_0"); + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00280_A5("a5_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a1_main.a3_0 = a1_main.a2_0.a3_0; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a6_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + int result = a1_main.sum + a6_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 1443) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00280_A1 { + Cycle_a_00280_A2 a2_0; + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + } + class Cycle_a_00280_A2 { + @Weak + Cycle_a_00280_A1 a1_0; + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00280_A3 { + @Weak + Cycle_a_00280_A1 a1_0; + @Weak + Cycle_a_00280_A2 a2_0; + Cycle_a_00280_A5 a5_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a5_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a2_0.a + a5_0.a; + } + } + class Cycle_a_00280_A5 { + @Unowned + Cycle_a_00280_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A5(String strObjectName) { + a6_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00280_A6 { + @Unowned + Cycle_a_00280_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00280_A6(String strObjectName) { + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a3_0.a; + } + } +} +public class RCAnnotationMultiCycleThread { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00280 A1_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A2_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A3_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A4_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A5_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + ThreadRc_Cycle_am_00280 A6_Cycle_am_00280 = new ThreadRc_Cycle_am_00280(); + A1_Cycle_am_00280.start(); + A2_Cycle_am_00280.start(); + A3_Cycle_am_00280.start(); + A4_Cycle_am_00280.start(); + A5_Cycle_am_00280.start(); + A6_Cycle_am_00280.start(); + try { + A1_Cycle_am_00280.join(); + A2_Cycle_am_00280.join(); + A3_Cycle_am_00280.join(); + A4_Cycle_am_00280.join(); + A5_Cycle_am_00280.join(); + A6_Cycle_am_00280.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00280.check() && A2_Cycle_am_00280.check() && A3_Cycle_am_00280.check() && A4_Cycle_am_00280.check() && A5_Cycle_am_00280.check() && A6_Cycle_am_00280.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/test.cfg b/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d997db35b74fcd6ab7ded6a38b75c968677d5d1a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0404-rc-Annotation-RCAnnotationMultiCycleThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationMultiCycleThread) +run(RCAnnotationMultiCycleThread,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java b/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..f4a1927eeb6696412fbbb947aa3fa599a50c1656 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/RCAnnotationMultiCycleThread2.java @@ -0,0 +1,267 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import com.huawei.ark.annotation.Weak; +class ThreadRc_Cycle_am_00370 extends Thread { + private boolean checkout; + public void run() { + Cycle_a_00370_A1 a1_main = new Cycle_a_00370_A1("a1_main"); + Cycle_a_00370_A4 a4_main = new Cycle_a_00370_A4("a4_main"); + Cycle_a_00370_A6 a6_main = new Cycle_a_00370_A6("a6_main"); + Cycle_a_00370_A9 a9_main = new Cycle_a_00370_A9("a9_main"); + a1_main.a2_0 = new Cycle_a_00370_A2("a2_0"); + a1_main.a2_0.a3_0 = new Cycle_a_00370_A3("a3_0"); + a1_main.a2_0.a4_0 = a4_main; + a4_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0 = new Cycle_a_00370_A5("a5_0"); + a1_main.a2_0.a3_0.a10_0 = new Cycle_a_00370_A10("a10_0"); + a1_main.a2_0.a3_0.a5_0.a6_0 = a6_main; + a6_main.a1_0 = a1_main; + a1_main.a2_0.a3_0.a5_0.a8_0 = new Cycle_a_00370_A8("a8_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0 = new Cycle_a_00370_A7("a7_0"); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.a2_0 = a1_main.a2_0; + a1_main.a2_0.a3_0.a10_0.a9_0 = a9_main; + a9_main.a6_0 = a6_main; + a6_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.add(); + a4_main.add(); + a6_main.add(); + a9_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main.a2_0.a3_0.a5_0.add(); + a1_main.a2_0.a3_0.a10_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.add(); + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.add(); + int result = a1_main.sum + a4_main.sum + a6_main.sum + a9_main.sum + a1_main.a2_0.sum + a1_main.a2_0.a3_0.sum + a1_main.a2_0.a3_0.a5_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.a7_0.sum + a1_main.a2_0.a3_0.a5_0.a8_0.sum + a1_main.a2_0.a3_0.a10_0.sum; + if (result == 2623) + checkout = true; + //System.out.println(checkout); + } + public boolean check() { + return checkout; + } + class Cycle_a_00370_A1 { + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A2 { + Cycle_a_00370_A3 a3_0; + @Unowned + Cycle_a_00370_A4 a4_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A2(String strObjectName) { + a3_0 = null; + a4_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + a3_0.a + a4_0.a; + } + } + class Cycle_a_00370_A3 { + @Weak + Cycle_a_00370_A1 a1_0; + Cycle_a_00370_A5 a5_0; + Cycle_a_00370_A10 a10_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A3(String strObjectName) { + a1_0 = null; + a5_0 = null; + a10_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a5_0.a + a10_0.a; + } + } + class Cycle_a_00370_A4 { + @Unowned + Cycle_a_00370_A1 a1_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A4(String strObjectName) { + a1_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + a1_0.a; + } + } + class Cycle_a_00370_A5 { + @Unowned + Cycle_a_00370_A6 a6_0; + Cycle_a_00370_A8 a8_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A5(String strObjectName) { + a6_0 = null; + a8_0 = null; + a = 105; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A5_"+strObjectName); + } + void add() { + sum = a + a6_0.a + a8_0.a; + } + } + class Cycle_a_00370_A6 { + @Unowned + Cycle_a_00370_A1 a1_0; + @Unowned + Cycle_a_00370_A3 a3_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A6(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 106; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A6_"+strObjectName); + } + void add() { + sum = a + a1_0.a + a3_0.a; + } + } + class Cycle_a_00370_A7 { + @Unowned + Cycle_a_00370_A2 a2_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A7(String strObjectName) { + a2_0 = null; + a = 107; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A7_"+strObjectName); + } + void add() { + sum = a + a2_0.a; + } + } + class Cycle_a_00370_A8 { + Cycle_a_00370_A7 a7_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A8(String strObjectName) { + a7_0 = null; + a = 108; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A8_"+strObjectName); + } + void add() { + sum = a + a7_0.a; + } + } + class Cycle_a_00370_A9 { + @Unowned + Cycle_a_00370_A6 a6_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A9(String strObjectName) { + a6_0 = null; + a = 109; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A9_"+strObjectName); + } + void add() { + sum = a + a6_0.a; + } + } + class Cycle_a_00370_A10 { + @Unowned + Cycle_a_00370_A9 a9_0; + int a; + int sum; + String strObjectName; + Cycle_a_00370_A10(String strObjectName) { + a9_0 = null; + a = 110; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A10_"+strObjectName); + } + void add() { + sum = a + a9_0.a; + } + } +} +public class RCAnnotationMultiCycleThread2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_Cycle_am_00370 A1_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A2_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A3_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A4_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A5_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + ThreadRc_Cycle_am_00370 A6_Cycle_am_00370 = new ThreadRc_Cycle_am_00370(); + A1_Cycle_am_00370.start(); + A2_Cycle_am_00370.start(); + A3_Cycle_am_00370.start(); + A4_Cycle_am_00370.start(); + A5_Cycle_am_00370.start(); + A6_Cycle_am_00370.start(); + try { + A1_Cycle_am_00370.join(); + A2_Cycle_am_00370.join(); + A3_Cycle_am_00370.join(); + A4_Cycle_am_00370.join(); + A5_Cycle_am_00370.join(); + A6_Cycle_am_00370.join(); + } catch (InterruptedException e) { + } + if (A1_Cycle_am_00370.check() && A2_Cycle_am_00370.check() && A3_Cycle_am_00370.check() && A4_Cycle_am_00370.check() && A5_Cycle_am_00370.check() && A6_Cycle_am_00370.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/test.cfg b/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1aba109e66fe77cff092d05b4d62013909bd62a9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0405-rc-Annotation-RCAnnotationMultiCycleThread2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCAnnotationMultiCycleThread2) +run(RCAnnotationMultiCycleThread2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/expected.txt b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java new file mode 100755 index 0000000000000000000000000000000000000000..1ae84a70b0d867e39e4a8ccd68dd2fbba4d4f66f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/stringIntern.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class stringIntern { + private static int check = 0; + public static void main(String[] args) { + String s1 = new String("aaa"); + String s2 = "aaa"; + if (s1 != s2) { + check++; //=1 + } + s1 = new String("bbb").intern(); + s2 = "bbb"; + if (s1 == s2) { + check++; //=2 + } + s1 = "ccc"; + s2 = "ccc"; + if (s1 == s2) { + check++; //=3 + } + s1 = new String("ddd").intern(); + s2 = new String("ddd").intern(); + if (s1 == s2) { + check++; //=4 + } + s1 = "ab" + "cd"; + s2 = "abcd"; + if (s1 == s2) { + check++; //=5 + } + String temp = "hh"; + s1 = "a" + temp; + s2 = "ahh"; + if (s1 != s2) { + check++; //=6 + } + temp = "hh".intern(); + s1 = "a" + temp; + s2 = "ahh"; + if (s1 != s2) { + check++; //=7 + } + temp = "hh".intern(); + s1 = ("a" + temp).intern(); + s2 = "ahh"; + if (s1 == s2) { + check++; //=8 + } + s1 = new String("1"); + s1.intern(); + s2 = "1"; + if (s1 != s2) { + check++; //=9 + } + String s3 = new String("1") + new String("1"); + s3.intern(); + String s4 = "11"; + if (s1 != s2) { + check++; //=10 + } + s3 = new String("2") + new String("2"); + s4 = "22"; + s3.intern(); + if (s1 != s2) { + check++; //=11 + } + if (check == 11) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/test.cfg b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3e5c356a09539c0b9747fc2f01eda7acea30724b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0406-rc-DTS-stringIntern/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(stringIntern) +run(stringIntern,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/expected.txt b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java new file mode 100755 index 0000000000000000000000000000000000000000..e24428da6413575161f60dbbe1c0195202769ab3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/stackAllocField.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class stackAllocField { + private static A a1 = new A(); + private static A a2 = new A(); + private static A a3 = new A(); + private static A a4 = new A(); + public static void main(String[] args) { + wrapper(a1, a2, a3, a4); + } + public static void wrapper(A tempa1, A tempa2, A tempa3, A tempa4) { + A testa1 = new A(); + testa1.a = tempa1; + A testa2 = new A(); + testa2.a = tempa2; + A testa3 = new A(); + testa3.a = tempa3; + A testa4 = new A(); + testa4.a = tempa4; + tempa1 = null; + tempa2 = null; + tempa3 = null; + tempa4 = null; + a1 = null; + a2 = null; + a3 = null; + a4 = null; + for (int i = 0; i <= 50; i++) { + Runtime.getRuntime().gc(); + } + if (testa1.a != null && testa2.a != null && testa3.a != null && testa4.a != null) { + System.out.println("ExpectResult"); + } + } + private static class A { + A a; + } +} diff --git a/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/test.cfg b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c4ed6fb83738577f2683f2faaae3d196a4bf0c57 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0407-rc-DTS-stackAllocField/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(stackAllocField) +run(stackAllocField,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java new file mode 100755 index 0000000000000000000000000000000000000000..72d80670a4e86de48e138ebcb511440a53da7421 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/OOMtest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +public class OOMtest { + private static ArrayList store; + private static int alloc_test() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024 * 10; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + public static void main(String[] args) { + try { + int result = alloc_test(); + } catch (OutOfMemoryError o) { + System.out.println("ExpectResult"); + } + if (store == null) { + System.out.println("Error"); + } else { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/expected.txt b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/test.cfg b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..55cccd2a728e682a79a1d6d554d9527dd8354b6b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0408-rc-DTS-OOMtest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(OOMtest) +run(OOMtest,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java new file mode 100755 index 0000000000000000000000000000000000000000..97e99a9185aef2e9dc9e15f87903392664a91df2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/Ex_eight_arguments.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Array; +public class Ex_eight_arguments { + static int check_count = 0; + public static void main(String[] args) { + int first = 1988; + byte second = 2; + char third = 'g'; + long four = 19881110; + float five = 601.5f; + double six = 60.15f; + String seven = "huawei"; + boolean eight = true; + Object nine = new String("CC is a cat"); + int[] ten = {2012, 2020, 2019, 2040, 3301}; + Ex_eight_arguments Test = new Ex_eight_arguments(); + //test static method no return no exception + test01(first, second, third, four, five, six, seven, eight, nine, ten); + //test no static method no return no exception + Test.test02(first, second, third, four, five, six, seven, eight, nine, ten); + //test no static method return value no exception + first = Test.test03(first, second, third, four, five, six, seven, eight, nine, ten); + //test no static method no return throws exception + try { + Test.test04(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test04 not catch Exception"); + } catch (ArrayIndexOutOfBoundsException e) { + check_count++; + } + //test static method return value no exception + seven = test05(first, second, third, four, five, six, seven, eight, nine, ten); + //test static method no return value throws exception + try { + test06(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test06 not catch Exception"); + } catch (IllegalArgumentException e) { + check_count++; + } + //test no static method return value throws exception + try { + boolean result7 = Test.test07(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test07 not catch Exception"); + } catch (ArithmeticException e) { + check_count++; + } + //test static method return value throws exception + try { + int[] result8 = test08(first, second, third, four, five, six, seven, eight, nine, ten); + System.out.println("ErrorResult in test08 not catch Exception"); + } catch (NegativeArraySizeException e) { + check_count++; + } + //Result judgment + if (check_count == 12) + System.out.println("ExpectResult"); + //System.out.println(check_count); + } + private static void test01(int first, byte second, char third, long four, float five, double six, String seven, + boolean eight, Object nine, int[] ten) { + /*test static method no return no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test01"); + } + private static String test05(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test static method return value no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test05"); + return new String("test05 is End"); + } + private static void test06(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws IllegalArgumentException { + /*test static method no return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test06"); + Array.getInt(test_ten, 5); + } + private static int[] test08(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws NegativeArraySizeException { + /*test static method return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test08"); + int[] chck = new int[-1]; + return chck; + } + private void test02(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test no static method no return no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test02"); + } + private int test03(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) { + /*test no static method return value no exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1989 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test03"); + return first; + } + private void test04(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws ArrayIndexOutOfBoundsException { + /*test no static method no return throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test04"); + ten[5] = 1988; + } + private boolean test07(int first, byte second, char third, long four, float five, double six, String seven, + Boolean eight, Object nine, int[] ten) throws ArithmeticException { + /*test no static method return value throws exception*/ + first++; + second = 56; + third = (char) second; + four = (long) third; + five = (float) four; + six = (double) five; + seven = "fei fei is not a pig"; + eight = false; + nine = (Object) eight; + ten = ten.clone(); + int[][] test_ten = {ten, ten, ten, ten, ten, ten}; + if (first == 1990 && second == 56 && third == '8' && four == 56 && five == 56f && six == 56f && seven == "fei fei is not a pig" + && eight == false && nine == (Object) false && ten[4] == 3301) + check_count++; + else + System.out.println("ErrorResult in test07"); + first = first / 0; + return true; + } +} diff --git a/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/expected.txt b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/test.cfg b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..431e608bd20b494942d7ef59446e1e84ee2dc065 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0409-rc-DTS-Ex_eight_arguments/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Ex_eight_arguments) +run(Ex_eight_arguments,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java new file mode 100755 index 0000000000000000000000000000000000000000..27cb9d2d8fb94a0d4f2968f1ae90ffce90fbccb6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/Memory_stressTestCase29.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import sun.misc.Cleaner; +public class Memory_stressTestCase29 { + private static final int INIT_DEFAULT_THREAD_NUM = 100; + private static int DEFAULT_THREAD_NUM = INIT_DEFAULT_THREAD_NUM; + static List> mAllThread = new ArrayList>(); + public static void main(String[] args) { + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + Runtime.getRuntime().gc(); + testCase29(); + System.out.println("ExpectResult"); + } + public static void testCase29() { + ArrayList list = new ArrayList<>(); + for (int i = 0; i < (DEFAULT_THREAD_NUM / 10); i++) { + list.add(new StopAbleThread(() -> { + ArrayList units = new ArrayList<>(); + Random r = new Random(); + for (int j = 0; j < 100; j++) { + units.add(new Memory_stressTestCase29.AllocUnitwithVerifyCleaner(r.nextInt(512))); + } + trySleep(r.nextInt(500)); + for (Memory_stressTestCase29.AllocUnitwithVerifyCleaner unit : units) { + unit.CanbeFree(); + } + units.clear(); + }, "testCase29_alloc_" + (i + 1))); + } + startAllThread(list); + waitAllThreadFinish(list); + } + public static void waitAllThreadFinish(List list) { + for (Thread s : list) { + try { + s.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } finally { + removeDeadThread(s); + } + } + } + public static void removeDeadThread(Thread t) { + if (t == null) { + return; + } + if (!t.isAlive()) { + synchronized (mAllThread) { + mAllThread.remove(t); + } + } + } + public static void startAllThread(List list) { + for (Thread s : list) { + s.start(); + trySleep(new Random().nextInt(2)); + } + } + public static void trySleep(long time) { + try { + Thread.sleep(time); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + public static class StopAbleThread extends Thread { + public static boolean mRuning = true; + static List> mAllThread = new ArrayList>(); + public StopAbleThread(Runnable r, String name) { + super(r, name); + } + } + public static class AllocUnit { + public byte unit[]; + public AllocUnit(int arrayLength) { + unit = new byte[arrayLength]; + } + } + public static class AllocUnitwithVerifyCleaner extends AllocUnit { + static final int FLAG_INUSE = 0x112233; + static final int FLAG_CANBECLEAN = 0xddee; + static final int FLAG_CLEARED = 0xaabb; + public CleanerStatus status; + public AllocUnitwithVerifyCleaner(int arrayLength) { + super(arrayLength); + status = new CleanerStatus(); + this.cleaner = Cleaner.create(this, new TestCleaner(status)); + } + private final Cleaner cleaner; + private static class CleanerStatus { + public int status; + CleanerStatus() { + status = FLAG_INUSE; + } + } + public void CanbeFree() { + if (this.status.status != FLAG_INUSE) { + throw new NullPointerException(); + } + this.status.status = FLAG_CANBECLEAN; + } + private static class TestCleaner implements Runnable { + public CleanerStatus status; + public TestCleaner(CleanerStatus status) { + this.status = status; + } + public void run() { + if (this.status.status != FLAG_CANBECLEAN) { + } + this.status.status = FLAG_CLEARED; + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/expected.txt b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/test.cfg b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..aa4f28b9998c85ec37f5920fddeea8d76255f5f6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0410-rc-Memory-stressTestCase29/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(Memory_stressTestCase29) +run(Memory_stressTestCase29,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java b/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..db3d9a1a75114e8b706fb8b73b46441935d7154d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/RCUnownedRefTest3.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import java.util.LinkedList; +import java.util.List; +public class RCUnownedRefTest3 { + public static void main(String[] args) { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture("test"); + UnownedLambda unownedLambda = new UnownedLambda(); + List list = new LinkedList<>(); + list.add("test"); + unownedLambda.lambdaCapture(list, "test"); + if (unownedAnnoymous.checkAnnoy == true && unownedLambda.checkLambda == true) { + System.out.println("ExpectResult"); + } + } +} +class UnownedLambda { + String name; + static boolean checkLambda = false; + void lambdaCapture(List list, String suffix) { + final @Unowned String capSuffix = suffix; + final @Unowned UnownedLambda self = this; + list.forEach((str) -> { + if ((self.name + str + capSuffix).equals("nulltesttest")) { + checkLambda = true; + } + }); + } +} +class UnownedAnnoymous { + String name; + static boolean checkAnnoy = false; + void anonymousCapture(String suffix) { + final @Unowned String capSuffix = suffix; + Runnable r = new Runnable() { + @Override + public void run() { + if ((name + capSuffix).equals("nulltest")) { + checkAnnoy = true; + } + } + }; + r.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/test.cfg b/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..52da7b50b5bb0b40d435cb0d5265508900e80764 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0417-rc-Annotation-RCUnownedRefTest3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefTest3) +run(RCUnownedRefTest3,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java b/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..f0512ff7615ae220cfaa10699831983b41bcd632 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/RCUnownedRefThreadTest3.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +import java.util.LinkedList; +import java.util.List; +class RCUnownedRefTest3 extends Thread { + private boolean checkout; + public void run() { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture("test"); + UnownedLambda unownedLambda = new UnownedLambda(); + List list = new LinkedList<>(); + list.add("test"); + unownedLambda.lambdaCapture(list, "test"); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (unownedAnnoymous.checkAnnoy == true && unownedLambda.checkLambda == true) { + checkout = true; + } else { + System.out.println("unownedAnnoymous.checkAnnoy:" + unownedAnnoymous.checkAnnoy); + System.out.println("unownedLambda.checkLambda:" + unownedLambda.checkLambda); + System.out.println("555555555555555"); + checkout = false; + } + } + public boolean check() { + return checkout; + } +} +class UnownedLambda { + String name; + static boolean checkLambda; + void lambdaCapture(List list, String suffix) { + checkLambda = false; + final String capSuffix = suffix; + final UnownedLambda self = this; + list.forEach((str) -> { + if ((self.name + str + capSuffix).equals("nulltesttest")) { + checkLambda = true; + } else { + System.out.println("self.name + str + capSuffix:" + self.name + " " + str + " " + capSuffix); + } + }); + } +} +class UnownedAnnoymous { + String name; + static boolean checkAnnoy; + void anonymousCapture(String suffix) { + checkAnnoy = false; + final @Unowned String capSuffix = suffix; + Runnable r = new Runnable() { + @Override + public void run() { + if ((name + capSuffix).equals("nulltest")) { + checkAnnoy = true; + } else { + System.out.println("name + capSuffix:" + name + " " + capSuffix); + } + } + }; + r.run(); + } +} +public class RCUnownedRefThreadTest3 { + public static void main (String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCUnownedRefTest3 rcTest1 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest2 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest3 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest4 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest5 = new RCUnownedRefTest3(); + RCUnownedRefTest3 rcTest6 = new RCUnownedRefTest3(); + rcTest1.start(); + rcTest2.start(); + rcTest3.start(); + rcTest4.start(); + rcTest5.start(); + rcTest6.start(); + try { + rcTest1.join(); + rcTest2.join(); + rcTest3.join(); + rcTest4.join(); + rcTest5.join(); + rcTest6.join(); + } catch (InterruptedException e) { + } + Thread.sleep(2000); + if (rcTest1.check() && rcTest2.check() && rcTest3.check() && rcTest4.check() && rcTest5.check() && rcTest6.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcTest1.check():" + rcTest1.check()); + System.out.println("rcTest2.check():" + rcTest2.check()); + System.out.println("rcTest3.check():" + rcTest3.check()); + System.out.println("rcTest4.check():" + rcTest4.check()); + System.out.println("rcTest5.check():" + rcTest5.check()); + System.out.println("rcTest6.check():" + rcTest6.check()); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/test.cfg b/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fdd39ce411444d236ffc4444fc0570962ed41700 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0418-rc-Annotation-RCUnownedRefThreadTest3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefThreadTest3) +run(RCUnownedRefThreadTest3,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java b/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java new file mode 100755 index 0000000000000000000000000000000000000000..e5ab8672fdc5b5ca3acc2f2080efc42e396e77c6 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/RCUnownedLocalTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.UnownedLocal; +import java.util.LinkedList; +import java.util.List; +public class RCUnownedLocalTest { + static Integer a = new Integer(1); + static Object[] arr = new Object[]{1, 2, 3}; + @UnownedLocal + static int method(Integer a, Object[] arr) { + int check = 0; + Integer c = a + a; + if (c == 2) { + check++; + } else { + check--; + } + for (Object array : arr) { + //System.out.println(array); + check++; + } + return check; + } + public static void main(String[] args) { + int result = method(a, arr); + if (result == 4) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/test.cfg b/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eda60d878ba6b5f92b65c4aaf02e4b7aa1117889 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0419-rc-Annotation-RCUnownedLocalTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedLocalTest) +run(RCUnownedLocalTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java b/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8b065211bb05da2226b5a6f5725d7f893942cb05 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/RCUnownedLocalThreadTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.*; +import java.util.LinkedList; +import java.util.List; +class RCUnownedLocalTest extends Thread { + private boolean checkout; + Integer a = new Integer(1); + Object[] arr = new Object[]{1, 2, 3}; + @UnownedLocal + int method(Integer a, Object[] arr) { + int check = 0; + Integer c = a + a; + if (c == 2) { + check++; + } else { + check--; + } + for (Object array : arr) { + //System.out.println(array); + check++; + } + return check; + } + public void run() { + int result = method(a, arr); + if (result == 4) { + checkout = true; + } else { + checkout = false; + System.out.println("result:" + result); + } + } + public boolean check() { + return checkout; + } +} +public class RCUnownedLocalThreadTest { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + RCUnownedLocalTest rcTest1 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest2 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest3 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest4 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest5 = new RCUnownedLocalTest(); + RCUnownedLocalTest rcTest6 = new RCUnownedLocalTest(); + rcTest1.start(); + rcTest2.start(); + rcTest3.start(); + rcTest4.start(); + rcTest5.start(); + rcTest6.start(); + try { + rcTest1.join(); + rcTest2.join(); + rcTest3.join(); + rcTest4.join(); + rcTest5.join(); + rcTest6.join(); + } catch (InterruptedException e) { + } + if (rcTest1.check() && rcTest2.check() && rcTest3.check() && rcTest4.check() && rcTest5.check() && rcTest6.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/test.cfg b/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..940f5a56afee6fe269caf20deb1e8e6d76da511d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0420-rc-Annotation-RCUnownedLocalThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedLocalThreadTest) +run(RCUnownedLocalThreadTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java b/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java new file mode 100755 index 0000000000000000000000000000000000000000..472a6a1a620e90f2373bed23bd077b752382ae79 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/RCUnownedOuterTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.UnownedOuter; +import java.util.LinkedList; +import java.util.List; +public class RCUnownedOuterTest { + public static void main(String[] args) { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture(); + UnownedInner unownedInner = new UnownedInner(); + unownedInner.method(); + UnownedInner.InnerClass innerClass = unownedInner.new InnerClass(); + innerClass.myName(); + if (unownedAnnoymous.checkAnnoy == 1 && unownedInner.checkInner == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("unownedAnnoymous.checkAnnoy:" + unownedAnnoymous.checkAnnoy); + System.out.println("unownedInner.checkInner:" + unownedInner.checkInner); + } + } +} +class UnownedInner { + String name = "test"; + int checkInner = 0; + InnerClass innerClass; + void method() { + innerClass = new InnerClass(); + } + @UnownedOuter + class InnerClass { + void myName() { + checkInner = 0; + String myname; + myname = name + name; + if (myname.equals("testtest")) { + checkInner++; + } + } + } +} +class UnownedAnnoymous { + String name = "test"; + static int checkAnnoy; + void anonymousCapture() { + Runnable r = new Runnable() { + @UnownedOuter + @Override + public void run() { + checkAnnoy = 0; + String myName = name + name; + if (myName.equals("testtest")) { + checkAnnoy++; + } + } + }; + r.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/test.cfg b/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7dc848412e5ef37b9bbc7ba93d27d175d8b3feb1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0421-rc-Annotation-RCUnownedOuterTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedOuterTest) +run(RCUnownedOuterTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java new file mode 100755 index 0000000000000000000000000000000000000000..26e309311e5812e3e21e866e5e99da3739fafb03 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/SoftRefTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +public class SoftRefTest { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + public static void main(String[] args) throws Exception { + setSoftReference(); + new Thread(new TriggerRP()).start(); + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + } + Reference r = rq.poll(); + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + SoftReference sr = new SoftReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/expected.txt b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/test.cfg b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3d1f6aa3db27e895bfecddbfb51306296b5e8008 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0431-rc-SoftRef-SoftRefTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest) +run(SoftRefTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..50a5bb511f6ed1865cac90f477203a713492b311 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/SoftRefTest02.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +public class SoftRefTest02 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + public static void main(String[] args) throws Exception { + setSoftReference(); + for (int i = 0; i < 3; i++) { + System.gc(); + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + } + } + Reference r = rq.poll(); + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/expected.txt b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/test.cfg b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..42c45848a0e2bfb496fda56cf452545408e74922 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0432-rc-SoftRef-SoftRefTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest02) +run(SoftRefTest02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java new file mode 100755 index 0000000000000000000000000000000000000000..0c40fb00b1d5725efbe4ae3ebd815c636cf5bb1d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/SoftRefTest03.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +public class SoftRefTest03 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + public static void main(String[] args) throws Exception { + setSoftReference(); + for (int i = 0; i < 3; i++) { + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (rp.get() == null) { + System.out.println("Error Result when second check "); + a++; + break; //rp指向的对象不应该被释放,如果出现释放,则打印、a++;然后break跳出循环 + } + } + Reference r = rq.poll(); //ReferenceQueue里不应该有对象,poll返回值应该是空指针 + if (r != null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/expected.txt b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/test.cfg b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b23b1a8ccf3c8ce50c8f6e84c57b25a4f826a056 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0433-rc-SoftRef-SoftRefTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest03) +run(SoftRefTest03,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java new file mode 100755 index 0000000000000000000000000000000000000000..07aa576a47e0cd743c00cb8b3ea9892585f36472 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/SoftRefTest05.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +public class SoftRefTest05 { + static final int TEST_NUM = 1; + static int check_count = 0; + static int allSum; + public static void main(String[] args) { + for (int i = 0; i < TEST_NUM; i++) { + test_01(); + Runtime.getRuntime().gc(); + // resultLine = null; + test_01(); + if (allSum == 20) { + check_count++; + System.out.println("sum is srong"); + } + if (check_count == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println(" errorResult ----checkcount" + check_count); + } + } + } + private static void test_01() { + Cycle_A a1 = new Cycle_A(); + a1.cyb = new Cycle_B(); + a1.cyb.cyc = new Cycle_C(); + a1.cyb.cyc.cyd = new Cycle_D(); + a1.cyb.cyc.cyd.cya = a1; + allSum = a1.sum + a1.cyb.sum + a1.cyb.cyc.sum + a1.cyb.cyc.cyd.sum; + sleep(4000); + if ((a1.sr.get() == null) || (a1.cyb.sr.get() == null) || (a1.cyb.cyc.pr.get() == null) || (a1.cyb.cyc.cyd.str.get() == null)) { + check_count++; + } + } + private static void sleep(int sleepnum) { + try { + Thread.sleep(sleepnum); + } catch (InterruptedException e) { + System.out.println(Thread.currentThread().getStackTrace()[2].getClassName() + " sleep was Interrupted"); + } + } +} +class Cycle_A { + static StringBuffer a = new StringBuffer("ref_processor_cycle_A"); + Reference sr; + Cycle_B cyb; + int aNum; + int sum; + Cycle_A() { + a = new StringBuffer("ref_processor_cycle_A"); + sr = new SoftReference(a); + if (sr.get() == null) { + assert false; + } + a = null; + cyb = null; + aNum = 1; + } + int joinStr() { + try { + sum = aNum + cyb.bNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_B { + static StringBuffer b = new StringBuffer("ref_processor_cycle_B"); + Reference sr; + Cycle_C cyc; + int bNum; + int sum; + Cycle_B() { + b = new StringBuffer("ref_processor_cycle_B"); + sr = new SoftReference<>(b); + if (sr.get() == null) { + assert false; + } + b = null; + cyc = null; + bNum = 2; + } + int joinStr() { + try { + sum = bNum + cyc.cNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_C { + Reference pr; + Cycle_D cyd; + StringBuffer c = new StringBuffer("ref_processor_cycle_C"); + int sum; + int cNum; + Cycle_C() { + c = new StringBuffer("ref_processor_cycle_C"); + pr = new SoftReference<>(c); + if (pr.get() == null) { + assert false; + } + c = null; + cyd = null; + cNum = 3; + } + int joinStr() { + try { + sum = cNum + cyd.dNum; + } catch (Exception e) { + } + return sum; + } +} +class Cycle_D { + Reference str; + Cycle_A cya; + StringBuffer d = new StringBuffer("ref_processor_cycle_D"); + int dNum; + int sum; + Cycle_D() { + d = new StringBuffer("ref_processor_cycle_D"); + str = new SoftReference(d); + d = null; + cya = null; + dNum = 4; + } + int joinStr() { + try { + int sum = dNum + cya.aNum; + } catch (Exception e) { + } + return sum; + } +} diff --git a/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/expected.txt b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/test.cfg b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a02debc430a831d0b185cd9569aa19dce4226d31 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0435-rc-SoftRef-SoftRefTest05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest05) +run(SoftRefTest05,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..02f6f0a2911863ddeee1078fb61b4358be688bcb --- /dev/null +++ b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/RCHeaderTest04.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.lang.ref.SoftReference; +import com.huawei.ark.annotation.Weak; +class RCRunner04 implements Runnable { + public void run() { + RCHeaderTest04.iArray = null; + } +} +public class RCHeaderTest04 { + static int[] iArray; + @Weak + static int[] wr_annotation = null; + static Cleaner c = null; + static SoftReference sr = null; + public RCHeaderTest04() { + iArray = new int[4]; + int[] temp = {1, 2, 3, 4}; + wr_annotation = temp; + sr = new SoftReference<>(temp); + } + //方法退出后,实例变量sr声明周期结束,触发对SoftReference的处理,它指向的数组占用空间被释放。 + static void foo() { + RCHeaderTest04 rcht = new RCHeaderTest04(); + c = Cleaner.create(rcht.sr, new RCRunner04()); + if (c == null && wr_annotation.length != 4) { + System.out.println("Cleaner create failly"); + } + } + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + if (c != null && wr_annotation != null && sr.get() != null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/expected.txt b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/test.cfg b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9e3f91ecff66295ec17c27169712c6a11af68566 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0440-rc-RCHeader-RCHeaderTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest04) +run(RCHeaderTest04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java new file mode 100755 index 0000000000000000000000000000000000000000..66fe2f3304d975b9df6fed67f45ab82d26cc8520 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/PlacementRCTest01.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class B { + static A a; + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class A { + public int count = 0; + public String className = "A"; + public A(String name) { + this.className = name; + } + public void changeName(String name) { + this.className = name; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest01.lock) { + if (this.count % 25 == 0) { + PlacementRCTest01.result += ("End"); + } + } + B.a = this; + } +} +public class PlacementRCTest01 { + public volatile static String result = new String(); + public static String lock = ""; + private static volatile int count = 0; + private static A infiniteLoop = null; + private A defInsideUseOutside = null; + public static void onlyUseInsideLoop() { + A a1 = new A("a1"); + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count == 99) + a1.toString(); + } + Runtime.getRuntime().runFinalization(); + //try{ Thread.sleep(5000); } catch( Exception e ){ } + synchronized (PlacementRCTest01.lock) { + result += "Method1"; + } + } + public static void defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + A a2 = new A("a2_i" + count); + a2.count = count; + a2.changeName("null"); + for (int j = 0; j < 5; j++) { + a2 = new A("a2_i" + count + "_j" + j); + } + if (count == 99) { + a2.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method2"; + } + } + public void defInsideAndUseOutsideLoop() { + count = 0; + do { + this.defInsideUseOutside = new A("a2_i" + count); + this.defInsideUseOutside.count = count; + for (int j = 0; j < 2; j++) + this.defInsideUseOutside = new A("a2_i" + count + "_j" + j); + if (count == 99) + this.defInsideUseOutside.toString(); + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method3"; + } + } + public static void defInBranchInsideLoop() { + A a4 = new A("a4"); + for (count = 0; count < 100; count++) { + a4.changeName("a" + count); + a4.count = count; + if (count % 2 == 0) { + a4 = new A("a4_" + count); + } + a4.toString(); + } + a4.changeName("End"); + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method4"; + } + } + public static void infiniteLoop() { + infiniteLoop = new A("infinite loop"); + count = 0; + while (count < 100) { + A a5 = new A("a2_i" + count); + a5.changeName("null"); + a5.count = count; + infiniteLoop.changeName("infinite loop" + count); + for (int j = 0; j < 2; j++) { + a5 = new A("a2_i" + count + "_j" + j); + } + if (count == 99) { + a5.toString(); + } + count++; + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest01.lock) { + result += "Method5"; + } + } + public static void main(String[] args) { + onlyUseInsideLoop(); + defAndUseInsideLoop(); + new PlacementRCTest01().defInsideAndUseOutsideLoop(); + defInBranchInsideLoop(); + infiniteLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("Method4") && result.contains("Method5") && result.contains("End") && infiniteLoop.className.equals("infinite loop99")) + System.out.println("ExpectResult"); + else + System.out.println("ErrorResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/expected.txt b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/test.cfg b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..540208ba39e706f3b77fa1883642a5936a4bacc5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0443-rc-PlacementRC-PlacementRCTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(PlacementRCTest01) +run(PlacementRCTest01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java b/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..617658ea5aa7cda971954665ab33abe3c0006786 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/PlacementRCTest02.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class PlacementRC_A2 { + public int count = 0; + public String className = "A"; + public PlacementRC_A2(String name) { + this.className = name; + } + public void changeName(String name) { + this.className = name; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest02.lock) { + if (this.count % 25 == 0) { + PlacementRCTest02.result += ("End" + count); + } + } + } +} +public class PlacementRCTest02 { + public static String result = new String(); + public static String lock = ""; + private volatile static int count = 0; + private PlacementRC_A2 defInsideUseOutside = null; + public static void onlyUseInsideLoop() { + PlacementRC_A2 a1 = new PlacementRC_A2("a1"); + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count % 11 == 0) { + a1.changeName("a" + 100); + a1 = new PlacementRC_A2("a10"); + a1.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method1"; + } + } + public static void defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + PlacementRC_A2 a2 = new PlacementRC_A2("a2_i" + count); + a2.changeName("null"); + a2.count = count; + for (int j = 0; j < 2; j++) + a2 = new PlacementRC_A2("a2_i" + count + "_j" + j); + if (count % 11 == 0) { + a2.changeName("a" + 100); + a2 = new PlacementRC_A2("a10"); + a2.toString(); + } else { + a2.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method2"; + } + } + public static void main(String[] args) { + onlyUseInsideLoop(); + defAndUseInsideLoop(); + new PlacementRCTest02().defInsideAndUseOutsideLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("End")) + System.out.println("ExpectResult"); + else + System.out.println("Error Result"); + } + public void defInsideAndUseOutsideLoop() { + count = 0; + do { + int choice = count % 4; + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count); + switch (choice) { + case 1: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (count == 99) + this.defInsideUseOutside.toString(); + break; + case 2: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside.changeName("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + break; + case 3: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (this.defInsideUseOutside.className.equals("a2_i95_j4")) + System.out.println(this.defInsideUseOutside.className); + break; + default: + this.defInsideUseOutside = new PlacementRC_A2("a2_i" + count); + this.defInsideUseOutside.count = count; + } + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest02.lock) { + result += "Method3"; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/test.cfg b/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3d695603047deeca357bbbd2f9761df21ceda909 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0444-rc-PlacementRC-PlacementRCTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(PlacementRCTest02) +run(PlacementRCTest02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java b/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..1860e72f6a97de8caaa7a481fe8d7e0471280696 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/PlacementRCTest04.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.IllegalFormatException; +class PlacementRC_A4 { + public int count = 0; + public String className = "A"; + public PlacementRC_A4(String name) { + this.className = name; + } + public void changeName(String name) { + this.className = name; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "End"; + } + } +} +public class PlacementRCTest04 { + public static String result = ""; + public static String lock = ""; + static int res = 99; + public static void main(String[] argv) { + run1(); + Runtime.getRuntime().runFinalization(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // do nothing + } + if (result.contains("run1") && result.contains("run4") && result.contains("run5") && result.contains("run3") + && result.contains("run2") && result.contains("End")) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static int run1() { + int result = 2; + PlacementRC_A4 place = new PlacementRC_A4("run4"); + try { + place.className = "run1"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run1"; + } + result = run2(); + } catch (StringIndexOutOfBoundsException e) { + res--; + } + if (res == 96) { + result = 0; + res--; + } + return result; + } + private static int run2() { + int result = 2; + try { + PlacementRC_A4 place = new PlacementRC_A4("run4"); + result = run3(); + place.changeName("run2"); + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run2"; + } + } catch (ClassCastException e) { + res -= 2; + } + if (res == 95) { + result = 0; + } + return result; + } + private static int run3() { + int result = 3; + try { + result = run4(); + PlacementRC_A4 place = new PlacementRC_A4("run4"); + synchronized (PlacementRCTest04.lock) { + place.className = "run3"; + } + PlacementRCTest04.result += place.className; + } catch (IllegalStateException e) { + res -= 3; + } + if (res == 94) { + result = 0; + } + return result; + } + private static int run4() { + int result = 4; + try { + PlacementRC_A4 place = new PlacementRC_A4("run4"); + place.className = "run4"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run4"; + } + result = run5(); + } catch (IllegalFormatException e) { + res -= 4; + } + if (res == 93) { + result = 0; + } + return result; + } + private static int run5() { + int result = 5; + try { + result = ExcpCover03330(); + } catch (Exception e) { + res -= 5; + } + PlacementRC_A4 place = new PlacementRC_A4(" "); + if (res == 92) { + result = 0; + } + place.className = "run5"; + synchronized (PlacementRCTest04.lock) { + PlacementRCTest04.result += "run5"; + } + return result; + } + private static int ExcpCover03330() { + int result1 = 4; + PlacementRC_A4 place4 = new PlacementRC_A4("123#456"); + try { + Integer.parseInt(place4.className); + } catch (IndexOutOfBoundsException e) { + res -= 10; + } catch (IllegalArgumentException e) { + res--; + } finally { + res--; + try { + place4 = new PlacementRC_A4("123#4567"); + res += 100; + try { + place4 = new PlacementRC_A4("123#4568"); + PlacementRC_A4 place09 = new PlacementRC_A4("123#4561"); + res += 100; + place09.count = res; + try { + place4 = new PlacementRC_A4("123#4569"); + PlacementRC_A4 place9 = new PlacementRC_A4("123#4561"); + res += 100; + place9.count = res; + try { + place4 = new PlacementRC_A4("123#4560"); + PlacementRC_A4 place18 = new PlacementRC_A4("123#4561"); + res += 100; + place18.count = res; + place9.count = place18.count; + try { + place4 = new PlacementRC_A4("123#4561"); + PlacementRC_A4 place19 = new PlacementRC_A4("123#4561"); + res += 100; + place19.count = res; + place9.count = place19.count; + System.out.println(place4.className.substring(-5)); + } catch (ClassCastException e) { + place9.className = "catch info 1"; + res -= 10; + } finally { + res -= 100; + } + } catch (ClassCastException e1) { + place4.className = "catch info 2"; + res -= 10; + } finally { + res -= 100; + } + } catch (IllegalStateException e2) { + place09.className = "catch info 3"; + res -= 10; + } finally { + res -= 100; + } + } catch (ClassCastException e3) { + place4.className = "catch info 4"; + res -= 10; + } finally { + res -= 100; + } + } catch (IllegalArgumentException e4) { + place4.className = "catch info 5"; + res -= 10; + } finally { + res -= 100; + } + } + res -= 10; + place4.count = result1; + return place4.count; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/test.cfg b/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0dddb7403e99c73f0910c213b1ef5ee36734acbe --- /dev/null +++ b/testsuite/java_test/rc_test/RC0446-rc-PlacementRC-PlacementRCTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(PlacementRCTest04) +run(PlacementRCTest04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..4ffd24200a07c154ad92429788d11aeb045093cd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/FinalizerReferenceTest01.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class FinalizerReferenceTest01 { + static int check = 3; + public static void main(String[] args) { + SoftReference softReference = new SoftReference<>(new ReferenceTest01(10)); + ReferenceTest01 rt01 = softReference.get(); + if (rt01.stringArray.length == 10 && rt01.stringArray[9].equals("test9")) { + check--; + } + rt01 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + Runtime.getRuntime().runFinalization(); + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} +class ReferenceTest01 { + String[] stringArray; + public ReferenceTest01(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/expected.txt b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/test.cfg b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6d624d7e677e96b6d09d781b9225e9438510f7c2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0449-rc-RP-FinalizerReferenceTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest01) +run(FinalizerReferenceTest01,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..4bfe40be6a4712a330579df2f51dc61eb928e3d1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/FinalizerReferenceTest02.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +public class FinalizerReferenceTest02 { + static int check = 2; + public static void main(String[] args) { + WeakReference weakReference = new WeakReference<>(new ReferenceTest02(10)); + ReferenceTest02 rt02 = weakReference.get(); + if (rt02.stringArray.length == 10 && rt02.stringArray[9].equals("test9")) { + check--; + } + rt02 = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (weakReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} +class ReferenceTest02 { + String[] stringArray; + public ReferenceTest02(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/expected.txt b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/test.cfg b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..bd6f13aa2fbca2ff1489768f886c574d572ac472 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0450-rc-RP-FinalizerReferenceTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest02) +run(FinalizerReferenceTest02,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..e83266d106b2cdad6ba53bea9956b4d73ed4a156 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/FinalizerReferenceTest03.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +public class FinalizerReferenceTest03 { + static int check = 1; + public static void main(String[] args) { + ReferenceQueue referenceQueue = new ReferenceQueue(); + PhantomReference pr = new PhantomReference<>(new ReferenceTest03(10), referenceQueue); + if (pr.get() == null) { + check--; + } + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} +class ReferenceTest03 { + String[] stringArray; + public ReferenceTest03(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/expected.txt b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/test.cfg b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cca281e4047bc570edb2fbad1c227b67c5dd2959 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0451-rc-RP-FinalizerReferenceTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest03) +run(FinalizerReferenceTest03,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..b3cb949416d92a50dd38b176246a2b20b84458b2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/FinalizerReferenceTest04.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +public class FinalizerReferenceTest04 { + static Cleaner cleaner; + public static void main(String[] args) { + Cleaner.create(new ReferenceTest04(10), null); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + } +} +class ReferenceTest04 { + String[] stringArray; + public ReferenceTest04(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + for (int i = 0; i < this.stringArray.length; i++) { + stringArray[i] = null; + } + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/expected.txt b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/test.cfg b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..943520c16fd7080da07137f97057ca7a77d3abac --- /dev/null +++ b/testsuite/java_test/rc_test/RC0452-rc-RP-FinalizerReferenceTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest04) +run(FinalizerReferenceTest04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..47b8be9d9709a607c6e26e2ef279f20adb7d8cc4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/FinalizerReferenceTest05.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class FinalizerReferenceTest05 { + static SoftReference sr05; + static int check = 3; + public static void main(String[] args) { + new ReferenceTest05(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + ReferenceTest05 rt05 = sr05.get(); + if (rt05.stringArray.length == 10 && rt05.stringArray[9].equals("test9")) { + check--; + } + rt05 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + Runtime.getRuntime().runFinalization(); + if (sr05.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} +class ReferenceTest05 { + String[] stringArray; + public ReferenceTest05(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest05.sr05 = new SoftReference(this); + } +} diff --git a/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/expected.txt b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/test.cfg b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..bc7317ee8eb04391733c28a7a8e547a6792141c5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0453-rc-RP-FinalizerReferenceTest05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest05) +run(FinalizerReferenceTest05,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..dc4f8b17765bee5bae2458392f38c4e111583464 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/FinalizerReferenceTest06.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +public class FinalizerReferenceTest06 { + static WeakReference sr06; + static int check = 2; + public static void main(String[] args) { + new ReferenceTest06(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (sr06.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} +class ReferenceTest06 { + String[] stringArray; + public ReferenceTest06(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest06.sr06 = new WeakReference<>(this); + ReferenceTest06 rt06 = FinalizerReferenceTest06.sr06.get(); + if (rt06.stringArray.length == 10 && rt06.stringArray[9].equals("test9")) { + FinalizerReferenceTest06.check--; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/expected.txt b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/test.cfg b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d47f3b25c9acc3fa9a02a40aef28bd5eba6ec2ed --- /dev/null +++ b/testsuite/java_test/rc_test/RC0454-rc-RP-FinalizerReferenceTest06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest06) +run(FinalizerReferenceTest06,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java new file mode 100755 index 0000000000000000000000000000000000000000..b62be6083edf4e861f3abb9d281f7ecc33ef3c85 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/FinalizerReferenceTest07.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +public class FinalizerReferenceTest07 { + static ReferenceQueue referenceQueue = new ReferenceQueue(); + static PhantomReference sr07; + static int check = 2; + public static void main(String[] args) { + new ReferenceTest07(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + if (sr07.get() == null) { + check--; + } + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // do nothing + } + if (referenceQueue.poll() != null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} +class ReferenceTest07 { + String[] stringArray; + public ReferenceTest07(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + System.out.println("ExpectResult"); + FinalizerReferenceTest07.sr07 = new PhantomReference<>(this, FinalizerReferenceTest07.referenceQueue); + } +} diff --git a/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/expected.txt b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/test.cfg b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c34d634ce58934ec5bb95fe0469bd870254a0626 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0455-rc-RP-FinalizerReferenceTest07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest07) +run(FinalizerReferenceTest07,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java new file mode 100644 index 0000000000000000000000000000000000000000..cee40ead82519072bcea2a67ab24046a4451b82d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/FinalizerReferenceTest08.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +public class FinalizerReferenceTest08 { + static Cleaner cleaner; + static int check = 2; + public static void main(String[] args) { + new ReferenceTest08(10); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + } +} +class ReferenceTest08 { + String[] stringArray; + public ReferenceTest08(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } + @Override + public void finalize() { + System.out.println("ExpectResult"); + Cleaner.create(this, null); + } +} diff --git a/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/expected.txt b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/test.cfg b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..74cb39952e6b36d1f09dc82eed7e439e4706bd07 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0456-rc-RP-FinalizerReferenceTest08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FinalizerReferenceTest08) +run(FinalizerReferenceTest08,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java b/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..a45c226429ff530c3ed6255af27543ef13ce6ed0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/TriggerGCTest01.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class TriggerGCTest01 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + public static void main(String[] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + Thread.sleep(1000); + if (rp.get() != null) { + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/test.cfg b/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c3329376cfea189f534c20a093d826252da73e29 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0457-rc-GC-TriggerGCTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest01) +run(TriggerGCTest01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..45a292aeaceb8301f109186bccaf9b2946624e9b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/TriggerGCTest02.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class TriggerGCTest02 { + static Reference rp; + static ReferenceQueue rq = new ReferenceQueue(); + static int a = 100; + static void setWeakReference() { + rp = new WeakReference(new Object(), rq); + if (rp.get() == null) { + a++; + } + } + public static void main(String[] args) throws Exception { + Reference r; + setWeakReference(); + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + if (rp.get() != null) { + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 60; i++) { + WeakReference wr = new WeakReference(new Object()); + try { + Thread.sleep(50); + } catch (Exception e) { + } + } + } + } +} diff --git a/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/expected.txt b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/test.cfg b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3fcdd133278d56ddb98357af86c6c4d9dd188fb2 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0458-rc-GC-TriggerGCTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest02) +run(TriggerGCTest02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..ee2fe5fed36e84eb771fd369df53e2c830ca850a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/TriggerGCTest03.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class TriggerGCTest03 { + static int check = 3; + public static void main(String[] args) { + SoftReference softReference = new SoftReference<>(new Reference03(100000)); + Reference03 rt01 = softReference.get(); + if (rt01.stringArray.length == 100000 && rt01.stringArray[9].equals("test9")) { + check--; + } + rt01 = null; + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + Runtime.getRuntime().runFinalization(); + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + } + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 1034 * 1034; i <= 1034 * 1034 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} +class Reference03 { + String[] stringArray; + public Reference03(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/expected.txt b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/test.cfg b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ed20f57e87e0a2f780d5fa8d8a8d96831844c5f0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0459-rc-GC-TriggerGCTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest03) +run(TriggerGCTest03,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java new file mode 100644 index 0000000000000000000000000000000000000000..525d7917d32ca98d5da6fe2c7695d750a7b7f8dc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/TriggerGCTest07.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +public class TriggerGCTest07 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/expected.txt b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/test.cfg b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..510f1fb0b6ad0818a075d25cc6c3a661e862b22c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0463-rc-GC-TriggerGCTest07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest07) +run(TriggerGCTest07,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java new file mode 100644 index 0000000000000000000000000000000000000000..2af087ac8ebae6fd1e0550391a7636ce96e8bb47 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/TriggerGCTest08.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +public class TriggerGCTest08 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private final static int SEC_MEMORY = 150; // MB + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = INIT_MEMORY; i < SEC_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/expected.txt b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/test.cfg b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ed3cc73fbb4162bcfec9ec61a13a3be7dd09a464 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0464-rc-GC-TriggerGCTest08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest08) +run(TriggerGCTest08,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java new file mode 100644 index 0000000000000000000000000000000000000000..7041baed6fe9cc6fd5344f780c447fd16f6fd8e4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/TriggerGCTest09.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +public class TriggerGCTest09 { + static WeakReference observer; + static int check = 2; + private final static int SEC_MEMORY = 150; // MB + private final static int TRI_MEMORY = 225; // MB + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + for (int i = 0; i < SEC_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = SEC_MEMORY; i < TRI_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/expected.txt b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/test.cfg b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..46137686a72439d7ceb8a2285539a7c802894f27 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0465-rc-GC-TriggerGCTest09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest09) +run(TriggerGCTest09,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java new file mode 100644 index 0000000000000000000000000000000000000000..e1a2786f0c3ef4f077bf7b7c196d49a23c0fbe6d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/TriggerGCTest10.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +public class TriggerGCTest10 { + static WeakReference observer; + static int check = 2; + private final static int TRI_MEMORY = 225; // MB + private final static int FOU_MEMORY = 350; // MB + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + for (int i = 0; i < TRI_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(2000); + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + try { + for (int i = TRI_MEMORY; i < FOU_MEMORY; i++) { + byte[] temp = new byte[1024 * 1024]; + store.add(temp); + } + } catch (OutOfMemoryError e) { + // do nothing + } + Thread.sleep(1000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/expected.txt b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/test.cfg b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..30669c242f056e2aff7b62ea1c4d6ce3bfc817dd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0466-rc-GC-TriggerGCTest10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest10) +run(TriggerGCTest10,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b9cfe4a051386ffda18f170c9ad1968f90797ab3 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/ArrayCloneTest.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ArrayCloneTest { + public static void main(String[] args) { + if (functionTest01()) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static boolean functionTest01() { + String[] test1 = {"test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"}; + String[] test2 = test1.clone(); + if (test2 != test1 && test2.length == 10 && test2[0].equals("test1") && test2[9].equals("test10")) { + return true; + } + return false; + } +} diff --git a/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/expected.txt b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/test.cfg b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..fb7fa36156b04d98a5c5a9ccc9648ad3aeec6c3f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0468-rc-BindingMethod-ArrayCloneTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayCloneTest) +run(ArrayCloneTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..de1117f3afa94229c2864bfe94a4083953411d85 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/ArrayCloneTest02.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ArrayCloneTest02 { + private Integer id; + public ArrayCloneTest02(Integer id) { + this.id = id; + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + @Override + public String toString() { + return "CloneTest{" + + "id=" + id + + '}'; + } + public static void main(String[] args) { + try { + ArrayCloneTest02 cloneTest = new ArrayCloneTest02(1); + ArrayCloneTest02 cloneTest1 = (ArrayCloneTest02) cloneTest.clone(); + System.out.println("ErrorResult"); + } catch (CloneNotSupportedException e) { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/expected.txt b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/test.cfg b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..18dd65d0fd0d479af9f41e24f58225804f98f401 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0469-rc-BindingMethod-ArrayCloneTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayCloneTest02) +run(ArrayCloneTest02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c05d3ba8f510906bea482ad0d6a76521c8c77185 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/ArrayCopyTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ArrayCopyTest { + public static void main(String[] args) { + if (functionTest01() && functionTest02() && functionTest03() && functionTest04()) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static boolean functionTest01() { + String[] test1 = {"test1","test2","test3","test4","test5","test6","test7","test8","test9","test10"}; + String[] test2 = new String[10]; + System.arraycopy(test1,0,test2,0,10); + if (test2[0].equals("test1") && test2[9].equals("test10")) { + return true; + } + return false; + } + private static boolean functionTest02() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + int[] test2 = new int[10]; + System.arraycopy(test1, 0, test2, 0, 10); + } catch (ArrayStoreException e) { + return true; + } + return false; + } + private static boolean functionTest03() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + String[] test2 = new String[9]; + System.arraycopy(test1, 0, test2, 0, 10); + } catch (ArrayIndexOutOfBoundsException e) { + return true; + } + return false; + } + private static boolean functionTest04() { + try { + String[] test1 = {"test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8", "test9", "test10"}; + String[] test2 = null; + System.arraycopy(test1, 0, test2, 0, 10); + } catch (NullPointerException e) { + return true; + } + return false; + } +} diff --git a/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/expected.txt b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/test.cfg b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7a54a91dde39ec5b168e261988332a43276b82db --- /dev/null +++ b/testsuite/java_test/rc_test/RC0470-rc-BindingMethod-ArrayCopyTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ArrayCopyTest) +run(ArrayCopyTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java new file mode 100644 index 0000000000000000000000000000000000000000..cc5804979f3fd892d9b447ff9639304ff1d3c427 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/CB_01.java @@ -0,0 +1,355 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_Nolcycle_a_00180_A1 { + CB_Nolcycle_a_00180_B1 b1_0; + CB_Nolcycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class CB_Nolcycle_a_00180_A2 { + CB_Nolcycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class CB_Nolcycle_a_00180_A3 { + CB_Nolcycle_a_00180_B2 b2_0; + CB_Nolcycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class CB_Nolcycle_a_00180_A4 { + CB_Nolcycle_a_00180_B3 b3_0; + CB_Nolcycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class CB_Nolcycle_a_00180_B1 { + CB_Nolcycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class CB_Nolcycle_a_00180_B2 { + CB_Nolcycle_a_00180_C1 c1_0; + CB_Nolcycle_a_00180_D1 d1_0; + CB_Nolcycle_a_00180_D2 d2_0; + CB_Nolcycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class CB_Nolcycle_a_00180_B3 { + CB_Nolcycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class CB_Nolcycle_a_00180_C1 { + CB_Nolcycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class CB_Nolcycle_a_00180_C2 { + CB_Nolcycle_a_00180_D2 d2_0; + CB_Nolcycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class CB_Nolcycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class CB_Nolcycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +//该树有12个节点 +class CB_Nolcycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + CB_Nolcycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class CB_Nolcycle_a_00180 { + public CB_Nolcycle_a_00180() { + CB_Nolcycle_a_00180_A1 a1_main = new CB_Nolcycle_a_00180_A1("a1_main"); + CB_Nolcycle_a_00180_A2 a2_main = new CB_Nolcycle_a_00180_A2("a2_main"); + CB_Nolcycle_a_00180_A3 a3_main = new CB_Nolcycle_a_00180_A3("a3_main"); + CB_Nolcycle_a_00180_A4 a4_main = new CB_Nolcycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new CB_Nolcycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new CB_Nolcycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new CB_Nolcycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new CB_Nolcycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + a4_main.b3_0 = new CB_Nolcycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new CB_Nolcycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new CB_Nolcycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new CB_Nolcycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new CB_Nolcycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new CB_Nolcycle_a_00180_D3("d3_0"); + } +} +class CB_01_A1 { + static HashMap test1; + static + int a; + CB_01_A2 a2_0; + CB_01_A3 a3_0; + int sum; + String strObjectName; + CB_01_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + //System.out.println("A finalize"); + CB_01.check = this; + } +} +class CB_01_A2 { + static CB_01_A1 a1_0; + volatile static HashMap test2; + CB_01_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_01_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + CB_01_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_01_A3 { + static CB_Nolcycle_a_00180[] test1; + CB_01_A1 a1_0; + CB_01_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_01_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_01_A1.a + a2_0.a; + } +} +public class CB_01 { + public static CB_01_A1 check = null; + private static CB_01_A1 a1_main = null; + private CB_01() { + a1_main = new CB_01_A1("a1_main"); + a1_main.a2_0 = new CB_01_A2("a2_0"); + CB_01_A2.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_01(int times) { + CB_01_A1.test1 = new HashMap(); + CB_01_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_01_A1.test1.put(i, new CB_Nolcycle_a_00180()); + CB_01_A2.test2.put(i, new CB_Nolcycle_a_00180()); + } + } + private static void rc_testcase_main_wrapper() { + CB_01 cb01 = new CB_01(); + test_CB_01(10000); + check = a1_main; + try { + int result = CB_01.check.sum + CB_01.check.a2_0.sum + CB_01.check.a2_0.a3_0.sum + CB_01_A1.test1.size() + CB_01_A2.test2.size(); + if (result == 20918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/expected.txt b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/test.cfg b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c57edd57d46b673262bb7cec6e6c82e3ddef0a12 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0477-rc-StackScan-CB_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_01) +run(CB_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java new file mode 100644 index 0000000000000000000000000000000000000000..a3b5a7cf7e16d97e49d25a4d99f6dfca7c3547a9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/CB_02.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_02_A1 { + static HashMap test1; + static + int a; + CB_02_A2 a2_0; + CB_02_A3 a3_0; + int sum; + String strObjectName; + CB_02_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_02.check = this; + } +} +class CB_02_A2 { + volatile static HashMap test2; + CB_02_A1 a1_0; + CB_02_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_02_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + CB_02_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_02_A3 { + CB_02_A1 a1_0; + CB_02_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_02_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + CB_02_A1.a + a2_0.a; + } +} +public class CB_02 { + public volatile static CB_02_A1 check = null; + private static CB_02_A1 a1_main = null; + private CB_02() { + a1_main = new CB_02_A1("a1_main"); + a1_main.a2_0 = new CB_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_02(int times) { + CB_02_A1.test1 = new HashMap(); + CB_02_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_02_A1.test1.put(i, "Maple" + i); + CB_02_A2.test2.put(i, "Figo" + i); + } + } + private static void rc_testcase_main_wrapper() { + CB_02 cb01 = new CB_02(); + test_CB_02(100000); + check = a1_main; + try { + int result = CB_02.check.sum + CB_02.check.a2_0.sum + CB_02.check.a2_0.a3_0.sum + CB_02_A1.test1.size() + CB_02_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/expected.txt b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/test.cfg b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..905f28850ade92bb23c90b0786a1e0345c84604b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0478-rc-StackScan-CB_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_02) +run(CB_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java new file mode 100644 index 0000000000000000000000000000000000000000..14fa5760cbf08a5c8d516ffce50a6abd1c547b08 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/CB_03.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_03_A1 { + static HashMap test1; + static + int a; + CB_03_A2 a2_0; + CB_03_A3 a3_0; + int sum; + String strObjectName; + CB_03_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_03.check = this; + } +} +class CB_03_A2 { + CB_03_A1 a1_0; + CB_03_A3 a3_0; + volatile HashMap test2; + int a; + int sum; + String strObjectName; + CB_03_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_03_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_03_A3 { + CB_03_A1 a1_0; + CB_03_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_03_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_03_A1.a + a2_0.a; + } +} +public class CB_03 { + public volatile static CB_03_A1 check = null; + private static CB_03_A1 a1_main = null; + private CB_03() { + a1_main = new CB_03_A1("a1_main"); + a1_main.a2_0 = new CB_03_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_03_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_03(int times) { + CB_03_A1.test1 = new HashMap(); + a1_main.a2_0.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_03_A1.test1.put(i, new StringBuffer("Maple test").append(i)); + a1_main.a2_0.test2.put(i, new StringBuffer("Figo test").append(i)); + } + } + private static void rc_testcase_main_wrapper() { + CB_03 cb01 = new CB_03(); + test_CB_03(100000); + check = a1_main; + try { + int result = CB_03.check.sum + CB_03.check.a2_0.sum + CB_03.check.a2_0.a3_0.sum + CB_03_A1.test1.size() + check.a2_0.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/expected.txt b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/test.cfg b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5ef644516de4fa076e76e9050c5b2b609290c93d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0479-rc-StackScan-CB_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_03) +run(CB_03,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java new file mode 100644 index 0000000000000000000000000000000000000000..ee788dfc7018863bc2b3d30c5622f40242762d9b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/CB_04.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_04_A1 { + static HashMap test1; + static + int a; + CB_04_A2 a2_0; + CB_04_A3 a3_0; + int sum; + String strObjectName; + CB_04_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("A finalize"); + CB_04.check = this; + } +} +class CB_04_A2 { + volatile static HashMap test2; + CB_04_A1 a1_0; + CB_04_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_04_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + CB_04_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } +} +class CB_04_A3 { + CB_04_A1 a1_0; + CB_04_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_04_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + CB_04_A1.a + a2_0.a; + } +} +public class CB_04 { + public static CB_04_A1 a1_main = null; + public volatile static CB_04_A1 check = null; + public CB_04() { + a1_main = new CB_04_A1("a1_main"); + a1_main.a2_0 = new CB_04_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_04_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + public static void test_CB_04(int times) { + CB_04_A1.test1 = new HashMap(); + CB_04_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_04_A1.test1.put(i, new StringBuilder().append(i)); + CB_04_A2.test2.put(i, new StringBuilder().append(times + i)); + } + } + public static void rc_testcase_main_wrapper() { + CB_04 cb01 = new CB_04(); + test_CB_04(100000); + check = a1_main; + try { + int result = CB_04.check.sum + CB_04.check.a2_0.sum + CB_04.check.a2_0.a3_0.sum + CB_04_A1.test1.size() + CB_04_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/expected.txt b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/test.cfg b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..81b9e7a2ec90403105e7828e8bda1b46ff089dcc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0480-rc-StackScan-CB_04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_04) +run(CB_04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java new file mode 100644 index 0000000000000000000000000000000000000000..f76a2c81b2246aaf74ba2c90fd0d3cbe23a81a13 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/CB_05.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.HashMap; +class CB_05_A1 { + static HashMap test1; + static + int a; + CB_05_A2 a2_0; + CB_05_A3 a3_0; + int sum; + String strObjectName; + CB_05_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_05.check = this; + } +} +class CB_05_A2 { + volatile static HashMap test2; + CB_05_A1 a1_0; + CB_05_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_05_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_05_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_05_A3 { + CB_05_A1 a1_0; + CB_05_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_05_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_05_A1.a + a2_0.a; + } +} +public class CB_05 { + public volatile static CB_05_A1 check = null; + private static CB_05_A1 a1_main = null; + private CB_05() { + a1_main = new CB_05_A1("a1_main"); + a1_main.a2_0 = new CB_05_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_05_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_05(int times) { + CB_05_A1.test1 = new HashMap(); + CB_05_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_05_A1.test1.put(i, new SoftReference<>("maple" + i)); + CB_05_A2.test2.put(i, new SoftReference<>("maple" + times + i)); + } + } + private static void rc_testcase_main_wrapper() { + CB_05 cb01 = new CB_05(); + test_CB_05(10000); + check = a1_main; + try { + int result = CB_05.check.sum + CB_05.check.a2_0.sum + CB_05.check.a2_0.a3_0.sum + CB_05_A1.test1.size() + CB_05_A2.test2.size(); + if (result == 20918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/expected.txt b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/test.cfg b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..fb511097b9665a89fb9479ce29ba817bfe78bc61 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0481-rc-StackScan-CB_05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_05) +run(CB_05,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java new file mode 100644 index 0000000000000000000000000000000000000000..506b81175d2c082ca9806f02bf4cb50fc0ba0e7e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/CB_06.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.HashMap; +class CB_06_A1 { + static HashMap test1; + static + int a; + CB_06_A2 a2_0; + CB_06_A3 a3_0; + int sum; + String strObjectName; + CB_06_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_06.check = this; + } +} +class CB_06_A2 { + volatile static HashMap test2; + CB_06_A1 a1_0; + CB_06_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_06_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_06_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_06_A3 { + CB_06_A1 a1_0; + CB_06_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_06_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_06_A1.a + a2_0.a; + } +} +public class CB_06 { + public volatile static CB_06_A1 check = null; + static String str; + private static CB_06_A1 a1_main = null; + private CB_06() { + a1_main = new CB_06_A1("a1_main"); + a1_main.a2_0 = new CB_06_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_06_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_06(int times) { + CB_06_A1.test1 = new HashMap(); + CB_06_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_06_A1.test1.put(i, new WeakReference("Maple" + i)); + CB_06_A2.test2.put(i, new WeakReference("Figo" + i)); + } + } + private static void rc_testcase_main_wrapper() { + CB_06 cb01 = new CB_06(); + test_CB_06(100000); + check = a1_main; + try { + int result = CB_06.check.sum + CB_06.check.a2_0.sum + CB_06.check.a2_0.a3_0.sum + CB_06_A1.test1.size() + CB_06_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/expected.txt b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/test.cfg b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2f84e68a73833eb19f11617ebc3abcaaffef03e1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0482-rc-StackScan-CB_06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_06) +run(CB_06,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java new file mode 100644 index 0000000000000000000000000000000000000000..aeb3880671642a8066f4ce33b8365eb3ca2e4289 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/CB_07.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +import java.util.HashMap; +class CB_07_A1 { + static HashMap test1; + static + int a; + CB_07_A2 a2_0; + CB_07_A3 a3_0; + int sum; + String strObjectName; + CB_07_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_07.check = this; + } +} +class CB_07_A2 { + volatile static HashMap test2; + CB_07_A1 a1_0; + CB_07_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_07_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_07_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_07_A3 { + CB_07_A1 a1_0; + CB_07_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_07_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_07_A1.a + a2_0.a; + } +} +public class CB_07 { + public volatile static CB_07_A1 check = null; + static ReferenceQueue rq = new ReferenceQueue(); + static String str; + private static CB_07_A1 a1_main = null; + private CB_07() { + a1_main = new CB_07_A1("a1_main"); + a1_main.a2_0 = new CB_07_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_07_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_07(int times) { + CB_07_A1.test1 = new HashMap(); + CB_07_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_07_A1.test1.put(i, new PhantomReference<>("maple" + i, rq)); + CB_07_A2.test2.put(i, new PhantomReference<>("Figo" + times + i, rq)); + } + } + private static void rc_testcase_main_wrapper() { + CB_07 cb01 = new CB_07(); + test_CB_07(100000); + check = a1_main; + try { + int result = CB_07.check.sum + CB_07.check.a2_0.sum + CB_07.check.a2_0.a3_0.sum + CB_07_A1.test1.size() + CB_07_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/expected.txt b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/test.cfg b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..753f3cbe98a77c72b6fc9253f037962140eba1cd --- /dev/null +++ b/testsuite/java_test/rc_test/RC0483-rc-StackScan-CB_07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_07) +run(CB_07,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java new file mode 100644 index 0000000000000000000000000000000000000000..9aea8e5611d0bdbb8d3f7c2e9cec4e0906e9ea89 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/CB_08.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_08_A1 { + static HashMap test1; + static + int a; + CB_08_A2 a2_0; + CB_08_A3 a3_0; + int sum; + String strObjectName; + CB_08_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_08.check = this; + } +} +class CB_08_A2 { + volatile static HashMap test2; + CB_08_A1 a1_0; + CB_08_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_08_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_08_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_08_A3 { + CB_08_A1 a1_0; + CB_08_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_08_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_08_A1.a + a2_0.a; + } +} +public class CB_08 { + public volatile static CB_08_A1 check = null; + private static CB_08_A1 a1_main = null; + private volatile static OutOfMemoryError test1; + private static OutOfMemoryError test2; + private CB_08() { + a1_main = new CB_08_A1("a1_main"); + a1_main.a2_0 = new CB_08_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_08_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + private static void test_CB_08(int times) { + CB_08_A1.test1 = new HashMap(); + CB_08_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + test1 = new OutOfMemoryError(); + CB_08_A1.test1.put(i, test1); + test2 = new OutOfMemoryError(); + CB_08_A2.test2.put(i, test2); + } + } + private static void rc_testcase_main_wrapper() { + CB_08 cb01 = new CB_08(); + test_CB_08(100000); + check = a1_main; + try { + int result = CB_08.check.sum + CB_08.check.a2_0.sum + CB_08.check.a2_0.a3_0.sum + CB_08_A1.test1.size() + CB_08_A2.test2.size(); + if (result == 200918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/expected.txt b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/test.cfg b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0e9f5caa72af33bf88565390b60ccf2e1d25f8f5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0484-rc-StackScan-CB_08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_08) +run(CB_08,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java new file mode 100644 index 0000000000000000000000000000000000000000..88ddccdcad4c484701c79beea06d6c1f082b818e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/CB_09.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_09_A1 { + static HashMap test1; + static + int a; + CB_09_A2 a2_0; + CB_09_A3 a3_0; + int sum; + String strObjectName; + CB_09_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_09.check = this; + } +} +class CB_09_A2 { + volatile static HashMap test2; + CB_09_A1 a1_0; + CB_09_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_09_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_09_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_09_A3 { + CB_09_A1 a1_0; + CB_09_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_09_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_09_A1.a + a2_0.a; + } +} +public class CB_09 { + public static CB_09_A1 a1_main = null; + public volatile static CB_09_A1 check = null; + public volatile static ClassLoader test1; + public static ClassLoader test2; + public CB_09() { + a1_main = new CB_09_A1("a1_main"); + a1_main.a2_0 = new CB_09_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_09_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + } + public static void test_CB_09(int times) { + CB_09_A1.test1 = new HashMap(); + CB_09_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + test1 = CB_09_A1.class.getClassLoader(); + CB_09_A1.test1.put(i, test1); + test2 = CB_09_A1.class.getClassLoader(); + CB_09_A2.test2.put(i, test2); + } + } + public static void rc_testcase_main_wrapper() { + CB_09 cb01 = new CB_09(); + test_CB_09(100000); + check = a1_main; + try { + int result = CB_09.check.sum + CB_09.check.a2_0.sum + CB_09.check.a2_0.a3_0.sum; + if (result == 918) + System.out.println("ExpectResult"); + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } +} diff --git a/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/expected.txt b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/test.cfg b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4b951b8d2a02920d763382fe1c8bb5ee307347a8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0485-rc-StackScan-CB_09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_09) +run(CB_09,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java new file mode 100644 index 0000000000000000000000000000000000000000..89e58c20b4392cc8eb459a74740c688c23720580 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/CB_Thread_01.java @@ -0,0 +1,357 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_Nocycle_a_00180_A1 { + CB_Nocycle_a_00180_B1 b1_0; + CB_Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class CB_Nocycle_a_00180_A2 { + CB_Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b2_0.a; + } +} +class CB_Nocycle_a_00180_A3 { + CB_Nocycle_a_00180_B2 b2_0; + CB_Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class CB_Nocycle_a_00180_A4 { + CB_Nocycle_a_00180_B3 b3_0; + CB_Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class CB_Nocycle_a_00180_B1 { + CB_Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + d2_0.a; + } +} +class CB_Nocycle_a_00180_B2 { + CB_Nocycle_a_00180_C1 c1_0; + CB_Nocycle_a_00180_D1 d1_0; + CB_Nocycle_a_00180_D2 d2_0; + CB_Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class CB_Nocycle_a_00180_B3 { + CB_Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + c1_0.a; + } +} +class CB_Nocycle_a_00180_C1 { + CB_Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + d1_0.a; + } +} +class CB_Nocycle_a_00180_C2 { + CB_Nocycle_a_00180_D2 d2_0; + CB_Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class CB_Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CB_Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +// 该树有12个节点 +class CB_Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + CB_Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; + // System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class CB_Nocycle_a_00180 { + public CB_Nocycle_a_00180() { + CB_Nocycle_a_00180_A1 a1_main = new CB_Nocycle_a_00180_A1("a1_main"); + CB_Nocycle_a_00180_A2 a2_main = new CB_Nocycle_a_00180_A2("a2_main"); + CB_Nocycle_a_00180_A3 a3_main = new CB_Nocycle_a_00180_A3("a3_main"); + CB_Nocycle_a_00180_A4 a4_main = new CB_Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new CB_Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new CB_Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a2_main.b2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0 = new CB_Nocycle_a_00180_B2("b2_0"); + a3_main.b2_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a3_main.b2_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a3_main.b2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a3_main.b2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + a3_main.c2_0 = new CB_Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a3_main.c2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + a4_main.b3_0 = new CB_Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = new CB_Nocycle_a_00180_C1("c1_0"); + a4_main.b3_0.c1_0.d1_0 = new CB_Nocycle_a_00180_D1("d1_0"); + a4_main.c2_0 = new CB_Nocycle_a_00180_C2("c2_0"); + a4_main.c2_0.d2_0 = new CB_Nocycle_a_00180_D2("d2_0"); + a4_main.c2_0.d3_0 = new CB_Nocycle_a_00180_D3("d3_0"); + } +} +class CB_Thread_01_A1 { + static HashMap test1; + static + int a; + CB_Thread_01_A2 a2_0; + CB_Thread_01_A3 a3_0; + int sum; + String strObjectName; + CB_Thread_01_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + // System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + // System.out.println("A finalize"); + CB_Thread_01.check = this; + } +} +class CB_Thread_01_A2 { + volatile static HashMap test2; + CB_Thread_01_A1 a1_0; + CB_Thread_01_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_Thread_01_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_Thread_01_A1.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); +// System.out.println("B finalize"); + } +} +class CB_Thread_01_A3 { + static CB_Nocycle_a_00180[] test1; + CB_Thread_01_A1 a1_0; + CB_Thread_01_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_Thread_01_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_Thread_01_A1.a + a2_0.a; + } +} +class CB_Thread_01_test extends Thread { + private static CB_Thread_01_A1 a1_main = null; + private static void test_CB_Thread_01(int times) { + CB_Thread_01_A1.test1 = new HashMap(); + CB_Thread_01_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_Thread_01_A1.test1.put(i, new CB_Nocycle_a_00180()); + CB_Thread_01_A2.test2.put(i, new CB_Nocycle_a_00180()); + } + } + public void run() { + a1_main = new CB_Thread_01_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_01_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + test_CB_Thread_01(10000); + a1_main = null; + CB_Thread_01.check = null; + } +} +public class CB_Thread_01 { + public static CB_Thread_01_A1 check = null; + private static CB_Thread_01_A1 a1_main = null; + private static CB_Thread_01_test cbtest1; + private volatile static CB_Thread_01_test cbtest2; + public static void main(String[] args) { + a1_main = new CB_Thread_01_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_01_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_01_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + try { + int result = CB_Thread_01.check.sum + CB_Thread_01.check.a2_0.sum + CB_Thread_01.check.a2_0.a3_0.sum; + if (result == 918) { + System.out.println("ExpectResult"); + } + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/expected.txt b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/test.cfg b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d4bdedd7b1d41280480bb90450bd715b104a2f8a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0486-rc-StackScan-CB_Thread_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_Thread_01) +run(CB_Thread_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java new file mode 100644 index 0000000000000000000000000000000000000000..831d33bae443f17fb5f804b2801071c0a48b7a65 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/CB_Thread_02.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.HashMap; +class CB_Thread_02_A1 { + static HashMap test1; + static + int a; + CB_Thread_02_A2 a2_0; + CB_Thread_02_A3 a3_0; + int sum; + String strObjectName; + CB_Thread_02_A1(String strObjectName) { + a2_0 = null; + a3_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a2_0.a + a3_0.a; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + CB_Thread_02_test.check = this; + } +} +class CB_Thread_02_A2 { + volatile static HashMap test2; + CB_Thread_02_A1 a1_0; + CB_Thread_02_A3 a3_0; + int a; + int sum; + String strObjectName; + CB_Thread_02_A2(String strObjectName) { + a1_0 = null; + a3_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_Thread_02_A1.a + a3_0.a; + } + public void finalize() throws Throwable { + super.finalize(); + } +} +class CB_Thread_02_A3 { + CB_Thread_02_A1 a1_0; + CB_Thread_02_A2 a2_0; + int a; + int sum; + String strObjectName; + CB_Thread_02_A3(String strObjectName) { + a1_0 = null; + a2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + CB_Thread_02_A1.a + a2_0.a; + } +} +class CB_Thread_02_test extends Thread { + public volatile static CB_Thread_02_A1 check = null; + private static CB_Thread_02_A1 a1_main = null; + private static void test_CB_Thread_02(int times) { + CB_Thread_02_A1.test1 = new HashMap(); + CB_Thread_02_A2.test2 = new HashMap(); + for (int i = 0; i < times; i++) { + CB_Thread_02_A1.test1.put(i, "Maple" + i); + CB_Thread_02_A2.test2.put(i, "Figo" + i); + } + } + public void run() { + a1_main = new CB_Thread_02_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + test_CB_Thread_02(10000); + a1_main = null; + CB_Thread_02_test.check = null; + } +} +public class CB_Thread_02 { + private static CB_Thread_02_A1 a1_main = null; + public static void main(String[] args) { + a1_main = new CB_Thread_02_A1("a1_main"); + a1_main.a2_0 = new CB_Thread_02_A2("a2_0"); + a1_main.a2_0.a1_0 = a1_main; + a1_main.a2_0.a3_0 = new CB_Thread_02_A3("a3_0"); + a1_main.a3_0 = a1_main.a2_0.a3_0; + a1_main.a3_0.a1_0 = a1_main; + a1_main.a3_0.a2_0 = a1_main.a2_0; + a1_main.add(); + a1_main.a2_0.add(); + a1_main.a2_0.a3_0.add(); + a1_main = null; + Runtime.getRuntime().gc(); + Runtime.getRuntime().runFinalization(); + try { + int result = CB_Thread_02_test.check.sum + CB_Thread_02_test.check.a2_0.sum + + CB_Thread_02_test.check.a2_0.a3_0.sum; + if (result == 918) { + System.out.println("ExpectResult"); + } + } catch (NullPointerException n) { + System.out.println("ErrorResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/expected.txt b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/test.cfg b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4bdab2b9cec7ed38637649008aa01612f6ce341f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0487-rc-StackScan-CB_Thread_02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CB_Thread_02) +run(CB_Thread_02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java new file mode 100644 index 0000000000000000000000000000000000000000..1e84acb4e86d6bc27bbca20533df73c89cf03d09 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/CP_Thread_03.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class CP_Thread_03_A1 { + static StringBuffer[] test1; + static + int a; + CP_Thread_03_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_03_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_03_test extends Thread { + private static CP_Thread_03_A1 a1_main = null; + private volatile static CP_Thread_03_A1 a2 = null; + private volatile static StringBuffer test1; + private static StringBuffer test2; + private static void test_CP_Thread_03_A1(int times) { + CP_Thread_03_A1.test1 = new StringBuffer[times]; + for (int i = 0; i < times; i++) { + test1 = new StringBuffer("maple" + i); + CP_Thread_03_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_03_A2(int times) { + CP_Thread_03_A1.test1 = new StringBuffer[times]; + for (int i = 0; i < times; i++) { + test2 = new StringBuffer("maple" + times + i); + CP_Thread_03_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_03_A1("a1_main"); + a2 = new CP_Thread_03_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_03_A1(10000); + test_CP_Thread_03_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_03 { + private static CP_Thread_03_A1 a1_main = null; + private volatile static CP_Thread_03_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_03_test cptest1 = new CP_Thread_03_test(); + cptest1.run(); + CP_Thread_03_test cptest2 = new CP_Thread_03_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/expected.txt b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/test.cfg b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..399dd7af983389111eb7ada7d3beed86ac52093b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0488-rc-StackScan-CP_Thread_03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_03) +run(CP_Thread_03,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java new file mode 100644 index 0000000000000000000000000000000000000000..70d315602af4df784137714fa3d0dd68820503ab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/CP_Thread_04.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class CP_Thread_04_A1 { + static StringBuilder[] test1; + static + int a; + CP_Thread_04_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_04_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_04_test extends Thread { + private static CP_Thread_04_A1 a1_main = null; + private volatile static CP_Thread_04_A1 a2 = null; + private volatile static StringBuilder test1; + private static StringBuilder test2; + private static void test_CP_Thread_04_A1(int times) { + CP_Thread_04_A1.test1 = new StringBuilder[times]; + for (int i = 0; i < times; i++) { + test1 = new StringBuilder("maple" + i); + CP_Thread_04_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_04_A2(int times) { + CP_Thread_04_A1.test1 = new StringBuilder[times]; + for (int i = 0; i < times; i++) { + test2 = new StringBuilder("maple" + times + i); + CP_Thread_04_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_04_A1("a1_main"); + a2 = new CP_Thread_04_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_04_A1(10000); + test_CP_Thread_04_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_04 { + private static CP_Thread_04_A1 a1_main = null; + private static CP_Thread_04_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_04_test cptest1 = new CP_Thread_04_test(); + cptest1.run(); + CP_Thread_04_test cptest2 = new CP_Thread_04_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/expected.txt b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/test.cfg b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4498db34a210c7f685ef1a9752251e8e63480bc1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0489-rc-StackScan-CP_Thread_04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_04) +run(CP_Thread_04,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java new file mode 100644 index 0000000000000000000000000000000000000000..cc6b56bf24506b385721d1a1a926797c681363c9 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/CP_Thread_05.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +class CP_Thread_05_A1 { + static SoftReference[] test1; + static + int a; + CP_Thread_05_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_05_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_05_test extends Thread { + static String str; + private static CP_Thread_05_A1 a1_main = null; + private volatile static CP_Thread_05_A1 a2 = null; + private volatile static SoftReference test1; + private static SoftReference test2; + private static void test_CP_Thread_05_A1(int times) { + CP_Thread_05_A1.test1 = new SoftReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + test1 = new SoftReference<>(str); + CP_Thread_05_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_05_A2(int times) { + CP_Thread_05_A1.test1 = new SoftReference[times]; + for (int i = 0; i < times; i++) { + test2 = new SoftReference<>("maple" + times + i); + CP_Thread_05_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_05_A1("a1_main"); + a2 = new CP_Thread_05_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_05_A1(10000); + test_CP_Thread_05_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_05 { + private static CP_Thread_05_A1 a1_main = null; + private static CP_Thread_05_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_05_test cptest1 = new CP_Thread_05_test(); + cptest1.run(); + CP_Thread_05_test cptest2 = new CP_Thread_05_test(); + cptest2.run(); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/expected.txt b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/test.cfg b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f86e896d1c516360a92b496161228d8793342923 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0490-rc-StackScan-CP_Thread_05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_05) +run(CP_Thread_05,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java new file mode 100644 index 0000000000000000000000000000000000000000..d774cc0569ef525bad87425215f43cb6d084260d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/CP_Thread_06.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +class CP_Thread_06_A1 { + static WeakReference[] test1; + static + int a; + CP_Thread_06_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_06_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_06_test extends Thread { + static String str; + private static CP_Thread_06_A1 a1_main = null; + private volatile static CP_Thread_06_A1 a2 = null; + private volatile static WeakReference test1; + private static WeakReference test2; + private static void test_CP_Thread_06_A1(int times) { + CP_Thread_06_A1.test1 = new WeakReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + test1 = new WeakReference<>(str); + CP_Thread_06_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_06_A2(int times) { + CP_Thread_06_A1.test1 = new WeakReference[times]; + for (int i = 0; i < times; i++) { + test2 = new WeakReference<>("maple" + times + i); + CP_Thread_06_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_06_A1("a1_main"); + a2 = new CP_Thread_06_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_06_A1(10000); + test_CP_Thread_06_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_06 { + private static CP_Thread_06_A1 a1_main = null; + private static CP_Thread_06_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_06_test cptest1 = new CP_Thread_06_test(); + cptest1.run(); + CP_Thread_06_test cptest2 = new CP_Thread_06_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/expected.txt b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/test.cfg b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c1c130e02a1f14ce514724a3220d8030f95f0a1d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0491-rc-StackScan-CP_Thread_06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_06) +run(CP_Thread_06,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java new file mode 100644 index 0000000000000000000000000000000000000000..54661251e9ea4867f69e2434d20bc654886dc48f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/CP_Thread_07.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.PhantomReference; +import java.lang.ref.ReferenceQueue; +class CP_Thread_07_A1 { + static PhantomReference[] test1; + static + int a; + CP_Thread_07_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_07_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_07_test extends Thread { + static ReferenceQueue rq = new ReferenceQueue(); + static String str; + private static CP_Thread_07_A1 a1_main = null; + private volatile static CP_Thread_07_A1 a2 = null; + private static void test_CP_Thread_07_A1(int times) { + CP_Thread_07_A1.test1 = new PhantomReference[times]; + for (int i = 0; i < times; i++) { + str = "maple" + i; + PhantomReference temp = new PhantomReference<>(str, rq); + CP_Thread_07_A1.test1[i] = temp; + } + } + private static void test_CP_Thread_07_A2(int times) { + CP_Thread_07_A1.test1 = new PhantomReference[times]; + for (int i = 0; i < times; i++) { + PhantomReference temp = new PhantomReference<>(str + times + i, rq); + CP_Thread_07_A1.test1[i] = temp; + } + } + public void run() { + a1_main = new CP_Thread_07_A1("a1_main"); + a2 = new CP_Thread_07_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_07_A1(10000); + test_CP_Thread_07_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_07 { + private static CP_Thread_07_A1 a1_main = null; + private static CP_Thread_07_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_07_test cptest1 = new CP_Thread_07_test(); + cptest1.run(); + CP_Thread_07_test cptest2 = new CP_Thread_07_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/expected.txt b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/test.cfg b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b2f25b1928fd52e2fb097795f6704461b47c1943 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0492-rc-StackScan-CP_Thread_07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_07) +run(CP_Thread_07,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java new file mode 100644 index 0000000000000000000000000000000000000000..4e834019091a1bd9cb2841d2119b1909676c8b44 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/CP_Thread_08.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class CP_Thread_08_A1 { + static OutOfMemoryError[] test1; + static + int a; + CP_Thread_08_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_08_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class CP_Thread_08_test extends Thread { + private static CP_Thread_08_A1 a1_main = null; + private volatile static CP_Thread_08_A1 a2 = null; + private volatile static OutOfMemoryError test1; + private static OutOfMemoryError test2; + private static void test_CP_Thread_08_A1(int times) { + CP_Thread_08_A1.test1 = new OutOfMemoryError[times]; + for (int i = 0; i < times; i++) { + test1 = new OutOfMemoryError(); + CP_Thread_08_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_08_A2(int times) { + CP_Thread_08_A1.test1 = new OutOfMemoryError[times]; + for (int i = 0; i < times; i++) { + test2 = new OutOfMemoryError(); + CP_Thread_08_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_08_A1("a1_main"); + a2 = new CP_Thread_08_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_08_A1(10000); + test_CP_Thread_08_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_08 { + private static CP_Thread_08_A1 a1_main = null; + private volatile static CP_Thread_08_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_08_test cptest1 = new CP_Thread_08_test(); + cptest1.run(); + CP_Thread_08_test cptest2 = new CP_Thread_08_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/expected.txt b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/test.cfg b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1a41ad1d7d1d439264a0042d9d8d01a6bfe8b030 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0493-rc-StackScan-CP_Thread_08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_08) +run(CP_Thread_08,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java new file mode 100644 index 0000000000000000000000000000000000000000..a7015a5c9571de1c01c35f811458bb5453ca95ab --- /dev/null +++ b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/CP_Thread_09.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class CP_Thread_09_A1 { + static ClassLoader[] test1; + static + int a; + CP_Thread_09_A1 a2_0; + int sum; + String strObjectName; + CP_Thread_09_A1(String strObjectName) { + a2_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; + } + void add() { + sum = a + a; + } +} +class CP_Thread_09_test extends Thread { + private static CP_Thread_09_A1 a1_main = null; + private volatile static CP_Thread_09_A1 a2 = null; + private volatile static ClassLoader test1; + private static ClassLoader test2; + private static void test_CP_Thread_09_A1(int times) { + CP_Thread_09_A1.test1 = new ClassLoader[times]; + for (int i = 0; i < times; i++) { + test1 = CP_Thread_09_A1.class.getClassLoader(); + CP_Thread_09_A1.test1[i] = test1; + } + } + private static void test_CP_Thread_09_A2(int times) { + CP_Thread_09_A1.test1 = new ClassLoader[times]; + for (int i = 0; i < times; i++) { + test2 = CP_Thread_09_A1.class.getClassLoader(); + CP_Thread_09_A1.test1[i] = test2; + } + } + public void run() { + a1_main = new CP_Thread_09_A1("a1_main"); + a2 = new CP_Thread_09_A1("a2_0"); + a1_main.a2_0 = a2; + a1_main.a2_0.a2_0 = a2; + a1_main.add(); + a1_main.a2_0.add(); + test_CP_Thread_09_A1(10000); + test_CP_Thread_09_A2(10000); + int result = a1_main.sum + a1_main.a2_0.sum; + //System.out.println("RC-Testing_Result="+result); + if (result == 404) + System.out.println("ExpectResult"); + } +} +public class CP_Thread_09 { + private static CP_Thread_09_A1 a1_main = null; + private volatile static CP_Thread_09_A1 a2 = null; + public static void main(String[] args) { + CP_Thread_09_test cptest1 = new CP_Thread_09_test(); + cptest1.run(); + CP_Thread_09_test cptest2 = new CP_Thread_09_test(); + cptest2.run(); + } +} diff --git a/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/expected.txt b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/test.cfg b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9ff4ef509595cd80b71d7e6f1606a0962c939345 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0494-rc-StackScan-CP_Thread_09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CP_Thread_09) +run(CP_Thread_09,EXPECTNUM=2) diff --git a/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java new file mode 100644 index 0000000000000000000000000000000000000000..357872308f13ea7f147e0a465de5f2f26a0be437 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/FrequentSystemGC_01.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +class MyThread extends Thread { + public void run(){ + try { + Thread.sleep(index * FrequentSystemGC_01.THREAD_SLEEP_UNIT); + } catch (Exception e) { + // System.out.println("Exception from thread sleep: " + index); + // do nothing, just continue test... + } + WeakReference weak = new WeakReference(new Object()); + if (weak.get() == null) { + return; + } + Runtime.getRuntime().gc(); + if (weak.get() != null) { + System.out.println("MyThread" + index + " check fail"); + FrequentSystemGC_01.totalResult = false; + } + } + public MyThread(int i) { + index = i; + } + private int index; +} +public class FrequentSystemGC_01 { + public static final int THREAD_COUNT = 50; + public static boolean totalResult = true; + public static final long THREAD_SLEEP_UNIT = 1; + public static ArrayList threads = new ArrayList<>(); + public static void main(String[] args) { + for (int i = 0; i < THREAD_COUNT; i++) { + Thread t = new MyThread(i); + threads.add(t); + t.start(); + } + for (int i = 0; i < THREAD_COUNT; i++) { + try { + threads.get(i).join(); + } catch (Exception e) { + System.out.println("Exception from join thread: " + i + " need re-test!"); + return; + } + } + if (FrequentSystemGC_01.totalResult == true) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, weak is not freed after system.gc() in some thread!"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/expected.txt b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/test.cfg b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..42e064f0f120f338c4e415f8183d6b3f10b8f774 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0495-rc-GC-TaskQueue-FrequentSystemGC_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FrequentSystemGC_01) +run(FrequentSystemGC_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java new file mode 100644 index 0000000000000000000000000000000000000000..c9b0b19eb22aa6bb51d550a0ce32635e5388d108 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/StartupInvoke_01.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +public class StartupInvoke_01 { + static WeakReference observer; + static int check = 2; + private final static int INIT_MEMORY = 100; // MB + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = 0; i < INIT_MEMORY; i++) { + byte[] temp = new byte[1024*1024]; + store.add(temp); + } + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/expected.txt b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/test.cfg b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..67f5d042cd62a24c87daf1479b20c249a91db81d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0496-rc-GC-TaskQueue-StartupInvoke_01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StartupInvoke_01) +run(StartupInvoke_01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java new file mode 100755 index 0000000000000000000000000000000000000000..3b2169b8a678926f69f822a9a2f540b750c2bd1c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/CheckLoops.java @@ -0,0 +1,1005 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class CheckLoops { + private static int sResult; + // + // Various sequence variables used in bound checks. + // + // CHECK-START: void Main.bubble(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.bubble(int[]) BCE (after) + // CHECK-NOT: BoundsCheck + private static void bubble(int[] a) { + for (int i = a.length; --i >= 0; ) { + for (int j = 0; j < i; j++) { + if (a[j] > a[j + 1]) { + int tmp = a[j]; + a[j] = a[j + 1]; + a[j + 1] = tmp; + } + } + } + } + // CHECK-START: int Main.periodicIdiom(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicIdiom(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicIdiom(int tc) { + int[] x = {1, 3}; + // Loop with periodic sequence (0, 1). + int k = 0; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k]; + k = 1 - k; + } + return result; + } + // CHECK-START: int Main.periodicSequence2(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicSequence2(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicSequence2(int tc) { + int[] x = {1, 3}; + // Loop with periodic sequence (0, 1). + int k = 0; + int l = 1; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k]; + int t = l; + l = k; + k = t; + } + return result; + } + // CHECK-START: int Main.periodicSequence4(int) BCE (before) + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.periodicSequence4(int) BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int periodicSequence4(int tc) { + int[] x = {1, 3, 5, 7}; + // Loop with periodic sequence (0, 1, 2, 3). + int k = 0; + int l = 1; + int m = 2; + int n = 3; + int result = 0; + for (int i = 0; i < tc; i++) { + result += x[k] + x[l] + x[m] + x[n]; // all used at once + int t = n; + n = k; + k = l; + l = m; + m = t; + } + return result; + } + // CHECK-START: int Main.justRightUp1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp1() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10, k = 0; i < Integer.MAX_VALUE; i++) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.justRightUp2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp2() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp2() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10; i < Integer.MAX_VALUE; i++) { + result += x[i - Integer.MAX_VALUE + 10]; + } + return result; + } + // CHECK-START: int Main.justRightUp3() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightUp3() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightUp3() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MAX_VALUE - 10, k = 0; i <= Integer.MAX_VALUE - 1; i++) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.justOOBUp() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBUp() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBUp() BCE (after) + // CHECK-NOT: Deoptimize + private static int justOOBUp() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + // Infinite loop! + for (int i = Integer.MAX_VALUE - 9, k = 0; i <= Integer.MAX_VALUE; i++) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.justRightDown1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown1() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10, k = 0; i > Integer.MIN_VALUE; i--) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.justRightDown2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown2() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown2() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10; i > Integer.MIN_VALUE; i--) { + result += x[Integer.MAX_VALUE + i]; + } + return result; + } + // CHECK-START: int Main.justRightDown3() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justRightDown3() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int justRightDown3() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + for (int i = Integer.MIN_VALUE + 10, k = 0; i >= Integer.MIN_VALUE + 1; i--) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.justOOBDown() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBDown() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int Main.justOOBDown() BCE (after) + // CHECK-NOT: Deoptimize + private static int justOOBDown() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int result = 0; + // Infinite loop! + for (int i = Integer.MIN_VALUE + 9, k = 0; i >= Integer.MIN_VALUE; i--) { + result += x[k++]; + } + return result; + } + // CHECK-START: void Main.lowerOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.lowerOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.lowerOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void lowerOOB(int[] x) { + // OOB! + for (int i = -1; i < x.length; i++) { + sResult += x[i]; + } + } + // CHECK-START: void Main.upperOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.upperOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.upperOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void upperOOB(int[] x) { + // OOB! + for (int i = 0; i <= x.length; i++) { + sResult += x[i]; + } + } + // CHECK-START: void Main.doWhileUpOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileUpOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileUpOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void doWhileUpOOB() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int i = 0; + // OOB! + do { + sResult += x[i++]; + } while (i <= x.length); + } + // CHECK-START: void Main.doWhileDownOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileDownOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.doWhileDownOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void doWhileDownOOB() { + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int i = x.length - 1; + // OOB! + do { + sResult += x[i--]; + } while (-1 <= i); + } + // CHECK-START: void Main.hiddenOOB1(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenOOB1(int) BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenOOB1(int) BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenOOB1(int lo) { + int[] a = {1}; + for (int i = lo; i <= 10; i++) { + // Dangerous loop where careless static range analysis would yield strict upper bound + // on index j of 5. When, for instance, lo and thus i = -2147483648, the upper bound + // becomes really positive due to arithmetic wrap-around, causing OOB. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = 4; j < i - 5; j++) { + sResult += a[j - 4]; + } + } + } + // CHECK-START: void Main.hiddenOOB2(int) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenOOB2(int) BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenOOB2(int) BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenOOB2(int hi) { + int[] a = {1}; + for (int i = 0; i < hi; i++) { + // Dangerous loop where careless static range analysis would yield strict lower bound + // on index j of 5. When, for instance, hi and thus i = 2147483647, the upper bound + // becomes really negative due to arithmetic wrap-around, causing OOB. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = 6; j > i + 5; j--) { + sResult += a[j - 6]; + } + } + } + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenInfiniteOOB() BCE (after) + // CHECK-NOT: Deoptimize + private static void hiddenInfiniteOOB() { + int[] a = {11}; + for (int i = -1; i <= 0; i++) { + // Dangerous loop where careless static range analysis would yield a safe upper bound + // of -3. In reality, due to arithmetic wrap-around (when i = -1, j <= 2147483647; + // whereas when i = 0, j <= -3), this is an infinite loop that goes OOB. + for (int j = -3; j <= 2147483646 * i - 3; j++) { + sResult += a[j + 3]; + } + } + } + // CHECK-START: void Main.hiddenFiniteOOB() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.hiddenFiniteOOB() BCE (after) + // CHECK-DAG: Deoptimize + // + // CHECK-START: void Main.hiddenFiniteOOB() BCE (after) + // CHECK-NOT: BoundsCheck + private static void hiddenFiniteOOB() { + int[] a = {111}; + for (int i = -1; i <= 0; i++) { + // Dangerous loop similar as above where the loop is now finite, but the + // loop still goes out of bounds for i = -1 due to the large upper bound. + // Dynamic BCE is feasible though, since it checks the range. + for (int j = -4; j < 2147483646 * i - 3; j++) { + sResult += a[j + 4]; + } + } + } + // CHECK-START: void Main.inductionOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.inductionOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.inductionOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void inductionOOB(int[] a) { + // Careless range analysis would remove the bounds check. + // However, the narrower induction b wraps around arithmetically + // before it reaches the end of arrays longer than 127. + byte b = 0; + for (int i = 0; i < a.length; i++) { + a[b++] = i; + } + } + // CHECK-START: void Main.controlOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.controlOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.controlOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void controlOOB(int[] a) { + // As above, but now the loop control also wraps around. + for (byte i = 0; i < a.length; i++) { + a[i] = -i; + } + } + // CHECK-START: void Main.conversionOOB(int[]) BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.conversionOOB(int[]) BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: void Main.conversionOOB(int[]) BCE (after) + // CHECK-NOT: Deoptimize + private static void conversionOOB(int[] a) { + // As above, but with wrap around caused by an explicit conversion. + for (int i = 0; i < a.length; ) { + a[i] = i; + i = (byte) (i + 1); + } + } + // CHECK-START: int[] Main.add() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.add() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int[] add() { + int[] a = new int[10]; + for (int i = 0; i <= 3; i++) { + for (int j = 0; j <= 6; j++) { + a[i + j] += 1; + } + } + return a; + } + // CHECK-START: int[] Main.multiply1() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply1() BCE (after) + // CHECK-NOT: BoundsCheck + // CHECK-NOT: Deoptimize + private static int[] multiply1() { + int[] a = new int[10]; + try { + for (int i = 0; i <= 3; i++) { + for (int j = 0; j <= 3; j++) { + // Range [0,9]: safe. + a[i * j] += 1; + } + } + } catch (Exception e) { + a[0] += 1000; + } + return a; + } + // CHECK-START: int[] Main.multiply2() BCE (before) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply2() BCE (after) + // CHECK-DAG: BoundsCheck + // + // CHECK-START: int[] Main.multiply2() BCE (after) + // CHECK-NOT: Deoptimize + private static int[] multiply2() { + int[] a = new int[10]; + try { + for (int i = -3; i <= 3; i++) { + for (int j = -3; j <= 3; j++) { + // Range [-9,9]: unsafe. + a[i * j] += 1; + } + } + } catch (Exception e) { + a[0] += 1000; + } + return a; + } + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.linearDynamicBCE1(int[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int linearDynamicBCE1(int[] x, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + sResult += x[i]; + } + return result; + } + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.linearDynamicBCE2(int[], int, int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int linearDynamicBCE2(int[] x, int lo, int hi, int offset) { + int result = 0; + for (int i = lo; i < hi; i++) { + sResult += x[offset + i]; + } + return result; + } + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.wrapAroundDynamicBCE(int[]) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int wrapAroundDynamicBCE(int[] x) { + int w = 9; + int result = 0; + for (int i = 0; i < 10; i++) { + result += x[w]; + w = i; + } + return result; + } + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.periodicDynamicBCE(int[]) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int periodicDynamicBCE(int[] x) { + int k = 0; + int result = 0; + for (int i = 0; i < 10; i++) { + result += x[k]; + k = 1 - k; + } + return result; + } + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:{{B\d+}} + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.dynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int dynamicBCEPossiblyInfiniteLoop(int[] x, int lo, int hi) { + // This loop could be infinite for hi = max int. Since i is also used + // as subscript, however, dynamic bce can proceed. + int result = 0; + for (int i = lo; i <= hi; i++) { + result += x[i]; + } + return result; + } + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEPossiblyInfiniteLoop(int[], int, int) BCE (after) + // CHECK-NOT: Deoptimize + static int noDynamicBCEPossiblyInfiniteLoop(int[] x, int lo, int hi) { + // As above, but now the index is not used as subscript, + // and dynamic bce is not applied. + int result = 0; + for (int k = 0, i = lo; i <= hi; i++) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.noDynamicBCEMixedInductionTypes(int[], long, long) BCE (after) + // CHECK-NOT: Deoptimize + static int noDynamicBCEMixedInductionTypes(int[] x, long lo, long hi) { + int result = 0; + // Mix of int and long induction. + int k = 0; + for (long i = lo; i < hi; i++) { + result += x[k++]; + } + return result; + } + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (before) + // CHECK-DAG: BoundsCheck loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: If loop:<> + // CHECK-DAG: If loop:<> + // CHECK-EVAL: "<>" != "<>" + // + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: Deoptimize loop:<> + // CHECK-EVAL: "<>" != "<>" + // + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-NOT: BoundsCheck + // + // No additional top tests were introduced. + // CHECK-START: int Main.dynamicBCEConstantRange(int[]) BCE (after) + // CHECK-DAG: If + // CHECK-DAG: If + // CHECK-NOT: If + static int dynamicBCEConstantRange(int[] x) { + int result = 0; + for (int i = 2; i <= 6; i++) { + // Range analysis sees that innermost loop is finite and always taken. + for (int j = i - 2; j <= i + 2; j++) { + result += x[j]; + } + } + return result; + } + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (before) + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (after) + // Order matters: + // CHECK: Deoptimize loop:<> + // CHECK-NOT: Goto loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK-DAG: {{l\d+}} ArrayGet loop:<> + // CHECK: Goto loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndices(int[], int[][], int, int) BCE (after) + // CHECK-DAG: Deoptimize loop:none + static int dynamicBCEAndConstantIndices(int[] x, int[][] a, int lo, int hi) { + // Deliberately test array length on a before the loop so that only bounds checks + // on constant subscripts remain, making them a viable candidate for hoisting. + if (a.length == 0) { + return -1; + } + // Loop that allows BCE on x[i]. + int result = 0; + for (int i = lo; i < hi; i++) { + result += x[i]; + if ((i % 10) != 0) { + // None of the subscripts inside a conditional are removed by dynamic bce, + // making them a candidate for deoptimization based on constant indices. + // Compiler should ensure the array loads are not subsequently hoisted + // "above" the deoptimization "barrier" on the bounds. + a[0][i] = 1; + a[1][i] = 2; + a[99][i] = 3; + } + } + return result; + } + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: ArrayGet loop:<> + // For brevity, just test occurrence of at least one of each in the loop: + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-NOT: ArrayGet loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-NOT: NullCheck loop:{{B\d+}} + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + // + // CHECK-START: int Main.dynamicBCEAndConstantIndicesAllPrimTypes(int[], boolean[], byte[], char[], short[], int[], long[], float[], double[], int, int) BCE (after) + // CHECK-DAG: Deoptimize loop:none + private static int dynamicBCEAndConstantIndicesAllPrimTypes(int[] q, boolean[] r, byte[] s, char[] t, short[] u, int[] v, long[] w, float[] x, double[] y, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + // All constant index array references can be hoisted out of the loop during BCE on q[i]. + result += q[i] + (r[0] ? 1 : 0) + (int) s[0] + (int) t[0] + (int) u[0] + v[0] + (int) w[0] + (int) x[0] + (int) y[0]; + } + return result; + } + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (before) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: NullCheck loop:<> + // CHECK-DAG: ArrayLength loop:<> + // CHECK-DAG: BoundsCheck loop:<> + // + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (after) + // CHECK-DAG: ArrayGet loop:<> + // CHECK-DAG: Deoptimize loop:none + // + // CHECK-START: int Main.dynamicBCEAndConstantIndexRefType(int[], java.lang.Integer[], int, int) BCE (after) + // CHECK-NOT: ArrayLength loop:{{B\d+}} + // CHECK-NOT: BoundsCheck loop:{{B\d+}} + private static int dynamicBCEAndConstantIndexRefType(int[] q, Integer[] z, int lo, int hi) { + int result = 0; + for (int i = lo; i < hi; i++) { + // Similar to above, but now implicit call to intValue() may prevent hoisting + // z[0] itself during BCE on q[i]. Therefore, we just check BCE on q[i]. + result += q[i] + z[0]; + } + return result; + } + // + // Verifier. + // + public static void main(String[] args) { + // Set to run expensive tests for correctness too. + boolean heavy = false; + int[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int[] a200 = new int[200]; + // Sorting. + int[] sort = {5, 4, 1, 9, 10, 2, 7, 6, 3, 8}; + bubble(sort); + for (int i = 0; i < 10; i++) { + expectEquals(sort[i], x[i]); + } + // Periodic adds (1, 3), one at the time. + expectEquals(0, periodicIdiom(-1)); + for (int tc = 0; tc < 32; tc++) { + int expected = (tc >> 1) << 2; + if ((tc & 1) != 0) + expected += 1; + expectEquals(expected, periodicIdiom(tc)); + } + // Periodic adds (1, 3), one at the time. + expectEquals(0, periodicSequence2(-1)); + for (int tc = 0; tc < 32; tc++) { + int expected = (tc >> 1) << 2; + if ((tc & 1) != 0) + expected += 1; + expectEquals(expected, periodicSequence2(tc)); + } + // Periodic adds (1, 3, 5, 7), all at once. + expectEquals(0, periodicSequence4(-1)); + for (int tc = 0; tc < 32; tc++) { + expectEquals(tc * 16, periodicSequence4(tc)); + } + // Large bounds. + expectEquals(55, justRightUp1()); + expectEquals(55, justRightUp2()); + expectEquals(55, justRightUp3()); + expectEquals(55, justRightDown1()); + expectEquals(55, justRightDown2()); + expectEquals(55, justRightDown3()); + sResult = 0; + try { + justOOBUp(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + sResult = 0; + try { + justOOBDown(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + // Lower bound goes OOB. + sResult = 0; + try { + lowerOOB(x); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + // Upper bound goes OOB. + sResult = 0; + try { + upperOOB(x); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + // Do while up goes OOB. + sResult = 0; + try { + doWhileUpOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + // Do while down goes OOB. + sResult = 0; + try { + doWhileDownOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + // Hidden OOB. + sResult = 0; + try { + hiddenOOB1(10); // no OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1, sResult); + sResult = 0; + try { + hiddenOOB1(-2147483648); // OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1001, sResult); + sResult = 0; + try { + hiddenOOB2(1); // no OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1, sResult); + if (heavy) { + sResult = 0; + try { + hiddenOOB2(2147483647); // OOB + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1002, sResult); + } + sResult = 0; + try { + hiddenInfiniteOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1011, sResult); + sResult = 0; + try { + hiddenFiniteOOB(); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1111, sResult); + sResult = 0; + try { + inductionOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? i : 0, a200[i]); + } + sResult = 0; + try { + controlOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? -i : 0, a200[i]); + } + sResult = 0; + try { + conversionOOB(a200); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + for (int i = 0; i < 200; i++) { + expectEquals(i < 128 ? i : 0, a200[i]); + } + // Addition. + { + int[] e1 = {1, 2, 3, 4, 4, 4, 4, 3, 2, 1}; + int[] a1 = add(); + for (int i = 0; i < 10; i++) { + expectEquals(a1[i], e1[i]); + } + } + // Multiplication. + { + int[] e1 = {7, 1, 2, 2, 1, 0, 2, 0, 0, 1}; + int[] a1 = multiply1(); + for (int i = 0; i < 10; i++) { + expectEquals(a1[i], e1[i]); + } + int[] e2 = {1001, 0, 0, 1, 0, 0, 1, 0, 0, 1}; + int[] a2 = multiply2(); + for (int i = 0; i < 10; i++) { + expectEquals(a2[i], e2[i]); + } + } + // Dynamic BCE. + sResult = 0; + try { + linearDynamicBCE1(x, -1, x.length); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + sResult = 0; + linearDynamicBCE1(x, 0, x.length); + expectEquals(55, sResult); + sResult = 0; + try { + linearDynamicBCE1(x, 0, x.length + 1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1055, sResult); + // Dynamic BCE with offset. + sResult = 0; + try { + linearDynamicBCE2(x, 0, x.length, -1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1000, sResult); + sResult = 0; + linearDynamicBCE2(x, 0, x.length, 0); + expectEquals(55, sResult); + sResult = 0; + try { + linearDynamicBCE2(x, 0, x.length, 1); + } catch (ArrayIndexOutOfBoundsException e) { + sResult += 1000; + } + expectEquals(1054, sResult); + // Dynamic BCE candidates. + expectEquals(55, wrapAroundDynamicBCE(x)); + expectEquals(15, periodicDynamicBCE(x)); + expectEquals(55, dynamicBCEPossiblyInfiniteLoop(x, 0, 9)); + expectEquals(55, noDynamicBCEPossiblyInfiniteLoop(x, 0, 9)); + expectEquals(55, noDynamicBCEMixedInductionTypes(x, 0, 10)); + expectEquals(125, dynamicBCEConstantRange(x)); + // Dynamic BCE combined with constant indices. + int[][] a; + a = new int[0][0]; + expectEquals(-1, dynamicBCEAndConstantIndices(x, a, 0, 10)); + a = new int[100][10]; + expectEquals(55, dynamicBCEAndConstantIndices(x, a, 0, 10)); + for (int i = 0; i < 10; i++) { + expectEquals((i % 10) != 0 ? 1 : 0, a[0][i]); + expectEquals((i % 10) != 0 ? 2 : 0, a[1][i]); + expectEquals((i % 10) != 0 ? 3 : 0, a[99][i]); + } + a = new int[2][10]; + sResult = 0; + try { + expectEquals(55, dynamicBCEAndConstantIndices(x, a, 0, 10)); + } catch (ArrayIndexOutOfBoundsException e) { + sResult = 1; + } + expectEquals(1, sResult); + expectEquals(a[0][1], 1); + expectEquals(a[1][1], 2); + // Dynamic BCE combined with constant indices of all types. + boolean[] x1 = {true}; + byte[] x2 = {2}; + char[] x3 = {3}; + short[] x4 = {4}; + int[] x5 = {5}; + long[] x6 = {6}; + float[] x7 = {7}; + double[] x8 = {8}; + expectEquals(415, dynamicBCEAndConstantIndicesAllPrimTypes(x, x1, x2, x3, x4, x5, x6, x7, x8, 0, 10)); + Integer[] x9 = {9}; + expectEquals(145, dynamicBCEAndConstantIndexRefType(x, x9, 0, 10)); + System.out.println("ExpectResult"); + } + private static void expectEquals(int expected, int result) { + if (expected != result) { + throw new Error("Expected: " + expected + ", found: " + result); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/expected.txt b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/test.cfg b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..769599ffb88a3ff2bc10106af8068cccd3becd0a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0507-JTreg-CheckLoops/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CheckLoops) +run(CheckLoops,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java new file mode 100755 index 0000000000000000000000000000000000000000..6858144745a41b48c78e4ef39fdc54d4def18b8a --- /dev/null +++ b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/ConstCharAppend.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ConstCharAppend { + public static void main(String[] args) { + if (!("" + 'a' + 'b').equals("ab")) { + System.out.println("append of chars is wrong: 4103959"); + } else { + System.out.println("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/expected.txt b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/test.cfg b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2d1d95e58b4d70afe7f0b1fd629e9467b44e04e5 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0508-JTreg-ConstCharAppend/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstCharAppend) +run(ConstCharAppend,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java new file mode 100755 index 0000000000000000000000000000000000000000..0e1c8bce35f09615a2ef182616ca86184d1129bf --- /dev/null +++ b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/RelaxedArrays.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import java.util.List; +public class RelaxedArrays { + static T select(T... tl) { + return tl.length == 0 ? null : tl[tl.length - 1]; + } + public static void main(String[] args) { + List[] a = new StringList[20]; + if (select("A", "B", "C") != "C") { + System.out.println("error"); + } else { + System.out.println("ExpectResult"); + } + } + static class StringList extends ArrayList { + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/expected.txt b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/test.cfg b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..62e185a596d794bd17391a5f48bf3849a56d1b77 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0509-JTreg-RelaxedArrays/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RelaxedArrays) +run(RelaxedArrays,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/T4711694.java b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/T4711694.java new file mode 100755 index 0000000000000000000000000000000000000000..4bc44d2a4b7908a848b0a82cbf342ffa7276c1fc --- /dev/null +++ b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/T4711694.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class T4711694 { + public static void main(String[] args) { + D.main(args); + System.out.println("ExpectResult"); + } + interface A { + void f(T u); + } + static class B { + public void f(Integer i) { + } + } + static abstract class C extends B implements A { + public void g(T t) { + f(t); + } + } + static class D extends C { + public static void main(String[] args) { + new D().g(new Integer(3)); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/expected.txt b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/test.cfg b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d7a2f23312b9e232f252ea2ac4d94b69adb34f3f --- /dev/null +++ b/testsuite/java_test/rc_test/RC0510-JTreg-T4711694/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(T4711694) +run(T4711694,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/T7040104.java b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/T7040104.java new file mode 100755 index 0000000000000000000000000000000000000000..7f8bc09e3167e7f61677fc38ee5c26266fd57ce0 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/T7040104.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class T7040104 { + int npeCount = 0; + public static void main(String[] args) { + T7040104 t = new T7040104(); + t.test1(); + t.test2(); + t.test3(); + if (t.npeCount != 3) { + System.out.println("error"); + } else { + System.out.println("ExpectResult"); + } + } + void test1() { + Object[] a; + try { + Object o = (a = null)[0]; + } catch (NullPointerException npe) { + npeCount++; + } + } + void test2() { + Object[][] a; + try { + Object o = (a = null)[0][0]; + } catch (NullPointerException npe) { + npeCount++; + } + } + void test3() { + Object[][][] a; + try { + Object o = (a = null)[0][0][0]; + } catch (NullPointerException npe) { + npeCount++; + } + } +} diff --git a/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/expected.txt b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/test.cfg b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e73468723754790b8b970dcbcefc282d9bb16d9d --- /dev/null +++ b/testsuite/java_test/rc_test/RC0511-JTreg-T7040104/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(T7040104) +run(T7040104,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/WrongNew.java b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/WrongNew.java new file mode 100755 index 0000000000000000000000000000000000000000..95265ab16d417ab9f9a44423eaa36eae26c4ac7b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/WrongNew.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class WrongNewList { +} +class WrongNewArrayList extends WrongNewList { +} +public class WrongNew { + public static void main(String[] ps) { + WrongNewList list = getList(); + if (list != null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + public static WrongNewList getList() { + return new WrongNewArrayList(); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/expected.txt b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/test.cfg b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e1fe2dc5f8d4bc167c9d771fa21ade7cfc86cec4 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0512-JTreg-WrongNew/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(WrongNew) +run(WrongNew,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/T6481655.java b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/T6481655.java new file mode 100755 index 0000000000000000000000000000000000000000..0b1800b4884e2e83883e58457f7af159cb015d6b --- /dev/null +++ b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/T6481655.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class T6481655 { + public static T getT(T t) { + return t; + } + public static void main(String... s) { + if (T6481655.getT("").equals("") && (T6481655.getT("")).getClass().isInstance("java.lang.String")) { + System.out.println("ExpectResult"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/expected.txt b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/test.cfg b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..90011bf2ed6c77cccfd7599a4cb9a6ea1cc29b01 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0513-JTreg-T6481655/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(T6481655) +run(T6481655,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java new file mode 100755 index 0000000000000000000000000000000000000000..a66b76ab40b9c485fb4ff4c227214e0f61ca7992 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/SingleLocalTest.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class SingleLocalTest { + static F f; + public static void main(String[] args) { + StringBuffer sb = new StringBuffer(); + class Local1 { + public Local1() { + f = () -> new Local1(); + sb.append("1"); + } + } + new Local1(); + f.f(); + String s = sb.toString(); + if (!s.equals("11")) { + System.out.println("Expected '11' got '" + s + "'"); + } else { + System.out.println("ExpectResult"); + } + } + interface F { + void f(); + } +} diff --git a/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/expected.txt b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/test.cfg b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1b2e974d0afb9b5bdfbe474b8db080813ecdc472 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0514-JTreg-SingleLocalTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SingleLocalTest) +run(SingleLocalTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..d5ca1359d9dcd4e33a910c655f8f06ef9813f0e1 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/FrequentGCTest01.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +public class FrequentGCTest01 { + static int a = 100; + public static void main(String[] args) throws Exception { + for (int i = 0; i < 100; i++) { + WeakReference rp = new WeakReference(new Object()); + if (rp.get() == null) { + a++; + } + new Thread(new TriggerRP()).start(); + Runtime.getRuntime().gc(); + Thread.sleep(100); + if (rp.get() != null) { + a++; + } + if (a != 100) { + System.out.println("ErrorResult"); + return; + } + } + System.out.println("ExpectResult"); + } + static class TriggerRP implements Runnable { + public void run() { + for (int i = 0; i < 10; i++) { + WeakReference wr = new WeakReference(new Object()); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/expected.txt b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/test.cfg b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ab2d6ea0f003a5501f611da6ebbd00dcbe861db8 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0515-GC-FrequentGCTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FrequentGCTest01) +run(FrequentGCTest01,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..4228be88e0fe5138ecc6717bfd1d07903c989a4c --- /dev/null +++ b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/FrequentGCTest02.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.WeakReference; +public class FrequentGCTest02 { + static int a = 100; + public static void main(String[] args) { + for (int i = 0; i < 100; i++) { + WeakReference rp = new WeakReference(new Object()); + if (rp.get() == null) { + a++; + } + System.gc(); + if (rp.get() == null) { + a++; + } + if (a != 100) { + System.out.println("ErrorResult"); + return; + } + } + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/expected.txt b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/test.cfg b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b03e1f272a49a77fead0728c0ea801e971261e09 --- /dev/null +++ b/testsuite/java_test/rc_test/RC0516-GC-FrequentGCTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FrequentGCTest02) +run(FrequentGCTest02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java new file mode 100644 index 0000000000000000000000000000000000000000..d0a8ed468addfc91c3ea972d07db4dad68c6c48a --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/SubsumeRC01.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class SubsumeRC01 { + private String str; + public String testfunc() { + return str; + } + public static void main(String[] args){ + SubsumeRC01 temp = new SubsumeRC01(); + temp.testfunc(); + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/expected.txt b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/test.cfg b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..948fc286708a4bc36229fd28a82cf7e17a2e23d0 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0305-rc-function-SubsumeRC01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SubsumeRC01) +run(SubsumeRC01) diff --git a/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java new file mode 100755 index 0000000000000000000000000000000000000000..c348a06c2b0c082ffd05f8435707461650708ebf --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/SubsumeRC02.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class SubsumeRC02 { + private String str; + public SubsumeRC02() { + } + public void testfunc() { + str = new String("test"); + return ; + } + public static void main(String[] args){ + SubsumeRC02 temp = new SubsumeRC02(); + temp.testfunc(); + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/expected.txt b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/test.cfg b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9a5a6ba4ed27541a7b73afabbded9c22497128d8 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0306-rc-function-SubsumeRC02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SubsumeRC02) +run(SubsumeRC02) diff --git a/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java new file mode 100755 index 0000000000000000000000000000000000000000..21cd5575ee52ef9308d17d5c62494efaf67b13ce --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/SubsumeRC03.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class SubsumeRC03 { + private String str; + public SubsumeRC03() { + } + public void testfunc(SubsumeRC03 t) { + str = t.str; + return ; + } + public static void main(String[] args){ + SubsumeRC03 temp0 = new SubsumeRC03(); + SubsumeRC03 temp1 = new SubsumeRC03(); + temp1.testfunc(temp0); + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/expected.txt b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/test.cfg b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..597de5ce7e0430066bbff3c6a95ceab05de7efa9 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0307-rc-function-SubsumeRC03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SubsumeRC03) +run(SubsumeRC03) diff --git a/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java new file mode 100755 index 0000000000000000000000000000000000000000..59764292114ae666543cbfa6ae95af60f494dce0 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/CondBasedRC01.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class CondBasedRC01 { + private String str1; + public static String str2; + public CondBasedRC01() { + } + public String testfunc(String s) { + if (s == null) { + s = str1; + } + return s; + } + public String strfunc() { + return str1; + } + public String testfunc1() { + String t = strfunc(); + if (t == null) { + t = str1; + } + return t; + } + public static void main(String[] args){ + CondBasedRC01 temp1 = new CondBasedRC01(); + String s = new String("test"); + str2 = temp1.testfunc(s); + str2 = temp1.testfunc1(); + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/expected.txt b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/test.cfg b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b6a72582d89e1e9c3c99dbcf6b471a453430a67 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0308-rc-function-CondBasedRC01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(CondBasedRC01) +run(CondBasedRC01) diff --git a/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java new file mode 100755 index 0000000000000000000000000000000000000000..4c07a9b4cf17e3ff583e3ee0aaec074d65e4791a --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/RCMixTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.*; +import java.lang.reflect.Field; +public class RCMixTest { + public static void main(String[] args) { + new Test_A_Weak().test(); + new Test_A_Unowned().test(); + Runtime.getRuntime().gc(); + } +} +class Test_A_Weak { + @Weak + Test_B_Weak bb; + Test_B_Weak bb2; + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("NullPointerException"); + } + bb2.run(); + } + private void foo() { + bb = new @Permanent Test_B_Weak(); + bb2 = new Test_B_Weak(); + } +} +class Test_B_Weak { + public void run() { + System.out.println("ExpectResult"); + } +} +class Test_B_Unowned { + @Unowned + Test_A_Unowned aa ; + // add volatile will crash + // static Test_A a1; + protected void finalize() { + System.out.println("ExpectResult"); + } +} +class Test_A_Unowned { + Test_B_Unowned bb; + public void test() { + setReferences(); + System.runFinalization(); + } + private void setReferences() { + @Unowned + Test_A_Unowned ta; + ta = new @Permanent Test_A_Unowned(); + ta.bb = new Test_B_Unowned(); + //ta.bb.aa = ta; + try { + Field m = Test_B_Unowned.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A_Unowned a_temp = (Test_A_Unowned) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + } catch (Exception e) { + System.out.println(e); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/expected.txt b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..309f6d50570536aa5ec2bd6eba765f9c8fa03b0f --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/expected.txt @@ -0,0 +1,3 @@ +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/test.cfg b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b262d9cf5c1295a3174dfc14dfe3ed168cf42814 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0427-rc-Annotation-RCMixTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCMixTest) +run(RCMixTest) diff --git a/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..c0ec405a55ae95b761b7c45973bc1c51d500c06f --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/RCMixThreadTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.ArrayList; +import com.huawei.ark.annotation.*; +public class RCMixThreadTest { + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + public static void rc_testcase_main_wrapper() throws InterruptedException { + RCMixTest_Weak rcMixTest_weak = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak2 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak3 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak4 = new RCMixTest_Weak(); + RCMixTest_Weak rcMixTest_weak5 = new RCMixTest_Weak(); + rcMixTest_weak.start(); + rcMixTest_weak2.start(); + rcMixTest_weak3.start(); + rcMixTest_weak4.start(); + rcMixTest_weak5.start(); + rcMixTest_weak.join(); + rcMixTest_weak2.join(); + rcMixTest_weak3.join(); + rcMixTest_weak4.join(); + rcMixTest_weak5.join(); + } +} +class RCMixTest_Weak extends Thread { + public void run() { + new Test_A_Weak().test(); + } +} +class Test_A_Weak { + @Weak + Test_B_Weak bb; + Test_B_Weak bb2; + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("NullPointerException"); + } + bb2.run(); + } + private void foo() { + bb = new @Permanent Test_B_Weak(); + bb2 = new Test_B_Weak(); + } +} +class Test_B_Weak { + public void run() { + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/expected.txt b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..9bee6719557871df108511be25e915c084d19061 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/expected.txt @@ -0,0 +1,10 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/test.cfg b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..201b657b56febbc83eb8b0beca2995366149e5fa --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0428-rc-Annotation-RCMixThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCMixThreadTest) +run(RCMixThreadTest) diff --git a/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..cfc25d4c2e260e9367566f624530fc71f3dcf11f --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/SoftRefTest04.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class SoftRefTest04 { + private static Reference rp; + private static ReferenceQueue rq = new ReferenceQueue(); + private static int a = 100; + private static ArrayList store; + static void setSoftReference() { + rp = new SoftReference(new Object(), rq); + if (rp.get() == null) { + System.out.println("Error Result when first check "); + a++; + } + } + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + public static void main(String[] args) throws Exception { + setSoftReference(); + try { + int Result = oomTest(); + } catch (OutOfMemoryError o) { + // do nothing + } + if (rp.get() != null) { + System.out.println("Error Result when second check "); + a++; + } + Thread.sleep(500); + Reference r = rq.poll(); + if (r == null) { + System.out.println("Error Result when checking ReferenceQueue"); + a++; + } + if (a == 100) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult finally"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/expected.txt b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/test.cfg b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6b9b1067439290eae9c48f0e087e4ab59af7953a --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0434-rc-SoftRef-SoftRefTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest04) +run(SoftRefTest04) diff --git a/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java new file mode 100755 index 0000000000000000000000000000000000000000..7a3e94956c55f6f388ee028256fb16f72b650ed0 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/SoftRefTest06.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; + +public class SoftRefTest06 { + private static Reference rp; + private static ReferenceQueue rq = new ReferenceQueue(); + private static ArrayList store; + private static AtomicInteger count = new AtomicInteger(1); + // 生命周期结束的软指针指向的对象,应该被释放,放到它的ReferenceQueue里 + public static void objectDeadNormally() { + Reference sr = new SoftReference(new SoftRefTest06(), rq); + if (sr.get() == null) { + System.out.println("ErrorResult"); + } + // sr will die now. + } + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + private static void setSoftRef() { + // oom出发,回收软引用对象使用的内存 + rp = new SoftReference(new SoftRefTest06(), rq); + } + public static void main(String[] args) { + objectDeadNormally(); + Runtime.getRuntime().runFinalization(); + setSoftRef(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) { + // do nothing + } + if (rp.get() != null) { + System.out.println("Error Result when second check "); + } + Runtime.getRuntime().runFinalization(); + } + @Override + public void finalize() { + System.out.println("ExpectResult" + count.getAndIncrement()); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/expected.txt b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3c34261ca9e88d22e09187c66a1064c0c3efc52e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/expected.txt @@ -0,0 +1,2 @@ +ExpectResult1 +ExpectResult2 diff --git a/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/test.cfg b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1fd49e7406441594d2fc1bc3fd0b0c0eba81f08e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0436-rc-SoftRef-SoftRefTest06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(SoftRefTest06) +run(SoftRefTest06) diff --git a/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java new file mode 100755 index 0000000000000000000000000000000000000000..b3a01b00e394113844cd646232fbb83321ced565 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/RCHeaderTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +class RCRunner implements Runnable { + public void run() { + RCHeaderTest.iArray = null; + } +} +class Resource { + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} +public class RCHeaderTest { + static int[] iArray; + static Cleaner c = null; + Resource res; + public RCHeaderTest() { + iArray = new int[4]; + res = new Resource(); + } + static void foo() { + RCHeaderTest rcht = new RCHeaderTest(); + c = Cleaner.create(rcht, new RCRunner()); + if (c == null) { + System.out.println("Cleaner create failly"); + } + } + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); //ReleaseEnd + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/expected.txt b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3135ee23be98bff95690f925de6d0ea9083cef87 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResultEnd diff --git a/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/test.cfg b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5276b278be50c4d268e78f5f21fb3c87d259341b --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0437-rc-RCHeader-RCHeaderTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest) +run(RCHeaderTest) diff --git a/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..21a359488852151cbdd6c46efce24f6939685bb5 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/RCHeaderTest02.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.util.ArrayList; +import java.lang.ref.SoftReference; +class RCRunner02 implements Runnable { + public void run() { + RCHeaderTest02.iArray = null; + } +} +class Resource02 { + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} +public class RCHeaderTest02 { + private static ArrayList store; + static int[] iArray; + static Cleaner c = null; + Resource02 res02 = null; + public RCHeaderTest02() { + iArray = new int[4]; + res02 = new Resource02(); + } + //方法退出后,sr_rcht02声明周期结束,触发对SoftReference的处理,它指向的对象占用空间被释放。 + static void foo() { + SoftReference sr_rcht02 = new SoftReference<>(new RCHeaderTest02()); + c = Cleaner.create(sr_rcht02, new RCRunner02()); + if (sr_rcht02.get() == null || c == null) { + System.out.println("SoftReference error or Cleaner create failly"); + } + } + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + public static void main(String[] args) { + foo(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) {} + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); //ReleaseEnd + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/expected.txt b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3135ee23be98bff95690f925de6d0ea9083cef87 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResultEnd diff --git a/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/test.cfg b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..cc39390254af9646ccb6b7bbc40f1e22c23d630e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0438-rc-RCHeader-RCHeaderTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest02) +run(RCHeaderTest02) diff --git a/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..e4b8bac62508e37a153e8306df42009154e50d3b --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/RCHeaderTest03.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import java.util.ArrayList; +import java.lang.ref.SoftReference; +import com.huawei.ark.annotation.Weak; +class RCRunner03 implements Runnable { + public void run() { + RCHeaderTest03.iArray = null; + } +} +public class RCHeaderTest03 { + static String[] iArray; + private static ArrayList store; + String @Weak [] wr_annotation = null; + Cleaner c = null; + SoftReference sr = null; + public RCHeaderTest03() { + iArray = new String[4]; + String[] temp = {"1", "2", "3", "4"}; + wr_annotation = temp; + sr = new SoftReference<>(temp); + } + //方法退出后,实例变量sr声明周期结束,触发对SoftReference的处理,它指向的数组占用空间被释放。 + void foo() { + c = Cleaner.create(wr_annotation, new RCRunner03()); + if (c == null || wr_annotation.length != 4) { + System.out.println("Cleaner create failly"); + } + } + private static int oomTest() { + int sum = 0; + store = new ArrayList(); + byte[] temp; + for (int i = 1024 * 1024; i <= 1024 * 1024 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } + public static void main(String[] args) { + RCHeaderTest03 rcht = new RCHeaderTest03(); + rcht.foo(); + try { + int oom = oomTest(); + } catch (OutOfMemoryError ofm) { + System.out.println("oom occured"); + } + Runtime.getRuntime().gc(); + if (rcht.sr.get() == null ) { + System.out.println("SR release"); + } + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + if (rcht.wr_annotation == null) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/expected.txt b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..87e92946f8148f67f23a882689697925cf27c4b4 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/expected.txt @@ -0,0 +1,3 @@ +oom occured +SR release +ExpectResult diff --git a/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/test.cfg b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..bd7b6994b3227b710fabe09848d5d54cf4ffa35a --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0439-rc-RCHeader-RCHeaderTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest03) +run(RCHeaderTest03) diff --git a/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java new file mode 100755 index 0000000000000000000000000000000000000000..80c2325031d4f85f25828fe14ed16591cd85e195 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/RCHeaderTest06.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +import com.huawei.ark.annotation.Weak; +class RCRunner06 implements Runnable { + public void run() { + RCHeaderTest06.iArray = null; + } +} +class Resource06 { + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} +public class RCHeaderTest06 { + static int[] iArray; + static Cleaner cleaner = null; + @Weak + Resource06 c = null; + public RCHeaderTest06() { + iArray = new int[4]; + c = new Resource06(); + } + static void foo() { + RCHeaderTest06 rcht = new RCHeaderTest06(); + RCHeaderTest06.cleaner = Cleaner.create(rcht.c, new RCRunner06()); + if (cleaner == null) { + System.out.println("Weak Annotation Object shouldn't be null"); + } + } + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/expected.txt b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3135ee23be98bff95690f925de6d0ea9083cef87 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResultEnd diff --git a/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/test.cfg b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2c77d854f2aa659514f37d20ef1eb3c745b47486 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0441-rc-RCHeader-RCHeaderTest06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest06) +run(RCHeaderTest06) diff --git a/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java new file mode 100755 index 0000000000000000000000000000000000000000..2e9e6e79adb87d1963eaad67b5c9472184aa3c4e --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/RCHeaderTest07.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Cleaner; +class RCRunner07 implements Runnable { + public void run() { + RCHeaderTest07.iArray = null; + } +} +class Resource07 { + @Override + public void finalize() { + System.out.println("ExpectResult"); + } +} +public class RCHeaderTest07 { + static int[] iArray; + static Cleaner c = null; + Resource07 res; + public RCHeaderTest07() { + iArray = new int[4]; + res = new Resource07(); + } + static void foo() { + RCHeaderTest07 rcht = new RCHeaderTest07(); + c = Cleaner.create(rcht.res, new RCRunner07()); + if (c == null) { + System.out.println("Cleaner create failly"); + } + } + public static void main(String[] args) { + foo(); + Runtime.getRuntime().runFinalization(); + System.out.println("ExpectResultEnd"); + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/expected.txt b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3135ee23be98bff95690f925de6d0ea9083cef87 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResultEnd diff --git a/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/test.cfg b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..10bb9dcdec69c3d8cb69d4d2ee2dfbd9af3cf53c --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0442-rc-RCHeader-RCHeaderTest07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCHeaderTest07) +run(RCHeaderTest07) diff --git a/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java new file mode 100755 index 0000000000000000000000000000000000000000..52fa4bdda5c764733bd82adde9bd75eda91fb3ed --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/PlacementRCTest03.java @@ -0,0 +1,152 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class PlacementRC_A3 { + public int count = 0; + public String className = "temp"; + public PlacementRC_A3(String name) { + this.className = name; + } + public void changeName(String name) { + this.className = name; + } + @Override + public void finalize() throws Throwable { + super.finalize(); + synchronized (PlacementRCTest03.lock) { + if (this.count % 25 == 0) { + PlacementRCTest03.result += ("End" + count); + } + } + } +} +public class PlacementRCTest03 { + public static String result = new String(); + public static String lock = ""; + private volatile static int count = 0; + private PlacementRC_A3 defInsideUseOutside = null; + //def outside, only use inside loop + public static void onlyUseInsideLoop() { + PlacementRC_A3 a1 = new PlacementRC_A3("a1"); + continueTag: + for (count = 0; count < 100; count++) { + a1.changeName("a" + count); + a1.count = count; + if (count % 95 == 0) { + count = 100; + continue continueTag; + } + if (count % 4 == 0) { + if (count % 8 == 0) + continue; + a1.changeName("a" + 100); + a1 = new PlacementRC_A3("a10"); + a1.toString(); + } + if (count >= 95) + System.out.println("Wrong Result"); + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method1"; + } + } + public static PlacementRC_A3 defAndUseInsideLoop() { + for (count = 0; count < 100; count++) { + PlacementRC_A3 a2 = new PlacementRC_A3("a2_i" + count); + a2.count = count; + a2.changeName("null"); + for (int j = 0; j < 2; j++) + a2 = new PlacementRC_A3("a2_i" + count + "_j" + j); + if (count % 4 == 0) { + a2.changeName("a" + 100); + a2 = new PlacementRC_A3("a10"); + if (count == 96) { + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method2"; + } + return a2; + } + a2.toString(); + } else { + a2.toString(); + } + } + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method2"; + } + return new PlacementRC_A3("wrong"); + } + public static void main(String[] args) { + onlyUseInsideLoop(); + System.out.println(defAndUseInsideLoop().className); + new PlacementRCTest03().defInsideAndUseOutsideLoop(); + //System.out.println(result); + if(result.contains("Method1") && result.contains("Method2") && result.contains("Method3") && result.contains("End")) + System.out.println("Expect Result"); + else + System.out.println("Error Result"); + } + public void defInsideAndUseOutsideLoop() { + count = 0; + breakTag: + do { + int choice = count % 4; + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count); + switch (choice) { + case 1: + for (int j = 0; j < 5; j++) { + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (count == 99) + this.defInsideUseOutside.toString(); + break; + case 2: + for (int j = 0; j < 2; j++) { + this.defInsideUseOutside.changeName("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + break; + case 3: + for (int j = 0; j < 5; j++) { + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count + "_j" + j); + this.defInsideUseOutside.count = count; + } + if (this.defInsideUseOutside.className.equals("a2_i91_j4")) { + System.out.println(this.defInsideUseOutside.className); + break breakTag; + } + if (this.defInsideUseOutside.className.equals("a2_i99_j4")) { + System.out.println(this.defInsideUseOutside.className); + break breakTag; + } + break; + default: + this.defInsideUseOutside = new PlacementRC_A3("a2_i" + count); + this.defInsideUseOutside.count = count; + } + count++; + } while (this.defInsideUseOutside.count < 100 && count < 100); + this.defInsideUseOutside.changeName("finish"); + this.defInsideUseOutside = null; + Runtime.getRuntime().runFinalization(); + synchronized (PlacementRCTest03.lock) { + result += "Method3"; + } + } +} diff --git a/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/expected.txt b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c0985af3e3640527f8f5ae54c4ff99f093538d33 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/expected.txt @@ -0,0 +1,3 @@ +a10 +a2_i91_j4 +Expect Result diff --git a/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/test.cfg b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..87de74c21b6bffaf3f73f3020e1e33444d4d39c9 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0445-rc-PlacementRC-PlacementRCTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(PlacementRCTest03) +run(PlacementRCTest03) diff --git a/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..fc18dd95de92b6acff0c3b2ffff8a2e22a722b36 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/UnsafeTest01.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest01 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafecompareAndSwapObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest01.res = UnsafeTest01.res - 10; + } + if (result == 3 && UnsafeTest01.res == 97){ + result =0; + } + return result; + } + private static int UnsafecompareAndSwapObjectTest_1(){ + Unsafe unsafe; + Field field; + Field param; + Object obj; + long offset; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + obj = new Billie5(); + param = Billie5.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + unsafe.compareAndSwapObject(obj, offset, "Me", "billie5"); + result = unsafe.getObject(obj, offset); + if(result.equals("billie5")){ + UnsafeTest01.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie5{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/expected.txt b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/test.cfg b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d591443836bb5575cdae17c0df403b8fdd61e70d --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0471-rc-BindingMethod-UnsafeTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest01) +run(UnsafeTest01) diff --git a/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..ed868df8a8ce76aefef62ea0ec7df4014135f9e0 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/UnsafeTest02.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest02 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafegetObjectVolatileTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest02.res -= 2; + } + if (result == 3 && UnsafeTest02.res == 97){ + result =0; + } + return result; + } + private static int UnsafegetObjectVolatileTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie10.class.getDeclaredField("lastname"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie10(); + result = unsafe.getObjectVolatile(obj, offset); + if(result.equals("eilish")){ + UnsafeTest02.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie10{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/expected.txt b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/test.cfg b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..acf4a5384bf4fa8b75fc8daf73c1b890996207c8 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0472-rc-BindingMethod-UnsafeTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest02) +run(UnsafeTest02) diff --git a/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..a031dc5484623cabc3e44905342da8e780666dbf --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/UnsafeTest03.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest03 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafegetObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest03.res -= 2; + } + if (result == 3 && UnsafeTest03.res == 97){ + result =0; + } + return result; + } + private static int UnsafegetObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie18.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie18(); + result = unsafe.getObject(obj, offset); + if(result.equals("Me")){ + UnsafeTest03.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie18{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} diff --git a/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/expected.txt b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/test.cfg b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..332b3a2173f6c5b4831d21e624cb639f9e53636b --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0473-rc-BindingMethod-UnsafeTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest03) +run(UnsafeTest03) diff --git a/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..cc08d6eaf9b9c2937c8253299b9d436f323d812d --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/UnsafeTest04.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest04 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest04.res -= 2; + } + if (result == 3 && UnsafeTest04.res == 97){ + result =0; + } + return result; + } + private static int UnsafeputObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie19.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie19(); + result = unsafe.getObject(obj, offset); + unsafe.putObject(obj, offset, "she"); + result = unsafe.getObject(obj,offset); + if(result.equals("she")){ + UnsafeTest04.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie19{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/expected.txt b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/test.cfg b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4140fc766cbddc38d3c24094d8b47b2eeff355bf --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0474-rc-BindingMethod-UnsafeTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest04) +run(UnsafeTest04) diff --git a/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..1a5d64b92bce76cf2800becfd3fd89de97c80e5d --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/UnsafeTest05.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest05 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputObjectVolatileTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest05.res -= 2; + } + if (result == 3 && UnsafeTest05.res == 97){ + result =0; + } + return result; + } + private static int UnsafeputObjectVolatileTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie11.class.getDeclaredField("lastname"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie11(); + result = unsafe.getObjectVolatile(obj, offset); + unsafe.putObjectVolatile(obj, offset, "Eilish"); + result = unsafe.getObjectVolatile(obj, offset); + if(result.equals("Eilish")){ + UnsafeTest05.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie11{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} diff --git a/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/expected.txt b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/test.cfg b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..324a5aa620732190b0d86853a4eb05b932e1dac6 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0475-rc-BindingMethod-UnsafeTest05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest05) +run(UnsafeTest05) diff --git a/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..d8ac37f086dfea9327f1425e860f51177b659579 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/UnsafeTest06.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import sun.misc.Unsafe; +import java.io.PrintStream; +import java.lang.reflect.Field; +public class UnsafeTest06 { + private static int res = 99; + public static void main(String[] args){ + System.out.println(run(args, System.out)); + } + private static int run(String[] args, PrintStream out){ + int result = 2/*STATUS_FAILED*/; + try { + result = UnsafeputOrderedObjectTest_1(); + } catch(Exception e){ + e.printStackTrace(); + UnsafeTest06.res -= 2; + } + if (result == 3 && UnsafeTest06.res == 97){ + result =0; + } + return result; + } + private static int UnsafeputOrderedObjectTest_1(){ + Unsafe unsafe; + Field field; + Long offset; + Field param; + Object obj; + Object result; + try{ + field = Unsafe.class.getDeclaredField("theUnsafe"); + field.setAccessible(true); + unsafe = (Unsafe)field.get(null); + param = Billie20.class.getDeclaredField("owner"); + offset = unsafe.objectFieldOffset(param); + obj = new Billie20(); + result = unsafe.getObject(obj, offset); + unsafe.putOrderedObject(obj, offset, "she"); + result = unsafe.getObject(obj,offset); + if(result.equals("she")){ + UnsafeTest06.res -= 2; + } + }catch (NoSuchFieldException e){ + e.printStackTrace(); + return 40; + }catch (IllegalAccessException e){ + e.printStackTrace(); + return 41; + } + return 3; + } +} +class Billie20{ + public int height = 8; + private String[] color = {"black","white"}; + private String owner = "Me"; + private byte length = 0x7; + private String[] water = {"day","wet"}; + private long weight = 100L; + private volatile int age = 18; + private volatile long birth = 20010214L; + private volatile String lastname = "eilish"; +} diff --git a/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/expected.txt b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/test.cfg b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..32b6005e4816e6cf8b179b0012851a41e8735a0d --- /dev/null +++ b/testsuite/java_test/rc_test/common_test/RC0476-rc-BindingMethod-UnsafeTest06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(UnsafeTest06) +run(UnsafeTest06) diff --git a/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/RCUnownedRefUncycle02.java b/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/RCUnownedRefUncycle02.java new file mode 100755 index 0000000000000000000000000000000000000000..713bcb0d9b58643c1f430231085a50cb16e723b2 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/RCUnownedRefUncycle02.java @@ -0,0 +1,290 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } +} +class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } +} +class Nocycle_a_00180_A3 { + @Unowned + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } +} +class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + @Unowned + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } +} +class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } +} +class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + @Unowned + Nocycle_a_00180_D1 d1_0; + @Unowned + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_00180_B3 { + @Unowned + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } +} +class Nocycle_a_00180_C1 { + @Unowned + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } +} +class Nocycle_a_00180_C2 { + @Unowned + Nocycle_a_00180_D2 d2_0; + @Unowned + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } +} +class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } +} +class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } +} +public class RCUnownedRefUncycle02 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = a1_main.b1_0.d2_0; + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0.d1_0 = a1_main.d1_0; + a3_main.b2_0.d2_0 = a1_main.b1_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = a1_main.b1_0.d2_0; + a3_main.c2_0.d3_0 = a2_main.b2_0.d3_0; + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = a2_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a1_main.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a1_main.b1_0.d2_0; + a4_main.c2_0.d3_0 = a2_main.b2_0.d3_0; + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a3_main.c2_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum + a1_main.d1_0.sum + a2_main.b2_0.c1_0.sum; + if (result == 9260) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/test.cfg b/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..591714b161421f72deb4ecd71b144b05a60ac266 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0388-rc-Annotation-RCUnownedRefUnCycle02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefUncycle02) +run(RCUnownedRefUncycle02,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/RCUnownedRefUncycleThread2.java b/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/RCUnownedRefUncycleThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..395320961cf1639b643a6ec0e4719e6f0b8216bc --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/RCUnownedRefUncycleThread2.java @@ -0,0 +1,321 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Unowned; +class ThreadRc_00180 extends Thread { + private boolean checkout; + public void run() { + Nocycle_a_00180_A1 a1_main = new Nocycle_a_00180_A1("a1_main"); + Nocycle_a_00180_A2 a2_main = new Nocycle_a_00180_A2("a2_main"); + Nocycle_a_00180_A3 a3_main = new Nocycle_a_00180_A3("a3_main"); + Nocycle_a_00180_A4 a4_main = new Nocycle_a_00180_A4("a4_main"); + a1_main.b1_0 = new Nocycle_a_00180_B1("b1_0"); + a1_main.d1_0 = new Nocycle_a_00180_D1("d1_0"); + a1_main.b1_0.d2_0 = new Nocycle_a_00180_D2("d2_0"); + a2_main.b2_0 = new Nocycle_a_00180_B2("b2_0"); + a2_main.b2_0.c1_0 = new Nocycle_a_00180_C1("c1_0"); + a2_main.b2_0.d1_0 = a1_main.d1_0; + a2_main.b2_0.d2_0 = a1_main.b1_0.d2_0; + a2_main.b2_0.d3_0 = new Nocycle_a_00180_D3("d3_0"); + a2_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0 = a2_main.b2_0; + a3_main.b2_0.c1_0 = a2_main.b2_0.c1_0; + a3_main.b2_0.c1_0.d1_0 = a1_main.d1_0; + a3_main.b2_0.d1_0 = a1_main.d1_0; + a3_main.b2_0.d2_0 = a1_main.b1_0.d2_0; + a3_main.b2_0.d3_0 = a2_main.b2_0.d3_0; + a3_main.c2_0 = new Nocycle_a_00180_C2("c2_0"); + a3_main.c2_0.d2_0 = a1_main.b1_0.d2_0; + a3_main.c2_0.d3_0 = a2_main.b2_0.d3_0; + a4_main.b3_0 = new Nocycle_a_00180_B3("b3_0"); + a4_main.b3_0.c1_0 = a2_main.b2_0.c1_0; + a4_main.b3_0.c1_0.d1_0 = a1_main.d1_0; + a4_main.c2_0 = a3_main.c2_0; + a4_main.c2_0.d2_0 = a1_main.b1_0.d2_0; + a4_main.c2_0.d3_0 = a2_main.b2_0.d3_0; + a1_main.add(); + a2_main.add(); + a3_main.add(); + a4_main.add(); + a1_main.b1_0.add(); + a1_main.d1_0.add(); + a1_main.b1_0.d2_0.add(); + a2_main.b2_0.add(); + a2_main.b2_0.c1_0.add(); + a2_main.b2_0.d1_0.add(); + a2_main.b2_0.d2_0.add(); + a2_main.b2_0.d3_0.add(); + a2_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.add(); + a3_main.b2_0.c1_0.add(); + a3_main.b2_0.c1_0.d1_0.add(); + a3_main.b2_0.d1_0.add(); + a3_main.b2_0.d2_0.add(); + a3_main.b2_0.d3_0.add(); + a3_main.c2_0.add(); + a3_main.c2_0.d2_0.add(); + a3_main.c2_0.d3_0.add(); + a4_main.b3_0.add(); + a4_main.b3_0.c1_0.add(); + a4_main.b3_0.c1_0.d1_0.add(); + a4_main.c2_0.add(); + a4_main.c2_0.d2_0.add(); + a4_main.c2_0.d3_0.add(); + int result = a1_main.sum + a2_main.sum + a3_main.sum + a4_main.sum + a1_main.b1_0.sum + a2_main.b2_0.sum + a4_main.b3_0.sum + a3_main.c2_0.sum + a3_main.c2_0.d2_0.sum + a3_main.c2_0.d3_0.sum + a1_main.d1_0.sum + a2_main.b2_0.c1_0.sum; + if (result == 9260) + checkout = true; + } + public boolean check() { + return checkout; + } + class Nocycle_a_00180_A1 { + Nocycle_a_00180_B1 b1_0; + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A1(String strObjectName) { + b1_0 = null; + d1_0 = null; + a = 101; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A1_"+strObjectName); + } + void add() { + sum = a + b1_0.a + d1_0.a; + } + } + class Nocycle_a_00180_A2 { + Nocycle_a_00180_B2 b2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A2(String strObjectName) { + b2_0 = null; + a = 102; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A2_"+strObjectName); + } + void add() { + sum = a + b2_0.a; + } + } + class Nocycle_a_00180_A3 { + @Unowned + Nocycle_a_00180_B2 b2_0; + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A3(String strObjectName) { + b2_0 = null; + c2_0 = null; + a = 103; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A3_"+strObjectName); + } + void add() { + sum = a + b2_0.a + c2_0.a; + } + } + class Nocycle_a_00180_A4 { + Nocycle_a_00180_B3 b3_0; + @Unowned + Nocycle_a_00180_C2 c2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_A4(String strObjectName) { + b3_0 = null; + c2_0 = null; + a = 104; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_A4_"+strObjectName); + } + void add() { + sum = a + b3_0.a + c2_0.a; + } + } + class Nocycle_a_00180_B1 { + Nocycle_a_00180_D2 d2_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B1(String strObjectName) { + d2_0 = null; + a = 201; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B1_"+strObjectName); + } + void add() { + sum = a + d2_0.a; + } + } + class Nocycle_a_00180_B2 { + Nocycle_a_00180_C1 c1_0; + @Unowned + Nocycle_a_00180_D1 d1_0; + @Unowned + Nocycle_a_00180_D2 d2_0; + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B2(String strObjectName) { + c1_0 = null; + d1_0 = null; + d2_0 = null; + d3_0 = null; + a = 202; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B2_"+strObjectName); + } + void add() { + sum = a + c1_0.a + d1_0.a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_B3 { + @Unowned + Nocycle_a_00180_C1 c1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_B3(String strObjectName) { + c1_0 = null; + a = 203; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_B3_"+strObjectName); + } + void add() { + sum = a + c1_0.a; + } + } + class Nocycle_a_00180_C1 { + @Unowned + Nocycle_a_00180_D1 d1_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C1(String strObjectName) { + d1_0 = null; + a = 301; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C1_"+strObjectName); + } + void add() { + sum = a + d1_0.a; + } + } + class Nocycle_a_00180_C2 { + @Unowned + Nocycle_a_00180_D2 d2_0; + @Unowned + Nocycle_a_00180_D3 d3_0; + int a; + int sum; + String strObjectName; + Nocycle_a_00180_C2(String strObjectName) { + d2_0 = null; + d3_0 = null; + a = 302; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_C2_"+strObjectName); + } + void add() { + sum = a + d2_0.a + d3_0.a; + } + } + class Nocycle_a_00180_D1 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D1(String strObjectName) { + a = 401; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D1_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D2 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D2(String strObjectName) { + a = 402; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D2_"+strObjectName); + } + void add() { + sum = a + a; + } + } + class Nocycle_a_00180_D3 { + int a; + int sum; + String strObjectName; + Nocycle_a_00180_D3(String strObjectName) { + a = 403; + sum = 0; + this.strObjectName = strObjectName; +// System.out.println("RC-Testing_Construction_D3_"+strObjectName); + } + void add() { + sum = a + a; + } + } +} +public class RCUnownedRefUncycleThread2 { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + ThreadRc_00180 A1_00180 = new ThreadRc_00180(); + ThreadRc_00180 A2_00180 = new ThreadRc_00180(); + ThreadRc_00180 A3_00180 = new ThreadRc_00180(); + ThreadRc_00180 A4_00180 = new ThreadRc_00180(); + ThreadRc_00180 A5_00180 = new ThreadRc_00180(); + ThreadRc_00180 A6_00180 = new ThreadRc_00180(); + A1_00180.start(); + A2_00180.start(); + A3_00180.start(); + A4_00180.start(); + A5_00180.start(); + A6_00180.start(); + try { + A1_00180.join(); + A2_00180.join(); + A3_00180.join(); + A4_00180.join(); + A5_00180.join(); + A6_00180.join(); + } catch (InterruptedException e) { + } + if (A1_00180.check() && A2_00180.check() && A3_00180.check() && A4_00180.check() && A5_00180.check() && A6_00180.check()) + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/test.cfg b/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..af22355abfcb207071e8e6b14d9631dc9bbd5979 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0390-rc-Annotation-RCUnownedRefUncycleThread2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedRefUncycleThread2) +run(RCUnownedRefUncycleThread2,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/RCUnownedOuterThreadTest.java b/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/RCUnownedOuterThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..451b1553144480cc211843e2ee48cb2ff974e1b3 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/RCUnownedOuterThreadTest.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.*; +import java.util.LinkedList; +import java.util.List; +class RCUnownedOuterTest extends Thread { + private boolean checkout; + public void run() { + UnownedAnnoymous unownedAnnoymous = new UnownedAnnoymous(); + unownedAnnoymous.anonymousCapture(); + UnownedInner unownedInner = new UnownedInner(); + unownedInner.method(); + UnownedInner.InnerClass innerClass = unownedInner.new InnerClass(); + innerClass.myName(); + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + if (unownedAnnoymous.checkAnnoy == true && unownedInner.checkInner == true) { + checkout = true; + } else { + checkout = false; + System.out.println("error"); + System.out.println("unownedAnnoymous.checkAnnoy:" + unownedAnnoymous.checkAnnoy); + System.out.println("unownedInner.checkInner:" + unownedInner.checkInner); + } + } + public boolean check() { + return checkout; + } +} +class UnownedInner { + String name = "test"; + boolean checkInner = false; + InnerClass innerClass; + void method() { + innerClass = new InnerClass(); + } + @UnownedOuter + class InnerClass { + void myName() { + checkInner = false; + String myname; + myname = name + name; + if (myname.equals("testtest")) { + checkInner=true; + // System.out.println("checkInner:"+checkInner); + } + } + } +} +class UnownedAnnoymous { + String name = "test"; + boolean checkAnnoy=false; + void anonymousCapture() { + Runnable r = new Runnable() { + @UnownedOuter + @Override + public void run() { + checkAnnoy = false; + String myName = name + name; + if (myName.equals("testtest")) { + checkAnnoy=true; + // System.out.println("checkAnnoy:"+checkAnnoy); + } + } + }; + r.run(); + } +} +public class RCUnownedOuterThreadTest { + public static void main(String[] args) { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() { + RCUnownedOuterTest rcTest1 = new RCUnownedOuterTest(); + RCUnownedOuterTest rcTest2 = new RCUnownedOuterTest(); + RCUnownedOuterTest rcTest3 = new RCUnownedOuterTest(); + RCUnownedOuterTest rcTest4 = new RCUnownedOuterTest(); + RCUnownedOuterTest rcTest5 = new RCUnownedOuterTest(); + RCUnownedOuterTest rcTest6 = new RCUnownedOuterTest(); + rcTest1.start(); + rcTest2.start(); + rcTest3.start(); + rcTest4.start(); + rcTest5.start(); + rcTest6.start(); + try { + rcTest1.join(); + rcTest2.join(); + rcTest3.join(); + rcTest4.join(); + rcTest5.join(); + rcTest6.join(); + } catch (InterruptedException e) { + } + if (rcTest1.check() && rcTest2.check() && rcTest3.check() && rcTest4.check() && rcTest5.check() && rcTest6.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcTest1.check():" + rcTest1.check()); + System.out.println("rcTest2.check():" + rcTest2.check()); + System.out.println("rcTest3.check():" + rcTest3.check()); + System.out.println("rcTest4.check():" + rcTest4.check()); + System.out.println("rcTest5.check():" + rcTest5.check()); + System.out.println("rcTest6.check():" + rcTest6.check()); + } + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/test.cfg b/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1a3283b883385e046d1cdc01bfe2d4b46f3583b2 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0422-rc-Annotation-RCUnownedOuterThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCUnownedOuterThreadTest) +run(RCUnownedOuterThreadTest,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/TriggerGCTest04.java b/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/TriggerGCTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..e7b2336ca962671b0e6a0e7435b9c0c9f02100c2 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/TriggerGCTest04.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class TriggerGCTest04 { + static int check = 4; + public static void main(String[] args) { + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + SoftReference softReference = new SoftReference<>(new Reference04(100)); + Reference04 rt01 = softReference.get(); + // rt01 must check null because of the difference between maple and art. + // In maple runtime, SoftReference could be released when memory is sufficient. + if (rt01 == null || (rt01.stringArray.length == 100 && rt01.stringArray[9].equals("test9"))) { + check--; + } + rt01 = null; + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + // do nothing + } + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult"); + } + } + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 1044 * 1044; i <= 1044 * 1044 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} +class Reference04 { + String[] stringArray; + public Reference04(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/test.cfg b/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..e0e317f7896fdd8951dab677eb7cf0bcefc9ea79 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0460-rc-GC-TriggerGCTest04_Phone/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest04) +run(TriggerGCTest04,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/TriggerGCTest05.java b/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/TriggerGCTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..9c643817fb9292aaeebc7fa6245a9dcd73a7730f --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/TriggerGCTest05.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.SoftReference; +import java.util.ArrayList; +public class TriggerGCTest05 { + static int check = 4; + public static void main(String[] args) { + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + SoftReference softReference = new SoftReference<>(new Reference05(100)); + Reference05 rt01 = softReference.get(); + if (rt01.stringArray.length == 100 && rt01.stringArray[9].equals("test9")) { + check--; + } + rt01 = null; + try { + Thread.sleep(4000); + } catch (InterruptedException e) { + // do nothing + } + try { + int oom = oomTest(); // 触发oom + } catch (OutOfMemoryError o) { + check--; + } + if (softReference.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } + private static int oomTest() { + int sum = 0; + ArrayList store = new ArrayList(); + byte[] temp; + for (int i = 1054 * 1054; i <= 1054 * 1054 * 10; ) { + temp = new byte[i]; + store.add(temp); + sum += store.size(); + } + return sum; + } +} +class Reference05 { + String[] stringArray; + public Reference05(int length) { + stringArray = new String[length]; + for (int i = 0; i < length; i++) { + stringArray[i] = "test" + i; + } + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/test.cfg b/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ffaed6dd741b69d3c61cbba56d00f116d505494d --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0461-rc-GC-TriggerGCTest05_Phone/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest05) +run(TriggerGCTest05,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/TriggerGCTest06.java b/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/TriggerGCTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..0811d5382fbd2b94965fe111c566285c7e7582b7 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/TriggerGCTest06.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +public class TriggerGCTest06 { + static WeakReference observer; + static ReferenceQueue rq = new ReferenceQueue(); + static int check = 2; + private final static int RPLENGTH = 10000; + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + for (int i = 0; i < RPLENGTH; i++) { + WeakReference wr = new WeakReference(new Object(),rq); + wr = null; + } + Thread.sleep(3000); + if (observer.get() == null) { // gconly因为该触发机制已经去使能,所以不会隐式触发GC; rc使能了该机制。 + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/test.cfg b/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..317c22587d7b7bc1a03d35398f251aa24e2d939e --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0462-rc-GC-TriggerGCTest06_Phone/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(TriggerGCTest06) +run(TriggerGCTest06,EXPECTNUM=1) diff --git a/testsuite/java_test/rc_test/issue-RC0467-rc-GC-TriggerGCTest11-Phone/TriggerGCTest11.java b/testsuite/java_test/rc_test/issue-RC0467-rc-GC-TriggerGCTest11-Phone/TriggerGCTest11.java new file mode 100644 index 0000000000000000000000000000000000000000..2f7b6209e533d347a2bb5b592e6ef6e4b51b35c4 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0467-rc-GC-TriggerGCTest11-Phone/TriggerGCTest11.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.File; +import java.io.FileInputStream; +import java.lang.ref.WeakReference; +public class TriggerGCTest11 { + static WeakReference observer; + static int check = 2; + public static String str = new String("Native memory test"); + public static int[] arr = new int[10 * 1024 * 1024]; + public static void main(String[] args) throws Exception { + observer = new WeakReference(new Object()); + if (observer.get() != null) { + check--; + } + rc_testcase_main_wrapper(); + Thread.sleep(3000); + if (observer.get() == null) { + check--; + } + if (check == 0) { + System.out.println("ExpectResult"); + } else { + System.out.println("ErrorResult, check should be 0, but now check = " + check); + } + } + private static void rc_testcase_main_wrapper() { + try { + String filePath = "/system/lib64/libmaplecore-all.so"; + FileInputStream fis = new FileInputStream(filePath); // Any file with size >= 501*501*501*2 + int fileSize = fis.available(); + byte buf[] = new byte[fileSize]; + fis.read(buf); + System.out.println("buffRead ok"); + } catch (Exception e) { + // do nothing + } + } +} diff --git a/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/TrimTest01.java b/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/TrimTest01.java new file mode 100644 index 0000000000000000000000000000000000000000..9da5dc8712953d8be140994c6b5a080f68fa1473 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/TrimTest01.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest01 { + private static final int MEMORY_LIMIT = 10; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest01().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo); + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) < 3.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..775fea8178a46b6004c9c5d4de6f28dc9858edc0 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0495-rc-Trim-TrimTest01-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest01_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/TrimTest02.java b/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/TrimTest02.java new file mode 100644 index 0000000000000000000000000000000000000000..405d4da0f8b807e2411de60c7d3ac0332cb66b2b --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/TrimTest02.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest02 { + private static final int MEMORY_LIMIT = 10; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest02().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 9; i >= 5; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) > 3.8 * 1024 && + (Integer.valueOf(rosInfo) - Integer.valueOf(rosInfo2) > 2.7 * 1024)) { + System.out.println("ExpectResult"); + } else { + System.out.println("before gc: " + rosInfo + " after gc: " + rosInfo2); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8f190c6bac45b1366b8a3fa680e7e660f5e396a --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0496-rc-Trim-TrimTest02-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest02_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/TrimTest03.java b/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/TrimTest03.java new file mode 100644 index 0000000000000000000000000000000000000000..58656626e8bb5fe8c92f8bdf77ed8481bab14f17 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/TrimTest03.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest03 { + private static final int MEMORY_LIMIT = 10; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest03().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 9; i > 7; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) - Integer.valueOf(rosInfo2) < 1.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..df2f338e506656f56a0b64c9a5efc430eb7575df --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0497-rc-Trim-TrimTest03-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest03_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/TrimTest04.java b/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/TrimTest04.java new file mode 100644 index 0000000000000000000000000000000000000000..d49d93ee831f30903f5ce56d957690b1bae1d3af --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/TrimTest04.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest04 { + private static final int MEMORY_LIMIT = 20; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest04().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo); + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) < 3.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cf002752ab4778a8165767f3b9b1ef752e0017ec --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0498-rc-Trim-TrimTest04-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest04_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/TrimTest05.java b/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/TrimTest05.java new file mode 100644 index 0000000000000000000000000000000000000000..10159c0fc8fd7369c2a883b95efc744895966e94 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/TrimTest05.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest05 { + private static final int MEMORY_LIMIT = 20; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest05().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 19; i > 10; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) > 11 * 1024 && + Integer.valueOf(rosInfo2) < 15.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..846dfaa300137915f15c3b7747783f8595f7b21c --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0499-rc-Trim-TrimTest05-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest05_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/TrimTest06.java b/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/TrimTest06.java new file mode 100644 index 0000000000000000000000000000000000000000..3b13b31ac6faf937b1f27d4ecadfd52ebd24f026 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/TrimTest06.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest06 { + private static final int MEMORY_LIMIT = 20; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest06().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo); + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 19; i > 16; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) - Integer.valueOf(rosInfo2) < 1.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f1647e169b835b3f1855446210bbb089d60adde5 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0500-rc-Trim-TrimTest06-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest06_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/TrimTest07.java b/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/TrimTest07.java new file mode 100644 index 0000000000000000000000000000000000000000..5c668649580c5fe8e560e77bd45ef94ea2360931 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/TrimTest07.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest07 { + private static final int MEMORY_LIMIT = 50; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest07().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) < 5 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7813a1b5574751e760cc1044a850f2fb367e06ae --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0501-rc-Trim-TrimTest07-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest07_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/TrimTest08.java b/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/TrimTest08.java new file mode 100644 index 0000000000000000000000000000000000000000..9f5dcaf7247d7fb90bf7264af5221c6c48e5c602 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/TrimTest08.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest08 { + private static final int MEMORY_LIMIT = 50; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest08().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 49; i > 39; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + // System.out.println(rosInfo2); + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) >= 41.8 * 1024 && + Integer.valueOf(rosInfo2) < 44.2 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..516df219c5df1063a5f38e2df7aac9955ff7036b --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0502-rc-Trim-TrimTest08-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest08_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/TrimTest09.java b/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/TrimTest09.java new file mode 100644 index 0000000000000000000000000000000000000000..c668f8ded867e81b529309dc8b6adfcbe88b940c --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/TrimTest09.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest09 { + private static final int MEMORY_LIMIT = 50; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest09().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 49; i > 42; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) - Integer.valueOf(rosInfo2) < 1.5 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b4716a7a0639f525b0848a3a1339b365daa9d6ac --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0503-rc-Trim-TrimTest09-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest09_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/TrimTest10.java b/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/TrimTest10.java new file mode 100644 index 0000000000000000000000000000000000000000..74da6b5d978286d54720acb4f311b27db3b1d27c --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/TrimTest10.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest10 { + private static final int MEMORY_LIMIT = 100; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest10().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + store.clear(); + store = null; + Thread.sleep(4000); + Runtime.getRuntime().gc(); + Thread.sleep(3000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) < 5 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7b4686a24677fc24c884187766d298a60a2a2832 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0504-rc-Trim-TrimTest10-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest10_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/TrimTest11.java b/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/TrimTest11.java new file mode 100644 index 0000000000000000000000000000000000000000..f478b207933ba75907b2a75f1d68a1d9a44d8fc3 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/TrimTest11.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest11 { + private static final int MEMORY_LIMIT = 100; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest11().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 99; i > 89; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) > MEMORY_LIMIT * 1024 && Integer.valueOf(rosInfo2) > 89 * 1024 && + Integer.valueOf(rosInfo2) < 94.5 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..29a7db35c621f168c3062b8e293597f88de63962 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0505-rc-Trim-TrimTest11-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest11_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/TrimTest12.java b/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/TrimTest12.java new file mode 100644 index 0000000000000000000000000000000000000000..7d8d65acd05219d987a43cf7ff60bcec5ca9ec48 --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/TrimTest12.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; +public class TrimTest12 { + private static final int MEMORY_LIMIT = 100; + private static ArrayList store = new ArrayList(); + public static void main(String[] args) throws Exception { + Thread.sleep(2000); + for (int i = 0; i < MEMORY_LIMIT; i++) { + byte[] temp = new byte[1024 * 1024]; + for (int j = 0; j < 1024 * 1024; j += 4096) { + temp[j] = (byte) 1; + } + store.add(temp); + } + int pid = new TrimTest12().getPid(); + String command = "showmap " + pid; + Process process = Runtime.getRuntime().exec(command); + BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo = ""; + while ((rosInfo = input.readLine()) != null) { + if (rosInfo.contains("maple_alloc_ros]")) { + rosInfo = rosInfo.split("\\s+")[3]; + break; + } + } + input.close(); + for (int i = 99; i > 94; i--) { + store.remove(i); + } + Thread.sleep(2000); + Runtime.getRuntime().gc(); + Thread.sleep(2000); + process = Runtime.getRuntime().exec(command); + input = new BufferedReader(new InputStreamReader(process.getInputStream())); + String rosInfo2 = ""; + while ((rosInfo2 = input.readLine()) != null) { + if (rosInfo2.contains("maple_alloc_ros]")) { + // System.out.println(rosInfo2); + rosInfo2 = rosInfo2.split("\\s+")[3]; + break; + } + } + input.close(); + store = null; + if (Integer.valueOf(rosInfo) - Integer.valueOf(rosInfo2) < 1.5 * 1024) { + System.out.println("ExpectResult"); + } + } + public native int getPid(); +} diff --git a/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/jniNativeGetPid.cpp b/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/jniNativeGetPid.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4b5aa622213bbc35feafba1c13e7616e977e8b4d --- /dev/null +++ b/testsuite/java_test/rc_test/issue-RC0506-rc-Trim-TrimTest12-Phone/jniNativeGetPid.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include +#include +#include + +extern "C" { +JNIEXPORT jint JNICALL Java_TrimTest12_getPid__ +(JNIEnv *env, jobject j_obj) { + return getpid(); +} +} diff --git a/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java b/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java new file mode 100755 index 0000000000000000000000000000000000000000..5432d8b5e24c12c665814def63ac8f3d08c3d44f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/RCPermanentTest.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import java.lang.ref.WeakReference; +public class RCPermanentTest { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int @Permanent [8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + /* + 验证new int [8] + */ + + + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + /* + 验证new @Permanent int[8] + */ + + + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + /* + 验证new Integer @Permanent [10] + */ + + + static void method4(Object obj) { + Integer[] arr = new Integer @Permanent [10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + /* + 验证new @Permanent Integer [10] + */ + + + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + /* + 验证new Integer[10]; + */ + + + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + } + } + /* + 验证new @Permanent ArrayList[]{}; + */ + + + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + /* + 验证new ArrayList @Permanent []{}; + */ + + + static void method8(Object obj) { + obj = new ArrayList @Permanent []{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + /* + 验证new ArrayList []{}; + */ + + + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + static ArrayList noleak = new ArrayList<>(); + public static int NUM = 5; + public static void main(String[] args) { + for(int i=0;i +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/test.cfg b/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a6514fe3121e08b3a0d7bb13906fd72b51f83f9f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0411-rc-Annotation-RCPermanentTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest) diff --git a/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java new file mode 100755 index 0000000000000000000000000000000000000000..e4d472b8724bdfcaf0f11ad3380c9bb79fc6a5a6 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/RCPermanentTest2.java @@ -0,0 +1,202 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import java.lang.ref.WeakReference; +public class RCPermanentTest2 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + public static Integer INT = new @Permanent Integer(100); + public static Integer INT2 = new Integer(100); + static String STRING = new @Permanent String("test"); + static Long LONG = new @Permanent Long(522222); + static Long LONG2 = null; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + /* + 验证public final static Integer INT = new @Permanent Integer(100); + */ + + + static void method1() { + boolean result = checkRC(INT); + boolean heapResult = isHeapObject(INT); + if ((result == false) && (heapResult == false)) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result:" + result + " isHeap:" + heapResult); + System.out.println(String.valueOf(result)); + System.out.println(String.valueOf(heapResult)); + } + } + /* + 验证public final static Integer INT2 = new Integer(100); + */ + + + static void method2() { + boolean result = checkRC(INT2); + if (result == true && isHeapObject(INT2) == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(INT2)); + } + } + /* + 验证static String STRING = new @Permanent String("test"); + */ + + + static void method3() { + // static String STRING = new @Permanent String("test"); + boolean result = checkRC(STRING); + if (result == true && isHeapObject(STRING) == true) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(STRING)); + } + } + /* + 验证static Long LONG2 = new Long("test4"); + */ + + + static void method4() { + LONG2 = new Long(2222222); + boolean result = checkRC(LONG2); + if (result == true && isHeapObject(LONG2) == true) { + checkNum++; + } else { + System.out.println("error in method4"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG2)); + } + } + /* + 验证String obj = new @Permanent Long("test5"); + */ + + + static void method5() { + //String obj = new @Permanent String("test5"); + Double obj = new @Permanent Double(3333.3); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method5"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证String obj = new String("test6"); + */ + + + static void method6() { + Double obj = new Double(3333.3); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method6"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证obj = new @Permanent Integer("test"); + */ + + + static volatile Integer obj = null; + static void method7() { + obj = new @Permanent Integer(123); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method7"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证obj = new @Permanent Integer("test"); + */ + + + static void method8() { + obj = new Integer(123); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method8"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证static Long LONG = new @Permanent Long(522222); + */ + + + static void method9() { + boolean result = checkRC(LONG); + if (result == false && isHeapObject(LONG) == false) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG)); + } + } + public static void main(String[] args) { + method1(); + method2(); + method3(); + method4(); + method5(); + method6(); + method7(); + method8(); + method9(); + if (checkNum == 9) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/expected.txt b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4ff4a1fb47ec7c07ee280d491dbca9e264a7d985 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest2"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest2_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/test.cfg b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a5396c9bebb65dfd342e1c71664bc1d4aa03327c --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0412-rc-Annotation-RCPermanentTest2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest2,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest2) diff --git a/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java new file mode 100755 index 0000000000000000000000000000000000000000..d16fc0db790d03e51146331a5d8bf3976b228cfd --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/RCPermanentTest3.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import java.lang.ref.WeakReference; +public class RCPermanentTest3 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1() { + ArrayList list = null; + list = new @Permanent ArrayList<>(); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("false") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + static void method2() { + ArrayList list = null; + list = new ArrayList(); + list.add("test"); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + public static void main(String[] args) { + method1(); + Runtime.getRuntime().gc(); + method1(); + method2(); + Runtime.getRuntime().gc(); + method2(); + if (checkNum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/expected.txt b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5fe2ed467e5dd437a9773b26517c09c24ce80fb7 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest3_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest3"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest3_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/test.cfg b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6d32e0d59dc69674b4be0ebdfbd4793eb2515255 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0413-rc-Annotation-RCPermanentTest3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest3,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest3) diff --git a/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java new file mode 100755 index 0000000000000000000000000000000000000000..2ef488ea1e6273413c336815148ad035cef8c87e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/RCPermanentTest4.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import java.lang.ref.WeakReference; +public class RCPermanentTest4 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + /* + 验证环场景 + */ + + + static void method1() { + Cycle_A a = new Cycle_A(); + a.b = null; + a.b = new @Permanent Cycle_B(); + a.b.a = a; + int result = a.add() + a.b.add(); + if (result == 16) { + checkNum++; + } else { + System.out.println("result:" + result); + } + boolean resultA1 = checkRC(a); + boolean resultA2 = isHeapObject(a); + boolean resultB1 = checkRC(a.b); + boolean resultB2 = isHeapObject(a.b); + if (String.valueOf(resultA1).equals("true") && String.valueOf(resultA2).equals("true") && String.valueOf(resultB1).equals("false") && String.valueOf(resultB2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error"); + System.out.println("CycleA_checkRC:" + resultA1); + System.out.println("CycleA_isHeap:" + resultA2); + System.out.println("CycleB_checkRC:" + resultB1); + System.out.println("CycleB_isHeap:" + resultB2); + //System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + public static void main(String[] args) { + method1(); + if (checkNum == 2) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +class Cycle_A { + Cycle_B b; + static int sum; + static int a; + Cycle_A() { + a = 3; + } + int add() { + sum = a + b.b; + return sum; + } +} +class Cycle_B { + Cycle_A a; + static int sum; + static int b; + Cycle_B() { + b = 5; + } + int add() { + sum = a.a + b; + return sum; + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/expected.txt b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bea76f7a2974199204d8fc53442f00a9f68e69b7 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest4_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest4"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest4_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/test.cfg b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..49b8f9566e931e1f5cdf3f86f738d7a70a13842f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0414-rc-Annotation-RCPermanentTest4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest4,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest4) diff --git a/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java new file mode 100755 index 0000000000000000000000000000000000000000..86eb5886a218cc9868c8121fefbd07ea0dda113e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/RCPermanentTest5.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import sun.misc.Cleaner; +import java.lang.ref.*; +import static java.lang.Thread.sleep; +class FinalizableObject { + // static int value; + public void finalize() { + System.out.println("ExpectResult"); + } +} +public class RCPermanentTest5 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + static Object owner; + static int checkSum; + static Object referent = new Object(); + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + static void methodRef1(Object obj) { + obj = new @Permanent WeakReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodRef2(Object obj) { + obj = new @Permanent SoftReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodRef3(Object obj) { + ReferenceQueue rq = new ReferenceQueue(); + obj = new @Permanent PhantomReference(referent, rq); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodFinal(Object obj) throws InterruptedException { + obj = new @Permanent FinalizableObject(); + sleep(3000); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + public static void main(String[] args) throws InterruptedException { + Object obj = null; + methodRef1(obj); + methodRef2(obj); + methodRef3(obj); + methodFinal(obj); + if (checkSum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkSum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/expected.txt b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a13833282f618115eb3ceee4d7290550e74c272e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest5_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest5"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest5_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/test.cfg b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e2f6bd77ac64add5ba792815e61ef89941ae6f3 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0415-rc-Annotation-RCPermanentTest5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest5,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest5) diff --git a/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java new file mode 100755 index 0000000000000000000000000000000000000000..026278b24a567a7ba33cc5ff876042ad04d71dfa --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/RCPermanentThread.java @@ -0,0 +1,674 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import sun.misc.Cleaner; +import java.lang.ref.*; +public class RCPermanentThread { + static { + System.loadLibrary("jniTestHelper"); + } + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest2 rcPermanentTest2 = new RCPermanentTest2(); + RCPermanentTest3 rcPermanentTest3 = new RCPermanentTest3(); + RCPermanentTest4 rcPermanentTest4 = new RCPermanentTest4(); + RCPermanentTest5 rcPermanentTest5 = new RCPermanentTest5(); + rcPermanentTest.start(); + rcPermanentTest2.start(); + rcPermanentTest3.start(); + rcPermanentTest4.start(); + rcPermanentTest5.start(); + rcPermanentTest.join(); + rcPermanentTest2.join(); + rcPermanentTest3.join(); + rcPermanentTest4.join(); + rcPermanentTest5.join(); + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } +} +class RCPermanentTest extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + /* + 验证new int [8] + */ + + + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + /* + 验证new @Permanent int[8] + */ + + + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + /* + 验证new Integer @Permanent [10] + */ + + + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + /* + 验证new @Permanent Integer [10] + */ + + + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + /* + 验证new Integer[10]; + */ + + + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + } + } + /* + 验证new @Permanent ArrayList[]{}; + */ + + + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + /* + 验证new ArrayList @Permanent []{}; + */ + + + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + /* + 验证new ArrayList []{}; + */ + + + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + static ArrayList noleak = new ArrayList<>(); + public void run( + ) { + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + public boolean check() { + return checkout; + } +} +class RCPermanentTest2 extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + public static Integer INT = new @Permanent Integer(100); + public static Integer INT2 = new Integer(100); + static String STRING = new @Permanent String("test"); + static Long LONG = new @Permanent Long(23534); + static Long LONG2 = null; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + /* + 验证public final static Integer INT = new @Permanent Integer(100); + */ + + + static void method1() { + boolean result = checkRC(INT); + boolean heapResult = isHeapObject(INT); + if ((result == false) && (heapResult == false)) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result:" + result + " isHeap:" + heapResult); + System.out.println(String.valueOf(result)); + System.out.println(String.valueOf(heapResult)); + } + } + /* + 验证public final static Integer INT2 = new Integer(100); + */ + + + static void method2() { + boolean result = checkRC(INT2); + if (result == true && isHeapObject(INT2) == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(INT2)); + } + } + /* + 验证static String STRING = new @Permanent String("test"); + */ + + + static void method3() { + // STRING = new @Permanent (454555); + boolean result = checkRC(STRING); + if (result == true && isHeapObject(STRING) == true) { + checkNum++; + } else { + System.out.println("error in method3"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(STRING)); + } + } + /* + 验证static Long LONG2 = new Long("test4"); + */ + + + static void method4() { + LONG2 = new Long(2222222); + boolean result = checkRC(LONG2); + if (result == true && isHeapObject(LONG2) == true) { + checkNum++; + } else { + System.out.println("error in method4"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG2)); + } + } + /* + 验证String obj = new @Permanent Long("test5"); + */ + + + static void method5() { + //String obj = new @Permanent String("test5"); + Double obj = new @Permanent Double(3333.3); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method5"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证String obj = new String("test6"); + */ + + + static void method6() { + Double obj = new Double(3333.3); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method6"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证obj = new @Permanent Integer("test"); + */ + + + static volatile Integer obj = null; + static void method7() { + obj = new @Permanent Integer(123); + boolean result = checkRC(obj); + if (result == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in method7"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证obj = new @Permanent Integer("test"); + */ + + + static void method8() { + obj = new Integer(123); + boolean result = checkRC(obj); + if (result == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in method8"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(obj)); + } + } + /* + 验证static long LONG = new @Permanent long(23534); + */ + + + static void method9() { + boolean result = checkRC(LONG); + if (result == false && isHeapObject(LONG) == false) { + checkNum++; + } else { + System.out.println("error in method9"); + System.out.println("result:" + result + " isHeap:" + isHeapObject(LONG)); + } + } + public void run() { + method1(); + method2(); + method3(); + method4(); + method5(); + method6(); + method7(); + method8(); + method9(); + //System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + public boolean check() { + return checkout; + } +} +class RCPermanentTest3 extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1() { + ArrayList list = null; + list = new @Permanent ArrayList<>(); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("false") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method1"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + static void method2() { + ArrayList list = null; + list = new ArrayList(); + list.add("test"); + boolean result1 = checkRC(list); + boolean result2 = isHeapObject(list); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error in method2"); + System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + public void run() { + method1(); + Runtime.getRuntime().gc(); + method1(); + method2(); + Runtime.getRuntime().gc(); + method2(); + if (checkNum == 4) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + public boolean check() { + return checkout; + } +} +class RCPermanentTest4 extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + /* + 验证环场景 + */ + + + static void method1() { + Cycle_A a = new Cycle_A(); + a.b = null; + a.b = new @Permanent Cycle_B(); + a.b.a = a; + int result = a.add() + a.b.add(); + if (result == 16) { + checkNum++; + } else { + System.out.println("result:" + result); + } + boolean resultA1 = checkRC(a); + boolean resultA2 = isHeapObject(a); + boolean resultB1 = checkRC(a.b); + boolean resultB2 = isHeapObject(a.b); + if (String.valueOf(resultA1).equals("true") && String.valueOf(resultA2).equals("true") && String.valueOf(resultB1).equals("false") && String.valueOf(resultB2).equals("true")) { + //if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("error"); + System.out.println("CycleA_checkRC:" + resultA1); + System.out.println("CycleA_isHeap:" + resultA2); + System.out.println("CycleB_checkRC:" + resultB1); + System.out.println("CycleB_isHeap:" + resultB2); + //System.out.println("result1:" + result1 + " is Heap:" + result2); + } + } + public void run() { + method1(); + if (checkNum == 2) { + checkout = true; + } else { + System.out.println(checkNum); + checkout = false; + } + } + public boolean check() { + return checkout; + } +} +class Cycle_A { + Cycle_B b; + static int sum; + static int a; + Cycle_A() { + a = 3; + } + int add() { + sum = a + b.b; + return sum; + } +} +class Cycle_B { + Cycle_A a; + static int sum; + static int b; + Cycle_B() { + b = 5; + } + int add() { + sum = a.a + b; + return sum; + } +} +class RCPermanentTest5 extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + static Object owner; + static Object referent = new Object(); + static int checkSum; + public void run() { + Object obj = null; + methodRef1(obj); + methodRef2(obj); + methodRef3(obj); + methodFinal(obj); + if (checkSum == 4) { + checkout = true; + } else { + checkout = false; + System.out.println(checkSum); + } + } + public boolean check() { + return checkout; + } + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + } + static void methodRef1(Object obj) { + obj = new @Permanent WeakReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodRef2(Object obj) { + obj = new @Permanent SoftReference(referent); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodRef3(Object obj) { + ReferenceQueue rq = new ReferenceQueue(); + obj = new @Permanent PhantomReference(referent, rq); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } + static void methodFinal(Object obj) { + obj = new @Permanent FinalizableObject(); + boolean result1 = checkRC(obj); + boolean result2 = isHeapObject(obj); + if (String.valueOf(result1).equals("true") && String.valueOf(result2).equals("true")) { + checkSum++; + } else { + System.out.println("resultRC:" + result1); + System.out.println("result_isHeap:" + result2); + } + } +} +class FinalizableObject { + // static int value; + public void finalize() { + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/expected.txt b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4672998a3981406136e3b2b807ae078b4ee7d43c --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/jniTestHelper.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest3_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest4_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest5_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + + jclass c = env->FindClass("RCPermanentTest"); + if (!c) return JNI_ERR; + // Register your class' native methods. + static const JNINativeMethod methods1[]= { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods1, sizeof(methods1)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + + c = env->FindClass("RCPermanentTest2"); + if (!c) return JNI_ERR; + // Register your class' native methods. + static const JNINativeMethod methods2[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest2_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest2_refCount__Ljava_lang_Object_2)}, + + }; + rc = env->RegisterNatives(c, methods2, sizeof(methods2)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + + c = env->FindClass("RCPermanentTest3"); + if (!c) return JNI_ERR; + // Register your class' native methods. + static const JNINativeMethod methods3[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest3_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest3_refCount__Ljava_lang_Object_2)}, + + }; + rc = env->RegisterNatives(c, methods3, sizeof(methods3)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + + c = env->FindClass("RCPermanentTest4"); + if (!c) return JNI_ERR; + // Register your class' native methods. + static const JNINativeMethod methods4[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest4_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest4_refCount__Ljava_lang_Object_2)}, + + }; + rc = env->RegisterNatives(c, methods4, sizeof(methods4)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + + c = env->FindClass("RCPermanentTest5"); + if (!c) return JNI_ERR; + // Register your class' native methods. + static const JNINativeMethod methods5[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest5_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest5_refCount__Ljava_lang_Object_2)}, + + }; + rc = env->RegisterNatives(c, methods5, sizeof(methods5)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/test.cfg b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9779e1593db143015b34b652ab26ed7488730a83 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0416-rc-Annotation-RCPermanentThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentThread,NATIVE_SRC=jniTestHelper) +run(RCPermanentThread) diff --git a/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java new file mode 100755 index 0000000000000000000000000000000000000000..5fc060ac3078f81cba66de3002a1a2e6bcb54ea4 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/RCPermanentTest6.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.ArrayList; +import com.huawei.ark.annotation.*; +import java.lang.ref.WeakReference; +public class RCPermanentTest6 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + public static void main(String[] args) { + Object obj = null; + method1(obj); + new Test_A().test(); + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +class Test_B { + @Unowned + Test_A aa; + // add volatile will crash + // static Test_A a1; + protected void finalize() { + System.out.println("ExpectResult"); + } +} +class Test_A { + Test_B bb; + public void test() { + setReferences(); + System.runFinalization(); + } + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/expected.txt b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6ec111985d15aad3d089c85dc0ed30e2058b9e93 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/expected.txt @@ -0,0 +1,2 @@ +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a4ca8829ee61ccaeea1372b2d781a5e5814c1c66 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest6_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest6_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest6"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest6_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest6_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/test.cfg b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8eec88cfef92da04119b8ec30b5a95be524a582f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0423-rc-Annotation-RCPermanentTest6/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest6,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest6) diff --git a/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java new file mode 100755 index 0000000000000000000000000000000000000000..90dca48441c16998782e4c3a8fcc17292a303560 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/RCPermanentThread2.java @@ -0,0 +1,296 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.ArrayList; +import com.huawei.ark.annotation.*; +public class RCPermanentThread2 { + static { + System.loadLibrary("jniTestHelper"); + } + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + rc_testcase_main_wrapper2(); + } + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + rcPermanentTest.start(); + rcPermanentTest.join(); + rcPermanentTest2.start(); + rcPermanentTest2.join(); + rcPermanentTest3.start(); + rcPermanentTest3.join(); + rcPermanentTest4.start(); + rcPermanentTest4.join(); + rcPermanentTest5.start(); + rcPermanentTest5.join(); + // rcPermanentTest.join(); + // rcPermanentTest2.join(); + // rcPermanentTest3.join(); + // rcPermanentTest4.join(); + // rcPermanentTest5.join(); + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } + private static void rc_testcase_main_wrapper2() throws InterruptedException { + RCUnownedTest rcUnownedTest = new RCUnownedTest(); + RCUnownedTest rcUnownedTest2 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest3 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest4 = new RCUnownedTest(); + RCUnownedTest rcUnownedTest5 = new RCUnownedTest(); + rcUnownedTest.start(); + rcUnownedTest2.start(); + rcUnownedTest3.start(); + rcUnownedTest4.start(); + rcUnownedTest5.start(); + rcUnownedTest.join(); + rcUnownedTest2.join(); + rcUnownedTest3.join(); + rcUnownedTest4.join(); + rcUnownedTest5.join(); + } +} +class RCPermanentTest extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + /* + 验证new int [8] + */ + + + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + /* + 验证new @Permanent int[8] + */ + + + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + /* + 验证new Integer @Permanent [10] + */ + + + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + /* + 验证new @Permanent Integer [10] + */ + + + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + /* + 验证new Integer[10]; + */ + + + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + System.out.println("checkRC(obj):" + result1 + " isHeapObject(obj):" + isHeapObject(obj)); + } + } + /* + 验证new @Permanent ArrayList[]{}; + */ + + + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + /* + 验证new ArrayList @Permanent []{}; + */ + + + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + /* + 验证new ArrayList []{}; + */ + + + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + static ArrayList noleak = new ArrayList<>(); + public void run( + ) { + checkNum = 0; + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + // System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println("checkout== false,checkNum:"+checkNum); + } + } + public boolean check() { + return checkout; + } +} +class RCUnownedTest extends Thread { + public void run() { + new Test_A().test(); + } +} +class Test_A { + Test_B bb; + public void test() { + setReferences(); + System.runFinalization(); + } + private void setReferences() { + Test_A ta = new Test_A(); + ta.bb = new Test_B(); + //ta.bb.aa = ta; + try { + Field m = Test_B.class.getDeclaredField("aa"); + m.set(ta.bb, ta); + Test_A a_temp = (Test_A) m.get(ta.bb); + if (a_temp != ta) { + System.out.println("error"); + } + //Field m1 = Test_B.class.getDeclaredField("a1"); + //m1.set(null, ta); + } catch (Exception e) { + System.out.println(e); + } + } +} +class Test_B { + @Unowned + Test_A aa; + // add volatile will crash + // static Test_A a1; + protected void finalize() { + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/expected.txt b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3f44f268b8913e6a81e85022f8a04b1cac53c71d --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/expected.txt @@ -0,0 +1,6 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8f5a082bd2f6cd40abefbd061f93efe9c9b3695 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/test.cfg b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e6334af0480760a018d958aed2ef776b54ec4423 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0424-rc-Annotation-RCPermanentThread2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentThread2,NATIVE_SRC=jniTestHelper) +run(RCPermanentThread2) diff --git a/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java new file mode 100755 index 0000000000000000000000000000000000000000..4079febc1c4a32228696fe2379a1b83df6824830 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/RCPermanentTest7.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.*; +public class RCPermanentTest7 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + public static void main(String[] args) { + Object obj = null; + method1(obj); + new Test_A().test(); + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/expected.txt b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..309f6d50570536aa5ec2bd6eba765f9c8fa03b0f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/expected.txt @@ -0,0 +1,3 @@ +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a0565849e9a09770d9ac3f093dfe1a2d3fe0da97 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/jniTestHelper.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest7_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest7_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest7"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest7_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest7_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} + +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/test.cfg b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f56b863bd960fb977d78e99a5df7596e8409a0b --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0425-rc-Annotation-RCPermanentTest7/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest7,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest7) diff --git a/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java new file mode 100755 index 0000000000000000000000000000000000000000..8adff38c439f018792d0127f891fc97401786e78 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/RCPermanentThread3.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.ArrayList; +import com.huawei.ark.annotation.*; +public class RCPermanentThread3 { + static { + System.loadLibrary("jniTestHelper"); + } + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + rc_testcase_main_wrapper2(); + } + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + rcPermanentTest.start(); + rcPermanentTest.join(); + rcPermanentTest2.start(); + rcPermanentTest2.join(); + rcPermanentTest3.start(); + rcPermanentTest3.join(); + rcPermanentTest4.start(); + rcPermanentTest4.join(); + rcPermanentTest5.start(); + rcPermanentTest5.join(); + // rcPermanentTest.join(); + // rcPermanentTest2.join(); + // rcPermanentTest3.join(); + // rcPermanentTest4.join(); + // rcPermanentTest5.join(); + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } + private static void rc_testcase_main_wrapper2() throws InterruptedException { + RCWeakTest rcWeakTest = new RCWeakTest(); + RCWeakTest rcWeakTest2 = new RCWeakTest(); + RCWeakTest rcWeakTest3 = new RCWeakTest(); + RCWeakTest rcWeakTest4 = new RCWeakTest(); + RCWeakTest rcWeakTest5 = new RCWeakTest(); + rcWeakTest.start(); + rcWeakTest2.start(); + rcWeakTest3.start(); + rcWeakTest4.start(); + rcWeakTest5.start(); + rcWeakTest.join(); + rcWeakTest2.join(); + rcWeakTest3.join(); + rcWeakTest4.join(); + rcWeakTest5.join(); + } +} +class RCPermanentTest extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } + /* + 验证new int [8] + */ + + + static void method2(Object obj) { + obj = new int[8]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new int [8];in method2"); + } + } + /* + 验证new @Permanent int[8] + */ + + + static void method3(Object obj) { + obj = new @Permanent int[1]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent int[8];in method3"); + } + } + /* + 验证new Integer @Permanent [10] + */ + + + static void method4(Object obj) { + Integer[] arr = new Integer@Permanent[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new Integer @Permanent [10];in method4"); + } + } + /* + 验证new @Permanent Integer [10] + */ + + + static void method5(Object obj) { + Integer[] arr = new @Permanent Integer[10]; + boolean result1 = checkRC(obj); + noleak.add(arr); // let leak check happy + arr[0] = new Integer(10000); + arr[9] = new Integer(20000); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent Integer [10];in method5"); + } + } + /* + 验证new Integer[10]; + */ + + + static void method6(Object obj) { + obj = new Integer[10]; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new Integer[10];in method6"); + System.out.println("checkRC(obj):" + result1 + " isHeapObject(obj):" + isHeapObject(obj)); + } + } + /* + 验证new @Permanent ArrayList[]{}; + */ + + + static void method7(Object obj) { + obj = new @Permanent ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new @Permanent ArrayList[]{};in method7"); + } + } + /* + 验证new ArrayList @Permanent []{}; + */ + + + static void method8(Object obj) { + obj = new ArrayList@Permanent[]{}; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new ArrayList @Permanent []{};in method8"); + } + } + /* + 验证new ArrayList []{}; + */ + + + static void method9(Object obj) { + obj = new ArrayList[]{}; + boolean result1 = checkRC(obj); + if (result1 == true && isHeapObject(obj) == true) { + checkNum++; + } else { + System.out.println("error in new ArrayList []{}; method9"); + } + } + static ArrayList noleak = new ArrayList<>(); + public void run( + ) { + checkNum = 0; + Object obj = null; + method1(obj); + method2(obj); + method3(obj); + method4(obj); + method5(obj); + method6(obj); + method7(obj); + method8(obj); + method9(obj); + // System.out.println(checkNum); + if (checkNum == 9) { + checkout = true; + } else { + checkout = false; + System.out.println("checkout== false,checkNum:"+checkNum); + } + } + public boolean check() { + return checkout; + } +} +class RCWeakTest extends Thread { + public void run() { + new Test_A().test(); + } +} +class Test_A { + @Weak + Test_B bb; + Test_B bb2; + public void test() { + foo(); + try { + Thread.sleep(5000); + } catch (Exception e) { + e.printStackTrace(); + } + try { + bb.run(); + } catch (NullPointerException e) { + System.out.println("ExpectResult"); + } + bb2.run(); + } + private void foo() { + bb = new Test_B(); + bb2 = new Test_B(); + } +} +class Test_B { + public void run() { + System.out.println("ExpectResult"); + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/expected.txt b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..7751055d0f5d0bff59328f021666ba2ce929ba46 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/expected.txt @@ -0,0 +1,11 @@ +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e8f5a082bd2f6cd40abefbd061f93efe9c9b3695 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/test.cfg b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f18e7d3d80b7591bd63c3d34944bb6e9e54b2c14 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0426-rc-Annotation-RCPermanentThread3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentThread3,NATIVE_SRC=jniTestHelper) +run(RCPermanentThread3) diff --git a/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java new file mode 100755 index 0000000000000000000000000000000000000000..f4806d6003152fbd41b42882d88dfa3ddcd5afc2 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/RCPermanentTest8.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +import java.lang.ref.WeakReference; +public class RCPermanentTest8 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + try { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public static void main(String[] args) { + Object obj = null; + method1(obj); + if (checkNum == 1) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/expected.txt b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1b7000fce227a25e7d1e7ac50e4a61bbb7dd028a --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest8_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest8_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest8"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest8_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest8_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/test.cfg b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b9c4d9cc91b23a93def6211bf40fc0db3b31eb0e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0429-rc-Annotation-RCPermanentTest8/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentTest8,NATIVE_SRC=jniTestHelper) +run(RCPermanentTest8) diff --git a/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java new file mode 100755 index 0000000000000000000000000000000000000000..ab0247a5e03cdfa242dc8b0cdccad631e7d6b6d8 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/RCPermanentThread4.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import com.huawei.ark.annotation.Permanent; +public class RCPermanentThread4 { + static { + System.loadLibrary("jniTestHelper"); + } + public static void main(String[] args) throws InterruptedException { + rc_testcase_main_wrapper(); + } + private static void rc_testcase_main_wrapper() throws InterruptedException { + RCPermanentTest rcPermanentTest = new RCPermanentTest(); + RCPermanentTest rcPermanentTest2 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest3 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest4 = new RCPermanentTest(); + RCPermanentTest rcPermanentTest5 = new RCPermanentTest(); + rcPermanentTest.start(); + rcPermanentTest.join(); + rcPermanentTest2.start(); + rcPermanentTest2.join(); + rcPermanentTest3.start(); + rcPermanentTest3.join(); + rcPermanentTest4.start(); + rcPermanentTest4.join(); + rcPermanentTest5.start(); + rcPermanentTest5.join(); + if (rcPermanentTest.check() && rcPermanentTest2.check() && rcPermanentTest3.check() && rcPermanentTest4.check() && rcPermanentTest5.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + rcPermanentTest.check()); + System.out.println("rcPermanentTest2.check() :" + rcPermanentTest2.check()); + System.out.println("rcPermanentTest3.check() :" + rcPermanentTest3.check()); + System.out.println("rcPermanentTest4.check() :" + rcPermanentTest4.check()); + System.out.println("rcPermanentTest5.check() :" + rcPermanentTest5.check()); + } + } + private static void rc_testcase_main_wrapper2() throws InterruptedException { + SyncTest syncTest = new SyncTest(); + SyncTest syncTest1 = new SyncTest(); + SyncTest syncTest2 = new SyncTest(); + SyncTest syncTest3 = new SyncTest(); + SyncTest syncTest4 = new SyncTest(); + syncTest.start(); + syncTest.join(); + syncTest1.start(); + syncTest1.join(); + syncTest2.start(); + syncTest2.join(); + syncTest3.start(); + syncTest3.join(); + syncTest4.start(); + syncTest4.join(); + if (syncTest.check() && syncTest1.check() && syncTest2.check() && syncTest3.check() && syncTest4.check()) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("rcPermanentTest.check() :" + syncTest.check()); + System.out.println("rcPermanentTest2.check() :" + syncTest1.check()); + System.out.println("rcPermanentTest3.check() :" + syncTest2.check()); + System.out.println("rcPermanentTest4.check() :" + syncTest3.check()); + System.out.println("rcPermanentTest5.check() :" + syncTest4.check()); + } + } +} +class RCPermanentTest extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证new int @Permanent [8] + */ + + + static void method1(Object obj) { + try { + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkNum++; + } else { + System.out.println("error in new int @Permanent [8];in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public void run() { + checkNum = 0; + Object obj = null; + method1(obj); + if (checkNum == 1) { + checkout = true; + } else { + checkout = false; + System.out.println(checkNum); + } + } + public boolean check() { + return checkout; + } +} +class SyncTest extends Thread { + public boolean checkout; + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + public void run() { + synchronized (this) { + Object obj = null; + obj = new int@Permanent[8]; + boolean result1 = checkRC(obj); + if (result1 == false && isHeapObject(obj) == false) { + checkout = true; + } else { + checkout = false; + System.out.println("error in new int @Permanent [8];in method1"); + } + } + } + public boolean check() { + return checkout; + } +} \ No newline at end of file diff --git a/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/expected.txt b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e82688edab0b68e12e69b04e42056b0e54be9b5d --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/jniTestHelper.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentTest_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentTest"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentTest_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentTest_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} + +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/test.cfg b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9543f807894d3e947cb71021ed796b78e001fdf --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0430-rc-Annotation-RCPermanentThread4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentThread4,NATIVE_SRC=jniTestHelper) +run(RCPermanentThread4) diff --git a/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java new file mode 100755 index 0000000000000000000000000000000000000000..7c941f3ffe1c908566a501e9c93401f7d1e44d0a --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/RCPermanentLimit2.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +public class RCPermanentLimit2 { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证加了注解Permanent,申请的内存为64K+1byte的情况 + */ + + + static void method1(Object obj) { + try { + obj = new @Permanent ArrayList(); + for (int i = 0; i < 64 * 1024+1; i++) { + byte tmp = 2; + ((ArrayList) obj).add(tmp); + } +// int check_size = ((ArrayList) obj).size(); +// System.out.println(check_size); + boolean result1 = checkRC(obj); + boolean result2 =isHeapObject(obj); + if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("result1:" + result1); + System.out.println("isHeapObject:" + result2); + System.out.println("error in new int test1;in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + /* + 验证加了注解Permanent,申请的内存为128K的情况 + */ + + + static void method2(Object obj) { + try { + obj = new @Permanent ArrayList(); + for (int i = 0; i < 128 * 1024; i++) { + byte tmp = 2; + ((ArrayList) obj).add(tmp); + } +// int check_size = ((ArrayList) obj).size(); +// System.out.println(check_size); + boolean result1 = checkRC(obj); + boolean result2 =isHeapObject(obj); + if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("result1:" + result1); + System.out.println("isHeapObject:" + result2); + System.out.println("error in new int test1;in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public static void main(String[] args) { + Object obj = null; + method1(obj); + Runtime.getRuntime().gc(); + method1(obj); + method2(obj); + Runtime.getRuntime().gc(); + method2(obj); + if (checkNum == 4) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/expected.txt b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e5e8feb95ecab1dfe58e33f57c312c91ef1194bb --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/jniTestHelper.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentLimit2_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentLimit2_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentLimit2"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object;)Z", reinterpret_cast(Java_RCPermanentLimit2_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object;)I", reinterpret_cast(Java_RCPermanentLimit2_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/test.cfg b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..498ab5cfab1c08d5c99d1d84d78f7104792bf1eb --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/RC0448-rc-Annotation-RCPermanentLimit2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentLimit2,NATIVE_SRC=jniTestHelper) +run(RCPermanentLimit2) diff --git a/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/RCPermanentLimit.java b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/RCPermanentLimit.java new file mode 100755 index 0000000000000000000000000000000000000000..ad9cda358baf7c517b3fd3d78362f9f0e15e509f --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/RCPermanentLimit.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.util.ArrayList; +import com.huawei.ark.annotation.Permanent; +public class RCPermanentLimit { + static { + System.loadLibrary("jniTestHelper"); + } + public static native boolean isHeapObject(Object obj); + public static native int refCount(Object obj); + public static int checkNum = 0; + static Object owner; + static boolean checkRC(Object obj) { + int rc1 = refCount(obj); + owner = obj; + int rc2 = refCount(obj); + owner = null; + int rc3 = refCount(obj); + if (rc1 != rc3) { + throw new RuntimeException("rc incorrect!"); + } + if (rc1 == rc2 && rc2 == rc3) { + //如果相等,说明annotation生效,没有经过RC处理 + return false; + } else { + return true; + } + //System.out.printf("rc:%-5s heap:%-5s %s%n", !skipRC, isHeapObject(obj), title); + } + /* + 验证加了注解Permanent,申请的内存为64K的情况 + */ + + + static void method1(Object obj) { + try { + obj = new @Permanent ArrayList(); + for (int i = 0; i < 64 * 1024; i++) { + byte tmp = 2; + ((ArrayList) obj).add(tmp); + } +// int check_size = ((ArrayList) obj).size(); +// System.out.println(check_size); + boolean result1 = checkRC(obj); + boolean result2 =isHeapObject(obj); + if (result1 == false && result2 == true) { + checkNum++; + } else { + System.out.println("result1:" + result1); + System.out.println("isHeapObject:" + result2); + System.out.println("error in new int test1;in method1"); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + public static void main(String[] args) { + Object obj = null; + method1(obj); + Runtime.getRuntime().gc(); + method1(obj); + if (checkNum == 2) { + System.out.println("ExpectResult"); + } else { + System.out.println("error"); + System.out.println("checkNum:" + checkNum); + } + } +} diff --git a/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/expected.txt b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/jniTestHelper.cpp b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/jniTestHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0ed67d10abfc7c800e0b1dc740043314ce93e741 --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/jniTestHelper.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +#include +#include + +extern "C" { + +extern bool MRT_CheckHeapObj(void* ptr); +extern uint32_t MRT_RefCount(void* ptr); + +JNIEXPORT jboolean JNICALL Java_RCPermanentLimit_isHeapObject__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_CheckHeapObj((void*)obj); +} + +JNIEXPORT jint JNICALL Java_RCPermanentLimit_refCount__Ljava_lang_Object_2 +(JNIEnv *env, jclass cls, jobject obj) { + return MRT_RefCount((void*)obj); +} + +JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) { + JNIEnv* env; + if (vm->GetEnv(reinterpret_cast(&env), JNI_VERSION_1_6) != JNI_OK) { + return JNI_ERR; + } + // Find your class. JNI_OnLoad is called from the correct class loader context for this to work. + jclass c = env->FindClass("RCPermanentLimit"); + if (!c) return JNI_ERR; + + // Register your class' native methods. + static const JNINativeMethod methods[] = { + {"isHeapObject", "(Ljava/lang/Object)Z", reinterpret_cast(Java_RCPermanentLimit_isHeapObject__Ljava_lang_Object_2)}, + {"refCount", "(Ljava/lang/Object)I", reinterpret_cast(Java_RCPermanentLimit_refCount__Ljava_lang_Object_2)}, + + }; + int rc = env->RegisterNatives(c, methods, sizeof(methods)/sizeof(JNINativeMethod)); + if (rc != JNI_OK) return rc; + return JNI_VERSION_1_6; +} + +} /* extern "C" */ diff --git a/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/test.cfg b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..adc6d39d8a95bce69d032f64285a528183d20cfe --- /dev/null +++ b/testsuite/java_test/rc_test/native_test/issue-RC0447-rc-Annotation-RCPermanentLimit/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RCPermanentLimit,NATIVE_SRC=jniTestHelper,O0:O2) +run(RCPermanentLimit) diff --git a/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/ReflectingGetConstructor1.java b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/ReflectingGetConstructor1.java new file mode 100755 index 0000000000000000000000000000000000000000..584205402f608c08ac7866c12426aba108d9266c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/ReflectingGetConstructor1.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructor1 { + public GetConstructor1() { + } + public GetConstructor1(String name) { + } + public GetConstructor1(String name, int number) { + } + GetConstructor1(int number) { + } +} +public class ReflectingGetConstructor1 { + public static void main(String[] args) { + try { + Class getConstructor1 = Class.forName("GetConstructor1"); + Constructor constructor1 = getConstructor1.getConstructor(String.class); + Constructor constructor2 = getConstructor1.getConstructor(); + Constructor constructor3 = getConstructor1.getConstructor(String.class, int.class); + if (constructor1.toString().equals("public GetConstructor1(java.lang.String)") + && constructor2.toString().equals("public GetConstructor1()") + && constructor3.toString().equals("public GetConstructor1(java.lang.String,int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/expected.txt b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/test.cfg b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e78181523fee681686685e50b337def7df9854aa --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0001-rt-reflection-ReflectingetConstructor1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructor1) +run(ReflectingGetConstructor1) diff --git a/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/ReflectingGetConstructor2.java b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/ReflectingGetConstructor2.java new file mode 100755 index 0000000000000000000000000000000000000000..5d92760e8f33c76188b6ea2611c3eab98fdf6652 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/ReflectingGetConstructor2.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructor2 { + public GetConstructor2() { + } + public GetConstructor2(String name) { + } + public GetConstructor2(String name, int number) { + } + GetConstructor2(int number) { + } +} +public class ReflectingGetConstructor2 { + public static void main(String[] args) { + try { + Class getConstructor21 = Class.forName("GetConstructor2"); + Constructor constructor1 = getConstructor21.getConstructor(int.class); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e) { + try { + Class getConstructor22 = Class.forName("GetConstructor2"); + Constructor constructor2 = getConstructor22.getConstructor(String.class, char.class, int.class); + System.out.println(2); + } catch (ClassNotFoundException ee) { + System.err.println(ee); + System.out.println(2); + } catch (NoSuchMethodException ee) { + System.out.println(0); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/expected.txt b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/test.cfg b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..589142c7fb9dc4297d55cd00322db451975edd8e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0002-rt-reflection-ReflectingetConstructor2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructor2) +run(ReflectingGetConstructor2) diff --git a/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/ReflectingGetConstructors.java b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/ReflectingGetConstructors.java new file mode 100755 index 0000000000000000000000000000000000000000..da45f0a9f47f92939291956e15b82e745835dce4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/ReflectingGetConstructors.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetConstructors { + public GetConstructors() { + } + public GetConstructors(String name) { + } + public GetConstructors(String name, int number) { + } + GetConstructors(int number) { + } + GetConstructors(double id) { + } + public GetConstructors(double id, String name) { + } +} +class GetConstructors_a extends GetConstructors { + public GetConstructors_a() { + } + public GetConstructors_a(String name) { + } + public GetConstructors_a(String name, int number) { + } + GetConstructors_a(int number) { + } +} +public class ReflectingGetConstructors { + public static void main(String[] args) { + try { + Class getConstructors_a = Class.forName("GetConstructors_a"); + Constructor[] constructors = getConstructors_a.getConstructors(); + if (constructors.length == 3) { + for (int i = 0; i < constructors.length; i++) { + if (constructors[i].toString().indexOf("GetConstructors_a(int)") != -1) { + System.out.println(2); + } + } + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (ArrayIndexOutOfBoundsException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/expected.txt b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/test.cfg b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0dc5a7c7dc38f9dc115882f03d7aa67bfeb91aac --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0003-rt-reflection-ReflectingetConstructors/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetConstructors) +run(ReflectingGetConstructors) diff --git a/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java new file mode 100755 index 0000000000000000000000000000000000000000..9021043e5fdc3010d13c895f64f83ff4fbec5ec4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/ReflectingGetDeclaredConstructor1.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructor1 { + public GetDeclaredConstructor1() { + } + private GetDeclaredConstructor1(String name) { + } + protected GetDeclaredConstructor1(String name, int number) { + } + GetDeclaredConstructor1(int number) { + } +} +public class ReflectingGetDeclaredConstructor1 { + public static void main(String[] args) { + try { + Class getDeclaredConstructor1 = Class.forName("GetDeclaredConstructor1"); + Constructor constructor1 = getDeclaredConstructor1.getDeclaredConstructor(String.class); + Constructor constructor2 = getDeclaredConstructor1.getDeclaredConstructor(); + Constructor constructor3 = getDeclaredConstructor1.getDeclaredConstructor(String.class, int.class); + Constructor constructor4 = getDeclaredConstructor1.getDeclaredConstructor(int.class); + if (constructor1.toString().equals("private GetDeclaredConstructor1(java.lang.String)") + && constructor2.toString().equals("public GetDeclaredConstructor1()") + && constructor3.toString().equals("protected GetDeclaredConstructor1(java.lang.String,int)") + && constructor4.toString().equals("GetDeclaredConstructor1(int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/expected.txt b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/test.cfg b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..39d8ab0b1995690f410344eec43690149be8c6b4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0004-rt-reflection-ReflectingetDeclaredConstructor1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructor1) +run(ReflectingGetDeclaredConstructor1) diff --git a/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java new file mode 100755 index 0000000000000000000000000000000000000000..62660183305ddb2bbe21febb9584373f36158d0c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/ReflectingGetDeclaredConstructor2.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructor2 { + public GetDeclaredConstructor2() { + } + private GetDeclaredConstructor2(String name) { + } + protected GetDeclaredConstructor2(String name, int number) { + } + GetDeclaredConstructor2(int number) { + } +} +public class ReflectingGetDeclaredConstructor2 { + public static void main(String[] args) { + try { + Class getDeclaredConstructor2 = Class.forName("GetDeclaredConstructor2"); + Constructor constructor = getDeclaredConstructor2.getDeclaredConstructor(String.class, char.class, int.class); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/expected.txt b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/test.cfg b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eb35ae24eed507013e995fa6d052f5d85f5261b8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0005-rt-reflection-ReflectingetDeclaredConstructor2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructor2) +run(ReflectingGetDeclaredConstructor2) diff --git a/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java new file mode 100755 index 0000000000000000000000000000000000000000..d5a7cb5b52352e7255f9b2732fad955e2e517063 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/ReflectingGetDeclaredConstructors.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class GetDeclaredConstructors { + public GetDeclaredConstructors() { + } + private GetDeclaredConstructors(String name) { + } + protected GetDeclaredConstructors(String name, int number) { + } + GetDeclaredConstructors(int number) { + } +} +public class ReflectingGetDeclaredConstructors { + public static void main(String[] args) { + try { + Class getDeclaredConstructors = Class.forName("GetDeclaredConstructors"); + Constructor[] constructors = getDeclaredConstructors.getDeclaredConstructors(); + if (constructors.length == 4) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/expected.txt b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/test.cfg b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..37a637c82ad4eb4d65181b7742dd2eb95d08b967 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0006-rt-reflection-ReflectingetDeclaredConstructors/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectingGetDeclaredConstructors) +run(ReflectingGetDeclaredConstructors) diff --git a/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/ReflectionAsSubclass1.java b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/ReflectionAsSubclass1.java new file mode 100755 index 0000000000000000000000000000000000000000..9565c7e6b33f4bac1f79546b8e55c3eca6cfa30d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/ReflectionAsSubclass1.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface A { +} +class A_1 implements A { +} +class A_2 extends A_1 { +} +public class ReflectionAsSubclass1 { + public static void main(String[] args) { + try { + Class a_2 = Class.forName("A_1").asSubclass(A.class); + Class a_1 = Class.forName("A_2").asSubclass(A.class); + if (a_2.newInstance() instanceof A) { + if (a_1.newInstance() instanceof A) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.out.println(e1); + } catch (InstantiationException e2) { + System.out.println(e2); + } catch (IllegalAccessException e3) { + System.out.println(e3); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/expected.txt b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/test.cfg b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3190733f5121fb0be8aafa5fb483e876ad04beff --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0007-rt-reflection-ReflectionasSubclass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass1) +run(ReflectionAsSubclass1) diff --git a/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/ReflectionAsSubclass2.java b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/ReflectionAsSubclass2.java new file mode 100755 index 0000000000000000000000000000000000000000..a54c3774b3b516fcda86bc77b41b5f382e45e269 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/ReflectionAsSubclass2.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class B { +} +class B_1 extends B { +} +public class ReflectionAsSubclass2 { + public static void main(String[] args) { + try { + Class.forName("B_1").asSubclass(B.class); + } catch (ClassCastException e) { + System.out.println(2); + } catch (ClassNotFoundException e) { + System.out.println(2); + } + System.out.println(0); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/expected.txt b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/test.cfg b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7028ea169f87e4452e831d3c40276aac35ec2dc8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0008-rt-reflection-ReflectionasSubclass2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass2) +run(ReflectionAsSubclass2) diff --git a/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/ReflectionAsSubclass3.java b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/ReflectionAsSubclass3.java new file mode 100755 index 0000000000000000000000000000000000000000..4338a70bc5b6bcb154bc37c8b73d02e3d64ab314 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/ReflectionAsSubclass3.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface C { +} +class C_1 implements C { +} +class C_2 extends C_1 { +} +class D { +} +class D_1 extends D { +} +public class ReflectionAsSubclass3 { + public static void main(String[] args) { + try { + Class.forName("C_1").asSubclass(D.class); + } catch (ClassCastException e1) { + try { + Class.forName("C_2").asSubclass(D.class); + } catch (ClassCastException e2) { + try { + Class.forName("D_1").asSubclass(C.class); + } catch (ClassCastException e3) { + System.out.println(0); + } catch (ClassNotFoundException e4) { + System.out.println(2); + } + } catch (ClassNotFoundException e5) { + System.out.println(2); + } + } catch (ClassNotFoundException e6) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/expected.txt b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/test.cfg b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a7f3e3c67cdd821a99dbe2976b275d1657b9e5cb --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0009-rt-reflection-ReflectionasSubclass3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAsSubclass3) +run(ReflectionAsSubclass3) diff --git a/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/ReflectionCast1.java b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/ReflectionCast1.java new file mode 100755 index 0000000000000000000000000000000000000000..5dc332cc8d191e9c8956a6adbcf219d0e8785eae --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/ReflectionCast1.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast1 { +} +class Cast1_a extends Cast1 { +} +public class ReflectionCast1 { + public static void main(String[] args) { + Cast1_a cast1_a = new Cast1_a(); + Cast1 cast1 = new Cast1(); + cast1 = Cast1.class.cast(cast1_a); + if (cast1.getClass().toString().equals("class Cast1_a")) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/expected.txt b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/test.cfg b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..034d26a26182f4b8ad9f28cae17730998f36271a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0010-rt-reflection-Reflectioncast1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast1) +run(ReflectionCast1) diff --git a/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/ReflectionCast2.java b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/ReflectionCast2.java new file mode 100755 index 0000000000000000000000000000000000000000..a64290da52f997e3de5fb61ef94777ef0ec29ca7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/ReflectionCast2.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast2 { +} +class Cast2_a extends Cast2 { +} +public class ReflectionCast2 { + public static void main(String[] args) { + Cast2_a cast2_a = new Cast2_a(); + Cast2 cast2 = new Cast2(); + try { + cast2_a = Cast2_a.class.cast(cast2); + } catch (ClassCastException e) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/expected.txt b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/test.cfg b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..85638f07cef5c0e7e447ab71d7e623fb396eb421 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0011-rt-reflection-Reflectioncast2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast2) +run(ReflectionCast2) diff --git a/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/ReflectionCast3.java b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/ReflectionCast3.java new file mode 100755 index 0000000000000000000000000000000000000000..a15023908636b8d778fc030d4ac16cddfb2b44a1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/ReflectionCast3.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast3 { +} +class Cast3_a { +} +public class ReflectionCast3 { + public static void main(String[] args) { + Cast3_a cast3_a = new Cast3_a(); + Cast3 cast3 = new Cast3(); + try { + cast3_a = Cast3_a.class.cast(cast3); + } catch (ClassCastException e) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/expected.txt b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/test.cfg b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6ef93961c9e20d658f5e2878edf0d41b5128636f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0012-rt-reflection-Reflectioncast3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast3) +run(ReflectionCast3) diff --git a/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/ReflectionCast4.java b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/ReflectionCast4.java new file mode 100755 index 0000000000000000000000000000000000000000..0fb596401d01224ee4e8526591119d085483f9c7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/ReflectionCast4.java @@ -0,0 +1,27 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Cast4 { +} +public class ReflectionCast4 { + public static void main(String[] args) { + Object object = null; + Cast4 cast4 = new Cast4(); + cast4 = Cast4.class.cast(object); + if (cast4 == null) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/expected.txt b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/test.cfg b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..089c34315ad92054d04f4c61c4a49dfd124af168 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0013-rt-reflection-Reflectioncast4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionCast4) +run(ReflectionCast4) diff --git a/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java new file mode 100755 index 0000000000000000000000000000000000000000..8b70c1f9f5b411c860ab60c867e6253061f6966b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/ReflectionDesiredAssertionStatus.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionDesiredAssertionStatus { + public static void main(String[] args) { + ReflectionDesiredAssertionStatus reflectionDesiredAssertionStatus = new ReflectionDesiredAssertionStatus(); + Class clazz = reflectionDesiredAssertionStatus.getClass(); + if (!clazz.desiredAssertionStatus()) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/expected.txt b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/test.cfg b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3024136a06677336b5d02f91a3fec177365dec37 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0014-rt-reflection-ReflectiondesiredAssertionStatus/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionDesiredAssertionStatus) +run(ReflectionDesiredAssertionStatus) diff --git a/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/ReflectionForName1.java b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/ReflectionForName1.java new file mode 100755 index 0000000000000000000000000000000000000000..91844b19966ccdc8c564beb2b8eec48ce457f9f9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/ReflectionForName1.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ForName1 { +} +public class ReflectionForName1 { + public static void main(String[] args) throws ClassNotFoundException { + Class clazz = Class.forName("ForName1"); + if (clazz.toString().equals("class ForName1")) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/expected.txt b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/test.cfg b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..11c1b7e56224622ffba91540b41ae90e7cea14ec --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0015-rt-reflection-ReflectionforName1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName1) +run(ReflectionForName1) diff --git a/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/ReflectionForName4.java b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/ReflectionForName4.java new file mode 100755 index 0000000000000000000000000000000000000000..434bfa9a940628198717fef7b5ffa24734c60adc --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/ReflectionForName4.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ForName4 { + static { + } +} +class ForName4_a { + static { + } +} +public class ReflectionForName4 extends Thread { + public static void main(String[] args) { + try { + Class clazz = Class.forName("for*", true, ForName4_a.class.getClassLoader()); + } catch (ClassNotFoundException e) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/expected.txt b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/test.cfg b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1f80d81f34bc25f06b88175e11e5e268cc4f4689 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0016-rt-reflection-ReflectionforName4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName4) +run(ReflectionForName4) diff --git a/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/ReflectionForName5.java b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/ReflectionForName5.java new file mode 100755 index 0000000000000000000000000000000000000000..ecda8c007d431c47b2c3dd8cf776897ba0910b90 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/ReflectionForName5.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface ForName55_c { +} +class ForName55_b implements ForName55_c { +} +class ForName55_a extends ForName55_b { +} +class ForName55 extends ForName55_a { +} +class ForName5_e { +} +class ForName5_d extends ForName5_e { +} +class ForName5_c extends ForName5_d { +} +class ForName5_b extends ForName5_c { +} +class ForName5_a extends ForName5_b { +} +class ForName5 extends ForName5_a { +} +public class ReflectionForName5 { + public static void main(String[] args) throws ClassNotFoundException { + Class clazz = Class.forName("ForName5"); + if (clazz.toString().equals("class ForName5")) { + Class clazz2 = Class.forName("ForName55"); + if (clazz2.toString().equals("class ForName55")) { + System.out.println(0); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/expected.txt b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/test.cfg b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0fad02aa1edc519d8a7c985e631de97d2d747618 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0017-rt-reflection-ReflectionforName5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName5) +run(ReflectionForName5) diff --git a/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..6f70b4c7d388807c8496059766aa549f30415a51 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz1 { +int i() default 0; +String t() default ""; +} +@Zzz1(i = 333, t = "getAnnotation") +class GetAnnotation1_a { +} +class GetAnnotation1_b { +} +public class ReflectionGetAnnotation1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetAnnotation1_a"); + Class clazz2 = Class.forName("GetAnnotation1_b"); + if (clazz1.getAnnotation(Zzz1.class).toString().indexOf("t=getAnnotation") != -1 + && clazz1.getAnnotation(Zzz1.class).toString().indexOf("i=333") != -1 + && clazz2.getAnnotation(Zzz1.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..97f14563a4ff4981b724676736bc50ab2f68230a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0018-rt-reflection-ReflectiongetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation1) +run(ReflectionGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..a7bdad1aad1ead230a377b3d15470f980ab5b51f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/ReflectionGetAnnotation2.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +class GetAnnotation2_a { + @IF2(i = 333, t = "getAnnotation") + public int i_a; + public String t_a; +} +class GetAnnotation2_b { + public int i_b; + public String t_b; +} +public class ReflectionGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls1 = Class.forName("GetAnnotation2_a"); + Class cls2 = Class.forName("GetAnnotation2_b"); + Field instance1 = cls1.getField("i_a"); + Field instance2 = cls1.getField("t_a"); + Field instance3 = cls2.getField("i_b"); + if (instance1.getAnnotation(IF2.class).i() == 333 && instance1.getAnnotation(IF2.class). + t().equals("getAnnotation") && instance2.getAnnotation(IF2.class) == null && + instance3.getAnnotation(IF2.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/expected.txt b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/test.cfg b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d04c630e90e4c4f11bf0d71d5335ef98832c9a2e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0019-rt-reflection-ReflectiongetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation2) +run(ReflectionGetAnnotation2) diff --git a/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java new file mode 100755 index 0000000000000000000000000000000000000000..688f91174d30d0484c0e8893cc128dcfe23f6011 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/ReflectionGetAnnotation3.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz3 { + int i() default 0; + String t() default ""; +} +class GetAnnotation3_a { + @Zzz3(i = 333, t = "getAnnotation") + public void qqq() { + }; + public void rrr() { + }; +} +class GetAnnotation3_b { + public void www() { + }; +} +public class ReflectionGetAnnotation3 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation3_a"); + Method zhu1 = zqp1.getMethod("qqq"); + Method zhu2 = zqp1.getMethod("rrr"); + zhu1.getAnnotation(Zzz3.class).t(); + zhu2.getAnnotation(Zzz3.class).i(); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + try { + Class zqp2 = Class.forName("GetAnnotation3_b"); + Method zhu3 = zqp2.getMethod("www"); + zhu3.getAnnotation(Zzz3.class).i(); + System.out.println(2); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + System.out.println(2); + } catch (NoSuchMethodException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NullPointerException e5){ + System.out.println(0); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/expected.txt b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/test.cfg b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9e294b580cbfe68aeb7e7ad3df28b05b5bdc166 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0020-rt-reflection-ReflectiongetAnnotation3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation3) +run(ReflectionGetAnnotation3) diff --git a/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java new file mode 100755 index 0000000000000000000000000000000000000000..b501d929b036783dae2a1c8bb3e1e69ea1b62958 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/ReflectionGetAnnotation4.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz4 { + int i() default 0; + String t() default ""; +} +@interface Zzz4_a { +int ii() default 0; +String tt() default ""; +} +class GetAnnotation4_a { + @Zzz4(i = 333, t = "getAnnotation") + public void qqq() { + }; + @Zzz4_a(ii = 555, tt = "test") + public void rrr() { + }; +} +public class ReflectionGetAnnotation4 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation4_a"); + Method zhu1 = zqp1.getMethod("qqq"); + Method zhu2 = zqp1.getMethod("rrr"); + if (zhu1.getAnnotation(Zzz4_a.class) == null && zhu2.getAnnotation(Zzz4.class) == null) { + zhu1.getAnnotation(Zzz4_a.class).ii(); + System.out.println(2); + } + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/expected.txt b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/test.cfg b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8c874d0f7c02b9b785d3ffae813365eaea583143 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0021-rt-reflection-ReflectiongetAnnotation4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation4) +run(ReflectionGetAnnotation4) diff --git a/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java new file mode 100755 index 0000000000000000000000000000000000000000..6f75362044377c79244b7c30542776d78e5d7c25 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/ReflectionGetAnnotation5.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz5 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz5_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzz5(i = 333, t = "test1") +class GetAnnotation5 { + public int i; + public String t; +} +@Zzz5_a(i_a = 666, t_a = "right1") +class GetAnnotation5_a extends GetAnnotation5 { + public int i_a; + public String t_a; +} +class GetAnnotation5_b extends GetAnnotation5_a { +} +public class ReflectionGetAnnotation5 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation5_b"); + if (zqp1.getAnnotation(Zzz5.class).toString().indexOf("t=test1") != -1 && zqp1.getAnnotation(Zzz5.class). + toString().indexOf("i=333") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/expected.txt b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/test.cfg b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..577377a7252228975396fdadaf6a74d5488d7a5d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0022-rt-reflection-ReflectiongetAnnotation5/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation5) +run(ReflectionGetAnnotation5) diff --git a/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java new file mode 100755 index 0000000000000000000000000000000000000000..374cc346909f9c9d4fc61eb35f361e1f148d391e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/ReflectionGetAnnotation6.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz6 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz6_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzz6(i = 333, t = "test1") +class GetAnnotation6 { + public int i; + public String t; + @Zzz6_a(i_a = 666, t_a = "right1") + public static class GetAnnotation6_a { + public int j; + } +} +public class ReflectionGetAnnotation6 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation6"); + Class[] zhu1 = zqp1.getDeclaredClasses(); + if (zhu1[0].getAnnotation(Zzz6_a.class).toString().indexOf("t_a=right1") != -1 && zhu1[0]. + getAnnotation(Zzz6_a.class).toString().indexOf("i_a=666") != -1) { + if (zhu1[0].getAnnotation(Zzz6.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/expected.txt b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/test.cfg b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c585f054466737dae1c4a74b45c109d539d38e44 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0023-rt-reflection-ReflectiongetAnnotation6/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation6) +run(ReflectionGetAnnotation6) diff --git a/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java new file mode 100755 index 0000000000000000000000000000000000000000..6715604631f62fa5fc6f36bd19fd2301c3f84935 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/ReflectionGetAnnotation7.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +class GetAnnotation7 { + @Deprecated + public int aa(int num) { + return 0; + } +} +class GetAnnotation7_a extends GetAnnotation7 { + @Override + public int aa(int num) { + return 2; + } +} +public class ReflectionGetAnnotation7 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotation7_a"); + Method zhu1 = zqp1.getMethod("aa", int.class); + Annotation[] j = zhu1.getAnnotations(); + if (j.length == 0) { + try { + Class zqp2 = Class.forName("GetAnnotation7"); + Method zhu2 = zqp2.getMethod("aa", int.class); + if (zhu2.getAnnotation(Deprecated.class).toString().indexOf("Deprecated") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/expected.txt b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/test.cfg b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..17d3edcb5e2ebe6fd5a04cf9c1a49abf97959b66 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0024-rt-reflection-ReflectiongetAnnotation7/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation7) +run(ReflectionGetAnnotation7) diff --git a/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..71bdebdb77e537048ece045ec48d591bb5adf20a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/ReflectionGetAnnotationsByType1.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz1 { + int i() default 0; + String t() default ""; +} +@interface Zzzz1_a { +} +@interface Zzzz1_b { +} +class GetAnnotationsByType1_a { + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_a; + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_aa; + @Zzzz1(i = 333, t = "GetAnnotationsByType") + public int i_aaa; + public String t_a; + @Zzzz1_a + public String t_aa; + @Zzzz1_b + public String t_aaa; +} +public class ReflectionGetAnnotationsByType1 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType1_a"); + Field zhu1 = zqp1.getField("i_a"); + Field zhu2 = zqp1.getField("t_a"); + if (zqp1.getAnnotationsByType(Zzzz1.class).length == 0) { + if (zhu2.getAnnotationsByType(Zzzz1_a.class).length == 0) { + Annotation[] k = zhu1.getAnnotationsByType(Zzzz1.class); + if (k[0].toString().indexOf("t=GetAnnotationsByType") != -1 && k[0].toString().indexOf("i=333") + != -1) { + System.out.println(0); + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/expected.txt b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/test.cfg b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1f5a8bb5c15419f349fb590f058e328897a7bfd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0025-rt-reflection-ReflectiongetAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType1) +run(ReflectionGetAnnotationsByType1) diff --git a/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java new file mode 100755 index 0000000000000000000000000000000000000000..34d7b18fb91f34547837307865d246702846f2d2 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/ReflectionGetAnnotationsByType2.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz2 { + int i() default 0; + String t() default ""; +} +class GetAnnotationsByType2_a { + @Zzzz2(i = 333, t = "GetAnnotationsByType") + public int i_a; + public String t_a; +} +class GetAnnotationsByType2_b { + public int i_b; + public String t_b; +} +public class ReflectionGetAnnotationsByType2 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType2_a"); + Field zhu1 = zqp1.getField("t_a"); + Annotation[] j = zhu1.getAnnotationsByType(null); + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + try { + Class zqp2 = Class.forName("GetAnnotationsByType2_b"); + Field zhu2 = zqp2.getField("i_b"); + Annotation[] k = zhu2.getAnnotationsByType(null); + System.out.println(2); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + System.out.println(2); + } catch (NoSuchFieldException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NullPointerException e5) { + System.out.println(0); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/expected.txt b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/test.cfg b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..919ce3fc129d389228b8c4e1e6d3bdd2bd92c7d4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0026-rt-reflection-ReflectiongetAnnotationsByType2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType2) +run(ReflectionGetAnnotationsByType2) diff --git a/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java new file mode 100755 index 0000000000000000000000000000000000000000..5543714266c6ef12792a085fc71d66c61a70acfe --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/ReflectionGetAnnotationsByType3.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz3 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzzz3_a { + int i_a() default 2; + String t_a() default ""; +} +@Zzzz3(i = 333, t = "test1") +class GetAnnotationsByType3 { + public int i; + public String t; +} +@Zzzz3_a(i_a = 666, t_a = "right1") +class GetAnnotationsByType3_a extends GetAnnotationsByType3 { + public int i_a; + public String t_a; +} +class GetAnnotationsByType3_b extends GetAnnotationsByType3_a { +} +public class ReflectionGetAnnotationsByType3 { + public static void main(String[] args) { + try { + Class zqp1 = Class.forName("GetAnnotationsByType3_b"); + Annotation[] j = zqp1.getAnnotationsByType(Zzzz3.class); + if (j[0].toString().indexOf("t=test1") != -1 && j[0].toString().indexOf("i=333") != -1) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/expected.txt b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/test.cfg b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5037e188e2880b6b55813e9476a9022996751290 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0027-rt-reflection-ReflectiongetAnnotationsByType3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotationsByType3) +run(ReflectionGetAnnotationsByType3) diff --git a/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java new file mode 100755 index 0000000000000000000000000000000000000000..d8f474cb98ccf932a5b1f5c8eb429e89ad5d70fd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/ReflectionGetCanonicalName.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetCanonicalNameTest { +} +public class ReflectionGetCanonicalName { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetCanonicalNameTest"); + if (zqp.getCanonicalName().equals("GetCanonicalNameTest")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/expected.txt b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/test.cfg b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d9d6b51144684385a0738614b4f4fbe5b60fdba --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0028-rt-reflection-ReflectiongetCanonicalName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetCanonicalName) +run(ReflectionGetCanonicalName) diff --git a/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/ReflectionGetComponentType.java b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/ReflectionGetComponentType.java new file mode 100755 index 0000000000000000000000000000000000000000..661cfbae4d6c80dd3522d8beda1ec39c26742c4c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/ReflectionGetComponentType.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionGetComponentType { + public static void main(String[] args) { + if (char.class.getComponentType() == null && String[].class.getComponentType().toString(). + equals("class java.lang.String") && int[].class.getComponentType().toString().equals("int")) { + System.out.println(0); + }else{ + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/expected.txt b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/test.cfg b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..abfd96af7079ca17ed9937a595b4d57b92d98967 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0029-rt-reflection-ReflectiongetComponentType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetComponentType) +run(ReflectionGetComponentType) diff --git a/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..7b26e033cabf51ac5214dc9dd28105949743dc82 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/ReflectionGetDeclaredAnnotations1.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd1_a { + int i_a() default 2; + String t_a() default ""; +} +@Ddd1(i = 333, t = "test1") +class GetDeclaredAnnotations1 { + public int i; + public String t; +} +@Ddd1_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotations1_a extends GetDeclaredAnnotations1 { + public int i_a; + public String t_a; +} +public class ReflectionGetDeclaredAnnotations1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotations1_a"); + if (zqp1.getDeclaredAnnotations().length == 1) { + Annotation[] j = zqp1.getDeclaredAnnotations(); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + result = 0; + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b14075f4b5caa6b487c2feb3be2519afbb70c69c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0030-rt-reflection-ReflectiongetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotations1) +run(ReflectionGetDeclaredAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..0ccf1dce327d132b9bf43cc1296aebe79b4024fb --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/ReflectionGetDeclaredAnnotations2.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Ddd2_a { + int i_a() default 2; + String t_a() default ""; +} +@Ddd2(i = 333, t = "test1") +class GetDeclaredAnnotations2 { + public int i; + public String t; +} +@Ddd2_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotations2_a extends GetDeclaredAnnotations2 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotations2_b extends GetDeclaredAnnotations2_a { +} +public class ReflectionGetDeclaredAnnotations2 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotations2_b"); + if (zqp1.getDeclaredAnnotations().length == 0) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/expected.txt b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/test.cfg b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f3dd5d9e78c93d2155517151f561ccbc15c8d5fd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0031-rt-reflection-ReflectiongetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotations2) +run(ReflectionGetDeclaredAnnotations2) diff --git a/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..c67abc9efdb6f31b44bd66ca927d34360d9c599f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/ReflectionGetDeclaredAnnotationsByType1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd1_a { + int i_a() default 2; + String t_a() default ""; +} +@Dddd1(i = 333, t = "test1") +class GetDeclaredAnnotationsByType1 { + public int i; + public String t; +} +@Dddd1_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotationsByType1_a extends GetDeclaredAnnotationsByType1 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotationsByType1_b extends GetDeclaredAnnotationsByType1_a { +} +public class ReflectionGetDeclaredAnnotationsByType1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotationsByType1_b"); + Class zqp2 = Class.forName("GetDeclaredAnnotationsByType1_a"); + if (zqp1.getDeclaredAnnotationsByType(Dddd1.class).length == 0) { + Annotation[] j = zqp2.getDeclaredAnnotationsByType(Dddd1_a.class); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + result = 0; + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/expected.txt b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/test.cfg b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..494c73cc3227fb64110a4baa90ca4db85496dad3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0032-rt-reflection-ReflectiongetDeclaredAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotationsByType1) +run(ReflectionGetDeclaredAnnotationsByType1) diff --git a/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..3921730400d8a2f9e836e263c25bf6ce977224bf --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/ReflectionGetDeclaredAnnotationsByTypeNullPointerException.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Dddd2_a { + int i_a() default 2; + String t_a() default ""; +} +@Dddd2(i = 333, t = "test1") +class GetDeclaredAnnotationsByType2 { + public int i; + public String t; +} +@Dddd2_a(i_a = 666, t_a = "right1") +class GetDeclaredAnnotationsByType2_a extends GetDeclaredAnnotationsByType2 { + public int i_a; + public String t_a; +} +class GetDeclaredAnnotationsByType2_b extends GetDeclaredAnnotationsByType2_a { +} +public class ReflectionGetDeclaredAnnotationsByTypeNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredAnnotationsByType2_b"); + Annotation[] j = zqp1.getDeclaredAnnotationsByType(null); + result = 0; + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + result = 0; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e797e0a7dce87f039355389610d222fae54cecab --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0033-rt-reflection-ReflectionGetDeclaredAnnotationsByTypeNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredAnnotationsByTypeNullPointerException) +run(ReflectionGetDeclaredAnnotationsByTypeNullPointerException) diff --git a/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java new file mode 100755 index 0000000000000000000000000000000000000000..d86ae7990bd8f3e2fc27f3876e980294d8e8143f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/ReflectionGetDeclaredClasses.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class ReflectiongetDeclaredClasses_a { + public class getDeclaredClasses_a1 { + } + private class getDeclaredClasses_a2 { + } + protected class getDeclaredClasses_a3 { + } +} +public class ReflectionGetDeclaredClasses extends ReflectiongetDeclaredClasses_a { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ReflectionGetDeclaredClasses"); + Class[] j = zqp.getDeclaredClasses(); + if (j.length == 3) { + for (int i = 0; i < j.length; i++) { + if (j[i].getName().indexOf("getDeclaredClasses_a") != -1) { + result = -1; + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } + System.out.println(result); + } + public class getDeclaredClassestest1 { + } + private class getDeclaredClassestest2 { + } + protected class getDeclaredClassestest3 { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/expected.txt b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/test.cfg b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..45d87ff524cabd44f63a7873b84645323b152598 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0034-rt-reflection-ReflectiongetDeclaredClasses/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredClasses) +run(ReflectionGetDeclaredClasses) diff --git a/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java new file mode 100755 index 0000000000000000000000000000000000000000..0a79aa1fbcac4b40f56b39900911d8ceef885d34 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/ReflectionGetDeclaredField1.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredField1 { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +public class ReflectionGetDeclaredField1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetDeclaredField1"); + Field zhu1 = zqp.getDeclaredField("i"); + Field zhu2 = zqp.getDeclaredField("s"); + Field zhu3 = zqp.getDeclaredField("d"); + Field zhu4 = zqp.getDeclaredField("f"); + if (zhu1.getName().equals("i") && zhu2.getName().equals("s") && zhu3.getName().equals("d") && + zhu4.getName().equals("f")) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NoSuchFieldException e2) { + System.err.println(e2); + result = -1; + } catch (NullPointerException e3) { + System.err.println(e3); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/expected.txt b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/test.cfg b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7fa639743885b0365442e53eedd5c6bcc4303ef5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0035-rt-reflection-ReflectiongetDeclaredField1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredField1) +run(ReflectionGetDeclaredField1) diff --git a/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..e24b7c2783101f93d0cdf10426f3c624b6385e03 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/ReflectionGetDeclaredFieldNullPointerException.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredField2_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredField2 extends GetDeclaredField2_a { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +public class ReflectionGetDeclaredFieldNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("GetDeclaredField2"); + Field zhu1 = zqp.getDeclaredField("i_a"); + result = -1; + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } catch (NullPointerException e2) { + System.err.println(e2); + result = -1; + } catch (NoSuchFieldException e3) { + try { + Class zqp = Class.forName("GetDeclaredField2"); + Field zhu1 = zqp.getDeclaredField(null); + result = -1; + } catch (ClassNotFoundException e4) { + System.err.println(e4); + result = -1; + } catch (NoSuchFieldException e5) { + System.err.println(e5); + result = -1; + } catch (NullPointerException e6) { + result = 0; + } + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/expected.txt b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/test.cfg b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..456364c6e3d5f150d0a8e47b7e68d348f2a04d2b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0036-rt-reflection-ReflectionGetDeclaredFieldNullPointerException/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFieldNullPointerException) +run(ReflectionGetDeclaredFieldNullPointerException) diff --git a/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java new file mode 100755 index 0000000000000000000000000000000000000000..935b39bca9c54225f4d45ff619ff70c8e2137bd0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/ReflectionGetDeclaredFields1.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredFields1_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredFields1 extends GetDeclaredFields1_a { + public int i = 1; + String s = "aaa"; + private double d = 2.5; + protected float f = -222; +} +interface GetDeclaredFields1_b { + public int i_b = 2; + String s_b = "ccc"; +} +public class ReflectionGetDeclaredFields1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("GetDeclaredFields1"); + Class zqp2 = Class.forName("GetDeclaredFields1_b"); + Field[] j = zqp1.getDeclaredFields(); + Field[] k = zqp2.getDeclaredFields(); + if (j.length == 4 && k.length == 2) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/expected.txt b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/test.cfg b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7aebf1cf72d5b66e48c831042b1507b7a5d844ba --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0037-rt-reflection-ReflectiongetDeclaredFields1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFields1) +run(ReflectionGetDeclaredFields1) diff --git a/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java new file mode 100755 index 0000000000000000000000000000000000000000..2c489ed641a58f6985aa63897c64e743eb4a2de3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/ReflectionGetDeclaredFields.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetDeclaredFields_a { + public int i_a = 5; + String s_a = "bbb"; +} +class GetDeclaredFields extends GetDeclaredFields_a { +} +enum GetDeclaredFields_b { + i_b, s_b, f_b +} +public class ReflectionGetDeclaredFields { + public static void main(String[] args) { + int result = 0; + try { + Class zqp1 = Class.forName("GetDeclaredFields"); + Class zqp2 = Class.forName("GetDeclaredFields_b"); + Field[] j = zqp1.getDeclaredFields(); + Field[] k = zqp2.getDeclaredFields(); + if (j.length == 0 && k.length == 4) { + result = 0; + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/expected.txt b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/test.cfg b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cf5722ba04e0283473639f9a82f36e4c7ce2e663 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0038-rt-reflection-ReflectiongetDeclaredFields2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredFields) +run(ReflectionGetDeclaredFields) diff --git a/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java new file mode 100755 index 0000000000000000000000000000000000000000..e92eade50ca56a8c3df9065a50b061693900a466 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/ReflectionGetDeclaredMethod1.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethod1 { + public void empty1() { + } + void empty2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void empty1(int number) { + } + int getZero(String name) { + return 2; + } +} +public class ReflectionGetDeclaredMethod1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethod1"); + Method method1 = clazz.getDeclaredMethod("empty1", int.class); + Method method2 = clazz.getDeclaredMethod("getDd"); + Method method3 = clazz.getDeclaredMethod("empty1"); + Method method4 = clazz.getDeclaredMethod("empty2"); + Method method5 = clazz.getDeclaredMethod("getZero"); + Method method6 = clazz.getDeclaredMethod("getZero", String.class); + if (method1.toString().equals("public void GetDeclaredMethod1.empty1(int)") + && method2.toString().equals("private java.lang.String GetDeclaredMethod1.getDd()") + && method3.toString().equals("public void GetDeclaredMethod1.empty1()") + && method4.toString().equals("void GetDeclaredMethod1.empty2()") + && method5.toString().equals("int GetDeclaredMethod1.getZero()") + && method6.toString().equals("int GetDeclaredMethod1.getZero(java.lang.String)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/expected.txt b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/test.cfg b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b2502837ef9ddd003e0cb64b41b9ff3e07c77fd3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0039-rt-reflection-ReflectiongetDeclaredMethod1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod1) +run(ReflectionGetDeclaredMethod1) diff --git a/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java new file mode 100755 index 0000000000000000000000000000000000000000..8d4fe73d713c5b95babe4dac4572033b113c3810 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/ReflectionGetDeclaredMethod2.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethod2_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethod2 extends GetDeclaredMethod2_a { + public void void1() { + } + void void2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void setNumber(int number) { + } + int setName(String name) { + return 2; + } +} +public class ReflectionGetDeclaredMethod2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetDeclaredMethod2"); + Method method1 = clazz1.getDeclaredMethod("empty1"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + try { + Class clazz2 = Class.forName("GetDeclaredMethod2"); + Method method2 = clazz2.getDeclaredMethod(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchMethodException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/expected.txt b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/test.cfg b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..94b2ec7c0193d8a648c215fa1d21fee87c8eed26 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0040-rt-reflection-ReflectiongetDeclaredMethod2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod2) +run(ReflectionGetDeclaredMethod2) diff --git a/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java new file mode 100755 index 0000000000000000000000000000000000000000..57c86d7ec61cbd015b52c2934bc54f3203ab8ad9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/ReflectionGetDeclaredMethod3.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +abstract class GetDeclaredMethod3 { + abstract void empty1(); + abstract public int empty2(); +} +public class ReflectionGetDeclaredMethod3 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethod3"); + Method method1 = clazz.getDeclaredMethod("empty1"); + Method method2 = clazz.getMethod("empty2"); + if (method1.toString().equals("abstract void GetDeclaredMethod3.empty1()") + && method2.toString().equals("public abstract int GetDeclaredMethod3.empty2()")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/expected.txt b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/test.cfg b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5ea743940941993986756e6761a6984e23aa2533 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0041-rt-reflection-ReflectiongetDeclaredMethod3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethod3) +run(ReflectionGetDeclaredMethod3) diff --git a/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java new file mode 100755 index 0000000000000000000000000000000000000000..c63813abc8b207a711a71d4433721d31832d5be6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/ReflectionGetDeclaredMethods1.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethods1_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethods1 extends GetDeclaredMethods1_a { + public void void1() { + } + void void2() { + } + int getZero() { + return 0; + } + private String getDd() { + return "dd"; + } + public void setNumber(int number) { + } + int setName(String name) { + return 2; + } +} +interface GetDeclaredMethods1_b { + public default void test1() { + } + default void test2() { + } +} +public class ReflectionGetDeclaredMethods1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetDeclaredMethods1"); + Class clazz2 = Class.forName("GetDeclaredMethods1_b"); + Method[] methods1 = clazz1.getDeclaredMethods(); + Method[] methods2 = clazz2.getDeclaredMethods(); + if (methods1.length == 6 && methods2.length == 2) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/expected.txt b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/test.cfg b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..93a9f3a34a2014c19f243a5869657b3f242d52ac --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0042-rt-reflection-ReflectiongetDeclaredMethods1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethods1) +run(ReflectionGetDeclaredMethods1) diff --git a/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java new file mode 100755 index 0000000000000000000000000000000000000000..d3f668d585ef6bfb5581a1e931d7e8047888ff85 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/ReflectionGetDeclaredMethods2.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetDeclaredMethods2_a { + public void empty1() { + } + public void empty2() { + } +} +class GetDeclaredMethods2 extends GetDeclaredMethods2_a { +} +public class ReflectionGetDeclaredMethods2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetDeclaredMethods2"); + Method[] method = clazz.getDeclaredMethods(); + if (method.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/expected.txt b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/test.cfg b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a989e717a854f36c333fe01d757add682a0f29f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0043-rt-reflection-ReflectiongetDeclaredMethods2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaredMethods2) +run(ReflectionGetDeclaredMethods2) diff --git a/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java new file mode 100755 index 0000000000000000000000000000000000000000..c90c3ee92b2d2a55adf1270df3b31aa80782a1f7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/ReflectionGetDeclaringClass.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +class GetDeclaringClass { + public int num; + String str; + float fNum; + public GetDeclaringClass() { + } + GetDeclaringClass(int number) { + } + GetDeclaringClass(String name) { + } + GetDeclaringClass(int number, String name) { + } +} +class GetDeclaringClass_a { +} +public class ReflectionGetDeclaringClass { + public static void main(String[] args) { + try { + int num = 0; + Class clazz = Class.forName("GetDeclaringClass"); + Field[] fields = clazz.getDeclaredFields(); + Constructor[] constructors = clazz.getDeclaredConstructors(); + for (int i = 0; i < fields.length; i++) { + if (fields[i].getDeclaringClass().getName().equals("GetDeclaringClass")) { + for (int j = 0; j < constructors.length; j++) { + if (constructors[j].getDeclaringClass().getName().equals("GetDeclaringClass")) { + Class clazz2 = Class.forName("GetDeclaringClass_a"); + if (clazz2.getDeclaringClass() == null) { + num++; + } + } + } + } + } + if (num == 12) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/expected.txt b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/test.cfg b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7fd6ced2648e46b38a92004e94caef561133f04b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0044-rt-reflection-ReflectiongetDeclaringClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetDeclaringClass) +run(ReflectionGetDeclaringClass) diff --git a/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java new file mode 100755 index 0000000000000000000000000000000000000000..5bf3a8784910fd28de1c0916e150b5cf8d9f2c7a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/ReflectionGetEnclosingClass1.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionGetEnclosingClass1 { + public static void main(String[] args) { + Class clazz1 = (new GetEnclosingClassTest1()).test1().getClass(); + Class clazz2 = (new GetEnclosingClassTest1()).test2().getClass(); + if (clazz1.getEnclosingClass().getName().equals("ReflectionGetEnclosingClass1$GetEnclosingClassTest1") + && clazz2.getEnclosingClass().getName().equals("ReflectionGetEnclosingClass1$GetEnclosingClassTest1")) { + System.out.println(0); + } + } + public static class GetEnclosingClassTest1 { + public Object test1() { + class classA { + } + return new classA(); + } + Object test2() { + class classB { + } + return new classB(); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/expected.txt b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/test.cfg b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bb34cbfdf0ef9c91116160f24581d5ff3171038b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0045-rt-reflection-ReflectiongetEnclosingClass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnclosingClass1) +run(ReflectionGetEnclosingClass1) diff --git a/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java new file mode 100755 index 0000000000000000000000000000000000000000..dadfd167102437adecf3cf7ca6a5cf13e1641e35 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/ReflectionGetEnclosingClass2.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetEnclosingClassTest2 { + public Object test1() { + class classA { + } + return new classA(); + } + Object test2() { + class classB { + } + return new classB(); + } +} +public class ReflectionGetEnclosingClass2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetEnclosingClassTest2"); + Class clazz2 = (new GetEnclosingClassTest2()).test2().getClass(); + if (clazz1.getEnclosingClass() == null + && clazz2.getEnclosingClass().getName().equals("GetEnclosingClassTest2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/expected.txt b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/test.cfg b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..877748ddb590e3034702e6501a118f0e22a1b32f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0046-rt-reflection-ReflectiongetEnclosingClass2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnclosingClass2) +run(ReflectionGetEnclosingClass2) diff --git a/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java new file mode 100755 index 0000000000000000000000000000000000000000..c561df9dc126cb4012b1141961be9edddfaeb261 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/ReflectionGetEnumConstants.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +enum Weekday { + MONDAY { + Object test1() { + class classA { + } + return new classA(); + } + }, + TUESDAY { + Object test2() { + class classB { + } + return new classB(); + } + }, + WEDNESDAY { + Object test3() { + class classC { + } + return new classC(); + } + }, + THURSDAY { + Object test4() { + class classD { + } + return new classD(); + } + }, + FRIDAY { + Object test5() { + class classE { + } + return new classE(); + } + }, + SATURDAY { + Object test6() { + class classF { + } + return new classF(); + } + }, + SUNDAY { + Object test7() { + class classG { + } + return new classG(); + } + } +} +class GetEnumConstants { +} +public class ReflectionGetEnumConstants { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("Weekday"); + Class clazz2 = Class.forName("GetEnumConstants"); + Object[] objects1 = clazz1.getEnumConstants(); + Object[] objects2 = clazz2.getEnumConstants(); + if (objects1.length == 7) { + if (objects2 == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/expected.txt b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/test.cfg b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9080ec9b239805e9061b72b3b3947a14e2770488 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0047-rt-reflection-ReflectiongetEnumConstants/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetEnumConstants) +run(ReflectionGetEnumConstants) diff --git a/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/ReflectionGetField1.java b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/ReflectionGetField1.java new file mode 100755 index 0000000000000000000000000000000000000000..2d4a2d2e42b8431745981ed7ef95cb475a079649 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/ReflectionGetField1.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetField1_a { + int num2 = 5; + public String str = "bbb"; +} +class GetField1 extends GetField1_a { + public int num = 1; + String string = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +public class ReflectionGetField1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetField1"); + Field field1 = clazz.getField("num"); + Field field2 = clazz.getField("str"); + if (field1.getName().equals("num") && field2.getName().equals("str")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/expected.txt b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/test.cfg b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3b9e427aed0bffe105dc9807ec1527b68896145b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0048-rt-reflection-ReflectiongetField1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetField1) +run(ReflectionGetField1) diff --git a/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/ReflectionGetField2.java b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/ReflectionGetField2.java new file mode 100755 index 0000000000000000000000000000000000000000..1a88f63c3f37a8ad058669963afc753b91d41959 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/ReflectionGetField2.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetField2_a { + int num = 5; + public String str = "bbb"; +} +class GetField2 extends GetField2_a { + public int num = 1; + String str2 = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +public class ReflectionGetField2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetField2"); + Field field1 = clazz1.getField("str2"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + try { + Class clazz2 = Class.forName("GetField2"); + Field field2 = clazz2.getField(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchFieldException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/expected.txt b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/test.cfg b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5a58ad12c58aafabc785a7bd0f68fe17c7429c3f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0049-rt-reflection-ReflectiongetField2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetField2) +run(ReflectionGetField2) diff --git a/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/ReflectionGetFields.java b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/ReflectionGetFields.java new file mode 100755 index 0000000000000000000000000000000000000000..5f41236c96a36d9a7502ea74a732fb759bad9ce6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/ReflectionGetFields.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class GetFields_a { + public int num = 5; + String str = "bbb"; +} +class GetFields extends GetFields_a { + public int num = 1; + String str = "aaa"; + private double dNum = 2.5; + protected float fNum = -222; +} +interface GetFields_b { + public int num = 2; + String str = "ccc"; +} +class GetFields_c { +} +public class ReflectionGetFields { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetFields"); + Class clazz2 = Class.forName("GetFields_b"); + Class clazz3 = Class.forName("GetFields_c"); + Field[] fields1 = clazz1.getFields(); + Field[] fields2 = clazz2.getFields(); + Field[] fields3 = clazz3.getFields(); + if (fields1.length == 2 && fields2.length == 2 && fields3.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/expected.txt b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/test.cfg b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7b5ec262ddabf8f98214c275f6aacadd7cf21ab8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0050-rt-reflection-ReflectiongetFields/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetFields) +run(ReflectionGetFields) diff --git a/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/ReflectionGetMethod1.java b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/ReflectionGetMethod1.java new file mode 100755 index 0000000000000000000000000000000000000000..7425d77471291ce5e31d9b7e2309f6ba6c4040b6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/ReflectionGetMethod1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetMethod1_a { + public int setName(String name) { + return 10; + } + public String getStr() { + return "getDda"; + } +} +class GetMethod1 extends GetMethod1_a { + public void empty() { + } + void emptyB() { + } + int getNum() { + return 0; + } + private String getDd() { + return "getDd"; + } + public void empty(int number) { + } + int getNum(String name) { + return 2; + } +} +public class ReflectionGetMethod1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetMethod1"); + Method method1 = clazz.getMethod("empty"); + Method method2 = clazz.getMethod("empty", int.class); + Method method3 = clazz.getMethod("setName", String.class); + Method method4 = clazz.getMethod("getStr"); + if (method1.toString().equals("public void GetMethod1.empty()") + && method2.toString().equals("public void GetMethod1.empty(int)") + && method3.toString().equals("public int GetMethod1_a.setName(java.lang.String)") + && method4.toString().equals("public java.lang.String GetMethod1_a.getStr()")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/expected.txt b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/test.cfg b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7d65eb03f27915f644927faf9c0b4e7478480050 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0051-rt-reflection-ReflectiongetMethod1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetMethod1) +run(ReflectionGetMethod1) diff --git a/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/ReflectionGetMethod2.java b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/ReflectionGetMethod2.java new file mode 100755 index 0000000000000000000000000000000000000000..b293eef75e27879dc7c9e5c107b1a30dc3352aa1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/ReflectionGetMethod2.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class GetMethod2_a { + public int getName(String name) { + return 10; + } + public String getString() { + return "dda"; + } +} +class GetMethod2 extends GetMethod2_a { + public void getVoid() { + } + void empty() { + } + int getZero() { + return 0; + } + private String getStr() { + return "dd"; + } + public void setNum(int number) { + } + int getSecondNum(String name) { + return 2; + } +} +public class ReflectionGetMethod2 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetMethod2"); + Method method1 = clazz1.getMethod("empty"); + System.out.println(2); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + // NoSuchMethodException is thrown when method not exist. + try { + Class clazz2 = Class.forName("GetMethod2"); + Method method2 = clazz2.getMethod(null); + System.out.println(2); + } catch (ClassNotFoundException e4) { + System.err.println(e4); + System.out.println(2); + } catch (NoSuchMethodException e5) { + System.err.println(e5); + System.out.println(2); + } catch (NullPointerException e6) { + // Expected result: NullPointerException is thrown when method is null. + System.out.println(0); + } + } catch (NullPointerException e3) { + System.err.println(e3); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/expected.txt b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/test.cfg b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b516e0937280e94ae808668709eaf335e66edd9f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0052-rt-reflection-ReflectiongetMethod2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetMethod2) +run(ReflectionGetMethod2) diff --git a/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/ReflectionGetSigners.java b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/ReflectionGetSigners.java new file mode 100755 index 0000000000000000000000000000000000000000..a34d0ca76e12c0ade80b76e83728d1a8108d296c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/ReflectionGetSigners.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetSigners { +} +public class ReflectionGetSigners { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetSigners"); + Object[] objects = clazz.getSigners(); + if (objects == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/expected.txt b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/test.cfg b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8de86972a06dab4814c8757452be072351fd9461 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0053-rt-reflection-ReflectiongetSigners/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetSigners) +run(ReflectionGetSigners) diff --git a/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/ReflectionGetSimpleName.java b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/ReflectionGetSimpleName.java new file mode 100755 index 0000000000000000000000000000000000000000..d1a3ee1486078b0e70427035b70985549c467015 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/ReflectionGetSimpleName.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class GetSimpleName { +} +public class ReflectionGetSimpleName { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetSimpleName"); + String string = clazz.getSimpleName(); + if (string.equals("GetSimpleName")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/expected.txt b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/test.cfg b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9c8074f5131573b9b7bc377560b7a6de36351c30 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0054-rt-reflection-ReflectiongetSimpleName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetSimpleName) +run(ReflectionGetSimpleName) diff --git a/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..dac2c7b001091e5f248442a0d2becaad15585171 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/ReflectionGetTypeParameters.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.TypeVariable; +class GetTypeParameters { +} +public class ReflectionGetTypeParameters { + public static void main(String[] args) { + try { + Class clazz = Class.forName("GetTypeParameters"); + TypeVariable[] typeParameters = clazz.getTypeParameters(); + if (typeParameters.length == 2 && typeParameters[0].getName().equals("s") + && typeParameters[1].getName().equals("T")) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..858039960aaeb8b062feffae197e0e97548e4725 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0055-rt-reflection-ReflectiongetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetTypeParameters) +run(ReflectionGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/ReflectionIsArray.java b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/ReflectionIsArray.java new file mode 100755 index 0000000000000000000000000000000000000000..d7a167bacada422fffb61036f2cd8080240cf634 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/ReflectionIsArray.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class IsArray { + public int num; + String str; + float fNum; +} +public class ReflectionIsArray { + public static void main(String[] args) { + try { + Class clazz = Class.forName("IsArray"); + Field[] fields = clazz.getDeclaredFields(); + Class clazz1 = fields.getClass(); + if (clazz1.isArray()) { + if (!clazz.isArray()) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/expected.txt b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/test.cfg b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0ed00eadf4f7792e8b2cbe11c9edfc3a062c05cf --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0056-rt-reflection-ReflectionisArray/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsArray) +run(ReflectionIsArray) diff --git a/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java new file mode 100755 index 0000000000000000000000000000000000000000..c5e25eeb987b608f92d6d313be4eba3aebecbad4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/ReflectionIsAssignableFrom1.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class AssignableFrom1 { +} +class AssignableFrom1_a extends AssignableFrom1 { +} +interface AssignableFromTest1 { +} +interface AssignableFromTest1_a extends AssignableFromTest1 { +} +public class ReflectionIsAssignableFrom1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("AssignableFrom1"); + Class clazz2 = Class.forName("AssignableFrom1_a"); + Class clazz3 = Class.forName("AssignableFromTest1"); + Class clazz4 = Class.forName("AssignableFromTest1_a"); + if (clazz1.isAssignableFrom(clazz2) && !clazz2.isAssignableFrom(clazz1) && clazz3.isAssignableFrom(clazz4) + && !clazz4.isAssignableFrom(clazz3)) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/expected.txt b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/test.cfg b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a375b936a63f051626b8d8d62903bf6473cd5faa --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0057-rt-reflection-ReflectionisAssignableFrom1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsAssignableFrom1) +run(ReflectionIsAssignableFrom1) diff --git a/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java new file mode 100755 index 0000000000000000000000000000000000000000..30fd5cfc047c806e973926848ceaded70b8fc86d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/ReflectionIsAssignableFromNullPointerException.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class AssignableFromNullPointerException { +} +public class ReflectionIsAssignableFromNullPointerException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("AssignableFromNullPointerException"); + zqp1.isAssignableFrom(null); + result = -1; + } catch (ClassNotFoundException e1) { + result = -1; + } catch (NullPointerException e2) { + result = 0; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/expected.txt b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/test.cfg b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fe7d43920ddc4778b7d4d886a4ff13438cda3346 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0058-rt-reflection-ReflectionisAssignableFrom2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsAssignableFromNullPointerException) +run(ReflectionIsAssignableFromNullPointerException) diff --git a/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/ReflectionIsLocalClass.java b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/ReflectionIsLocalClass.java new file mode 100755 index 0000000000000000000000000000000000000000..bf3a9cf69e65046e02313808d99c5b1978f854ab --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/ReflectionIsLocalClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsLocalClass { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + class isLocalClass { + } + try { + Class zqp1 = isLocalClass.class; + Class zqp2 = Class.forName("ReflectionIsLocalClass"); + Class zqp3 = IsLocalClass_a.class; + Class zqp4 = IsLocalClass_b.class; + Class zqp5 = (new isLocalClass() { + }).getClass(); + if (!zqp2.isLocalClass()) { + if (!zqp3.isLocalClass()) { + if (!zqp4.isLocalClass()) { + if (!zqp5.isLocalClass()) { + if (zqp1.isLocalClass()) { + result = 0; + } + } + } + } + } + } catch (ClassNotFoundException e) { + result = 2; + } + System.out.println(result); + } + class IsLocalClass_a { + } + static class IsLocalClass_b { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/expected.txt b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/test.cfg b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eff558a3dc3eaa3a6dd782c9cea2d90e3eb41d44 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0059-rt-reflection-ReflectionisLocalClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsLocalClass) +run(ReflectionIsLocalClass) diff --git a/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/ReflectionIsMemberClass.java b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/ReflectionIsMemberClass.java new file mode 100755 index 0000000000000000000000000000000000000000..915854531ccf695b5a1a8818f756c4260c5f8359 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/ReflectionIsMemberClass.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsMemberClass { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + class IsMemberClass_a { + } + try { + Class zqp1 = IsMemberClass.class; + Class zqp2 = Class.forName("ReflectionIsMemberClass"); + Class zqp3 = IsMemberClass_a.class; + Class zqp4 = IsMemberClass_b.class; + Class zqp5 = (new IsMemberClass_b() { + }).getClass(); + if (!zqp2.isMemberClass()) { + if (!zqp3.isMemberClass()) { + if (zqp4.isMemberClass()) { + if (!zqp5.isMemberClass()) { + if (zqp1.isMemberClass()) { + result = 0; + } + } + } + } + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } + class IsMemberClass { + } + static class IsMemberClass_b { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/expected.txt b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/test.cfg b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b1afa27d4577522e7b8895cec74b1ef84828bb16 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0060-rt-reflection-ReflectionisMemberClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsMemberClass) +run(ReflectionIsMemberClass) diff --git a/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/ReflectionIsPrimitive.java b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/ReflectionIsPrimitive.java new file mode 100755 index 0000000000000000000000000000000000000000..90ef71d5c7c0e380843fea3560a34d1f61e44ef2 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/ReflectionIsPrimitive.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsPrimitive { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + Class zqp1 = ReflectionIsPrimitive.class; + Class zqp2 = int.class; + Class zqp3 = boolean.class; + Class zqp4 = byte.class; + Class zqp5 = char.class; + Class zqp6 = short.class; + Class zqp7 = long.class; + Class zqp8 = float.class; + Class zqp9 = double.class; + Class zqp10 = void.class; + if (!zqp1.isPrimitive() && zqp2.isPrimitive() && zqp3.isPrimitive() && zqp4.isPrimitive() && zqp5.isPrimitive() + && zqp6.isPrimitive() && zqp7.isPrimitive() && zqp8.isPrimitive() && zqp9.isPrimitive() && + zqp10.isPrimitive()) { + result = 0; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/expected.txt b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/test.cfg b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5105cc43d0ef19063284645ed0920cbda2e5af99 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0061-rt-reflection-ReflectionisPrimitive/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsPrimitive) +run(ReflectionIsPrimitive) diff --git a/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/ReflectionIsSynthetic.java b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/ReflectionIsSynthetic.java new file mode 100755 index 0000000000000000000000000000000000000000..07ce874047f3af7b33bbc20cd86130d28f975b26 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/ReflectionIsSynthetic.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ReflectionIsSynthetic { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + new IsSynthetic(); + try { + Class zqp1 = IsSynthetic.class; + Class zqp2 = int.class; + Class zqp3 = Class.forName("ReflectionIsSynthetic$1"); + if (!zqp2.isSynthetic()) { + if (!zqp1.isSynthetic()) { + if (zqp3.isSynthetic()) { + result = 0; + } + } + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } + private static class IsSynthetic { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/expected.txt b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/test.cfg b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9b5a9a7363439494f96c58a2bc946887c2adf24b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0062-rt-reflection-ReflectionisSynthetic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionIsSynthetic) +run(ReflectionIsSynthetic) diff --git a/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/ReflectionNewInstance1.java b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/ReflectionNewInstance1.java new file mode 100755 index 0000000000000000000000000000000000000000..9b78860e8bca8e564ed370ab0b1a21c642a9b410 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/ReflectionNewInstance1.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class NewInstance1 { +} +public class ReflectionNewInstance1 { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("NewInstance1"); + Object zhu = zqp.newInstance(); + if (zhu.toString().indexOf("NewInstance1@") != -1) { + result = 0; + } + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (InstantiationException e1) { + System.err.println(e1); + result = -1; + } catch (IllegalAccessException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/expected.txt b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/test.cfg b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2837ce4278673868101173fe54def9fdb99d89ab --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0063-rt-reflection-ReflectionnewInstance1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionNewInstance1) +run(ReflectionNewInstance1) diff --git a/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java new file mode 100755 index 0000000000000000000000000000000000000000..e1eaf39faa50ab6670bde33eb6fccd18c013130a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/ReflectionNewInstanceInstantiationExceptionIllegalAccessException.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface NewInstance2 { +} +class NewInstance2_a { + private NewInstance2_a() { + } +} +public class ReflectionNewInstanceInstantiationExceptionIllegalAccessException { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp1 = Class.forName("NewInstance2"); + Object zhu1 = zqp1.newInstance(); + } catch (ClassNotFoundException e) { + System.err.println(e); + result = -1; + } catch (InstantiationException e1) { + try { + Class zqp2 = Class.forName("NewInstance2_a"); + Object zhu2 = zqp2.newInstance(); + } catch (ClassNotFoundException e3) { + System.err.println(e3); + result = -1; + } catch (InstantiationException e4) { + System.err.println(e4); + result = -1; + } catch (IllegalAccessException e5) { + result = 0; + } + } catch (IllegalAccessException e2) { + System.err.println(e2); + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/expected.txt b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/test.cfg b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bdfe7d616118b97aa6f1d7bac0374acae51f2203 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0064-rt-reflection-ReflectionnewInstance2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionNewInstanceInstantiationExceptionIllegalAccessException) +run(ReflectionNewInstanceInstantiationExceptionIllegalAccessException) diff --git a/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/ReflectionToGenericString.java b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/ReflectionToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..89c1e6d8cede6c98b56a07f938bc0c4e6f8bc027 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/ReflectionToGenericString.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +@interface Eee { +} +@Eee +abstract class ToGenericString { +} +public class ReflectionToGenericString { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ToGenericString"); + String zhu = zqp.toGenericString(); + if (zhu.equals("abstract class ToGenericString")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dfa6a8fbf435aaf336128c5513878619be9edab7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0065-rt-reflection-ReflectiontoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionToGenericString) +run(ReflectionToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/ReflectionToString.java b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/ReflectionToString.java new file mode 100755 index 0000000000000000000000000000000000000000..9049254b592ca3a3256cd07187e773cd3985f182 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/ReflectionToString.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +@interface Fff { +} +@Fff +abstract class ToString_$ { +} +public class ReflectionToString { + public static void main(String[] args) { + int result = 0; /* STATUS_Success*/ + + try { + Class zqp = Class.forName("ToString_$"); + String zhu = zqp.toString(); + if (zhu.equals("class ToString_$")) { + result = 0; + } + } catch (ClassNotFoundException e) { + result = -1; + } + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/expected.txt b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/test.cfg b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c76e98d23b8c3d48209a6aa3003887bec4d29737 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0066-rt-reflection-ReflectiontoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionToString) +run(ReflectionToString) diff --git a/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..8a81e2eb0ad7e8975ba31bf361565847446457fc --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/RTConstructorGetAnnotation1.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Www1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Www1_a { + int c() default 0; + String d() default ""; +} +class ConstructorGetAnnotation1 { + @Www1(i = 333, t = "ConstructorgetAnnotation") + public ConstructorGetAnnotation1() { + } + public ConstructorGetAnnotation1(String name) { + } + @Www1_a(c = 666, d = "Constructor") + ConstructorGetAnnotation1(int number) { + } + ConstructorGetAnnotation1(String name, int number) { + } +} +public class RTConstructorGetAnnotation1 { + public static void main(String[] args) { + try { + Class zqp = Class.forName("ConstructorGetAnnotation1"); + Constructor zhu1 = zqp.getDeclaredConstructor(int.class); + Constructor zhu2 = zqp.getConstructor(); + Constructor zhu3 = zqp.getConstructor(String.class); + if ((zhu1.getAnnotation(Www1_a.class).toString().indexOf("c=666") != -1 && + zhu1.getAnnotation(Www1_a.class).toString().indexOf("d=Constructor") != -1 && + zhu2.getAnnotation(Www1.class).toString().indexOf("i=333") != -1 && + zhu2.getAnnotation(Www1.class).toString().indexOf("t=ConstructorgetAnnotation") != -1)) { + if (zhu3.getAnnotation(Www1.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..614b1890fa3357090810e242b881aa9f0c5cb3ac --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0067-rt-reflection-RTConstructorgetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetAnnotation1) +run(RTConstructorGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..0959d2a9f6bc9aabe53c40650d4f99be8c5a8779 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/RTConstructorGetAnnotation2.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class ConstructorGetAnnotation2 { + @IF2(i = 333, t = "ConstructorGetAnnotation") + public ConstructorGetAnnotation2() { + } + @IF2_a(c = 666, d = "Constructor") + ConstructorGetAnnotation2(int number) { + } +} +class ConstructorGetAnnotation2_a { + ConstructorGetAnnotation2_a(String name, int number) { + } +} +public class RTConstructorGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetAnnotation2"); + Constructor instance1 = cls.getDeclaredConstructor(int.class); + Constructor instance2 = cls.getConstructor(); + if (instance1.getAnnotation(IF2.class) == null && instance2.getAnnotation(IF2_a.class) == null) { + instance1.getAnnotation(IF2.class).toString(); + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(1); + return; + } catch (NoSuchMethodException e2) { + System.out.println(1); + return; + } catch (NullPointerException e3) { + try { + Class cls = Class.forName("ConstructorGetAnnotation2_a"); + Constructor instance3 = cls.getDeclaredConstructor(String.class, int.class); + if (instance3.getAnnotation(IF2.class) == null && instance3.getAnnotation(IF2_a.class) == null) { + instance3.getAnnotation(IF2.class).toString(); + } + System.out.println(1); + return; + } catch (ClassNotFoundException e4) { + System.out.println(2); + return; + } catch (NoSuchMethodException e5) { + System.out.println(3); + return; + } catch (NullPointerException e6) { + System.out.println(0); + return; + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/expected.txt b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/test.cfg b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..edde0d1d4578022b002a54334a879eb8a39ffdec --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0068-rt-reflection-RTConstructorgetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetAnnotation2) +run(RTConstructorGetAnnotation2) diff --git a/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..00cc679061f8c2ac8da6d651c7a9e038c2ffb90c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/RTConstructorGetDeclaredAnnotations1.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int i_a() default 2; + String t_a() default ""; +} +class ConstructorGetDeclaredAnnotations1 { + public ConstructorGetDeclaredAnnotations1() { + } + @IF1(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations1(String name) { + } + @IF1(i = 333, t = "test1") + ConstructorGetDeclaredAnnotations1(int number) { + } +} +class ConstructorGetDeclaredAnnotations1_a extends ConstructorGetDeclaredAnnotations1 { + @IF1_a(i_a = 666, t_a = "right1") + @IF1(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations1_a(String name) { + } + @IF1_a(i_a = 666, t_a = "right1") + ConstructorGetDeclaredAnnotations1_a(int number) { + } +} +public class RTConstructorGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetDeclaredAnnotations1_a"); + Constructor instance1 = cls.getConstructor(String.class); + if (instance1.getDeclaredAnnotations().length == 2) { + Constructor instance2 = cls.getDeclaredConstructor(int.class); + if (instance2.getDeclaredAnnotations().length == 1) { + Annotation[] j = instance2.getDeclaredAnnotations(); + if (j[0].toString().indexOf("i_a=666") != -1 && j[0].toString().indexOf("t_a=right1") != -1) { + System.out.println(0); + return; + } + } + System.out.println(1); + return; + } + System.out.println(2); + return; + } catch (ClassNotFoundException e) { + System.out.println(3); + return; + } catch (NoSuchMethodException e1) { + System.out.println(4); + return; + } catch (NullPointerException e2) { + System.out.println(5); + return; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b46882406cb70b15fd48440a93cd5e286e8ba956 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0069-rt-reflection-RTConstructorgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetDeclaredAnnotations1) +run(RTConstructorGetDeclaredAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..698ecec98de67d37e475fba56fd76263e3761691 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/RTConstructorGetDeclaredAnnotations2.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.CONSTRUCTOR) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int i_a() default 2; + String t_a() default ""; +} +class ConstructorGetDeclaredAnnotations2 { + public ConstructorGetDeclaredAnnotations2() { + } + @IF2(i = 333, t = "test1") + public ConstructorGetDeclaredAnnotations2(String name) { + } + @IF2(i = 333, t = "test1") + ConstructorGetDeclaredAnnotations2(int number) { + } +} +class ConstructorGetDeclaredAnnotations2_a extends ConstructorGetDeclaredAnnotations2 { + public ConstructorGetDeclaredAnnotations2_a(String name) { + } + ConstructorGetDeclaredAnnotations2_a(int number) { + } +} +public class RTConstructorGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetDeclaredAnnotations2_a"); + Constructor instance1 = cls.getConstructor(String.class); + Constructor instance2 = cls.getDeclaredConstructor(int.class); + if (instance1.getDeclaredAnnotations().length == 0 && instance2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } catch (NullPointerException e2) { + System.out.println(4); + return; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7f358e313b189f52b78f5b09a7853b2c9f3f7f2b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0070-rt-reflection-RTConstructorgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetDeclaredAnnotations2) +run(RTConstructorGetDeclaredAnnotations2) diff --git a/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..5f33f8e2c81ecb85ac577db566359de9a8e47735 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/RTConstructorGetExceptionTypes.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class ConstructorGetExceptionTypes { + ConstructorGetExceptionTypes() throws ExceptionInInitializerError, InstantiationException { + } +} +public class RTConstructorGetExceptionTypes { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetExceptionTypes"); + Constructor cons = cls.getDeclaredConstructor(); + Class[] exClass = cons.getExceptionTypes(); + if (exClass.length == 2) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(2); + return; + } catch (NoSuchMethodException e2) { + System.out.println(3); + return; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/expected.txt b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/test.cfg b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e01023d88afa5491d431d729bab48ae506f76444 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0071-rt-reflection-RTConstructorgetExceptionTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetExceptionTypes) +run(RTConstructorGetExceptionTypes) diff --git a/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..4d9cc4026377580d40a30e19d9c4bad5165f8cb3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/RTConstructorGetTypeParameters.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +import java.lang.reflect.TypeVariable; +class ConstructorGetTypeParameters { + public ConstructorGetTypeParameters(int number) { + } + ConstructorGetTypeParameters() { + } +} +public class RTConstructorGetTypeParameters { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorGetTypeParameters"); + Constructor instance1 = cls.getConstructor(int.class); + Constructor instance2 = cls.getDeclaredConstructor(); + TypeVariable[] q1 = instance1.getTypeParameters(); + TypeVariable[] q2 = instance2.getTypeParameters(); + if (q1.length == 5 && q2.length == 0) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } catch (ClassNotFoundException e1) { + System.out.println(2); + return; + } catch (NoSuchMethodException e2) { + System.out.println(3); + return; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..959b7b2a32cbb8d0816f8e79364f40ed1fffa506 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0072-rt-reflection-RTConstructorgetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorGetTypeParameters) +run(RTConstructorGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/RTConstructorToGenericString1.java b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/RTConstructorToGenericString1.java new file mode 100755 index 0000000000000000000000000000000000000000..716f3e5e760b105ba6b1aed61c34a87675215b58 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/RTConstructorToGenericString1.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +class ConstructorToGenericString1 { + public ConstructorToGenericString1(int number) { + } +} +public class RTConstructorToGenericString1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ConstructorToGenericString1"); + Constructor instance1 = cls.getConstructor(int.class); + if (instance1.toGenericString().equals("public ConstructorToGenericString1(int)")) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e1) { + System.out.println(1); + return; + } catch (NoSuchMethodException e2) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} diff --git a/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8fe87cfb0453d4664244c4c216839a9606d74b07 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0073-rt-reflection-RTConstructortoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTConstructorToGenericString1) +run(RTConstructorToGenericString1) diff --git a/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/RTFieldGet1.java b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/RTFieldGet1.java new file mode 100755 index 0000000000000000000000000000000000000000..7d33118d3b4f2e660ee8c87138f160fd9c0c03b5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/RTFieldGet1.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet1_a { + public static String str = "aaa"; + public int num = 2; + public int num1 = 5; + public static boolean aBoolean = false; +} +class FieldGet1 extends FieldGet1_a { + public static String str = "bbb"; + public int number = 1; + public int test = super.num1 + 1; + public static boolean bBoolean = true; + public char aChar = '国'; +} +public class RTFieldGet1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet1"); + Object obj = cls.newInstance(); + Object q1 = cls.getField("str").get(obj); + Object q2 = cls.getField("number").get(obj); + Object q3 = cls.getField("test").get(obj); + Object q4 = cls.getField("bBoolean").get(obj); + Object q5 = cls.getField("aChar").get(obj); + Object q6 = cls.getField("num").get(obj); + Object q7 = cls.getField("aBoolean").get(null); + if (q1.toString().equals("bbb") && (int) q2 == 1 && (int) q3 == 6 && (boolean) q4 && q5.toString(). + equals("国") && (int) q6 == 2) { + Class cls1 = Class.forName("FieldGet1_a"); + Object instance1 = cls1.newInstance(); + Object q8 = cls1.getField("str").get(instance1); + if (q8.toString().equals("aaa")) { + if (!(boolean) q7) { + System.out.println(0); + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/expected.txt b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/test.cfg b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b3d47ebb39ab743d2ad4a027f743f4b8f315cfae --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0074-rt-reflection-RTFieldget1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet1) +run(RTFieldGet1) diff --git a/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/RTFieldGet2.java b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/RTFieldGet2.java new file mode 100755 index 0000000000000000000000000000000000000000..3077ed396907485a84e614664c2ca8abc0ee0f18 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/RTFieldGet2.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet2_a { + public int num; +} +class FieldGet2 extends FieldGet2_a { + private int number = 1; + public boolean aBoolean = true; + public int number1 = 8; +} +class FieldGet2_b { + public int number1 = 18; +} +public class RTFieldGet2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet2"); + Object obj = cls.newInstance(); + Object q1 = cls.getDeclaredField("number").get(obj); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + try { + Class cls = Class.forName("FieldGet2"); + Class cls1 = Class.forName("FieldGet2_b"); + Object instance1 = cls1.newInstance(); + Object q2 = cls.getDeclaredField("number1").get(instance1); + } catch (ClassNotFoundException e5) { + System.err.println(e5); + System.out.println(2); + } catch (InstantiationException e6) { + System.err.println(e6); + System.out.println(2); + } catch (NoSuchFieldException e7) { + System.err.println(e7); + System.out.println(2); + } catch (IllegalAccessException e8) { + System.err.println(e8); + System.out.println(2); + } catch (IllegalArgumentException e9) { + try { + Class cls = Class.forName("FieldGet2"); + Object q3 = cls.getDeclaredField("aBoolean").get(null); + } catch (ClassNotFoundException e10) { + System.err.println(e10); + System.out.println(2); + } catch (NoSuchFieldException e11) { + System.err.println(e11); + System.out.println(2); + } catch (IllegalAccessException e12) { + System.err.println(e12); + System.out.println(2); + } catch (NullPointerException e13) { + System.out.println(0); + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/expected.txt b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/test.cfg b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..51cc0ad256fd577fc24cfdc6a80215aaa5c5367d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0075-rt-reflection-RTFieldget2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet2) +run(RTFieldGet2) diff --git a/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/RTFieldGet3.java b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/RTFieldGet3.java new file mode 100755 index 0000000000000000000000000000000000000000..57e7da6ac8a92ec0185d3ef2df5db8e4403b8a3a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/RTFieldGet3.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class FieldGet3_a { + public int num; +} +class FieldGet3 extends FieldGet3_a { + public static String str; +} +public class RTFieldGet3 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGet3"); + Object obj = cls.newInstance(); + Object obj1 = cls.getField("str").get(obj); + Object obj2 = cls.getField("num").get(obj); + if (obj1 == null && (int) obj2 == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/expected.txt b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/test.cfg b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6b617335cfddf3d0af440a0ec33c230e3f0d9241 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0076-rt-reflection-RTFieldget3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGet3) +run(RTFieldGet3) diff --git a/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/RTFieldGetAnnotation1.java b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/RTFieldGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..b96bbc93927d533d77e8c75b4108656721e1b8a8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/RTFieldGetAnnotation1.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface4 { + int num() default 0; + String str() default ""; +} +@interface interface4_a { + int number() default 0; + String string() default ""; +} +class FieldGetAnnotation1 { + @interface4(num = 333, str = "GetAnnotation") + public int num1; + @interface4_a(number = 555, string = "test") + public String str1; +} +public class RTFieldGetAnnotation1 { + public static void main(String[] args) { + try { + Class cls1 = Class.forName("FieldGetAnnotation1"); + Field instance1 = cls1.getField("num1"); + Field instance2 = cls1.getField("str1"); + if (instance1.getAnnotation(interface4_a.class) == null && instance2.getAnnotation(interface4.class) == null) + { + instance1.getAnnotation(interface4_a.class).number(); + } + System.out.println(2); + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..70955d8cc1511d67993ef3c4f55e90e60237189d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0077-rt-reflection-RTFieldgetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetAnnotation1) +run(RTFieldGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..50613bb4e7e1c61feab615f935d0e44489cc2e7c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/RTFieldGetDeclaredAnnotations1.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface1 { + int num() default 0; + String str() default ""; +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface1_a { + int num_a() default 2; + String str_a() default ""; +} +class FieldGetDeclaredAnnotations1 { + @interface1(num = 333, str = "test1") + public int num; + @interface1(num = 333, str = "test1") + public String str; +} +class FieldGetDeclaredAnnotations1_a extends FieldGetDeclaredAnnotations1 { + @interface1_a(num_a = 666, str_a = "right1") + public int num; + @interface1_a(num_a = 666, str_a = "right1") + public String str; +} +public class RTFieldGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaredAnnotations1_a"); + Field instance1 = cls.getField("num"); + if (instance1.getDeclaredAnnotations().length == 1) { + Annotation[] j = instance1.getDeclaredAnnotations(); + if (j[0].toString().indexOf("num_a=666") != -1 && j[0].toString().indexOf("str_a=right1") != -1) { + Field instance2 = cls.getDeclaredField("str"); + if (instance2.getDeclaredAnnotations().length == 1) { + Annotation[] k = instance2.getDeclaredAnnotations(); + if (k[0].toString().indexOf("num_a=666") != -1 && k[0].toString().indexOf("str_a=right1") != -1) + { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1b760c6fa451396a792949830bbe45a910bf7b1c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0078-rt-reflection-RTFieldgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaredAnnotations1) +run(RTFieldGetDeclaredAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..f275fb6bc031c90ad65da06eba2d628995602845 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/RTFieldGetDeclaredAnnotations2.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface2 { + int num() default 0; + String str() default ""; +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface interface2_a { + int i_a() default 2; + String t_a() default ""; +} +class FieldGetDeclaredAnnotations2 { + @interface2(num = 333, str = "test1") + public int num; + @interface2(num = 333, str = "test1") + public String str; +} +class FieldGetDeclaredAnnotations2_a extends FieldGetDeclaredAnnotations2 { + @interface2_a(i_a = 666, t_a = "right1") + public int num; + public String str; +} +public class RTFieldGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaredAnnotations2_a"); + Field instance1 = cls.getField("str"); + Field instance2 = cls.getDeclaredField("str"); + if (instance1.getDeclaredAnnotations().length == 0 && instance2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchFieldException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..727e62ae23b675a7ab5a3c1b7e503e6d4c9730bd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0079-rt-reflection-RTFieldgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaredAnnotations2) +run(RTFieldGetDeclaredAnnotations2) diff --git a/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java new file mode 100755 index 0000000000000000000000000000000000000000..538d8f0315d3b04be9314cbb8f1e715a0a5f1bd4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/RTFieldGetDeclaringClass.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetDeclaringClass { + public int num; + char aChar; +} +public class RTFieldGetDeclaringClass { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetDeclaringClass"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("aChar"); + Class j = instance1.getDeclaringClass(); + Class k = instance2.getDeclaringClass(); + if (j.getName().equals("FieldGetDeclaringClass") && k.getName().equals("FieldGetDeclaringClass")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/expected.txt b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/test.cfg b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e3ed4c8649c499aac9a1ec9ea6b3822598550d18 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0080-rt-reflection-RTFieldgetDeclaringClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetDeclaringClass) +run(RTFieldGetDeclaringClass) diff --git a/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/RTFieldGetModifiers.java b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/RTFieldGetModifiers.java new file mode 100755 index 0000000000000000000000000000000000000000..116af0cd73d0cf6e062502565b0374944f769a6b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/RTFieldGetModifiers.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetModifiers { + public static int num; + final String str = "aaa"; + private String string = "ccc"; + protected static int number; +} +public class RTFieldGetModifiers { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetModifiers"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("str"); + Field instance3 = cls.getDeclaredField("string"); + Field field = cls.getDeclaredField("number"); + if (instance1.getModifiers() == 9 && instance2.getModifiers() == 16 && instance3.getModifiers() == 2 + && field.getModifiers() + == 12) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/expected.txt b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/test.cfg b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e297b16ce8d1706e240e8beef84cd62e1c7efd3b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0081-rt-reflection-RTFieldgetModifiers/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetModifiers) +run(RTFieldGetModifiers) diff --git a/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/RTFieldGetName.java b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/RTFieldGetName.java new file mode 100755 index 0000000000000000000000000000000000000000..60d46ec88b1fe2ce2692048d794f9d7bd466cd75 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/RTFieldGetName.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetName { + public static int num; + final String str = "aaa"; +} +public class RTFieldGetName { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetName"); + Field instance1 = cls.getField("num"); + Field instance2 = cls.getDeclaredField("str"); + if (instance1.getName().equals("num") && instance2.getName().equals("str")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/expected.txt b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/test.cfg b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1bbf40e544099da77a2ddb809f776abc2473d378 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0082-rt-reflection-RTFieldgetName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetName) +run(RTFieldGetName) diff --git a/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/RTFieldGetType.java b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/RTFieldGetType.java new file mode 100755 index 0000000000000000000000000000000000000000..09b4a21ab4e7778d180fe06f3f947f1dec95198f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/RTFieldGetType.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldGetType { + public static short sNum; + final char aChar = '什'; + private float fNum; +} +public class RTFieldGetType { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldGetType"); + Field instance1 = cls.getField("sNum"); + Field instance2 = cls.getDeclaredField("aChar"); + Field instance3 = cls.getDeclaredField("fNum"); + if (instance1.getType().getName().equals("short") && instance2.getType().getName().equals("char") + && instance3.getType().getName().equals("float")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/expected.txt b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/test.cfg b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ecfd3fb43c92561ff602cd1c65d9762f844edb4b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0083-rt-reflection-RTFieldgetType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldGetType) +run(RTFieldGetType) diff --git a/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/RTFieldSet1.java b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/RTFieldSet1.java new file mode 100755 index 0000000000000000000000000000000000000000..f285ef981c65b1e558e0e74a5f6cbe243bd98437 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/RTFieldSet1.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet1_a { + public static String str = "aaa"; + public int num2 = 2; + public int number = 5; + public static int num1; +} +class FieldSet1 extends FieldSet1_a { + public static String str = "bbb"; + public int num = 1; + public int test = super.number + 1; + public static boolean aBoolean = true; + public char aChar; +} +public class RTFieldSet1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet1"); + Object obj = cls.newInstance(); + Field f1 = cls.getField("str"); + Field f2 = cls.getField("num"); + Field f3 = cls.getField("aBoolean"); + Field f4 = cls.getField("aChar"); + Field f5 = cls.getField("num1"); + Field f6 = cls.getField("num2"); + Field f7 = cls.getField("number"); + f1.set(obj, "ccc"); + f2.set(obj, 10); + f3.set(obj, false); + f4.set(obj, '国'); + f5.set(obj, 20); + f6.set(obj, 30); + f7.set(obj, 40); + if (f1.get(obj).toString().equals("ccc") && (int) f2.get(obj) == 10 && !(boolean) f3.get(obj) && (int) + f6.get(obj) == 30) { + if (f4.get(obj).toString().equals("国") && (int) f5.get(obj) == 20) { + if ((int) cls.getField("test").get(obj) == 6) { + Class cls1 = Class.forName("FieldSet1_a"); + Object instance1 = cls1.newInstance(); + Object p = cls1.getDeclaredField("str").get(instance1); + if (p.toString().equals("aaa")) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/expected.txt b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/test.cfg b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..54f53bff0e82a4c62f6fd21dc228d86fa2e5c411 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0084-rt-reflection-RTFieldset1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet1) +run(RTFieldSet1) diff --git a/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/RTFieldSet2.java b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/RTFieldSet2.java new file mode 100755 index 0000000000000000000000000000000000000000..51041e09adaeda45f5efc502415ec425609b9a9b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/RTFieldSet2.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet2_a { + public static String str = "aaa"; + public int num; +} +class FieldSet2 extends FieldSet2_a { + public static String str; + private int num = 1; + public boolean aBoolean = true; + public int num1 = 8; +} +class FieldSet2_b { + public int num = 18; +} +public class RTFieldSet2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet2"); + Object obj = cls.newInstance(); + Field field = cls.getDeclaredField("num"); + field.set(obj, 10); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + try { + Class cls = Class.forName("FieldSet2"); + Class cls1 = Class.forName("FieldSet2_b"); + Object instance1 = cls1.newInstance(); + Field f1 = cls.getDeclaredField("aBoolean"); + f1.set(instance1, 10); + } catch (ClassNotFoundException e5) { + System.err.println(e5); + System.out.println(2); + } catch (InstantiationException e6) { + System.err.println(e6); + System.out.println(2); + } catch (NoSuchFieldException e7) { + System.err.println(e7); + System.out.println(2); + } catch (IllegalAccessException e8) { + System.err.println(e8); + System.out.println(2); + } catch (IllegalArgumentException e9) { + try { + Class cls = Class.forName("FieldSet2"); + Field f2 = cls.getDeclaredField("aBoolean"); + f2.set(null, false); + } catch (ClassNotFoundException e10) { + System.err.println(e10); + System.out.println(2); + } catch (NoSuchFieldException e11) { + System.err.println(e11); + System.out.println(2); + } catch (IllegalAccessException e12) { + System.err.println(e12); + System.out.println(2); + } catch (NullPointerException e13) { + System.out.println(0); + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/expected.txt b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/test.cfg b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9967e5edd4d941a1995d0fd119629561ab5fb613 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0085-rt-reflection-RTFieldset2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet2) +run(RTFieldSet2) diff --git a/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/RTFieldSet3.java b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/RTFieldSet3.java new file mode 100755 index 0000000000000000000000000000000000000000..ad1144ed09cbd0abc7a8c105491560edb15d3a28 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/RTFieldSet3.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet3_a { + public final static String str = "aaa"; + public int num = 2; +} +class FieldSet3 extends FieldSet3_a { + public final int num = 1; +} +public class RTFieldSet3 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet3"); + Object obj = cls.newInstance(); + Field q1 = cls.getField("str"); + Field q2 = cls.getField("num"); + q1.set(obj, "bbb"); + q2.set(obj, 10); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/expected.txt b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/test.cfg b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f1921bf53b99e682f24ec182997617a63aee9c96 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0086-rt-reflection-RTFieldset3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet3) +run(RTFieldSet3) diff --git a/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/RTFieldSet4.java b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/RTFieldSet4.java new file mode 100755 index 0000000000000000000000000000000000000000..90a79838518f18e58eed435a627848f88d942475 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/RTFieldSet4.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +class FieldSet4 { + public static String str; + private int num = 1; + public boolean aBoolean = true; + public int num1 = 8; +} +public class RTFieldSet4 { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldSet4"); + Object obj = cls.newInstance(); + Field field = cls.getDeclaredField("str"); + field.set(null, "aaa"); + System.out.println(0); + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (InstantiationException e2) { + System.err.println(e2); + System.out.println(2); + } catch (NoSuchFieldException e3) { + System.err.println(e3); + System.out.println(2); + } catch (IllegalAccessException e4) { + System.err.println(e4); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/expected.txt b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/test.cfg b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9f34e54e4a70ac7a5c4de3a00dd10cbea7cd818 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0087-rt-reflection-RTFieldset4/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldSet4) +run(RTFieldSet4) diff --git a/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/RTFieldToGenericString.java b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/RTFieldToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..cd41a5608a0a9729bcd1f8bcc63e8bdf3924f22b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/RTFieldToGenericString.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.List; +class FieldToGenericString { + public List list1; + private List list2; +} +public class RTFieldToGenericString { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldToGenericString"); + Field instance1 = cls.getField("list1"); + Field instance2 = cls.getDeclaredField("list2"); + String q1 = instance1.toGenericString(); + String q2 = instance2.toGenericString(); + if (q1.equals("public java.util.List FieldToGenericString.list1") && q2.equals + ("private java.util.List FieldToGenericString.list2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..642120ca45dd8a1c4cfa0ebd809e9eb1dc47f4a5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0088-rt-reflection-RTFieldtoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldToGenericString) +run(RTFieldToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/RTFieldToString.java b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/RTFieldToString.java new file mode 100755 index 0000000000000000000000000000000000000000..660ba6c29aafadc4e2899865c40f817dbcf0f0a6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/RTFieldToString.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.util.List; +class FieldToString { + public List list1; + private List list2; +} +public class RTFieldToString { + public static void main(String[] args) { + try { + Class cls = Class.forName("FieldToString"); + Field instance1 = cls.getField("list1"); + Field instance2 = cls.getDeclaredField("list2"); + String q1 = instance1.toString(); + String q2 = instance2.toString(); + if (q1.equals("public java.util.List FieldToString.list1") + && q2.equals("private java.util.List FieldToString.list2")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchFieldException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/expected.txt b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/test.cfg b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06521d2700b197dc4257d8d79902720a102b8dfe --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0089-rt-reflection-RTFieldtoString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTFieldToString) +run(RTFieldToString) diff --git a/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..c41aa0027e666e3f7c450c607630b2e94680d994 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/RTMethodGetAnnotation1.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i_a() default 0; + String t_b() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int c() default 0; + String d() default ""; +} +class MethodGetAnnotation1 { + @IF1(i_a = 333, t_b = "MethodGetAnnotation") + public void test1() { + } + public void test2(String name) { + } + @IF1_a(c = 666, d = "Method") + void test3(int number) { + } + void test4(String name, int number) { + } +} +public class RTMethodGetAnnotation1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetAnnotation1"); + Method method1 = clazz.getDeclaredMethod("test3", int.class); + Method method2 = clazz.getMethod("test1"); + Method method3 = clazz.getMethod("test2", String.class); + if (method1.getAnnotation(IF1_a.class).c() == 666 + && method1.getAnnotation(IF1_a.class).d().equals("Method") + && method2.getAnnotation(IF1.class).i_a() == 333 + && method2.getAnnotation(IF1.class).t_b().equals("MethodGetAnnotation")) { + if (method3.getAnnotation(IF1.class) == null) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ac790d02d80f80fba9dbdeb8a93b9cd282f778c5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0090-rt-reflection-RTMethodgetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetAnnotation1) +run(RTMethodGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..55081039407542cb016e3cd2de1d527ce031c7ec --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/RTMethodGetAnnotation2.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.CLASS) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.SOURCE) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class MethodGetAnnotation2 { + @IF2(i = 333, t = "MethodGetAnnotation") + public void test1() { + } + @IF2_a(c = 666, d = "Method") + void test3(int number) { + } +} +public class RTMethodGetAnnotation2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetAnnotation2"); + Method method1 = clazz.getDeclaredMethod("test3", int.class); + Method method2 = clazz.getMethod("test1"); + if (method1.getAnnotation(IF2_a.class) == null && method2.getAnnotation(IF2.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/expected.txt b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/test.cfg b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..02a024b2056b2b65b20a78298016f7b289d5f3d5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0091-rt-reflection-RTMethodgetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetAnnotation2) +run(RTMethodGetAnnotation2) diff --git a/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..6abe4d0555ae9bbb2873062b75850c0a0f117567 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/RTMethodGetDeclaredAnnotations1.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw1_a { + int i_a() default 2; + String t_a() default ""; +} +class MethodGetDeclaredAnnotations1 { + @IFw1(i = 333, t = "test1") + public static void ii(String name) { + } + @IFw1(i = 333, t = "test1") + void tt(int number) { + } +} +class MethodGetDeclaredAnnotations1_a extends MethodGetDeclaredAnnotations1 { + @IFw1_a(i_a = 666, t_a = "right1") + public static void ii(String name) { + } + @IFw1_a(i_a = 666, t_a = "right1") + void tt(int number) { + } +} +public class RTMethodGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetDeclaredAnnotations1_a"); + Method method1 = clazz.getMethod("ii", String.class); + if (method1.getDeclaredAnnotations().length == 1) { + Annotation[] annotations1 = method1.getDeclaredAnnotations(); + if (annotations1[0].toString().indexOf("i_a=666") != -1 + && annotations1[0].toString().indexOf("t_a=right1") != -1) { + Method method2 = clazz.getDeclaredMethod("tt", int.class); + if (method2.getDeclaredAnnotations().length == 1) { + Annotation[] annotations2 = method2.getDeclaredAnnotations(); + if (annotations2[0].toString().indexOf("i_a=666") != -1 + && annotations2[0].toString().indexOf("t_a=right1") != -1) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ffaf58dd1a949bf122925c4ab9be940fc146d865 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0092-rt-reflection-RTMethodgetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDeclaredAnnotations1) +run(RTMethodGetDeclaredAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..7c53e93f726f6c6fb44ef67fae7d848c04e34634 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/RTMethodGetDeclaredAnnotations2.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IFw2_a { + int i_a() default 2; + String t_a() default ""; +} +class MethodGetDeclaredAnnotations2 { + @IFw2(i = 333, t = "test1") + public static void ii(String name) { + } + @IFw2_a(i_a = 666, t_a = "right1") + void tt(int number) { + } +} +class MethodGetDeclaredAnnotations2_a extends MethodGetDeclaredAnnotations2 { + public static void ii(String name) { + } + void tt() { + } +} +public class RTMethodGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetDeclaredAnnotations2_a"); + Method method1 = clazz.getMethod("ii", String.class); + Method method2 = clazz.getDeclaredMethod("tt"); + if (method1.getDeclaredAnnotations().length == 0 && method2.getDeclaredAnnotations().length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NullPointerException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/expected.txt b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/test.cfg b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4058221ea538db4d1fd8387bcd053dfcb6a03993 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0093-rt-reflection-RTMethodgetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDeclaredAnnotations2) +run(RTMethodGetDeclaredAnnotations2) diff --git a/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java new file mode 100755 index 0000000000000000000000000000000000000000..bdea54ae4e947dd170b413c49b2cf00050164c71 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/RTMethodGetDefaultValue1.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + public int i_a() default 2; + String t_a() default "string default value"; + String s(); +} +class MethodGetDefaultValue1 { + @IF1(i = 333, t = "test1") + public static void ii(String name) { + } + void tt(int number) { + } +} +public class RTMethodGetDefaultValue1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("IF1_a"); + Class clazz2 = Class.forName("IF1"); + Class clazz3 = Class.forName("MethodGetDefaultValue1"); + Method method1 = clazz1.getDeclaredMethod("i_a"); + Method method2 = clazz1.getMethod("t_a"); + Method method3 = clazz2.getDeclaredMethod("t"); + Method[] methods = clazz3.getMethods(); + Method method5 = clazz3.getDeclaredMethod("tt", int.class); + Method method6 = clazz1.getDeclaredMethod("s"); + if ((int) method1.getDefaultValue() == 2 + && method2.getDefaultValue().toString().equals("string default value")) { + if (method3.getDefaultValue().equals("")) { + if (methods[0].getDefaultValue() == null && method5.getDefaultValue() == null) { + if (method6.getDefaultValue() == null) { + System.out.println(0); + } + } + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/expected.txt b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/test.cfg b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e7d5df4dae778b529e0ea74ff58dd1c3a7b7d97 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0094-rt-reflection-RTMethodgetDefaultValue1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetDefaultValue1) +run(RTMethodGetDefaultValue1) diff --git a/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/RTMethodGetParameterCount.java b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/RTMethodGetParameterCount.java new file mode 100755 index 0000000000000000000000000000000000000000..87baf1c7cb9e694b2fe24eb73393f346939629d1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/RTMethodGetParameterCount.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class MethodGetParameterCount2 { + void test1() { + } + public void test2(String name, int number, char c, short s, float f, double d, long l, boolean b, byte bb) { + } +} +public class RTMethodGetParameterCount { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetParameterCount2"); + Method method = clazz.getDeclaredMethod("test1"); + Method[] methods = clazz.getMethods(); + if (method.getParameterCount() == 0) { + if (methods[0].getParameterCount() == 9) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/expected.txt b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/test.cfg b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a28e8173d86a1fe9c35ef523bc468cbc0c852d61 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0095-rt-reflection-RTMethodgetParameterCount/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetParameterCount) +run(RTMethodGetParameterCount) diff --git a/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..959e090f73a66cc6ee4a362df6decf374b5e2926 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/RTMethodGetTypeParameters.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.TypeVariable; +class MethodGetTypeParameters2 { + public void ss(int number) { + } + void kk() { + } +} +public class RTMethodGetTypeParameters { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodGetTypeParameters2"); + Method method1 = clazz.getMethod("ss", int.class); + Method method2 = clazz.getDeclaredMethod("kk"); + TypeVariable[] typeVariables1 = method1.getTypeParameters(); + TypeVariable[] typeVariables2 = method2.getTypeParameters(); + if (typeVariables1.length == 5 && typeVariables2.length == 0) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9dd6ac5bf1b6e816b812b542218526eba7dd6e8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0096-rt-reflection-RTMethodgetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodGetTypeParameters) +run(RTMethodGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/RTMethodIsDefault.java b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/RTMethodIsDefault.java new file mode 100755 index 0000000000000000000000000000000000000000..221690390eb0acf025a48bf77de8d4920287b089 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/RTMethodIsDefault.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +interface MethodIsDefault_A { + default public void run() { + String i; + } +} +class MethodIsDefault implements MethodIsDefault_A { + public void run() { + String i = "abc"; + } + void ss(int number) { + } +} +public class RTMethodIsDefault { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("MethodIsDefault_A"); + Class clazz2 = Class.forName("MethodIsDefault"); + Method method1 = clazz1.getMethod("run"); + Method method2 = clazz2.getMethod("run"); + Method method3 = clazz2.getDeclaredMethod("ss", int.class); + if (method1.isDefault()) { + if (!method2.isDefault() && !method3.isDefault()) { + System.out.println(0); + } + } + } catch (ClassNotFoundException e) { + System.err.println(e); + System.out.println(2); + } catch (NoSuchMethodException e) { + System.err.println(e); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/expected.txt b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/test.cfg b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ff4c051a6b498eb5fb5c12f1b8b637224e7d4dfa --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0097-rt-reflection-RTMethonisDefault/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodIsDefault) +run(RTMethodIsDefault) diff --git a/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/RTMethodToGenericString.java b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/RTMethodToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..f897ae4af2a96fbf9c2f50e3c6d81a900dc3a161 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/RTMethodToGenericString.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +class MethodToGenericString { + public void ss(int number) { + } +} +public class RTMethodToGenericString { + public static void main(String[] args) { + try { + Class clazz = Class.forName("MethodToGenericString"); + Method method = clazz.getMethod("ss", int.class); + if (method.toGenericString().equals("public void MethodToGenericString.ss(int)")) { + System.out.println(0); + } + } catch (ClassNotFoundException e1) { + System.err.println(e1); + System.out.println(2); + } catch (NoSuchMethodException e2) { + System.err.println(e2); + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..82b5a6b2417a7c96a4d90ef6bbecb40f19e34c79 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0098-rt-reflection-RTMethontoGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTMethodToGenericString) +run(RTMethodToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/RTModifierParameterModifiers.java b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/RTModifierParameterModifiers.java new file mode 100755 index 0000000000000000000000000000000000000000..0b85f66b8360085d1279e496bf0af4b1fd910faf --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/RTModifierParameterModifiers.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Modifier; +public class RTModifierParameterModifiers { + public static void main(String[] args) { + if (Modifier.parameterModifiers() == 16) { + System.out.println(0); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/expected.txt b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/test.cfg b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b6ae2b3bb67291151a13af881ac5c4e0ae3fd3d3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0099-rt-reflection-RTModifierparameterModifiers/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTModifierParameterModifiers) +run(RTModifierParameterModifiers) diff --git a/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/RTParameterGetAnnotation1.java b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/RTParameterGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..1bc5ab897fac76967a887abeda6ed011ca299870 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/RTParameterGetAnnotation1.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF1_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotation1 { + ParameterGetAnnotation1(@IF1(i = 222, t = "Parameter") int number) { + } + public ParameterGetAnnotation1(String name) { + } + public void test1(@IF1_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotation1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotation1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + if (p1[0].getAnnotation(IF1.class).i() == 222 && p1[0].getAnnotation(IF1.class).t().equals("Parameter") + && p3[0].getAnnotation(IF1_a.class).c() == 666 + && p3[0].getAnnotation(IF1_a.class).d().equals("Happy new year")) { + if (p2[0].getAnnotation(IF1.class) == null) { + System.out.println(0); + return; + } + System.out.println(2); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(3); + return; + } catch (NoSuchMethodException e1) { + System.out.println(4); + return; + } + System.out.println(5); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6e7a808567bbe9ef2a1630efb87e8b244de372b7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0100-rt-reflection-RTParametergetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotation1) +run(RTParameterGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/RTParameterGetAnnotation2.java b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/RTParameterGetAnnotation2.java new file mode 100755 index 0000000000000000000000000000000000000000..749cfbd386b6d96a109fcacd51b0c80b22bd3890 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/RTParameterGetAnnotation2.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF2_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotation2 { + ParameterGetAnnotation2(@IF2(i = 222, t = "Parameter") int number) { + } + public void test1(@IF2_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotation2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotation2"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getAnnotation(IF2_a.class) == null && p2[0].getAnnotation(IF2.class) == null) { + p1[0].getAnnotation(IF2_a.class).c(); + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } catch (NullPointerException e2) { + try { + Class cls1 = Class.forName("ParameterGetAnnotation2"); + Method method2 = cls1.getMethod("test1", int.class); + Parameter[] p3 = method2.getParameters(); + p3[0].getAnnotation(null); + System.out.println(3); + return; + } catch (ClassNotFoundException e3) { + System.out.println(4); + return; + } catch (NoSuchMethodException e4) { + System.out.println(5); + return; + } catch (NullPointerException e5) { + System.out.println(0); + return; + } + } + System.out.println(6); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/expected.txt b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/test.cfg b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..699fa3167c9c04f3fb71c5cab1499c52da48bf2d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0101-rt-reflection-RTParametergetAnnotation2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotation2) +run(RTParameterGetAnnotation2) diff --git a/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/RTParameterGetAnnotations1.java b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/RTParameterGetAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..d720e6ca1de1d84b271a5afa9d81ff42a58165f7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/RTParameterGetAnnotations1.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF3 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF3_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotations1 { + ParameterGetAnnotations1(@IF3(i = 222, t = "Parameter") @IF3_a(c = 666, d = "Happy new year") int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotations1"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getAnnotations().length == 2 && p2[0].getAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..caeda24b3aa66a7b3aa41367ed6b08b9203e0288 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0102-rt-reflection-RTParametergetAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotations1) +run(RTParameterGetAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..bde5b184faef1592eae1368fe36d9dd7677ad4d6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/RTParameterGetAnnotationsByType1.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF7 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF7_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotationsByType1 { + ParameterGetAnnotationsByType1(@IF7(i = 222, t = "Parameter") int number) { + } + public ParameterGetAnnotationsByType1(String name) { + } + public void test1(@IF7_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotationsByType1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotationsByType1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + Annotation[] q1 = p1[0].getAnnotationsByType(IF7.class); + Annotation[] q3 = p3[0].getAnnotationsByType(IF7_a.class); + if (p2[0].getAnnotationsByType(IF7.class).length == 0) { + if (q1[0].toString().indexOf("i=222") != -1 && q1[0].toString().indexOf("t=Parameter") != -1 + && q3[0].toString().indexOf("c=666") != -1 + && q3[0].toString().indexOf("d=Happy new year") != -1) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/expected.txt b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/test.cfg b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..208bd40d189764331ca51d39f42b6d7caf97cb61 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0103-rt-reflection-RTParametergetAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotationsByType1) +run(RTParameterGetAnnotationsByType1) diff --git a/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java new file mode 100755 index 0000000000000000000000000000000000000000..68369c3a25f9024761ac81bc63651f3360dbff70 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/RTParameterGetAnnotationsByType2.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF8 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF8_a { + int c() default 0; + String d() default ""; +} +class ParameterGetAnnotationsByType2 { + ParameterGetAnnotationsByType2(@IF8(i = 222, t = "Parameter") int number) { + } + public void test1(@IF8_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetAnnotationsByType2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetAnnotationsByType2"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + Annotation[] q1 = p1[0].getAnnotationsByType(IF8_a.class); + Annotation[] q2 = p2[0].getAnnotationsByType(IF8.class); + q1[0].toString(); + q2[0].toString(); + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } catch (ArrayIndexOutOfBoundsException e2) { + try { + Class cls1 = Class.forName("ParameterGetAnnotationsByType2"); + Constructor cons1 = cls1.getDeclaredConstructor(int.class); + Parameter[] p3 = cons1.getParameters(); + Annotation[] q3 = p3[0].getAnnotationsByType(null); + System.out.println(3); + return; + } catch (ClassNotFoundException e3) { + System.out.println(4); + return; + } catch (NoSuchMethodException e4) { + System.out.println(5); + return; + } catch (NullPointerException e5) { + System.out.println(0); + return; + } + } + System.out.println(6); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/expected.txt b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/test.cfg b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a9c3f557c9e3dd343fd832f763a949f6cbec863c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0104-rt-reflection-RTParametergetAnnotationsByType2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetAnnotationsByType2) +run(RTParameterGetAnnotationsByType2) diff --git a/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..1a84159717abf913653e3bf553f246f2fa94d64b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/RTParameterGetDeclaredAnnotation1.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF6 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF6_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotation1 { + ParameterGetDeclaredAnnotation1(@IF6(i = 222, t = "Parameter") int number) { + } + public ParameterGetDeclaredAnnotation1(String name) { + } + public void test1(@IF6_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetDeclaredAnnotation1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotation1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + if (p1[0].getDeclaredAnnotation(IF6.class).i() == 222 && p1[0].getDeclaredAnnotation(IF6.class).t() + .equals("Parameter") && p3[0].getDeclaredAnnotation(IF6_a.class).c() == 666 + && p3[0].getDeclaredAnnotation(IF6_a.class).d().equals("Happy new year")) { + if (p2[0].getDeclaredAnnotation(IF6.class) == null) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/expected.txt b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/test.cfg b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d176726d61857df4a6e81e90050dd0e2b02765ef --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0105-rt-reflection-RTParametergetDeclaredAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotation1) +run(RTParameterGetDeclaredAnnotation1) diff --git a/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java new file mode 100755 index 0000000000000000000000000000000000000000..99d91a9dfa75222b20538d3978a6721bb069b8b3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/RTParameterGetDeclaredAnnotations1.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF5 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF5_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotations1 { + ParameterGetDeclaredAnnotations1(@IF5(i = 222, t = "Parameter") @IF5_a(c = 666, d = "Happy new year") int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetDeclaredAnnotations1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotations1"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getDeclaredAnnotations().length == 2 && p2[0].getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/expected.txt b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/test.cfg b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d568dbd412030588a7424ef1f2558e8ab300d57b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0106-rt-reflection-RTParametergetDeclaredAnnotations1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotations1) +run(RTParameterGetDeclaredAnnotations1) diff --git a/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java new file mode 100755 index 0000000000000000000000000000000000000000..4af1505814a72d00ca7ad7ccac42ffe388045066 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/RTParameterGetDeclaredAnnotations2.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF4 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF4_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotations2 { + ParameterGetDeclaredAnnotations2() { + } + ParameterGetDeclaredAnnotations2(@IF4(i = 222, t = "Parameter") int number) { + } + public void test1(@IF4(i = 222, t = "Parameter") String name) { + } +} +class ParameterGetDeclaredAnnotations2_a extends ParameterGetDeclaredAnnotations2 { + ParameterGetDeclaredAnnotations2_a() { + } + ParameterGetDeclaredAnnotations2_a(@IF4_a(c = 666, d = "Happy new year") int number) { + } + public void test1(@IF4_a(c = 666, d = "Happy new year") String name) { + } +} +class ParameterGetDeclaredAnnotations2_b extends ParameterGetDeclaredAnnotations2_a { + ParameterGetDeclaredAnnotations2_b(int number) { + } + public void test1(String name) { + } +} +public class RTParameterGetDeclaredAnnotations2 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotations2_b"); + Constructor cons = cls.getDeclaredConstructor(int.class); + Method method = cls.getMethod("test1", String.class); + Parameter[] p1 = cons.getParameters(); + Parameter[] p2 = method.getParameters(); + if (p1[0].getDeclaredAnnotations().length == 0 && p2[0].getDeclaredAnnotations().length == 0) { + System.out.println(0); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(1); + return; + } catch (NoSuchMethodException e1) { + System.out.println(2); + return; + } + System.out.println(3); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/expected.txt b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/test.cfg b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5e5907a08d1f6341842e5f3c88c0876d06128ce4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0107-rt-reflection-RTParametergetDeclaredAnnotations2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotations2) +run(RTParameterGetDeclaredAnnotations2) diff --git a/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java new file mode 100755 index 0000000000000000000000000000000000000000..c8f60f1a7ab30d0f88bcca88d6bb42d8ba85d67e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/RTParameterGetDeclaredAnnotationsByType1.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF9 { + int i() default 0; + String t() default ""; +} +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface IF9_a { + int c() default 0; + String d() default ""; +} +class ParameterGetDeclaredAnnotationsByType1 { + ParameterGetDeclaredAnnotationsByType1(@IF9(i = 222, t = "Parameter") int number) { + } + public ParameterGetDeclaredAnnotationsByType1(String name) { + } + public void test1(@IF9_a(c = 666, d = "Happy new year") int age) { + } +} +public class RTParameterGetDeclaredAnnotationsByType1 { + public static void main(String[] args) { + try { + Class cls = Class.forName("ParameterGetDeclaredAnnotationsByType1"); + Constructor cons1 = cls.getDeclaredConstructor(int.class); + Constructor cons2 = cls.getConstructor(String.class); + Method method = cls.getMethod("test1", int.class); + Parameter[] p1 = cons1.getParameters(); + Parameter[] p2 = cons2.getParameters(); + Parameter[] p3 = method.getParameters(); + Annotation[] q1 = p1[0].getDeclaredAnnotationsByType(IF9.class); + Annotation[] q3 = p3[0].getDeclaredAnnotationsByType(IF9_a.class); + if (p2[0].getDeclaredAnnotationsByType(IF9.class).length == 0) { + if (q1[0].toString().indexOf("i=222") != -1 && q1[0].toString().indexOf("t=Parameter") != -1 + && q3[0].toString().indexOf("c=666") != -1 + && q3[0].toString().indexOf("d=Happy new year") != -1) { + System.out.println(0); + return; + } + System.out.println(1); + return; + } + } catch (ClassNotFoundException e) { + System.out.println(2); + return; + } catch (NoSuchMethodException e1) { + System.out.println(3); + return; + } + System.out.println(4); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/expected.txt b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/test.cfg b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..07a732bed1e56ada793a51ea39d07c6faffee95e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0108-rt-reflection-RTParametergetDeclaredAnnotationsByType1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTParameterGetDeclaredAnnotationsByType1) +run(RTParameterGetDeclaredAnnotationsByType1) diff --git a/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/RTProxyGetProxyClass1.java b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/RTProxyGetProxyClass1.java new file mode 100755 index 0000000000000000000000000000000000000000..0cfe49e8493007d1718159e1193908d978ed7066 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/RTProxyGetProxyClass1.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Proxy; +interface ProxyGetProxyClass1_1 { + default void test1() { + } + default void test2() { + } + default void test3() { + } + default void test4() { + } + default void test5() { + } + default void test6() { + } + default void test7() { + } + default void test8() { + } + default void test9() { + } + default void test10() { + } + default void test11() { + } + default void test12() { + } + default void test13() { + } + default void test14() { + } + default void test15() { + } + default void test16() { + } + default void test17() { + } + default void test18() { + } + default void test19() { + } + default void test20() { + } + default void test21() { + } + default void test22() { + } + default void test23() { + } + default void test24() { + } + default void test25() { + } + default void test26() { + } + default void test27() { + } + default void test28() { + } + default void test29() { + } + default void test30() { + } +} +interface ProxyGetProxyClass1_2 extends ProxyGetProxyClass1_1 { + default void test30() { + } +} +interface ProxyGetProxyClass1_3 { + default void test31() { + } +} +public class RTProxyGetProxyClass1 { + public static void main(String[] args) { + try { + Proxy.getProxyClass(ProxyGetProxyClass1_1.class.getClassLoader(), new Class[] {ProxyGetProxyClass1_1.class, + ProxyGetProxyClass1_2.class}); + Proxy.getProxyClass(ProxyGetProxyClass1_1.class.getClassLoader(), new Class[] {ProxyGetProxyClass1_1.class, + ProxyGetProxyClass1_3.class}); + } catch (IllegalArgumentException e) { + System.err.println(e); + } + System.out.println(0); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/expected.txt b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/test.cfg b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6e32644ab3be3e9531261720f23b8b5992a92de1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0109-rt-reflection-RTProxygetProxyClass1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(RTProxyGetProxyClass1) +run(RTProxyGetProxyClass1) diff --git a/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java new file mode 100755 index 0000000000000000000000000000000000000000..2256d7426fbc829f9478d8fbd0a484cee85964da --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/ClassGetDeclaredAnnotationNPE.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +public class ClassGetDeclaredAnnotationNPE { + public static void main(String argv[]) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = ClassGetDeclaredAnnotationNPE_1(); + } catch (Exception e) { + result = 3; + } + System.out.println(result); + } + public static int ClassGetDeclaredAnnotationNPE_1() { + try { + Annotation a = MyClass.class.getDeclaredAnnotation(Deprecated.class); + a = MyClass.class.getDeclaredAnnotation(null); + } catch (NullPointerException e) { + return 0; + } + return 4; + } + @Deprecated + class MyClass extends MySuperClass { + } + @MyAnnotation + class MySuperClass { + } + @interface MyAnnotation { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/expected.txt b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/test.cfg b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2f7328498c299e69341ca049f1b7f4cbbc0c1211 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0110-rt-reflection-ClassgetDeclaredAnnotationNPE/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetDeclaredAnnotationNPE) +run(ClassGetDeclaredAnnotationNPE) diff --git a/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java new file mode 100755 index 0000000000000000000000000000000000000000..5c3d31fcb9f6f4b2baf0f6541f3a3c5ee219baff --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/ClassIsAssignableFromNPE.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class ClassIsAssignableFromNPE { + public static void main(String argv[]) { + int result = 2; /* STATUS_FAILED*/ + + try { + result = ClassIsAssignableFromNPE_1(); + } catch (Exception e) { + System.out.println(e); + result = 3; + } + System.out.println(result); + } + public static int ClassIsAssignableFromNPE_1() { + int result1 = 4; /* STATUS_FAILED*/ + + int intArray[] = {1, 2, 3, 4, 5}; + Class cl = null; + try { + intArray.getClass().isAssignableFrom(cl); + } catch (SecurityException e) { + return 1; + } catch (NullPointerException e) { + return 0; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/expected.txt b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/test.cfg b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..78d5881a8c677b70ffaa8cca9ae537876fa442d1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0111-rt-reflection-reflectClasssetisAssignableFrom/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassIsAssignableFromNPE) +run(ClassIsAssignableFromNPE) diff --git a/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..c2e05eabad034f95ea0f2f62ed3fd1ea8ace0e13 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/ClassGetAnnotationsByType.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetAnnotationsByType1() { + Class m; + try { + m = MyTargetTest0.class; + MyTarget[] Target = m.getAnnotationsByType(MyTarget.class); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest0 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest0(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/expected.txt b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/test.cfg b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..957ebdd0ba202041797ebb31a39343ced64b4989 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0112-rt-reflection-ClassGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetAnnotationsByType) +run(ClassGetAnnotationsByType) diff --git a/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/ClassGetCanonicalName.java b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/ClassGetCanonicalName.java new file mode 100755 index 0000000000000000000000000000000000000000..793d1a033fe02ee9da05cf538c8409b5acf5b374 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/ClassGetCanonicalName.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetCanonicalName { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetCanonicalName1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetCanonicalName1() { + Class m; + try { + m = MyTargetTest1.class; + String str = m.getCanonicalName(); + if ("ClassGetCanonicalName.MyTargetTest1".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest1 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest1(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/expected.txt b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/test.cfg b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73150467b2c31c277fb9414ace43e49cd8349ad0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0113-rt-reflection-ClassGetCanonicalName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetCanonicalName) +run(ClassGetCanonicalName) diff --git a/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/ClassGetEnclosingClass.java b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/ClassGetEnclosingClass.java new file mode 100755 index 0000000000000000000000000000000000000000..e9b1d372d948a79ff3e96bfc7a6a16643b5213c4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/ClassGetEnclosingClass.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetEnclosingClass { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetEnclosingClass1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetEnclosingClass1() { + Class m; + try { + m = MyTargetTest2.class; + Class cl = m.getEnclosingClass(); + if (cl != null) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest2 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest2(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/expected.txt b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/test.cfg b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06636719e419b137b9d7fd62e7fd88cda439472e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0114-rt-reflection-ClassGetEnclosingClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetEnclosingClass) +run(ClassGetEnclosingClass) diff --git a/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/ClassGetEnumConstants.java b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/ClassGetEnumConstants.java new file mode 100755 index 0000000000000000000000000000000000000000..7e7925810ea9f83e42b48986da30c511e4bd5aa3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/ClassGetEnumConstants.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetEnumConstants { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetEnumConstants1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetEnumConstants1() { + Class m; + try { + m = MyTargetTest3.class; + MyTargetTest3[] target = m.getEnumConstants(); + if (target == null) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest3 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest3(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/expected.txt b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/test.cfg b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9237eebdc450d54f879bc6fc75c6fbfe38d7b41 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0115-rt-reflection-ClassGetEnumConstants/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetEnumConstants) +run(ClassGetEnumConstants) diff --git a/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/ClassGetSimpleName.java b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/ClassGetSimpleName.java new file mode 100755 index 0000000000000000000000000000000000000000..287ee245ec18379a141928115cd027802ff8c9e1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/ClassGetSimpleName.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassGetSimpleName { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetSimpleName1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetSimpleName1() { + Class m; + try { + m = MyTargetTest4.class; + String str = m.getSimpleName(); + if ("MyTargetTest4".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest4 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest4(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/expected.txt b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/test.cfg b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bf5aa4609cfa14fa57d58ededbcc82722f09066a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0116-rt-reflection-ClassGetSimpleName/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetSimpleName) +run(ClassGetSimpleName) diff --git a/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/ClassGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/ClassGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..620a9b89666a5f351788178d36146231a4a9dd14 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/ClassGetTypeParameters.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.TypeVariable; +public class ClassGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassGetTypeParameters1() { + Class m; + try { + m = MyTargetTest5.class; + TypeVariable>[] target = m.getTypeParameters(); + if (target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest5 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest5(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..115c64aee04d84fd5f802dc7504a4a16f706cb2c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0117-rt-reflection-ClassGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassGetTypeParameters) +run(ClassGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/ClassToGenericString.java b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/ClassToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..df8c0a68549ed64ff679880782a204c081c93663 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/ClassToGenericString.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ClassToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ClassToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ClassToGenericString1() { + Class m; + try { + m = MyTargetTest6.class; + String str = m.toGenericString(); + if ("class ClassToGenericString$MyTargetTest6".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest6 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest6(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc8a8e725e788bdac8b934fe106b8527be46700e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0118-rt-reflection-ClassToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassToGenericString) +run(ClassToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/ConstructorGetAnnotation.java b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/ConstructorGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..f25b61cf4b35ee92353ddd159d1f5e0761023b2b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/ConstructorGetAnnotation.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorAnnotation1() { + Constructor m; + try { + m = MyTargetTest00.class.getConstructor(new Class[] {ConstructorGetAnnotation.class, String.class}); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@ConstructorGetAnnotation$MyTarget(name=cons, value=constructor)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest00 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest00(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3ba012bd183940a6f3bf22b0361910f92a98f348 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0119-rt-reflection-ConstructorGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetAnnotation) +run(ConstructorGetAnnotation) diff --git a/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..1532e8ae3cc77883cde7ca335e4ac8d609c883d9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/ConstructorGetDeclaredAnnotations.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetDeclaredAnnotations1() { + Constructor m; + try { + m = MyTargetTest01.class.getConstructor(new Class[] {ConstructorGetDeclaredAnnotations.class, String.class}); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@ConstructorGetDeclaredAnnotations$MyTarget(name=cons, value=constructor)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest01 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest01(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/expected.txt b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/test.cfg b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b6ee06c13b4edfb418952cd317ed3e15db7ba085 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0120-rt-reflection-ConstructorGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetDeclaredAnnotations) +run(ConstructorGetDeclaredAnnotations) diff --git a/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java new file mode 100755 index 0000000000000000000000000000000000000000..f4f63ff8b30dccd4dfdda94c1bb685eb623e6d94 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/ConstructorGetExceptionTypes.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorGetExceptionTypes { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetExceptionTypes1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetExceptionTypes1() { + Constructor m; + try { + m = MyTargetTest02.class.getConstructor(new Class[] {ConstructorGetExceptionTypes.class, String.class}); + Class[] Target = m.getExceptionTypes(); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest02 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest02(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/expected.txt b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/test.cfg b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..950ac88e9d47d3f9c1ec505f47d17dc4caf4f6f5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0121-rt-reflection-ConstructorGetExceptionTypes/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetExceptionTypes) +run(ConstructorGetExceptionTypes) diff --git a/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..9c2107f9aacf468d44e902baf6ed920c64b80ac5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/ConstructorGetTypeParameters.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +import java.lang.reflect.TypeVariable; +public class ConstructorGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorGetTypeParameters1() { + Constructor m; + try { + m = MyTargetTest03.class.getConstructor(new Class[] {ConstructorGetTypeParameters.class, String.class}); + TypeVariable>[] Target = m.getTypeParameters(); + if (Target.length == 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest03 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest03(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..119a121e625beaa90fd3160f8ecab46587993479 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0122-rt-reflection-ConstructorGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorGetTypeParameters) +run(ConstructorGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/ConstructorToGenericString.java b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/ConstructorToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..bc18f2200d4021f88d6f7d800f19b966d9dbebfb --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/ConstructorToGenericString.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Constructor; +public class ConstructorToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ConstructorToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ConstructorToGenericString1() { + Constructor m; + try { + m = MyTargetTest04.class.getConstructor(new Class[] {ConstructorToGenericString.class, String.class}); + String str = m.toGenericString(); + if ("public ConstructorToGenericString$MyTargetTest04(ConstructorToGenericString,java.lang.String)" + .equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest04 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest04(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..525f2927186f00a14a8bc2480f7379080246cabd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0123-rt-reflection-ConstructorToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorToGenericString) +run(ConstructorToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/FieldGetAnnotation.java b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/FieldGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..ead36eba2ab4fe269723dbd9f87d5e45d81f7354 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/FieldGetAnnotation.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldGetAnnotation1() { + Field m; + try { + m = MyTargetTest06.class.getField("home"); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@FieldGetAnnotation$MyTarget(name=newName, value=newValue)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest06 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4c59ff9c0b25afa608dae0c99b817b9830fbbfc9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0124-rt-reflection-FieldGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetAnnotation) +run(FieldGetAnnotation) diff --git a/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..f0d0c61dcfb95400110ef9087b3eabb7614761c5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/FieldGetAnnotationsByType.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldGetAnnotationsByType1() { + Field m; + try { + m = MyTargetTest07.class.getField("home"); + MyTarget[] Target = m.getAnnotationsByType(MyTarget.class); + if (Target.length > 0) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest07 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest07(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/expected.txt b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/test.cfg b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..89df1af8a900edd4e3e0197a414851de1f18ca74 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0125-rt-reflection-FieldGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetAnnotationsByType) +run(FieldGetAnnotationsByType) diff --git a/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..3014d080066c41e40a6272284a16e14fade5ec16 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/FieldGetDeclaredAnnotations.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetDeclaredAnnotations1() { + Field m; + try { + m = MyTargetTest08.class.getField("home"); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@FieldGetDeclaredAnnotations$MyTarget(name=newName, value=newValue)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest08 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest08(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/expected.txt b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/test.cfg b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..99d700750a69b23b15586235fd5aee551b9119e6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0126-rt-reflection-FieldGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldGetDeclaredAnnotations) +run(FieldGetDeclaredAnnotations) diff --git a/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java new file mode 100755 index 0000000000000000000000000000000000000000..214c0f54c4efda21df833706a2cefe0d8d875922 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/FieldIsAnnotationPresent.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldIsAnnotationPresent { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodIsAnnotationPresent1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodIsAnnotationPresent1() { + Field m; + try { + m = MyTargetTest09.class.getField("home"); + boolean flag = m.isAnnotationPresent(MyTarget.class); + if (flag) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest09 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest09(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/expected.txt b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/test.cfg b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0493d725c24622bcad24bb7e657d49d633da7795 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0127-rt-reflection-FieldIsAnnotationPresent/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldIsAnnotationPresent) +run(FieldIsAnnotationPresent) diff --git a/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/FieldToGenericString.java b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/FieldToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..88d89c0a7f99eea8b7bfff1ae5a6eb42d44df9a2 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/FieldToGenericString.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Field; +public class FieldToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = FieldToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int FieldToGenericString1() { + Field m; + try { + m = MyTargetTest10.class.getField("home"); + String str = m.toGenericString(); + if ("public java.lang.String FieldToGenericString$MyTargetTest10.home".equals(str)) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest10 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest10(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..beffa74901ff38d380f441df8ae1233749f934f1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0128-rt-reflection-FieldToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldToGenericString) +run(FieldToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/MethodGetAnnotation.java b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/MethodGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..4131586e5490966778d197a035ab5ee787198fd5 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/MethodGetAnnotation.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetAnnotation1() { + Method m; + try { + m = MyTargetTest11.class.getMethod("MyTargetTest_1"); + MyTarget Target = m.getAnnotation(MyTarget.class); + if ("@MethodGetAnnotation$MyTarget(name=name, value=value)".equals(Target.toString())) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest11 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ecf9b41606c6b690b3299951bec10ff8da1c9bc2 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0129-rt-reflection-MethodGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetAnnotation) +run(MethodGetAnnotation) diff --git a/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..b81668d39c5c4c4b5d9256b790da79cbaccc5aee --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/MethodGetDeclaredAnnotations.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetDeclaredAnnotations1() { + Method m; + try { + m = MyTargetTest12.class.getMethod("MyTargetTest_1"); + MyTarget Target = m.getDeclaredAnnotation(MyTarget.class); + if ("@MethodGetDeclaredAnnotations$MyTarget(name=name, value=value)".equals(Target.toString())) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest12 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest12(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/expected.txt b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/test.cfg b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f48e752c0fd8b0e7f063ecabe5a62e51c342846f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0130-rt-reflection-MethodGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetDeclaredAnnotations) +run(MethodGetDeclaredAnnotations) diff --git a/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/MethodGetDefaultValue.java b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/MethodGetDefaultValue.java new file mode 100755 index 0000000000000000000000000000000000000000..533de7414ab103ec8c4f94cf59ab619286522379 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/MethodGetDefaultValue.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +public class MethodGetDefaultValue { + public static void main(String[] argv) { + int result = 2/* STATUS_FAILED*/ +; + try { + result = MethodGetDefaultValueTypeNotPresent_1(); + } catch (Exception e) { + result = 3; + } + System.out.println(result); + } + public static int MethodGetDefaultValueTypeNotPresent_1() { + try { + Method m = MyTargetTest13.class.getMethod("MyTargetTest_1"); + Object a = m.getDefaultValue(); + } catch (TypeNotPresentException e) { + return 3; + } catch (NoSuchMethodException e) { + return 4; + } + return 0; + } + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + Class style() default String.class; + } + @MyTarget() + class MyTargetTest13 { + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/expected.txt b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/test.cfg b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7045d53146539174e5a753eb5afa0353285d6102 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0131-rt-reflection-MethodgetDefaultValue/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetDefaultValue) +run(MethodGetDefaultValue) diff --git a/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/MethodGetParameterCount.java b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/MethodGetParameterCount.java new file mode 100755 index 0000000000000000000000000000000000000000..f4e20acf40a49f3251ba57b683f6a6831e712af8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/MethodGetParameterCount.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodGetParameterCount { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetParameterCount1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetParameterCount1() { + Method m; + try { + m = MyTargetTest14.class.getMethod("MyTargetTest_1"); + int num = m.getParameterCount(); + if (num == 0) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest14 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest14(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/expected.txt b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/test.cfg b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e468c2db25175e81ace9c828e5e903a05257da64 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0132-rt-reflection-MethodGetParameterCount/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetParameterCount) +run(MethodGetParameterCount) diff --git a/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/MethodGetTypeParameters.java b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/MethodGetTypeParameters.java new file mode 100755 index 0000000000000000000000000000000000000000..7e1757aec2da12a2978b242241be357057ec61ab --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/MethodGetTypeParameters.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.TypeVariable; +public class MethodGetTypeParameters { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodGetTypeParameters1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodGetTypeParameters1() { + Method m; + try { + m = MyTargetTest15.class.getMethod("MyTargetTest_1"); + TypeVariable[] Target = m.getTypeParameters(); + if (Target.length == 0) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest15 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest15(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/expected.txt b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/test.cfg b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7f6854e1c265986b12fa7e38f4187512768c9b8a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0133-rt-reflection-MethodGetTypeParameters/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodGetTypeParameters) +run(MethodGetTypeParameters) diff --git a/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/MethodIsDefault.java b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/MethodIsDefault.java new file mode 100755 index 0000000000000000000000000000000000000000..0955dfbf47461734ceebc6181ac674fe51febf79 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/MethodIsDefault.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodIsDefault { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodIsDefault1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodIsDefault1() { + Method m; + try { + m = MyTargetTest16.class.getMethod("MyTargetTest_1"); + boolean flag = m.isDefault(); + if (!flag) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest16 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest16(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/expected.txt b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/test.cfg b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ece76672147016a46a0aac4ae8c3b1b8c049dfa8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0134-rt-reflection-MethodIsDefault/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodIsDefault) +run(MethodIsDefault) diff --git a/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/MethodToGenericString.java b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/MethodToGenericString.java new file mode 100755 index 0000000000000000000000000000000000000000..92d65175aeadf73c6f6f4002ff5bffd81237a5a4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/MethodToGenericString.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +public class MethodToGenericString { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = MethodToGenericString1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int MethodToGenericString1() { + Method m; + try { + m = MyTargetTest17.class.getMethod("MyTargetTest_1"); + String str = m.toGenericString(); + if ("public void MethodToGenericString$MyTargetTest17.MyTargetTest_1()".equals(str)) { + return 0; + } + } catch (NoSuchMethodException | SecurityException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest17 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest17(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/expected.txt b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/test.cfg b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b76f84edd04516622cb4129c8b287273912c4674 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0135-rt-reflection-MethodToGenericString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodToGenericString) +run(MethodToGenericString) diff --git a/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/ParameterGetAnnotation.java b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/ParameterGetAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..86de54c336db91b6bfc15a2677b9f2c9559ac755 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/ParameterGetAnnotation.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotation { + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotation1() { + Method m; + try { + m = MyTargetTest18.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget Target = parameters[0].getAnnotation(MyTarget.class); + if ("@ParameterGetAnnotation$MyTarget(name=name1, value=value1)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest18 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + } + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c83b597de80ca9092cb898e9960d6d19481c1870 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0136-rt-reflection-ParameterGetAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotation) +run(ParameterGetAnnotation) diff --git a/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/ParameterGetAnnotations.java b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/ParameterGetAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..dc88efdca5e216a5b3d8eba102a66036732269a7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/ParameterGetAnnotations.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +public class ParameterGetAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotations1() { + Method m; + try { + m = MyTargetTest19.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + Annotation[] Target = parameters[0].getAnnotations(); + if ("@ParameterGetAnnotations$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest19 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest19(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/expected.txt b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/test.cfg b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..298a5d2e3f7f1722919c8ea157778c4197f361fa --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0137-rt-reflection-ParameterGetAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotations) +run(ParameterGetAnnotations) diff --git a/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..e53f77b41cce3357d0e6fd4ff7d7b99ed4ac73b1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/ParameterGetAnnotationsByType.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetAnnotationsByType1() { + Method m; + try { + m = MyTargetTest20.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget[] Target = parameters[0].getAnnotationsByType(MyTarget.class); + if ("@ParameterGetAnnotationsByType$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest20 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest20(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/expected.txt b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/test.cfg b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09d64a77841372f53826a71c09c50d94b98eaa9a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0138-rt-reflection-ParameterGetAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetAnnotationsByType) +run(ParameterGetAnnotationsByType) diff --git a/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java new file mode 100755 index 0000000000000000000000000000000000000000..73c96f1ef53a31eb295134f98a01046b78d88637 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/ParameterGetDeclaredAnnotation.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotation { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotation1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotation1() { + Method m; + try { + m = MyTargetTest21.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget Target = parameters[0].getDeclaredAnnotation(MyTarget.class); + if ("@ParameterGetDeclaredAnnotation$MyTarget(name=name1, value=value1)".equals(Target.toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest21 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest21(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/expected.txt b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/test.cfg b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..09fc082610eac6a59bb483425fa1b59c987b3667 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0139-rt-reflection-ParameterGetDeclaredAnnotation/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotation) +run(ParameterGetDeclaredAnnotation) diff --git a/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java new file mode 100755 index 0000000000000000000000000000000000000000..56b4ef51b3dd0c7f7485b450b7508060f3f87438 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/ParameterGetDeclaredAnnotations.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Annotation; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotations { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotations1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotations1() { + Method m; + try { + m = MyTargetTest22.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + Annotation[] Target = parameters[0].getDeclaredAnnotations(); + if ("@ParameterGetDeclaredAnnotations$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest22 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest22(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/expected.txt b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/test.cfg b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..db342d3e79ce78004110ded8f92885b22d90d0d7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0140-rt-reflection-ParameterGetDeclaredAnnotations/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotations) +run(ParameterGetDeclaredAnnotations) diff --git a/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java new file mode 100755 index 0000000000000000000000000000000000000000..ab0de6845cadfb58fe1a2373a46564a4f5be1db4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/ParameterGetDeclaredAnnotationsByType.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +public class ParameterGetDeclaredAnnotationsByType { + @Retention(RetentionPolicy.RUNTIME) + public @interface MyTarget { + public String name(); + public String value(); + } + public static void main(String[] args) { + int result = 2; + try { + result = ParameterGetDeclaredAnnotationsByType1(); + } catch (Exception e) { + e.printStackTrace(); + result = 3; + } + System.out.println(result); + } + public static int ParameterGetDeclaredAnnotationsByType1() { + Method m; + try { + m = MyTargetTest23.class.getMethod("newMethod", new Class[] {String.class}); + Parameter[] parameters = m.getParameters(); + MyTarget[] Target = parameters[0].getDeclaredAnnotationsByType(MyTarget.class); + if ("@ParameterGetDeclaredAnnotationsByType$MyTarget(name=name1, value=value1)".equals(Target[0].toString())) { + return 0; + } + } catch (SecurityException e) { + e.printStackTrace(); + } catch (NoSuchMethodException e) { + e.printStackTrace(); + } + return 2; + } + class MyTargetTest23 { + @MyTarget(name = "newName", value = "newValue") + public String home; + @MyTarget(name = "name", value = "value") + public void MyTargetTest_1() { + System.out.println("This is Example:hello world"); + } + public void newMethod(@MyTarget(name = "name1", value = "value1") String home) { + System.out.println("my home at:" + home); + } + @MyTarget(name = "cons", value = "constructor") + public MyTargetTest23(String home) { + this.home = home; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/expected.txt b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/test.cfg b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c33d69b4bb5e5e6f002e1e2bb0b5a27a6689bc6c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0141-rt-reflection-ParameterGetDeclaredAnnotationsByType/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ParameterGetDeclaredAnnotationsByType) +run(ParameterGetDeclaredAnnotationsByType) diff --git a/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java new file mode 100755 index 0000000000000000000000000000000000000000..823bc0c4a658d9eb96cfc540483d84ab693d6692 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/ReflectionAnnotationGetClass.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.util.Arrays; +public class ReflectionAnnotationGetClass { + public static void main(String[] args) { + int result = 2; + try{ + // Check point 1 : only 1 annotation in user-defined Class Two. + Annotation[] annotations1 = Class.forName("Two").getAnnotations(); + if (annotations1.length == 1){ + if (annotations1[0].getClass().toString().startsWith("class $Proxy")) { + result --; + } + } + // Check point 2 : 3 annotations in Class java.lang.annotation.Documented. + Annotation[] annotations2 = Class.forName("java.lang.annotation.Documented").getAnnotations(); + String [] annoClazz = new String[annotations2.length]; + for (int i = 0; i < annoClazz.length; i++) { + annoClazz[i] = annotations2[i].getClass().toString(); + } + Arrays.sort(annoClazz); + if (annotations2.length == 3) { + if (annoClazz[0].startsWith("class $Proxy") && annoClazz[1] + .startsWith("class $Proxy") + && annoClazz[2].startsWith("class $Proxy")) { + result --; + } + } + }catch (Exception e) { + result = 3; + } + System.out.println(result); + } +} +@A0 +class Two{} +@Retention(RetentionPolicy.RUNTIME) @interface A0 {} diff --git a/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/expected.txt b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/test.cfg b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..91f31237f23bac38c7f677da670be9660720c4ab --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0142-rt-reflection-ReflectionAnnotationGetClass/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionAnnotationGetClass) +run(ReflectionAnnotationGetClass) diff --git a/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/ClassInitClassNewInstance.java b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/ClassInitClassNewInstance.java new file mode 100755 index 0000000000000000000000000000000000000000..396877ebcb270e1cafd05fffe6ffc801546efbc9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/ClassInitClassNewInstance.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +public class ClassInitClassNewInstance { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try{ + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + /* Check point 1: no class initialization when calling following methods of Class + * not test clazz.cast(Object obj) because it success only when obj is an instance of One or Two, + * and need to call new One(), which result in Class initialization.*/ + + clazz.asSubclass(clazz); + clazz.desiredAssertionStatus(); + clazz.getAnnotation(A.class); + clazz.getAnnotations(); + clazz.getAnnotationsByType(A.class); + clazz.getCanonicalName(); + clazz.getClasses(); + clazz.getClassLoader(); + clazz.getComponentType(); + clazz.getConstructor(String.class); + clazz.getConstructors(); + clazz.getDeclaredAnnotation(A.class); + clazz.getDeclaredAnnotations(); + clazz.getDeclaredAnnotationsByType(A.class); + clazz.getDeclaredClasses(); + clazz.getDeclaredConstructor(String.class); + clazz.getDeclaredConstructors(); + clazz.getDeclaredField("what"); + clazz.getDeclaredFields(); + clazz.getDeclaredMethod("testOne", String.class); + clazz.getDeclaredMethods(); + clazz.getDeclaringClass(); + clazz.getEnclosingClass(); + clazz.getEnclosingConstructor(); + clazz.getEnclosingMethod(); + clazz.getEnumConstants(); + clazz.getField("hi"); + clazz.getFields(); + clazz.getGenericInterfaces(); + clazz.getGenericSuperclass(); + clazz.getInterfaces(); + clazz.getMethod("testOne",String.class); + clazz.getMethods(); + clazz.getModifiers(); + clazz.getName(); + clazz.getPackage(); + clazz.getProtectionDomain(); + clazz.getSigners(); + clazz.getSimpleName(); + clazz.getSuperclass(); + clazz.getTypeName(); + clazz.getTypeParameters(); + clazz.isAnnotation(); + clazz.isAnnotationPresent(A.class); + clazz.isAnonymousClass(); + clazz.isArray(); + clazz.isAssignableFrom(clazz); + clazz.isEnum(); + clazz.isInstance(new Object()); + clazz.isInterface(); + clazz.isLocalClass(); + clazz.isMemberClass(); + clazz.isPrimitive(); + clazz.isSynthetic(); + clazz.toString(); + clazz.toGenericString(); + clazz.getResource("hi"); + clazz.getResourceAsStream("hi"); + // Check point 2: when call newInstance, start class initialization + if (result.toString().compareTo("") == 0) { + clazz.newInstance(); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitClassNewInstance.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitClassNewInstance.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitClassNewInstance.result.append("One"); + } + String what = "lala"; + public String hi = ""; + One(){} + public One(String s){ + what = s; + System.out.println(s); + } + public int testOne(String a){ + System.out.println(a); + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitClassNewInstance.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitClassNewInstance.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/expected.txt b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/test.cfg b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1974ad87773ecfe146c71bf0377301c6a3974b0d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0143-rt-reflection-ClinitClassNewInstance/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitClassNewInstance) +run(ClassInitClassNewInstance) diff --git a/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java new file mode 100755 index 0000000000000000000000000000000000000000..113b45f4f6eca4dd1ee0a9e1f15d12fd4001797a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/ClassInitConstructorNewInstance.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Constructor; +public class ClassInitConstructorNewInstance { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Constructor constructor = clazz.getConstructor(String.class); + //check point 1: calling following methods, class not initialized + constructor.equals(constructor); + constructor.getAnnotation(A.class); + constructor.getDeclaredAnnotations(); + constructor.getDeclaringClass(); + constructor.getExceptionTypes(); + constructor.getGenericExceptionTypes(); + constructor.getGenericParameterTypes(); + constructor.getModifiers(); + constructor.getName(); + constructor.getParameterAnnotations(); + constructor.getParameterCount(); + constructor.getParameterTypes(); + constructor.hashCode(); + constructor.isSynthetic(); + constructor.isVarArgs(); + constructor.toString(); + constructor.toGenericString(); + //check point 2: after call newInstance(), class initialized + if (result.toString().compareTo("") == 0) { + constructor.newInstance("newInstance"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitConstructorNewInstance.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitConstructorNewInstance.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitConstructorNewInstance.result.append("One"); + } + String what = "lala"; + One(){} + public One(String s){ + what = s; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitConstructorNewInstance.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitConstructorNewInstance.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/expected.txt b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/test.cfg b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..25a361f0733633a7600320725e5240ddee4649c0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0144-rt-reflection-ClinitConstructorNewInstance/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitConstructorNewInstance) +run(ClassInitConstructorNewInstance) diff --git a/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..d95136e0b6578e5e2ec6befb42bf74c88978a21b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/ClassInitFieldGetBooleanStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetBooleanStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.getBoolean(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetBooleanStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetBooleanStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetBooleanStatic.result.append("One"); + } + public static boolean hiBoolean = false; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetBooleanStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetBooleanStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/expected.txt b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/test.cfg b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2099f29be693892bcb9ec921a7cca301e1f49f0f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0145-rt-reflection-ClinitFieldGetBooleanStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetBooleanStatic) +run(ClassInitFieldGetBooleanStatic) diff --git a/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..7eec7ad2fc5e5cb944ef7998589dec515ad59420 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/ClassInitFieldGetByteStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetByteStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.getByte(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetByteStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetByteStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetByteStatic.result.append("One"); + } + public static byte hiByte = (byte)0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetByteStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetByteStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/expected.txt b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/test.cfg b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f0bcec95178ff2c19752941b1ba34fcf411d4074 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0146-rt-reflection-ClinitFieldGetByteStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetByteStatic) +run(ClassInitFieldGetByteStatic) diff --git a/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..0383ee40890ce950955da1562d85add2c0a02259 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/ClassInitFieldGetCharStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetCharStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.getChar(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetCharStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetCharStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetCharStatic.result.append("One"); + } + public static char hiChar = (char)45; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetCharStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetCharStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/expected.txt b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/test.cfg b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..607f0c6737cd6ac740ada174adc712637dffcb62 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0147-rt-reflection-ClinitFieldGetCharStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetCharStatic) +run(ClassInitFieldGetCharStatic) diff --git a/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..d296eb26c1127d448fe28a1826803dd631505ec4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/ClassInitFieldGetDoubleStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetDoubleStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.getDouble(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetDoubleStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetDoubleStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetDoubleStatic.result.append("One"); + } + public static double hiDouble = 4.5; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetDoubleStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetDoubleStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/expected.txt b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/test.cfg b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bc534102a0c50cc0e6ca714d9ce35566f6aafe04 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0148-rt-reflection-ClinitFieldGetDoubleStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetDoubleStatic) +run(ClassInitFieldGetDoubleStatic) diff --git a/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..fb4590fbf7acb67dfbb3b1f6107746c68536c86c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/ClassInitFieldGetFloatStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetFloatStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.getFloat(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetFloatStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetFloatStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetFloatStatic.result.append("One"); + } + public static float hiFloat = 0.25f; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetFloatStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetFloatStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/expected.txt b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/test.cfg b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f5e98566242a11ee81668c3536656515aaf775b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0149-rt-reflection-ClinitFieldGetFloatStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetFloatStatic) +run(ClassInitFieldGetFloatStatic) diff --git a/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..b22247fad52e409409aad47142140ab8608eeeba --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/ClassInitFieldGetIntStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetIntStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.getInt(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetIntStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetIntStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetIntStatic.result.append("One"); + } + public static int hiInt = 0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetIntStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetIntStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/expected.txt b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/test.cfg b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46499c2a920987329489fdf526c3e14d4a7a211b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0150-rt-reflection-ClinitFieldGetIntStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetIntStatic) +run(ClassInitFieldGetIntStatic) diff --git a/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..25291ef6e83345e0848c453433b69d73233bb256 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/ClassInitFieldGetLongStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetLongStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.getLong(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetLongStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetLongStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetLongStatic.result.append("One"); + } + public static long hiLong = 4859l; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetLongStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetLongStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/expected.txt b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/test.cfg b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..afe14aec272391c4c16841b7e1b59bee48e1f1f8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0151-rt-reflection-ClinitFieldGetLongStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetLongStatic) +run(ClassInitFieldGetLongStatic) diff --git a/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..29d60063d1d32dcfebee8d560a352565267b3177 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/ClassInitFieldGetShortStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldGetShortStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.getShort(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetShortStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetShortStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetShortStatic.result.append("One"); + } + public static short hiShort = 48; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetShortStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetShortStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/expected.txt b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/test.cfg b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..11a217d81fcd445412385c7463a64939adc01311 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0152-rt-reflection-ClinitFieldGetShortStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetShortStatic) +run(ClassInitFieldGetShortStatic) diff --git a/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/ClassInitFieldGetStatic.java b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/ClassInitFieldGetStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..c1c9e77a9131e8a2134c3873f3371574cf327123 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/ClassInitFieldGetStatic.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.lang.reflect.Field; +public class ClassInitFieldGetStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + String fValue = ""; + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + fValue = (String)f.get(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0 && fValue.compareTo("hi") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldGetStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldGetStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldGetStatic.result.append("One"); + } + public static String hi = "hi"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldGetStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldGetStatic.result.append("Two"); + } +} diff --git a/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/expected.txt b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/test.cfg b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e51cb828f8e89d7fe47c5659aeda253c43a9a2df --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0153-rt-reflection-ClinitFieldGetStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetStatic) +run(ClassInitFieldGetStatic) diff --git a/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java new file mode 100755 index 0000000000000000000000000000000000000000..ae28dba754b7381d9f00760b13ef51c4a93a3ac4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/ClassInitFieldOtherMethod.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldOtherMethod { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + f.equals(f); + f.getAnnotation(B.class); + f.getAnnotationsByType(B.class); + f.getDeclaredAnnotations(); + f.getDeclaringClass(); + f.getGenericType(); + f.getModifiers(); + f.getName(); + f.getType(); + f.hashCode(); + f.isEnumConstant(); + f.isSynthetic(); + f.toGenericString(); + f.toString(); + } catch (Exception e) { + System.out.println(e); + } + if(result.toString().compareTo("") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldOtherMethod.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldOtherMethod.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldOtherMethod.result.append("One"); + } + @B("hello") + public static String hi = "value"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldOtherMethod.result.append("|InterfaceA|").toString(); +} +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +@interface B{ + String value() default "hi"; +} +class Two extends One { + static { + ClassInitFieldOtherMethod.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/expected.txt b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/test.cfg b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e732c328c09f173dee225a6f5da848150e715507 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0154-rt-reflection-ClinitFieldOtherMethod/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldOtherMethod) +run(ClassInitFieldOtherMethod) diff --git a/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..1c1038233d3493864631617e358b95424391cd13 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/ClassInitFieldSetBooleanStatic.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetBooleanStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.setBoolean(null, false); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetBooleanStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetBooleanStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetBooleanStatic.result.append("One"); + } + String what = "lala"; + public static boolean hiBoolean = false; + One(){} + public One(String s){ + what = s; + System.out.println(s); + } + public int testOne(String a){ + System.out.println(a); + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetBooleanStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetBooleanStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/expected.txt b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/test.cfg b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..06efaf3974a352b8f6a571a4fd82a232005fd619 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0155-rt-reflection-ClinitFieldSetBooleanStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetBooleanStatic) +run(ClassInitFieldSetBooleanStatic) diff --git a/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..2839e31e0538c56d90720d99e4e7995fbbdb8a09 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/ClassInitFieldSetByteStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetByteStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.setByte(null, (byte)1); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetByteStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetByteStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetByteStatic.result.append("One"); + } + public static byte hiByte = (byte)0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetByteStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetByteStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/expected.txt b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/test.cfg b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f13f3770322e8216edb0dcc9cf7d913f3826ae46 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0156-rt-reflection-ClinitFieldSetByteStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetByteStatic) +run(ClassInitFieldSetByteStatic) diff --git a/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..3ab632b803ab14468e0dceee5a0d255f3f730c7f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/ClassInitFieldSetCharStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetCharStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.setChar(null, (char)1); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetCharStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetCharStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetCharStatic.result.append("One"); + } + public static char hiChar = (char)45; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetCharStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetCharStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/expected.txt b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/test.cfg b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2fa8ac2248e976ba9330a76c955b7914393e9e73 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0157-rt-reflection-ClinitFieldSetCharStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetCharStatic) +run(ClassInitFieldSetCharStatic) diff --git a/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..a0aaf314c0152400ec8731b4cab2df48e521d258 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/ClassInitFieldSetDoubleStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetDoubleStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.setDouble(null, 0.2589); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetDoubleStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetDoubleStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetDoubleStatic.result.append("One"); + } + public static double hiDouble = 4.5; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetDoubleStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetDoubleStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/expected.txt b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/test.cfg b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..60060498b3dd722f45d5320c8307a4a631a2c8c3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0158-rt-reflection-ClinitFieldSetDoubleStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetDoubleStatic) +run(ClassInitFieldSetDoubleStatic) diff --git a/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..111ccef99c64738a0ebda1b3ee0bda96601e11ed --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/ClassInitFieldSetFloatStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetFloatStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.setFloat(null, 0.2589f); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetFloatStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetFloatStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetFloatStatic.result.append("One"); + } + public static float hiFloat = 0.25f; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetFloatStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetFloatStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/expected.txt b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/test.cfg b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..613dd74deb12ef27a97c26a0b23c27020112ec19 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0159-rt-reflection-ClinitFieldSetFloatStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetFloatStatic) +run(ClassInitFieldSetFloatStatic) diff --git a/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..d84601811881849fbe56f1b6188b32b1e11f6ef9 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/ClassInitFieldSetIntStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetIntStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.setInt(null, 25); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetIntStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetIntStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetIntStatic.result.append("One"); + } + public static int hiInt = 0; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetIntStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetIntStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/expected.txt b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/test.cfg b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c2d4510413fcd37d0839f4c5fb591bf85abc4ad3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0160-rt-reflection-ClinitFieldSetIntStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetIntStatic) +run(ClassInitFieldSetIntStatic) diff --git a/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..5d465fa175ea353774b209bae16a1a33324e1bad --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/ClassInitFieldSetLongStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetLongStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.setLong(null, 25l); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetLongStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetLongStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetLongStatic.result.append("One"); + } + public static long hiLong = 4859l; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetLongStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetLongStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/expected.txt b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/test.cfg b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..445b38a8eed543cdc19d7d361b934f0788a361d7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0161-rt-reflection-ClinitFieldSetLongStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetLongStatic) +run(ClassInitFieldSetLongStatic) diff --git a/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..2a378e03ad33e2864308e4201b6e39237afd938d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/ClassInitFieldSetShortStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetShortStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.setShort(null, (short)25); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetShortStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetShortStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetShortStatic.result.append("One"); + } + public static short hiShort = 48; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetShortStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetShortStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/expected.txt b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/test.cfg b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6547b397f9e7d3d651c50e0628d6231c2b27df13 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0162-rt-reflection-ClinitFieldSetShortStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetShortStatic) +run(ClassInitFieldSetShortStatic) diff --git a/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/ClassInitFieldSetStatic.java b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/ClassInitFieldSetStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..1e47061c0954dfc8ef58e114cb1510a63c032bda --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/ClassInitFieldSetStatic.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Field; +public class ClassInitFieldSetStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.set(null, "what"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitFieldSetStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitFieldSetStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitFieldSetStatic.result.append("One"); + } + public static String hi = "hi"; +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitFieldSetStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitFieldSetStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/expected.txt b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/test.cfg b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8fbc5aa95cfeea763b6239afab5b9aa7ca1cf946 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0163-rt-reflection-ClinitFieldSetStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetStatic) +run(ClassInitFieldSetStatic) diff --git a/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java new file mode 100755 index 0000000000000000000000000000000000000000..f4a975ba705c401a71d415d6aeac9085d95a510a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/ClassInitMethodInvokeStatic.java @@ -0,0 +1,90 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +import java.lang.reflect.Method; +public class ClassInitMethodInvokeStatic { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("One", false, One.class.getClassLoader()); + Method m = clazz.getDeclaredMethod("testOne", String.class); + // Check point 1: calling following methods, class not initialized. + m.equals(m); + m.getAnnotation(A.class); + m.getDeclaredAnnotations(); + m.getDeclaringClass(); + m.getDefaultValue(); + m.getExceptionTypes(); + m.getGenericExceptionTypes(); + m.getGenericParameterTypes(); + m.getGenericReturnType(); + m.getModifiers(); + m.getName(); + m.getParameterAnnotations(); + m.getParameterCount(); + m.getParameterTypes(); + m.getReturnType(); + m.getTypeParameters(); + m.hashCode(); + m.isBridge(); + m.isDefault(); + m.isSynthetic(); + m.isVarArgs(); + m.toString(); + m.toGenericString(); + // Check point 2: after newInstance, class initialized. + if (result.toString().compareTo("") == 0) { + m.invoke(null, "hi"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("SuperOne") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +@A +class Super { + static { + ClassInitMethodInvokeStatic.result.append("Super"); + } +} +interface InterfaceSuper { + String a = ClassInitMethodInvokeStatic.result.append("|InterfaceSuper|").toString(); +} +@A(i=1) +class One extends Super implements InterfaceSuper { + static { + ClassInitMethodInvokeStatic.result.append("One"); + } + public static int testOne(String a){ + return 0; + } +} +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@interface A { + int i() default 0; + String a = ClassInitMethodInvokeStatic.result.append("|InterfaceA|").toString(); +} +class Two extends One { + static { + ClassInitMethodInvokeStatic.result.append("Two"); + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/expected.txt b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/test.cfg b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e3f46cd636e5232a3bf5863a2c20dfd7dd998450 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0164-rt-reflection-ClinitMethodInvokeStatic/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitMethodInvokeStatic) +run(ClassInitMethodInvokeStatic) diff --git a/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..aa1163a8612f181951302dfc32213e83d9f1cb0f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/ClassInitFieldGetBooleanInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetBooleanInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.getBoolean(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetBooleanInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetBooleanInterface.result.append("One").toString(); + boolean hiBoolean = false; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetBooleanInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetBooleanInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/expected.txt b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/test.cfg b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..124c9cff27d3f489653b77f8612abd1245b144be --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0165-rt-reflection-ClinitFieldGetBooleanInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetBooleanInterface) +run(ClassInitFieldGetBooleanInterface) diff --git a/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..9f905e438277c1a473fbad27689e8a148b2a3a68 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/ClassInitFieldGetByteInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetByteInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.getByte(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetByteInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetByteInterface.result.append("One").toString(); + byte hiByte = (byte)1; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetByteInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetByteInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/expected.txt b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/test.cfg b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..3a8eb14296f74ec9d6795760985abafef4f11ea7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0166-rt-reflection-ClinitFieldGetByteInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetByteInterface) +run(ClassInitFieldGetByteInterface) diff --git a/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..e94075ae335dbfd4dcbedc34c30b889b281a31b1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/ClassInitFieldGetCharInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetCharInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.getChar(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetCharInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetCharInterface.result.append("One").toString(); + char hiChar = (char)45; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetCharInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetCharInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/expected.txt b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/test.cfg b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4812994d404ec302f3840e09dfd4027590337074 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0167-rt-reflection-ClinitFieldGetCharInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetCharInterface) +run(ClassInitFieldGetCharInterface) diff --git a/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..6fb7912fe595690b1052fd66c16c41d409166d93 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/ClassInitFieldGetDoubleInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetDoubleInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.getDouble(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetDoubleInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetDoubleInterface.result.append("One").toString(); + double hiDouble = 0.1532; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetDoubleInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetDoubleInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/expected.txt b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/test.cfg b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cfb69664aeddd9f74586b319c204cd5ac6e93090 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0168-rt-reflection-ClinitFieldGetDoubleInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetDoubleInterface) +run(ClassInitFieldGetDoubleInterface) diff --git a/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..27650c1b1bf439864711832fff83273341c2283a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/ClassInitFieldGetFloatInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetFloatInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.getFloat(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetFloatInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetFloatInterface.result.append("One").toString(); + float hiFloat = 0.25f; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetFloatInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetFloatInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/expected.txt b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/test.cfg b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c46b7b457ed0baf8108d7a2286c05d226cc62073 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0169-rt-reflection-ClinitFieldGetFloatInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetFloatInterface) +run(ClassInitFieldGetFloatInterface) diff --git a/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/ClassInitFieldGetInterface.java b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/ClassInitFieldGetInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..a3178f23eaa07c717529c5a9e5827dbfcda976a8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/ClassInitFieldGetInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.get(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetInterface.result.append("One").toString(); + String hi = "hiField"; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/expected.txt b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/test.cfg b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dc1fee4b22cd92f9295a3cb24a96f48d9258ea20 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0170-rt-reflection-ClinitFieldGetInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetInterface) +run(ClassInitFieldGetInterface) diff --git a/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..bd516deee6af31ffb29b374641b92378fb62940b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/ClassInitFieldGetIntInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetIntInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.getInt(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetIntInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetIntInterface.result.append("One").toString(); + int hiInt = 125; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetIntInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetIntInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/expected.txt b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/test.cfg b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e0af09c702d64eec6799483e866bebaad36accf0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0171-rt-reflection-ClinitFieldGetIntInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetIntInterface) +run(ClassInitFieldGetIntInterface) diff --git a/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..612555688c0d3b0dca97b5dd915aac7763ac2058 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/ClassInitFieldGetLongInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetLongInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.getLong(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetLongInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetLongInterface.result.append("One").toString(); + long hiLong = 4859l; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetLongInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetLongInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/expected.txt b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/test.cfg b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c4a59df5021deb0ccef8a2d419cf7b8ad336347 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0172-rt-reflection-ClinitFieldGetLongInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetLongInterface) +run(ClassInitFieldGetLongInterface) diff --git a/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..047dfa6e64c21de85ca87a178e837ba45b533ba4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/ClassInitFieldGetShortInterface.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldGetShortInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.getShort(null); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("One") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldGetShortInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldGetShortInterface.result.append("One").toString(); + short hiShort = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldGetShortInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldGetShortInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/expected.txt b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/test.cfg b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4f8d73542adb7dde372dadddbe0074e3b99ea28e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0173-rt-reflection-ClinitFieldGetShortInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldGetShortInterface) +run(ClassInitFieldGetShortInterface) diff --git a/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..8652a0e141ce2a51541b8b44251087d978b2f40f --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/ClassInitFieldOtherMethodInterface.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldOtherMethodInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + f.equals(f); + f.getAnnotation(A.class); + f.getAnnotationsByType(A.class); + f.getDeclaredAnnotations(); + f.getDeclaringClass(); + f.getGenericType(); + f.getModifiers(); + f.getName(); + f.getType(); + f.hashCode(); + f.isEnumConstant(); + f.isSynthetic(); + f.toGenericString(); + f.toString(); + } catch (Exception e) { + System.out.println(e); + } + if(result.toString().compareTo("") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldOtherMethodInterface.result.append("Super").toString(); +} +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldOtherMethodInterface.result.append("One").toString(); + @A + short hi = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldOtherMethodInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldOtherMethodInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/expected.txt b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/test.cfg b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1febba627f87de8fc07e5025a7c22b2636c41ca8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0174-rt-reflection-ClinitFieldOtherMethodInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldOtherMethodInterface) +run(ClassInitFieldOtherMethodInterface) diff --git a/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..d6a5003ecc548c56c75a535ceaf519c62d8e5fa1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/ClassInitFieldSetBooleanInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetBooleanInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiBoolean"); + if (result.toString().compareTo("") == 0) { + f.setBoolean(null, true); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetBooleanInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetBooleanInterface.result.append("One").toString(); + boolean hiBoolean = false; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetBooleanInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetBooleanInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/expected.txt b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/test.cfg b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..eccb561d025f20868cfba9e7870fd5aa2fdc3d8b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0175-rt-reflection-ClinitFieldSetBooleanInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetBooleanInterface) +run(ClassInitFieldSetBooleanInterface) diff --git a/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..0d5899e83b3aa2e6e1f4f99b709e3580708094c4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/ClassInitFieldSetByteInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetByteInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiByte"); + if (result.toString().compareTo("") == 0) { + f.setByte(null, (byte)0); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetByteInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetByteInterface.result.append("One").toString(); + byte hiByte = (byte)1; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetByteInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetByteInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/expected.txt b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/test.cfg b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..87b2d92832883e427078bc33eb113f6d91165ee0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0176-rt-reflection-ClinitFieldSetByteInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetByteInterface) +run(ClassInitFieldSetByteInterface) diff --git a/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..8589838d6f8ed8d7175e8a2b394d55a0c677c808 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/ClassInitFieldSetFloatInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetFloatInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiFloat"); + if (result.toString().compareTo("") == 0) { + f.setFloat(null, 0.654f); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetFloatInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetFloatInterface.result.append("One").toString(); + float hiFloat = 0.25f; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetFloatInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetFloatInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/expected.txt b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/test.cfg b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..286cb316d0ba00e807e834c56a39fd6c3b634084 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0177-rt-reflection-ClinitFieldSetFloatInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetFloatInterface) +run(ClassInitFieldSetFloatInterface) diff --git a/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/ClassInitFieldSetInterface.java b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/ClassInitFieldSetInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..f5e700120d45cfff39d9c477a1a987c0d8a13acb --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/ClassInitFieldSetInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hi"); + if (result.toString().compareTo("") == 0) { + f.set(null, "newString"); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetInterface.result.append("One").toString(); + String hi = "hiField"; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/expected.txt b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/test.cfg b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e962f1c79619a14be9fcdf201830489624173a4a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0178-rt-reflection-ClinitFieldSetInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetInterface) +run(ClassInitFieldSetInterface) diff --git a/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..fa2cdf308d24a76d5449eafac92d3b38b6fa319c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/ClassInitFieldSetIntInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetIntInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiInt"); + if (result.toString().compareTo("") == 0) { + f.setInt(null, 98); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetIntInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetIntInterface.result.append("One").toString(); + int hiInt = 125; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetIntInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetIntInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/expected.txt b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/test.cfg b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b98d7f9f68ebdea47b18abff533a8be416dfeef8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0179-rt-reflection-ClinitFieldSetIntInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetIntInterface) +run(ClassInitFieldSetIntInterface) diff --git a/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..c2f2236d93839869bcb7aa9020bccf9e07a4f2fb --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/ClassInitFieldSetLongInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetLongInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiLong"); + if (result.toString().compareTo("") == 0) { + f.setLong(null, 7456l); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetLongInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetLongInterface.result.append("One").toString(); + long hiLong = 4859l; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetLongInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetLongInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/expected.txt b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/test.cfg b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b800b479fa19149ce402c021d916f008c210ad82 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0180-rt-reflection-ClinitFieldSetLongInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetLongInterface) +run(ClassInitFieldSetLongInterface) diff --git a/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..ce462bf3d5da3cd8171de784fe776cbd38356f50 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/ClassInitFieldSetShortInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetShortInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiShort"); + if (result.toString().compareTo("") == 0) { + f.setShort(null, (short)124); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetShortInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetShortInterface.result.append("One").toString(); + short hiShort = 14; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetShortInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetShortInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/expected.txt b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/test.cfg b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6153336cd572a7c6e066044b7634c659d01f6a9e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0181-rt-reflection-ClinitFieldSetShortInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetShortInterface) +run(ClassInitFieldSetShortInterface) diff --git a/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..524503bddb4fcfad7068633cb2f46f5c088e7105 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/ClassInitMethodInvokeInterface.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class ClassInitMethodInvokeInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Method m = clazz.getDeclaredMethod("runInterface", String.class); + //check point 1: calling following methods, class not initialized + m.equals(m); + m.getAnnotation(A.class); + m.getDeclaredAnnotations(); + m.getDeclaringClass(); + m.getDefaultValue(); + m.getExceptionTypes(); + m.getGenericExceptionTypes(); + m.getGenericParameterTypes(); + m.getGenericReturnType(); + m.getModifiers(); + m.getName(); + m.getParameterAnnotations(); + m.getParameterCount(); + m.getParameterTypes(); + m.getReturnType(); + m.getTypeParameters(); + m.hashCode(); + m.isBridge(); + m.isDefault(); + m.isSynthetic(); + m.isVarArgs(); + m.toString(); + m.toGenericString(); + //check point 2: after newInstance, class initialized + if (result.toString().compareTo("") == 0) { + m.invoke(null, "hi"); + } + } catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneRunInterface") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitMethodInvokeInterface.result.append("Super").toString(); +} +interface OneInterface extends SuperInterface{ + String aOne = ClassInitMethodInvokeInterface.result.append("One").toString(); + @A + static void runInterface(String a){ + ClassInitMethodInvokeInterface.result.append("RunInterface"); + } +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitMethodInvokeInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitMethodInvokeInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/expected.txt b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/test.cfg b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2ba74e2e84412e33fd5cccfbc39f200617492db7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0182-rt-reflection-ClinitMethodInvokeInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitMethodInvokeInterface) +run(ClassInitMethodInvokeInterface) diff --git a/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/FieldMultiThreadTest.java b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/FieldMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..460a13b337891ba6007354da0795ff5d02afc758 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/FieldMultiThreadTest.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class FieldMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + fieldMultithread(); + System.out.println(passCnt/executeCnt - 10); + } catch (Exception e) { + System.out.println(e); + } + } + private static int fieldMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThread"); + String[] allFields = new String[] {"charPub", "fieldIntPri", "fieldIntPro", "fieldString"}; + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (String s : allFields) { + Field field = clazz.getDeclaredField(s); + field.setAccessible(true); + } + for (Field f: clazz.getDeclaredFields()) { + f.setAccessible(true); + } + Field field = clazz.getField("charPub"); + field.setAccessible(true); + for (Field f: clazz.getFields()) { + f.setAccessible(true); + } + } + } catch (Exception e) { + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (String s : allFields) { + Field field = clazz.getDeclaredField(s); + passCnt += field.isAccessible()== false ? 1 : 0; + } + for (Field f: clazz.getDeclaredFields()) { + passCnt += f.isAccessible()== false ? 1 : 0; + } + Field field = clazz.getField("charPub"); + passCnt += field.isAccessible()== false ? 1 : 0; + for (Field f: clazz.getFields()) { + passCnt += f.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThread { + public char charPub = 'a'; + private int fieldIntPri = 416; + protected int[] fieldIntPro = {123}; + String fieldString = "hey, hello"; +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/expected.txt b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/test.cfg b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..878d22ef234f866e229469c49414d7d72d877cc8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0183-rt-reflection-FieldMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(FieldMultiThreadTest) +run(FieldMultiThreadTest) diff --git a/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/MethodTest.java b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/MethodTest.java new file mode 100755 index 0000000000000000000000000000000000000000..bfa6b8632935316e2a6e2f1bc3afab52a257127e --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/MethodTest.java @@ -0,0 +1,343 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +public class MethodTest { + /** + * Verify that for the same method, different Method object is return when call following API twice: + * - Class.getMethods(), + * - Class.getEnclosingMethod(), + * - Class.getDeclaredMethods(), + * - Class.getMethod(String name, Class... parameterTypes), + * - Class.getDeclaredMethod(String name, Class... parameterTypes), + * if any Method failed the check, will print error message including testcase and method name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllMethodTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getMethods() + Method[] methods1 = clazz.getMethods(); + Method[] methods2 = clazz.getMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 2. Class.getMethod(String name) + Method m1 = clazz.getMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed"); + } + } + // checkpoint 3. Class.getDeclaredMethods() + methods1 = clazz.getDeclaredMethods(); + methods2 = clazz.getDeclaredMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 4. Class.getDeclaredMethod(String name) + Method m1 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for declared method"); + } + } + // checkpoint 5. Class.getEnclosingMethod() + if (clazz.getEnclosingMethod() != null) { + Method m1 = clazz.getEnclosingMethod(); + Method m2 = clazz.getEnclosingMethod(); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for Enclosing method"); + } + } + casesPassed++; + } + private static void checkMethods(Method[] methods1, Method[] methods2) { + for (Method m1: methods1) { + for (Method m2: methods2) { + // only when modifers and class and name is same, two Method object is for same method + if(m1.toString().equals(m2.toString())) { + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(m1.getName()+" failed in checkMethods"); + } + } + } + } + } + private static int singleMethodCheck(Method m1, Method m2) { + int passCnt = 0; + passCnt += m1 == m2 ? 0 : 1; + passCnt += m1.equals(m2) ? 1 : 0; + passCnt += m1.hashCode() == m2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + method01(); + method02(); + method03(); + method04(); + method05(); + method06(); + method07(); + method08(); + method09(); + method10(); + method11(); + System.out.println(casesPassed - 11); + } + + private static void method01() { + try { + classAllMethodTest(Class.forName("java.lang.Thread"), "method01"); + } catch (Exception e) { + System.out.println("Case method01 failed with exception" + e); + } + } + + private static void method02() { + try { + classAllMethodTest(Class.forName("TestMethod02"), "method02"); + } catch (Exception e) { + System.out.println("Case method02 failed with exception" + e); + } + } + + private static void method03() { + try { + classAllMethodTest(Class.forName("TestMethod03"), "method03"); + } catch (Exception e) { + System.out.println("Case method03 failed with exception" + e); + } + } + + private static void method04() { + try { + classAllMethodTest(Class.forName("TestMethod04"), "method04"); + } catch (Exception e) { + System.out.println("Case method04 failed with exception" + e); + } + } + + private static void method05() { + try { + // step 1 + Class clazz = Class.forName("MethodTest"); + MethodTest mainClass = new MethodTest(); + Field method = clazz.getDeclaredField("testMethod05"); + classAllMethodTest(method.get(mainClass).getClass(), "method05"); + } catch (Exception e) { + System.out.println("Case method05 failed with exception" + e); + } + } + private Runnable testMethod05 = new Runnable() { + private final synchronized int intRunnable() { + return 1; + } + @Override + public void run() { + for (int i = 0; i < 10; i++) { + } + } + }; + + private static void method06() { + class TestMethod06 { + private final int intLocalMethod() { + return 9; + } + public synchronized String stringLocal() { + return "a fake behind the fear"; + } + } + try { + classAllMethodTest(Class.forName("MethodTest$1TestMethod06"), "method06"); + } catch (Exception e) { + System.out.println("Case method06 failed with exception" + e); + } + } + + private static void method07() { + try { + classAllMethodTest(Class.forName("MethodTest$TestMethod07"), "method07"); + } catch (Exception e) { + System.out.println("Case method07 failed with exception" + e); + } + } + class TestMethod07 { + private char charInnerMethod(int a, double... b) { + return 'l'; + } + final public double doubleInnerMethod() { + return 1988.0416; + } + } + + private static void method08() { + try { + classAllMethodTest(Class.forName("TestMethod08"), "method08"); + } catch (Exception e) { + System.out.println("Case method08 failed with exception" + e); + } + } + + private static void method09() { + try { + classAllMethodTest(Class.forName("TestMethod09"), "method09"); + } catch (Exception e) { + System.out.println("Case method09 failed with exception" + e); + } + } + + private static void method10() { + try { + classAllMethodTest(Class.forName("TestMethod10"), "method10"); + } catch (Exception e) { + System.out.println("Case method10 failed with exception" + e); + } + } + + private static void method11() { + try { + classAllMethodTest(Class.forName("TestMethod11"), "method11"); + } catch (Exception e) { + System.out.println("Case method11 failed with exception" + e); + } + } +} +class TestMethod02 { + // step1 + void voidMethod() {} + boolean booleanMethod() { + return true; + } + byte byteMethod() { + return (byte)1; + } + short shortMethod() { + return (short)2; + } + int intMethod() { + return 3; + } + long longMethod() { + return 4l; + } + char charMethod() { + return 'a'; + } + float floatMethod() { + return 0.9f; + } + double doubleMethod() { + return 0.416; + } + String stringMethod() { + return "The queerest of the queer"; + } + Runnable[] rArrayMethod() { + return null; + } + boolean[][][][][][][] booleanArray7Method() { + return new boolean[][][][][][][] {{{{{{{true, false}}}}}}}; + } + String[][][] stringArray3Method() { + return new String[][][] {{{"the strangest of the strange"}}}; + } + int parameterMethod(boolean a, byte b, short c, int d, long e, char f, float g, double h, + boolean[] aa, byte[] bb, short[] cc, int[] dd, long[] ee, char[] ff, float[] gg, double[] hh, + String i, String[][][] iii, Runnable j, Byte k, Double l, Thread.State m, int... o) { + return 1; + } + // step2 + public int publicIntMethod(boolean a) { + return 88; + } + protected double protectedDoubleMethod(byte a) { + return 99; + } + private String privateStringMethod(String a) { + return "the coldest of the cool"; + } + // step3 + strictfp double[][] transientDoubleArrayMethod(float[][] a) { + return new double[][] {{1988, 4.16}}; + } + final int finalIntMethod() { + return 9876; + } + synchronized String volatileStringMethod() { + return "the lamest of the lame"; + } + static Character staticCharacterMethod(Thread.State a) { + return 'd'; + } + //step 4 + @Deprecated + String[][] stringsAnnotationMethod() { + return new String[][] {{"the numbest of the dumb"}}; + } +} +interface TestMethod03 { + String stringInterfaceMethod(int[] a); + char[][][] charArrayInterfaceMethod(double... a); +} +abstract class TestMethod04 { + public static final synchronized String[] stringsAbstractArrayMethod() { + return new String[] {"i hate to see you here", "you choke behind a smile"}; + } + abstract Runnable runnableAbstractMethod(); +} +enum TestMethod08 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + private static short shortEnumMethod() { + return (short)6; + } + public final String stringEnumMethod(int... a) { + return "Dry Martini"; + } +} +class TestMethod09 { + public int int09Method() { + return 1; + } + protected boolean boolean09Method() { + return false; + } + char[] chars09Method() { + return new char[] {'a', 'b', 'c'}; + } + private String string09Method() { + return "I'm only happy when it rains"; + } +} +class TestMethod10 extends TestMethod09 implements TestMethod11 { + public boolean boolean09Method() { + return true; + } + public double double10Method() { + return 0.416; + } + public char[] chars09Method() { + return new char[] {'a'}; + } + public String string09Method() { + return "SHALALALA"; + } +} +interface TestMethod11 { + int int09Method(); + boolean boolean09Method(); + char[] chars09Method(); + String string09Method(); +} diff --git a/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/expected.txt b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/test.cfg b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b52fd6d6794c91a5ade7d178fd2ec9cab17d13ea --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0184-rt-reflection-MethodTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodTest) +run(MethodTest) diff --git a/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/MethodMultiThreadTest.java b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/MethodMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..0825a5f5a8b5cb395becf7ea4807fed194f037bd --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/MethodMultiThreadTest.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Method; +public class MethodMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + methodMultithread(); + System.out.println(passCnt/executeCnt - 28); + } catch (Exception e) { + System.out.println(e); + } + } + private static int methodMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThreadM"); + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (Method m: clazz.getDeclaredMethods()) { + m.setAccessible(true); + Method method = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + method.setAccessible(true); + } + for (Method m: clazz.getMethods()) { + m.setAccessible(true); + Method method = clazz.getMethod(m.getName(), m.getParameterTypes()); + method.setAccessible(true); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (Method m: clazz.getDeclaredMethods()) { + passCnt += m.isAccessible()== false ? 1 : 0; + Method method = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + passCnt += method.isAccessible()== false ? 1 : 0; + } + for (Method m: clazz.getMethods()) { + passCnt += m.isAccessible()== false ? 1 : 0; + Method method = clazz.getMethod(m.getName(), m.getParameterTypes()); + passCnt += method.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThreadM { + public char charPubMethod(int... a) { + return 'a'; + } + private int intPriMethod() { + return 416; + } + protected int[] intProMethod(Double... b) { + return new int[] {123}; + } + String stringMethod() { + return "hey, hello"; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/expected.txt b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/test.cfg b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..98b348fceadc609093a1bb0cc57cfab58722659c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0185-rt-reflection-MethodMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(MethodMultiThreadTest) +run(MethodMultiThreadTest) diff --git a/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/ConstructorTest.java b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/ConstructorTest.java new file mode 100755 index 0000000000000000000000000000000000000000..124b19c2d3b546828fea9a1fb5e322da985be724 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/ConstructorTest.java @@ -0,0 +1,273 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Constructor; +public class ConstructorTest { + /** + * Verify that for the same constructor, different Constructor object is return when call following API twice: + * - Class.getConstructors(), + * - Class.getEnclosingConstructor(), + * - Class.getDeclaredConstructors(), + * - Class.getConstructor(String name, Class... parameterTypes), + * - Class.getDeclaredConstructor(String name, Class... parameterTypes), + * if any Constructor failed the check, will print error message including testcase and constructor name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllConstructorTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getConstructors() + Constructor[] constructors1 = clazz.getConstructors(); + Constructor[] constructors2 = clazz.getConstructors(); + checkConstructors(constructors1, constructors2); + for (Constructor c : constructors1) { + // checkpoint 2. Class.getConstructor(String name) + Constructor c1 = clazz.getConstructor(c.getParameterTypes()); + Constructor c2 = clazz.getConstructor(c.getParameterTypes()); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed"); + } + } + // checkpoint 3. Class.getDeclaredConstructors() + constructors1 = clazz.getDeclaredConstructors(); + constructors2 = clazz.getDeclaredConstructors(); + checkConstructors(constructors1, constructors2); + for (Constructor c : constructors1) { + // checkpoint 4. Class.getDeclaredConstructor(String name) + Constructor c1 = clazz.getDeclaredConstructor(c.getParameterTypes()); + Constructor c2 = clazz.getDeclaredConstructor(c.getParameterTypes()); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed for declared constructor"); + } + } + // checkpoint 5. Class.getEnclosingConstructor() + if (clazz.getEnclosingConstructor() != null) { + Constructor c1 = clazz.getEnclosingConstructor(); + Constructor c2 = clazz.getEnclosingConstructor(); + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(caseName + ": " + c1.toGenericString() + " failed for Enclosing constructor"); + } + } + casesPassed++; + } + private static void checkConstructors(Constructor[] constructors1, Constructor[] constructors2) { + for (Constructor c1: constructors1) { + for (Constructor c2: constructors2) { + // only when modifers and class and name is same, two Constructor object is for same constructor + if(c1.toString().equals(c2.toString())) { + if (singleConstructorCheck(c1, c2) != 3) { + System.out.println(c1.getName()+" failed in checkConstructors"); + } + } + } + } + } + private static int singleConstructorCheck(Constructor c1, Constructor c2) { + int passCnt = 0; + passCnt += c1 == c2 ? 0 : 1; + passCnt += c1.equals(c2) ? 1 : 0; + passCnt += c1.hashCode() == c2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + constructor01(); + constructor02(); + constructor03(); + constructor04(); + constructor05(); + constructor06(); + constructor07(); + constructor08(); + constructor09(); + constructor10(); + constructor11(); + System.out.println(casesPassed - 11); + } + + private static void constructor01() { + try { + classAllConstructorTest(Class.forName("java.lang.Thread"), "constructor01"); + } catch (Exception e) { + System.out.println("Case constructor01 failed with exception" + e); + } + } + + private static void constructor02() { + try { + classAllConstructorTest(Class.forName("TestConstructor02"), "constructor02"); + } catch (Exception e) { + System.out.println("Case constructor02 failed with exception" + e); + } + } + + private static void constructor03() { + try { + classAllConstructorTest(Class.forName("TestConstructor03"), "constructor03"); + } catch (Exception e) { + System.out.println("Case constructor03 failed with exception" + e); + } + } + + private static void constructor04() { + try { + classAllConstructorTest(Class.forName("TestConstructor04"), "constructor04"); + } catch (Exception e) { + System.out.println("Case constructor04 failed with exception" + e); + } + } + + private static void constructor05() { + try { + Class clazz = Class.forName("ConstructorTest"); + ConstructorTest mainClass = new ConstructorTest(); + Field constructor = clazz.getDeclaredField("testConstructor05"); + classAllConstructorTest(constructor.get(mainClass).getClass(), "constructor05"); + } catch (Exception e) { + System.out.println("Case constructor05 failed with exception" + e); + } + } + private Runnable testConstructor05 = new Runnable() { + @Override + public void run() { + for (int i = 0; i < 10; i++) { + } + } + }; + + private static void constructor06() { + class TestConstructor06 { + private TestConstructor06(int a) { + } + public TestConstructor06(String[][][] a) { + } + } + try { + classAllConstructorTest(Class.forName("ConstructorTest$1TestConstructor06"), "constructor06"); + } catch (Exception e) { + System.out.println("Case constructor06 failed with exception" + e); + } + } + + private static void constructor07() { + try { + classAllConstructorTest(Class.forName("ConstructorTest$TestConstructor07"), "constructor07"); + } catch (Exception e) { + System.out.println("Case constructor07 failed with exception" + e); + } + } + class TestConstructor07 { + private TestConstructor07(int a, double... b) { + } + public TestConstructor07() { + } + } + + private static void constructor08() { + try { + classAllConstructorTest(Class.forName("TestConstructor08"), "constructor08"); + } catch (Exception e) { + System.out.println("Case constructor08 failed with exception" + e); + } + } + + private static void constructor09() { + try { + classAllConstructorTest(Class.forName("TestConstructor09"), "constructor09"); + } catch (Exception e) { + System.out.println("Case constructor09 failed with exception" + e); + } + } + + private static void constructor10() { + try { + classAllConstructorTest(Class.forName("TestConstructor10"), "constructor10"); + } catch (Exception e) { + System.out.println("Case constructor10 failed with exception" + e); + } + } + + private static void constructor11() { + try { + Class clazz = (new TestConstructor11()).c.getClass(); + classAllConstructorTest(clazz, "constructor11"); + } catch (Exception e) { + System.out.println("Case constructor11 failed with exception" + e); + } + } +} +class TestConstructor02 { + // step1 + TestConstructor02() { + } + TestConstructor02(boolean a, byte b, short c, int d, long e, char f, float g, double h, + boolean[] aa, byte[] bb, short[] cc, int[] dd, long[] ee, char[] ff, float[] gg, double[] hh, + String i, String[][][] iii, Runnable j, Byte k, Double l, Thread.State m, int... o) { + } + // step2 + public TestConstructor02(int a) {} + TestConstructor02(byte a) {} + protected TestConstructor02(String a) {} + private TestConstructor02(Runnable[] a) {} + // step3 + @Deprecated + TestConstructor02(int... a) {} +} +strictfp class TestConstructor03 { + public TestConstructor03(float... a) { + } + TestConstructor03(float a, double b) { + } +} +abstract class TestConstructor04 { + public TestConstructor04() { + } + TestConstructor04(int a) { + } +} +enum TestConstructor08 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + TestConstructor08() { + } + TestConstructor08(String a) { + } +} +class TestConstructor09 { + public TestConstructor09() { + } + TestConstructor09(int... a) { + } + protected TestConstructor09(double[] a) { + } + private TestConstructor09(int a) { + } +} +class TestConstructor10 extends TestConstructor09 { + public TestConstructor10() { + } + TestConstructor10(int... a) { + } + protected TestConstructor10(double[] a) { + } + private TestConstructor10(int a) { + } +} +class TestConstructor11 { + public Object c; + public TestConstructor11( ) { + class ClassA { } + c = new ClassA( ); + } +} diff --git a/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/expected.txt b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/test.cfg b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..ccfa3945dcfed7451b625e074f0d76c8aab24c9a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0186-rt-reflection-ConstructorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorTest) +run(ConstructorTest) diff --git a/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java new file mode 100755 index 0000000000000000000000000000000000000000..6abe58a3be4f5e464c7e3de4e5ee39b51cd5f0c7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/ConstructorMultiThreadTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Constructor; +public class ConstructorMultiThreadTest { + volatile static boolean keepRunning = true; + static int passCnt = 0; + static int executeCnt = 0; + public static void main(String[] args) { + try { + constructorMultithread(); + System.out.println(passCnt/executeCnt - 10); + } catch (Exception e) { + System.out.println(e); + } + } + private static int constructorMultithread() throws Exception { + Class clazz = Class.forName("TestMultiThreadC"); + Thread writer = new Thread(() -> { + try { + while (keepRunning) { + for (Constructor c: clazz.getDeclaredConstructors()) { + c.setAccessible(true); + Constructor constructor = clazz.getDeclaredConstructor(c.getParameterTypes()); + constructor.setAccessible(true); + } + for (Constructor c: clazz.getConstructors()) { + c.setAccessible(true); + Constructor constructor = clazz.getConstructor(c.getParameterTypes()); + constructor.setAccessible(true); + } + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + Thread reader = new Thread(() -> { + try { + while (keepRunning) { + for (Constructor c: clazz.getDeclaredConstructors()) { + passCnt += c.isAccessible()== false ? 1 : 0; + Constructor constructor = clazz.getDeclaredConstructor(c.getParameterTypes()); + passCnt += constructor.isAccessible()== false ? 1 : 0; + } + for (Constructor c: clazz.getConstructors()) { + passCnt += c.isAccessible()== false ? 1 : 0; + Constructor constructor = clazz.getConstructor(c.getParameterTypes()); + passCnt += constructor.isAccessible()== false ? 1 : 0; + } + executeCnt++; + } + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e); + } + }); + writer.start(); + reader.start(); + Thread.sleep(100); + keepRunning = false; + Thread.sleep(100); + writer.join(); + reader.join(); + return passCnt; + } +} +class TestMultiThreadC { + public TestMultiThreadC(int... a) { + } + private TestMultiThreadC(String a) { + } + protected TestMultiThreadC(Double... a) { + } + TestMultiThreadC() { + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/expected.txt b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/test.cfg b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3df0352b8d4255745b1b5821da20b3ec1e930816 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0187-rt-reflection-ConstructorMultiThreadTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ConstructorMultiThreadTest) +run(ConstructorMultiThreadTest) diff --git a/testsuite/java_test/reflection_test/RT0188-rt-reflection-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java b/testsuite/java_test/reflection_test/RT0188-rt-reflection-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8f84e22154d378e764287628120ea746747ef266 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0188-rt-reflection-MethodHandleReflectCombineTest/MethodHandleReflectCombineTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import static java.lang.invoke.MethodHandles.lookup; +import static java.lang.invoke.MethodHandles.reflectAs; +import static java.lang.invoke.MethodType.methodType; +public class MethodHandleReflectCombineTest { + static int passCnt = 0; + private static int singleMethodCheck(T m1, T m2) { + int passCnt = 0; + passCnt += m1 == m2 ? 0 : 1; + passCnt += m1.equals(m2) ? 1 : 0; + passCnt += m1.hashCode() == m2.hashCode() ? 1 : 0; + return passCnt; + } + public static void main(String[] args) { + try { + System.out.println(run()); + } catch (Throwable e) { + e.printStackTrace(); + } + } + private static int run() throws Throwable { + Object[][] testData = new Object[][] { + {Member.class, lookup().findVirtual(String.class, "concat", methodType(String.class, String.class))}, + {Member.class, lookup().findStatic(String.class, "copyValueOf", methodType(String.class, char[].class))}, + {Member.class, RATest.LOOKUP().findSpecial(RATest.class, "mhVar", methodType(int.class, Object[].class), RATest.class)}, + {Constructor.class, lookup().findConstructor(RATest.class, methodType(void.class, int.class))}, + {Constructor.class, lookup().findConstructor(RATest.class, methodType(void.class, double[].class))}, + {Field.class, lookup().findStaticGetter(RATest.class, "svi", int.class)}, + {Field.class, lookup().findStaticSetter(RATest.class, "svi", int.class)}, + {Field.class, RATest.LOOKUP().findGetter(RATest.class, "vd", double.class)}, + {Field.class, lookup().findGetter(RATest.class, "vs", String[].class)}, + {Field.class, lookup().findSetter(RATest.class, "vs", String[].class)} + }; + for (int i = 0; i{ + private T obj; + public void setObj(T obj) { + this.obj = obj; + } + public void say(){ + System.out.println("hello "+obj); + } +} +interface PackageInfoInterface { + void test(); +} +class PackageInfoConst { + public static final String MESSAGE="Annotation Study"; +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/expected.txt b/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/test.cfg b/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a45b78761165f417dc2d535f52e690899c6b5bf --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0199-rt-reflection-AnnotationPackageSetTest/test.cfg @@ -0,0 +1,6 @@ +clean() +javac com/huawei/*.java +jar -cvf com.huawei.AnnotationPackageSetTest.jar com/ +${OUT_ROOT}/target/product/public/bin/jar2dex -p ${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/core-oj_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/core-libart_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/framework_intermediates/classes.jar:${OUT_ROOT}/target/product/public/third-party/JAVA_LIBRARIES/services_intermediates/classes.jar -i com.huawei.AnnotationPackageSetTest.jar +compile(com.huawei.AnnotationPackageSetTest) +run(com.huawei.AnnotationPackageSetTest) diff --git a/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoA.java b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..5f06bbbee2c53d37e325643d7aad8d49273e72e7 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE_PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoB.java b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java new file mode 100755 index 0000000000000000000000000000000000000000..4699d6adac9e2f5925733ffcca8d673f87b91d18 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/AnnotationTypeParameterSetTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeParameterSetTest { + static int[] passCnt; + public static void main(String[] args) { + System.out.println(Test.class.getAnnotations().length); +// TypeVeriable.getAnnotation not supported in ART +/* AnnoA anno = Test.class.getTypeParameters()[0].getAnnotation(AnnoA.class); + passCnt = new int[24]; + // 基本数据类型 + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + //enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + //基本类型数组 + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"));*/ + } +} +class Test<@AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) T> { +} diff --git a/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/expected.txt b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/test.cfg b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9be48f11000f5c42aabd320ed592c2821679881d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0200-rt-reflection-AnnotationTypeParameterSetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeParameterSetTest) +run(AnnotationTypeParameterSetTest) diff --git a/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoA.java b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..2104c625abbc58059295356101ddb20286205228 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE_USE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoB.java b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java new file mode 100755 index 0000000000000000000000000000000000000000..028a1d59dd9692d8e3eb1f174469ba7145ed75b0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/AnnotationTypeUseSetTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeUseSetTest { + static int[] passCnt; + public static void main(String[] args) { + System.out.println(Test.class.getAnnotations().length); +/* AnnoA anno = Test.class.getTypeParameters()[0].getAnnotation(AnnoA.class); + passCnt = new int[24]; + // 基本数据类型 + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + //enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + //基本类型数组 + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]"));*/ + } +} +class Test<@AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) T> { +} diff --git a/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/expected.txt b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/test.cfg b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..de633afd110d594010008fcc3e9c107993737fd6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0201-rt-reflection-AnnotationTypeUseSetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeUseSetTest) +run(AnnotationTypeUseSetTest) diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoA.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..bd35de2ef9e511bcbbe9ee4c21c20725314de948 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoA.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA() default Integer.MAX_VALUE; + double doubleA() default Double.MIN_VALUE; + String stringA() default ""; + AnnoB annoBA(); + ENUMA enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoB.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoC.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoC.java new file mode 100755 index 0000000000000000000000000000000000000000..cbf9e24cbbebe37e60dd66f776a237c46fded798 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoC.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoC { + int[] intA() default Integer.MAX_VALUE; + double[] doubleA() default Double.MIN_VALUE; + String[] stringA() default ""; + AnnoB[] annoBA() default @AnnoB; + ENUMA[] enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoD.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoD.java new file mode 100755 index 0000000000000000000000000000000000000000..e15b5d4c2881118deef1cd9bef9303abc3959410 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnoD.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoD { + int intA() default Integer.MAX_VALUE; + double doubleA() default Double.MIN_VALUE; + String stringA() default ""; + AnnoB annoBA(); + ENUMA enumA() default ENUMA.A; +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnotationMultiThread.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnotationMultiThread.java new file mode 100755 index 0000000000000000000000000000000000000000..6936d3e0c230ad9fc2960e06f62186aa79a48395 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/AnnotationMultiThread.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.Annotation; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicInteger; +public class AnnotationMultiThread { + static AtomicInteger passCnt = new AtomicInteger(); + public static void main(String[] args) throws ClassNotFoundException { + ThreadGroup threadGroup = new ThreadGroup("myGroup"); + String[][] expectedGF = new String[][]{ + {"@AnnoA", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + {"@AnnoB(intB=999)"}, + {"@AnnoC", "annoBA=[@AnnoB(intB=999)]", "intA=[2147483647]", "enumA=[A]", "stringA=[]", "doubleA=[4.9E-324]"} + }; + String[][] expectedF = new String[][]{ + {"@AnnoA", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + {"@AnnoB(intB=999)"}, + {"@AnnoC", "annoBA=[@AnnoB(intB=999)]", "intA=[2147483647]", "enumA=[A]", "stringA=[]", "doubleA=[4.9E-324]"}, + {"@AnnoD", "enumA=A", "intA=2147483647", "stringA=", "doubleA=4.9E-324", "annoBA=@AnnoB(intB=999)"}, + }; + new AnnotationGetter("GrandFather", expectedGF, expectedGF, threadGroup, "threadGF").start(); + new AnnotationGetter("Father", expectedF, expectedF, threadGroup, "threadF").start(); + new AnnotationGetter("Interface", expectedF, expectedF, threadGroup, "threadI").start(); + new AnnotationGetter("Son", expectedF, new String[][]{}, threadGroup, "threadS").start(); + new AnnotationGetter("Son2", expectedF, new String[][]{}, threadGroup, "threadS2").start(); + new AnnotationGetter("GrandFather", expectedGF, expectedGF, threadGroup, "threadGF").start(); + new AnnotationGetter("Father", expectedF, expectedF, threadGroup, "threadF").start(); + new AnnotationGetter("Interface", expectedF, expectedF, threadGroup, "threadI").start(); + new AnnotationGetter("Son", expectedF, new String[][]{}, threadGroup, "threadI").start(); + new AnnotationGetter("Son2", expectedF, new String[][]{}, threadGroup, "threadI").start(); + int i = 0; + while (threadGroup.activeCount() > 0){ + i++; + try { + Thread.sleep(100); + }catch (InterruptedException e){ + System.out.println(e); + } + if(i > 1000){ + break; + } + } + System.out.println(passCnt.get() - 200); + } + public static boolean checkAllAnnotations(Annotation[] annotations, String[][] expected){ + String[] actual = new String[annotations.length]; + for (int i = 0; i < annotations.length; i++){ + actual[i] = annotations[i].toString(); + } + Arrays.sort(actual); + if (actual.length != expected.length){ + return false; + } +// System.out.println(Arrays.toString(actual)); + for (int i = 0; i < annotations.length; i++){ + if (expected[i].length == 1){ + if (actual[i].compareTo(expected[i][0])!=0){ + System.out.println(actual[i]); + System.out.println(expected[i][0]); + return false; + } + }else { + for (int j = 0; j < expected[i].length; j++){ + if (!actual[i].contains(expected[i][j])){ + System.out.println(actual[i]); + System.out.println(expected[i][j]); + return false; + } + } + } + } + return true; + } +} +class AnnotationGetter extends Thread{ + String name; + String[][] expected; + String[][] expectedD; + AnnotationGetter(String nameI, String[][] expectedI, String[][] expectedDI, ThreadGroup threadGroup, String thread_name){ + super(threadGroup, thread_name); + name = nameI; + expected = expectedI; + expectedD = expectedDI; + } + @Override + public void run() { + try { + for (int i = 0; i < 10; i++) { + if (AnnotationMultiThread.checkAllAnnotations(Class.forName(this.name).getAnnotations(), this.expected)){ + AnnotationMultiThread.passCnt.incrementAndGet(); + } + if (AnnotationMultiThread.checkAllAnnotations(Class.forName(this.name).getDeclaredAnnotations(), this.expectedD)){ + AnnotationMultiThread.passCnt.incrementAndGet(); + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } +} +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +class GrandFather{ + public void method1(int a, double b, Object... objects){ + } +} +@SuppressWarnings("all") +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +@AnnoD(annoBA = @AnnoB) +class Father extends GrandFather implements Interface{ + @Override + public void method1(int a, double b, Object... objects) { + } + @Deprecated + public void method2(){ + } +} +class Son extends Father{ + @Override + @Deprecated + public void method2(){ + } +} +class Son2 extends Father{ + @Override + @Deprecated + public void method2(){ + } +} +@SuppressWarnings("all") +@AnnoB +@AnnoA(annoBA = @AnnoB) +@AnnoC() +@AnnoD(annoBA = @AnnoB) +interface Interface{ +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/ENUMA.java b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/ENUMA.java new file mode 100755 index 0000000000000000000000000000000000000000..bb9cee8770af2ae1fdcc7206c31bd5062d02d38c --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/ENUMA.java @@ -0,0 +1,19 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +public enum ENUMA { + A, + B, + C +} diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/expected.txt b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/test.cfg b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..548dbbdeb4d504827dd63b0c3b99ca11152e6ec8 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0202-rt-reflection-AnnotationMultiThread/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationMultiThread) +run(AnnotationMultiThread) diff --git a/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/ReflectClassNameTest.java b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/ReflectClassNameTest.java new file mode 100755 index 0000000000000000000000000000000000000000..0436ede5a91978cf03681c7212fb530fb6b63062 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/ReflectClassNameTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Arrays; +public class ReflectClassNameTest { + static int[] passCnt = new int[6]; + public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException { + int i = 0; + Class clazz = Class.forName("一"); + passCnt[i++] = clazz.getName().compareTo("一") == 0 ? 1 : 0; + Method method = clazz.getDeclaredMethod("дракон"); + passCnt[i++] = method.getName().compareTo("дракон") == 0 ? 1 : 0; + Field field = clazz.getDeclaredField("Rồng"); + passCnt[i++] = field.getName().compareTo("Rồng") == 0 ? 1 : 0; + Class clazz2 = Class.forName("二"); + passCnt[i++] = clazz2.getName().compareTo("二") == 0 ? 1 : 0; + class 三{ + } + Class clazz3 = Class.forName("ReflectClassNameTest$1三"); + passCnt[i++] = clazz3.getName().compareTo("ReflectClassNameTest$1三") == 0 ? 1 : 0; + Class clazz4 = Class.forName("ReflectClassNameTest$二"); + passCnt[i++] = clazz4.getName().compareTo("ReflectClassNameTest$二") == 0 ? 1 : 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1]")); + } + class 二{ + } +} +class 一{ + int Rồng; + public void дракон(){ + } +} +interface 二{ +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/expected.txt b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/test.cfg b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0dc062bd43fdc1400b8d99a4783c2690427199dc --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0203-rt-reflection-ReflectSpecialClassNameTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectClassNameTest) +run(ReflectClassNameTest) diff --git a/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoA.java b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..157d9b9509e006c87c49782ccf9f20b56e3716f4 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int 整型(); + byte 字节(); + char 字符(); + double 双精度浮点(); + boolean 布尔(); + long 长整(); + float 浮点(); + short 短整型(); + int[] あ(); + byte[] い(); + char[] う(); + double[] え(); + boolean[] お(); + long[] か(); + float[] き(); + short[] く(); + String 长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长(); + String[] 神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马(); + Class 类(); + Class[] 类类(); + Thread.State 类类类(); + Thread.State[] 类类类类(); + AnnoB 类类类类类(); + AnnoB[] 类类类类类类(); +} diff --git a/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoB.java b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnotationNotAscii.java b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnotationNotAscii.java new file mode 100755 index 0000000000000000000000000000000000000000..476e432bd802a7d6c85a72695e4a48ab62910f5b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/AnnotationNotAscii.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationNotAscii { + static int[] passCnt = new int[24]; + public static void main(String[] args) { + AnnoA anno = Test.class.getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.整型() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.字节() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.字符() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.双精度浮点()) ? 1: 0; + passCnt[i++] += anno.布尔() ? 1: 0; + passCnt[i++] += anno.长整() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.浮点())? 1: 0; + passCnt[i++] += anno.短整型() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.类类类() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.类() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.あ()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.い().length == 1 && anno.い()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.う().length == 1 && anno.う()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.え().length == 3 && Double.isNaN(anno.え()[0]) && Double.isInfinite(anno.え()[1]) && Double.isInfinite(anno.え()[2]))? 1: 0; + passCnt[i++] += (anno.お().length == 1 && anno.お()[0]) ? 1: 0; + passCnt[i++] += (anno.か().length == 1 && anno.か()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.き().length == 3 && Float.isNaN(anno.き()[0]) && Float.isInfinite(anno.き()[1]) && Float.isInfinite(anno.き()[2])) ? 1: 0; + passCnt[i++] += (anno.く().length == 1 && anno.く()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马().length == 1 && anno.神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.类类().length == 1 && anno.类类()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.类类类类().length == 1 && anno.类类类类()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.类类类类类().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.类类类类类类()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } +} +@AnnoA(整型 = Integer.MAX_VALUE, 字节 = Byte.MAX_VALUE, 字符 = Character.MAX_VALUE, 双精度浮点 = Double.NaN, + 布尔 = true, 长整 = Long.MAX_VALUE, 浮点 = Float.NaN, 短整型 = Short.MAX_VALUE, + あ = {1,2}, い = {0}, う = {' '}, え = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + お = {true}, か = {Long.MAX_VALUE}, き = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, く = {0}, + 长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长长 = "", 神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马神马 = "", 类 = Thread.class, 类类 = Thread.class, 类类类 = Thread.State.BLOCKED, + 类类类类 = Thread.State.NEW, 类类类类类 = @AnnoB, 类类类类类类 = {@AnnoB, @AnnoB}) +class Test{ +} diff --git a/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/expected.txt b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/test.cfg b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..be5afadc7c68bf8f256931092618480f1ca0009d --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0204-rt-reflection-AnnotationSpecialCharacter/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationNotAscii) +run(AnnotationNotAscii) diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoA.java b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..a11eacb37f45e1ebb430d60436afaf8f42ab27dc --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoA.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Repeatable(Test.class) +@AnnoB(intB = 1) +@AnnoB(intB = 2) +@AnnoB(intB = 3) +@AnnoB(intB = 4) +@AnnoB(intB = 5) +@AnnoB(intB = 6) +@AnnoB(intB = 7) +@AnnoB(intB = 8) +@AnnoB(intB = 9) +@AnnoB(intB = 10) +@AnnoB(intB = 11) +@AnnoB(intB = 12) +@AnnoB(intB = 13) +@AnnoB(intB = 14) +@AnnoB(intB = 15) +@AnnoB(intB = 16) +@AnnoB(intB = 17) +@AnnoB(intB = 18) +public @interface AnnoA { + int intA() default 0; + byte byteA() default 0; + char charA() default 0; + double doubleA() default 0; + boolean booleanA() default true; + long longA() default 0; + float floatA() default 0; + short shortA() default 0; + int[] intAA() default 0; + byte[] byteAA() default 0; + char[] charAA() default 0; + double[] doubleAA() default 0; + boolean[] booleanAA() default true; + long[] longAA() default 0; + float[] floatAA() default 0; + short[] shortAA() default 0; + String stringA() default ""; + String[] stringAA() default ""; + Class classA() default Thread.class; + Class[] classAA() default Thread.class; + Thread.State stateA() default Thread.State.BLOCKED; + Thread.State[] stateAA() default Thread.State.BLOCKED; + AnnoB annoBA() default @AnnoB; + AnnoB[] annoBAA() default @AnnoB; + AnnoB[] value(); +} diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoB.java b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..6d15656d5f53fd8dcd0d941b293cf4f9a6ba6d30 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnoB.java @@ -0,0 +1,23 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@Repeatable(AnnoA.class) +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnotationRepeatable.java b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnotationRepeatable.java new file mode 100755 index 0000000000000000000000000000000000000000..fdacc6b45e9c2b7e489f4d6e33bb8cc8f9595cad --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/AnnotationRepeatable.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationRepeatable { + static int[] passCnt = new int[25]; + public static void main(String[] args) { + checkAnnoA(Test.class.getAnnotation(Test.class).value()[0], "[@AnnoB(intB=-1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[1], "[@AnnoB(intB=-2), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[2], "[@AnnoB(intB=-3), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[3], "[@AnnoB(intB=-4), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[4], "[@AnnoB(intB=-5), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[5], "[@AnnoB(intB=-6), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[6], "[@AnnoB(intB=-7), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[7], "[@AnnoB(intB=-8), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[8], "[@AnnoB(intB=-9), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + checkAnnoA(Test.class.getAnnotation(Test.class).value()[9], "[@AnnoB(intB=-10), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1), @AnnoB(intB=1)]"); + boolean checkAnnoA = Arrays.toString(passCnt).compareTo("[1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]") == 0; + boolean checkAnnoB = Arrays.toString(AnnoA.class.getAnnotation(AnnoA.class).value()).compareTo("[@AnnoB(intB=1), @AnnoB(intB=2), @AnnoB(intB=3), @AnnoB(intB=4), @AnnoB(intB=5), @AnnoB(intB=6), @AnnoB(intB=7), @AnnoB(intB=8), @AnnoB(intB=9), @AnnoB(intB=10), @AnnoB(intB=11), @AnnoB(intB=12), @AnnoB(intB=13), @AnnoB(intB=14), @AnnoB(intB=15), @AnnoB(intB=16), @AnnoB(intB=17), @AnnoB(intB=18)]") == 0; + if (checkAnnoA && checkAnnoB){ + System.out.println(0); + } else { + System.out.println(2); + } + } + private static void checkAnnoA(AnnoA anno, String value){ + int i = 0; + passCnt[i++] = anno.intA() == 0 ? 1: 0; + passCnt[i++] += anno.byteA() == 0 ? 1: 0; + passCnt[i++] += anno.charA() == 0 ? 1: 0; + passCnt[i++] += anno.doubleA() == 0 ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == 0 ? 1: 0; + passCnt[i++] += anno.floatA() == 0? 1: 0; + passCnt[i++] += anno.shortA() == 0 ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + // array + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[0]") == 0 ? 1: 0; + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 1 && anno.doubleAA()[0] == 0)? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 1 && anno.floatAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.BLOCKED) ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999)]") == 0 ? 1: 0; + // value + passCnt[i++] += Arrays.toString(anno.value()).compareTo(value) == 0 ? 1: 0; + } +} diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/Test.java b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/Test.java new file mode 100755 index 0000000000000000000000000000000000000000..cb55e7627fe78db39c9395e773c54f456969b2d6 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/Test.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@AnnoA( value = @AnnoB(intB = -1)) +@AnnoA( value = {@AnnoB(intB = -2), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -3), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -4), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -5), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -6), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -7), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -8), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -9), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +@AnnoA( value = {@AnnoB(intB = -10), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1), @AnnoB(intB = 1)}) +public @interface Test{ + AnnoA[] value(); +} diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/expected.txt b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/test.cfg b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ece5cb4379e0abb8b4caa86e7d103af945663e73 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0205-rt-reflection-AnnotationRepeatable/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationRepeatable) +run(AnnotationRepeatable) diff --git a/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoA.java b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..cd152bebfc5b736c3b1bdda44dec59c6e482e58b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoB.java b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java new file mode 100755 index 0000000000000000000000000000000000000000..3c8e436a41a7b45907005ff9c2ccfbe11adcf486 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/AnnotationTypeInnerClassSet.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeInnerClassSet { + static int[] passCnt = new int[24]; + public static void main(String[] args) throws ClassNotFoundException { + AnnoA anno = Class.forName("AnnotationTypeInnerClassSet$Test").getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } + @AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) + class Test{ + } +} diff --git a/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/expected.txt b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/test.cfg b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e028fcbf9c6616c499512f0b608a56f1cdc10bb0 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0206-rt-reflection-AnnotationTypeInnerClassSet/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeInnerClassSet) +run(AnnotationTypeInnerClassSet) diff --git a/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoA.java b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoA.java new file mode 100755 index 0000000000000000000000000000000000000000..cd152bebfc5b736c3b1bdda44dec59c6e482e58b --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA(); + byte byteA(); + char charA(); + double doubleA(); + boolean booleanA(); + long longA(); + float floatA(); + short shortA(); + int[] intAA(); + byte[] byteAA(); + char[] charAA(); + double[] doubleAA(); + boolean[] booleanAA(); + long[] longAA(); + float[] floatAA(); + short[] shortAA(); + String stringA(); + String[] stringAA(); + Class classA(); + Class[] classAA(); + Thread.State stateA(); + Thread.State[] stateAA(); + AnnoB annoBA(); + AnnoB[] annoBAA(); +} diff --git a/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoB.java b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoB.java new file mode 100755 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java new file mode 100755 index 0000000000000000000000000000000000000000..7257bdc7d9b5acbe434299229f8e7d7f466860e3 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/AnnotationTypeLocalClassSet.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationTypeLocalClassSet { + static int[] passCnt = new int[24]; + public static void main(String[] args) throws ClassNotFoundException { + @AnnoA(intA = Integer.MAX_VALUE, byteA = Byte.MAX_VALUE, charA = Character.MAX_VALUE, doubleA = Double.NaN, + booleanA = true, longA = Long.MAX_VALUE, floatA = Float.NaN, shortA = Short.MAX_VALUE, + intAA = {1,2}, byteAA = {0}, charAA = {' '}, doubleAA = {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, + booleanAA = {true}, longAA = {Long.MAX_VALUE}, floatAA = {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, shortAA = {0}, + stringA = "", stringAA = "", classA = Thread.class, classAA = Thread.class, stateA = Thread.State.BLOCKED, + stateAA = Thread.State.NEW, annoBA = @AnnoB, annoBAA = {@AnnoB, @AnnoB}) + class Test{ + } + AnnoA anno = Class.forName("AnnotationTypeLocalClassSet$1Test").getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } +} diff --git a/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/expected.txt b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/test.cfg b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4a88f4936275d290e54ec20f25148f2ab3605eee --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0207-rt-reflection-AnnotationTypeLocalClassSet/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationTypeLocalClassSet) +run(AnnotationTypeLocalClassSet) diff --git a/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoA.java b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoA.java new file mode 100644 index 0000000000000000000000000000000000000000..40d499c74a9e1060b209c67df42b29512459ade1 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoA.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoA { + int intA() default Integer.MAX_VALUE; + byte byteA() default Byte.MAX_VALUE; + char charA() default Character.MAX_VALUE; + double doubleA() default Double.NaN; + boolean booleanA() default true; + long longA() default Long.MAX_VALUE; + float floatA() default Float.NaN; + short shortA() default Short.MAX_VALUE; + int[] intAA() default {1,2}; + byte[] byteAA() default {0}; + char[] charAA() default {' '}; + double[] doubleAA() default {Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}; + boolean[] booleanAA() default {true}; + long[] longAA() default {Long.MAX_VALUE}; + float[] floatAA() default {Float.NaN, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}; + short[] shortAA() default {0}; + String stringA() default ""; + String[] stringAA() default ""; + Class classA() default Thread.class; + Class[] classAA() default Thread.class; + Thread.State stateA() default Thread.State.BLOCKED; + Thread.State[] stateAA() default Thread.State.NEW; + AnnoB annoBA() default @AnnoB; + AnnoB[] annoBAA() default {@AnnoB, @AnnoB}; +} diff --git a/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoB.java b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoB.java new file mode 100644 index 0000000000000000000000000000000000000000..64e06d4daf24f6f78e5b31b447e0d31395602415 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnoB.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface AnnoB { + int intB() default 999; +} diff --git a/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnotationDefaultTest.java b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnotationDefaultTest.java new file mode 100644 index 0000000000000000000000000000000000000000..52bd1b07da2abed96de4ea67686b45e1bd2fae3a --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/AnnotationDefaultTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.util.Arrays; +public class AnnotationDefaultTest { + static int[] passCnt = new int[24]; + public static void main(String[] args) { + AnnoA anno = Test.class.getAnnotation(AnnoA.class); + // primitive type + int i = 0; + passCnt[i++] = anno.intA() == Integer.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.byteA() == Byte.MAX_VALUE ? 1: 0; + passCnt[i++] += anno.charA() == Character.MAX_VALUE ? 1: 0; + passCnt[i++] += Double.isNaN(anno.doubleA()) ? 1: 0; + passCnt[i++] += anno.booleanA() ? 1: 0; + passCnt[i++] += anno.longA() == Long.MAX_VALUE ? 1: 0; + passCnt[i++] += Float.isNaN(anno.floatA())? 1: 0; + passCnt[i++] += anno.shortA() == Short.MAX_VALUE ? 1: 0; + // enum, string, annotation, class + passCnt[i++] += anno.stateA() == Thread.State.BLOCKED ? 1: 0; + passCnt[i++] += anno.stringA().compareTo("") == 0 ? 1: 0; + passCnt[i++] += anno.classA() == Thread.class ? 1: 0; + passCnt[i++] += Arrays.toString(anno.intAA()).compareTo("[1, 2]") == 0 ? 1: 0; + // array + passCnt[i++] += (anno.byteAA().length == 1 && anno.byteAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.charAA().length == 1 && anno.charAA()[0] == ' ') ? 1: 0; + passCnt[i++] += (anno.doubleAA().length == 3 && Double.isNaN(anno.doubleAA()[0]) && Double.isInfinite(anno.doubleAA()[1]) && Double.isInfinite(anno.doubleAA()[2]))? 1: 0; + passCnt[i++] += (anno.booleanAA().length == 1 && anno.booleanAA()[0]) ? 1: 0; + passCnt[i++] += (anno.longAA().length == 1 && anno.longAA()[0] == Long.MAX_VALUE) ? 1: 0; + passCnt[i++] += (anno.floatAA().length == 3 && Float.isNaN(anno.floatAA()[0]) && Float.isInfinite(anno.floatAA()[1]) && Float.isInfinite(anno.floatAA()[2])) ? 1: 0; + passCnt[i++] += (anno.shortAA().length == 1 && anno.shortAA()[0] == 0) ? 1: 0; + passCnt[i++] += (anno.stringAA().length == 1 && anno.stringAA()[0].compareTo("")==0) ? 1: 0; + passCnt[i++] += (anno.classAA().length == 1 && anno.classAA()[0] == Thread.class)? 1: 0; + passCnt[i++] += (anno.stateAA().length == 1 && anno.stateAA()[0] == Thread.State.NEW) ? 1: 0; + passCnt[i++] += anno.annoBA().toString().compareTo("@AnnoB(intB=999)")==0 ? 1: 0; + passCnt[i++] += Arrays.toString(anno.annoBAA()).compareTo("[@AnnoB(intB=999), @AnnoB(intB=999)]") == 0 ? 1: 0; + System.out.println(Arrays.toString(passCnt).compareTo("[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]")); + } +} +@AnnoA +class Test{ +} diff --git a/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/expected.txt b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/test.cfg b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c46493c0872a31f1356c781850d30122a35c0767 --- /dev/null +++ b/testsuite/java_test/reflection_test/RT0211-rt-reflection-AnnotationDefaultTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AnnotationDefaultTest) +run(AnnotationDefaultTest) diff --git a/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/ReflectionForName2.java b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/ReflectionForName2.java new file mode 100755 index 0000000000000000000000000000000000000000..f7942e3ade3dd7cd869d9c5fc22ab4baa2924cd2 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/ReflectionForName2.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.File; +import java.io.IOException; +class ForName2 { + static { + File cls2 = new File("/data/local/tmp/ReflectionForName2.txt"); + try { + cls2.createNewFile(); + } catch (IOException e) { + System.err.println(e); + } + } +} +public class ReflectionForName2 { + public static void main(String[] args) throws ClassNotFoundException { + File cls1 = new File("/data/local/tmp/ReflectionForName2.txt"); + if (cls1.exists()) { + cls1.delete(); + } + Class cls = Class.forName("ForName2", true, ForName2.class.getClassLoader()); + if (cls1.exists()) { + System.out.println(0); + }else{ + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/expected.txt b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/test.cfg b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5baba823ff8bd1f47830893d6593c16ea9e9d162 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-0000-rt-Reflection-ReflectionforName2/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName2) +run(ReflectionForName2) diff --git a/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/ReflectionForName3.java b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/ReflectionForName3.java new file mode 100755 index 0000000000000000000000000000000000000000..aadd1b433ef5eedd5a3e4504498bb281a92405e0 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/ReflectionForName3.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.File; +import java.io.IOException; +class ForName3 { + static { + File cls2 = new File("/data/local/tmp/ReflectionForName3.txt"); + try { + cls2.createNewFile(); + } catch (IOException e) { + System.err.println(e); + } + } +} +public class ReflectionForName3 { + public static void main(String[] args) throws ClassNotFoundException { + File cls1 = new File("/data/local/tmp/ReflectionForName3.txt"); + if (cls1.exists()) { + cls1.delete(); + } + Class cls = Class.forName("ForName3", false, ForName3.class.getClassLoader()); + if (!cls1.exists()) { + System.out.println(0); + return; + } + System.out.println(2); + return; + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/expected.txt b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/test.cfg b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..53970e2e16fe06bdeefe11453b7dbdf91aa9c6bb --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0096-rt-Reflection-ReflectionforName3/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionForName3) +run(ReflectionForName3) diff --git a/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/FieldTest.java b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/FieldTest.java new file mode 100755 index 0000000000000000000000000000000000000000..fb97105e802d1e1ff4ce942a11c2d531c3f3c995 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/FieldTest.java @@ -0,0 +1,272 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.reflect.Field; +public class FieldTest { + /** + * Verify that for the same field, different Field object is return when call following API twice: + * - Class.getFields() + * - Class.getDeclaredFields() + * - Class.getField(String name) + * - Class.getDeclareedField(String name) + * if any Field failed the check, will print error message including testcase and field name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllFieldTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getFields() + Field[] fields1 = clazz.getFields(); + Field[] fields2 = clazz.getFields(); + checkFields(fields1, fields2); + for (Field f : fields1) { + // checkpoint 2. Class.getDeclaredFields() + Field f1 = clazz.getField(f.getName()); + Field f2 = clazz.getField(f.getName()); + if (singleFieldCheck(f1, f2) != 3) { + System.out.println(caseName + ": " + f1.getDeclaringClass().toString() + "." + f1.getName() + " failed"); + } + } + // checkpoint 3. Class.getField(String name) + fields1 = clazz.getDeclaredFields(); + fields2 = clazz.getDeclaredFields(); + checkFields(fields1, fields2); + for (Field f : fields1) { + // checkpoint 4. Class.getDeclareedField(String name) + Field f1 = clazz.getDeclaredField(f.getName()); + Field f2 = clazz.getDeclaredField(f.getName()); + if (singleFieldCheck(f1, f2) != 3) { + System.out.println(caseName + ": " + f1.getDeclaringClass().toString() + "." + f1.getName() + " failed for declared fields"); + } + } + casesPassed++; + } + private static void checkFields(Field[] fields1, Field[] fields2) { + for (Field f1: fields1) { + for (Field f2: fields2) { + // only when modifers and class and name is same, two Field object is for same field + if(f1.toGenericString().equals(f2.toGenericString())) { + if (singleFieldCheck(f1, f2) != 3) { + System.out.println(f1.getName()+" failed in checkFields"); + } + } + } + } + } + private static int singleFieldCheck(Field f1, Field f2) { + int passCnt = 0; + passCnt += f1 == f2 ? 0 : 1; + passCnt += f1.equals(f2) ? 1 : 0; + passCnt += f1.hashCode() == f2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + field01(); + field02(); + field03(); + field04(); + field05(); + field06(); + field07(); + field08(); + field09(); + field10(); + field11(); + field12(); + System.out.println(casesPassed - 12); + } + + private static void field01() { + try { + classAllFieldTest(Class.forName("java.lang.Thread"), "field01"); + } catch (Exception e) { + System.out.println("Case field01 failed with exception" + e); + } + } + + private static void field02() { + try { + classAllFieldTest(Class.forName("TestField02"), "field02"); + } catch (Exception e) { + System.out.println("Case field02 failed with exception" + e); + } + } + + private static void field03() { + try { + classAllFieldTest(Class.forName("TestField03"), "field03"); + } catch (Exception e) { + System.out.println("Case field03 failed with exception" + e); + } + } + + private static void field04() { + try { + classAllFieldTest(Class.forName("TestField04"), "field04"); + } catch (Exception e) { + System.out.println("Case field04 failed with exception" + e); + } + } + + private static void field05() { + try { + classAllFieldTest(Class.forName("TestField05"), "field05"); + } catch (Exception e) { + System.out.println("Case field05 failed with exception" + e); + } + } + + private static void field06() { + try { + // step 1 + Class clazz = Class.forName("FieldTest"); + FieldTest mainClass = new FieldTest(); + Field field = clazz.getDeclaredField("testField06"); + classAllFieldTest(field.get(mainClass).getClass(), "field06"); + } catch (Exception e) { + System.out.println("Case field06 failed with exception" + e); + } + } + private Runnable testField06 = new Runnable() { + int intAnonymous = 10; + public double doubleAnonymous = 1988.416; + @Override + public void run() { + for (int i = 0; i < intAnonymous; i++) { + intAnonymous += i; + } + } + }; + + private static void field07() { + class TestField07 { + private final transient int intLocal = 9; + public volatile String stringLocal = "a fake behind the fear"; + } + try { + classAllFieldTest(Class.forName("FieldTest$1TestField07"), "field07"); + } catch (Exception e) { + System.out.println("Case field07 failed with exception" + e); + } + } + + private static void field08() { + try { + classAllFieldTest(Class.forName("FieldTest$TestField08"), "field08"); + } catch (Exception e) { + System.out.println("Case field08 failed with exception" + e); + } + } + class TestField08 { + volatile private char charInner = 'l'; + public final static transient double doubleInner = 0.88; + } + + private static void field09() { + try { + classAllFieldTest(Class.forName("TestField09"), "field09"); + } catch (Exception e) { + System.out.println("Case field09 failed with exception" + e); + } + } + + private static void field10() { + try { + classAllFieldTest(Class.forName("TestField10"), "field10"); + } catch (Exception e) { + System.out.println("Case field10 failed with exception" + e); + } + } + + private static void field11() { + try { + classAllFieldTest(Class.forName("TestField11"), "field11"); + } catch (Exception e) { + System.out.println("Case field11 failed with exception" + e); + } + } + + private static void field12() { + try { + classAllFieldTest(Class.forName("TestField12"), "field12"); + } catch (Exception e) { + System.out.println("Case field12 failed with exception" + e); + } + } +} +class TestField02 { + // step1 + boolean booleanField = true; + byte byteField = (byte)2; + short shortField = (short)4; + int intField = 6; + long longField = 8; + char charField = 10; + float floatField = 0.4f; + double doubleField = 0.8; + String stringField = "The queerest of the queer"; + Runnable r = null; + boolean[][][][][][][] booleanArray7 = new boolean[][][][][][][] {{{{{{{true, false}}}}}}}; + String[][][] stringArray3 = new String[][][] {{{"the strangest of the strange"}}}; + // step2 + public int publicInt = 88; + protected double protectedDouble = 99; + private String privateString = "the coldest of the cool"; + // step3 + transient double[][] transientDoubleArray = new double[][] {{1988, 4.16}}; + final int finalInt = 9876; + volatile String volatileString = "the lamest of the lame"; + static Character staticCharacter = 'd'; + //step 4 + @Deprecated + String[][] stringsAnnotation = new String[][] {{"the numbest of the dumb"}}; +} +strictfp class TestField03 { + float floatField = 4.16f; + public double doubleField = 19.88; +} +interface TestField04 { + String stringInterface = "i know what's good for you"; + char[] charInterface = new char[] {'l', 'e', 't'}; +} +abstract class TestField05 { + String[] stringsAbstractArray = {"i hate to see you here", "you choke behind a smile"}; + Runnable[] runnableAbstractArray = {new Runnable() { + @Override + public void run() { + } + } + }; +} +enum TestField09 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + private static short shortEnum = (short)6; + public final String stringEnum = "Dry Martini"; +} +class TestField10 { + public int int10; + protected boolean boolean10; + char[] chars10 = new char[] {'a', 'b', 'c'}; + private String string10 = "I'm only happy when it rains"; +} +class TestField11 extends TestField10 implements TestField12 { + boolean boolean10 = true; + public double double11 = 0.416; +} +interface TestField12 { + int int10 = 9; + boolean boolean10 = false; + char[] chars10 = new char[] {'a', 'b', 'c'}; + String string10 = "I'm only happy when it rains"; +} diff --git a/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/MethodTest.java b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/MethodTest.java new file mode 100755 index 0000000000000000000000000000000000000000..b32da6f26ea7f240abc83a4bea255dff801a08d5 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/MethodTest.java @@ -0,0 +1,342 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +public class MethodTest { + /** + * Verify that for the same method, different Method object is return when call following API twice: + * - Class.getMethods(), + * - Class.getEnclosingMethod(), + * - Class.getDeclaredMethods(), + * - Class.getMethod(String name, Class... parameterTypes), + * - Class.getDeclaredMethod(String name, Class... parameterTypes), + * if any Method failed the check, will print error message including testcase and method name; + * after all check is pass, casePassed will be increased; + */ + + private static void classAllMethodTest(Class clazz, String caseName) throws Exception { + // checkpoint 1. Class.getMethods() + Method[] methods1 = clazz.getMethods(); + Method[] methods2 = clazz.getMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 2. Class.getMethod(String name) + Method m1 = clazz.getMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed"); + } + } + // checkpoint 3. Class.getDeclaredMethods() + methods1 = clazz.getDeclaredMethods(); + methods2 = clazz.getDeclaredMethods(); + checkMethods(methods1, methods2); + for (Method m : methods1) { + // checkpoint 4. Class.getDeclaredMethod(String name) + Method m1 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + Method m2 = clazz.getDeclaredMethod(m.getName(), m.getParameterTypes()); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for declared method"); + } + } + // checkpoint 5. Class.getEnclosingMethod() + if (clazz.getEnclosingMethod() != null) { + Method m1 = clazz.getEnclosingMethod(); + Method m2 = clazz.getEnclosingMethod(); + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(caseName + ": " + m1.toGenericString() + " failed for Enclosing method"); + } + } + casesPassed++; + } + private static void checkMethods(Method[] methods1, Method[] methods2) { + for (Method m1: methods1) { + for (Method m2: methods2) { + // only when modifers and class and name is same, two Method object is for same method + if(m1.toString().equals(m2.toString())) { + if (singleMethodCheck(m1, m2) != 3) { + System.out.println(m1.getName()+" failed in checkMethods"); + } + } + } + } + } + private static int singleMethodCheck(Method m1, Method m2) { + int passCnt = 0; + passCnt += m1 == m2 ? 0 : 1; + passCnt += m1.equals(m2) ? 1 : 0; + passCnt += m1.hashCode() == m2.hashCode() ? 1 : 0; + return passCnt; + } + static int casesPassed = 0; + public static void main(String [] args) { + method01(); + method02(); + method03(); + method04(); + method05(); + method06(); + method07(); + method08(); + method09(); + method10(); + method11(); + System.out.println(casesPassed - 11); + } + + private static void method01() { + try { + classAllMethodTest(Class.forName("java.lang.Thread"), "method01"); + } catch (Exception e) { + System.out.println("Case method01 failed with exception" + e); + } + } + + private static void method02() { + try { + classAllMethodTest(Class.forName("TestMethod02"), "method02"); + } catch (Exception e) { + System.out.println("Case method02 failed with exception" + e); + } + } + + private static void method03() { + try { + classAllMethodTest(Class.forName("TestMethod03"), "method03"); + } catch (Exception e) { + System.out.println("Case method03 failed with exception" + e); + } + } + + private static void method04() { + try { + classAllMethodTest(Class.forName("TestMethod04"), "method04"); + } catch (Exception e) { + System.out.println("Case method04 failed with exception" + e); + } + } + + private static void method05() { + try { + // step 1 + Class clazz = Class.forName("MethodTest"); + MethodTest mainClass = new MethodTest(); + Field method = clazz.getDeclaredField("testMethod05"); + classAllMethodTest(method.get(mainClass).getClass(), "method05"); + } catch (Exception e) { + System.out.println("Case method05 failed with exception" + e); + } + } + private Runnable testMethod05 = new Runnable() { + private final synchronized int intRunnable() { + return 1; + } + @Override + public void run() { + for (int i = 0; i < 10; i++) { + } + } + }; + + private static void method06() { + class TestMethod06 { + private final int intLocalMethod() { + return 9; + } + public synchronized String stringLocal() { + return "a fake behind the fear"; + } + } + try { + classAllMethodTest(Class.forName("MethodTest$1TestMethod06"), "method06"); + } catch (Exception e) { + System.out.println("Case method06 failed with exception" + e); + } + } + + private static void method07() { + try { + classAllMethodTest(Class.forName("MethodTest$TestMethod07"), "method07"); + } catch (Exception e) { + System.out.println("Case method07 failed with exception" + e); + } + } + class TestMethod07 { + private char charInnerMethod(int a, double... b) { + return 'l'; + } + final public double doubleInnerMethod() { + return 1988.0416; + } + } + + private static void method08() { + try { + classAllMethodTest(Class.forName("TestMethod08"), "method08"); + } catch (Exception e) { + System.out.println("Case method08 failed with exception" + e); + } + } + + private static void method09() { + try { + classAllMethodTest(Class.forName("TestMethod09"), "method09"); + } catch (Exception e) { + System.out.println("Case method09 failed with exception" + e); + } + } + + private static void method10() { + try { + classAllMethodTest(Class.forName("TestMethod10"), "method10"); + } catch (Exception e) { + System.out.println("Case method10 failed with exception" + e); + } + } + + private static void method11() { + try { + classAllMethodTest(Class.forName("TestMethod11"), "method11"); + } catch (Exception e) { + System.out.println("Case method11 failed with exception" + e); + } + } +} +class TestMethod02 { + // step1 + void voidMethod() {} + boolean booleanMethod() { + return true; + } + byte byteMethod() { + return (byte)1; + } + short shortMethod() { + return (short)2; + } + int intMethod() { + return 3; + } + long longMethod() { + return 4l; + } + char charMethod() { + return 'a'; + } + float floatMethod() { + return 0.9f; + } + double doubleMethod() { + return 0.416; + } + String stringMethod() { + return "The queerest of the queer"; + } + Runnable[] rArrayMethod() { + return null; + } + boolean[][][][][][][] booleanArray7Method() { + return new boolean[][][][][][][] {{{{{{{true, false}}}}}}}; + } + String[][][] stringArray3Method() { + return new String[][][] {{{"the strangest of the strange"}}}; + } + int parameterMethod(boolean a, byte b, short c, int d, long e, char f, float g, double h, + boolean[] aa, byte[] bb, short[] cc, int[] dd, long[] ee, char[] ff, float[] gg, double[] hh, + String i, String[][][] iii, Runnable j, Byte k, Double l, Thread.State m, int... o) { + return 1; + } + // step2 + public int publicIntMethod(boolean a) { + return 88; + } + protected double protectedDoubleMethod(byte a) { + return 99; + } + private String privateStringMethod(String a) { + return "the coldest of the cool"; + } + // step3 + strictfp double[][] transientDoubleArrayMethod(float[][] a) { + return new double[][] {{1988, 4.16}}; + } + final int finalIntMethod() { + return 9876; + } + synchronized String volatileStringMethod() { + return "the lamest of the lame"; + } + static Character staticCharacterMethod(Thread.State a) { + return 'd'; + } + //step 4 + @Deprecated + String[][] stringsAnnotationMethod() { + return new String[][] {{"the numbest of the dumb"}}; + } +} +interface TestMethod03 { + String stringInterfaceMethod(int[] a); + char[][][] charArrayInterfaceMethod(double... a); +} +abstract class TestMethod04 { + public static final synchronized String[] stringsAbstractArrayMethod() { + return new String[] {"i hate to see you here", "you choke behind a smile"}; + } + abstract Runnable runnableAbstractMethod(); +} +enum TestMethod08 { + WHISKY, VODKA, BRANDY, GIN, RUM, TEQUILA; + private static short shortEnumMethod() { + return (short)6; + } + public final String stringEnumMethod(int... a) { + return "Dry Martini"; + } +} +class TestMethod09 { + public int int09Method() { + return 1; + } + protected boolean boolean09Method() { + return false; + } + char[] chars09Method() { + return new char[] {'a', 'b', 'c'}; + } + private String string09Method() { + return "I'm only happy when it rains"; + } +} +class TestMethod10 extends TestMethod09 implements TestMethod11 { + public boolean boolean09Method() { + return true; + } + public double double10Method() { + return 0.416; + } + public char[] chars09Method() { + return new char[] {'a'}; + } + public String string09Method() { + return "SHALALALA"; + } +} +interface TestMethod11 { + int int09Method(); + boolean boolean09Method(); + char[] chars09Method(); + String string09Method(); +} diff --git a/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/check_s.py b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/check_s.py new file mode 100644 index 0000000000000000000000000000000000000000..ca8e2c6d0d538f83b4f76441bf85e0e68afa6348 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/check_s.py @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import sys + +def check_vtableimpl_s(filename): + f = open(filename, 'r') + result = list() + check_cnt = 0 + pass_cnt = 0 + fail_cnt = 0 + for line in f.readlines(): + line = line.strip() + if line.startswith(".type"): + result = list() + result.append(line) + if line.startswith(".size"): + if result[0].find("methods_info") != -1: + check_cnt += 1 + for i in result: + if i.find(".section") != -1: + if i == '.section .metadata.method,"aw",%progbits': + pass_cnt += 1 + else: + fail_cnt += 1 + elif i.find(".data") != -1: + fail_cnt += 1 + elif result[0].find("fields_info") != -1: + check_cnt += 1 + for i in result: + if i.find(".section") != -1: + if i == '.section .rometadata.field,"a",%progbits': + pass_cnt += 1 + else: + fail_cnt += 1 + elif i.find(".data") != -1: + fail_cnt += 1 + elif result[0].find("fieldOffsetData") != -1: + check_cnt += 1 + for i in result: + if i.find(".section") != -1: + fail_cnt += 1 + elif i.find(".data") != -1: + pass_cnt += 1 + else: + continue + if check_cnt == pass_cnt and fail_cnt == 0: + print(0) + else: + print(2) + + +if __name__ == '__main__': + check_vtableimpl_s(sys.argv[1]) + diff --git a/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/expected.txt b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aa47d0d46d47a06090f436b0b851b76bb6f3b6e2 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/expected.txt @@ -0,0 +1,2 @@ +0 +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/test.cfg b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dd791e36d5a7fbf0819ed4fa23c3b8b4b5f04f28 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0208-rt-reflection-MetadataCheck/test.cfg @@ -0,0 +1,6 @@ +clean() +compile(FieldTest) +compile(MethodTest) +python3 check_s.py MethodTest.VtableImpl.s > output.log 2>&1 +python3 check_s.py FieldTest.VtableImpl.s >> output.log 2>&1 +diff output.log expected.txt diff --git a/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java new file mode 100755 index 0000000000000000000000000000000000000000..a325e0ad87742f7236086c6e10d4f7027b99b395 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/ReflectionGetAnnotation1.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Retention(RetentionPolicy.RUNTIME) +@interface Zzz1 { +} +@Zzz1 +class GetAnnotation1_a { +} +class GetAnnotation1_b { +} +public class ReflectionGetAnnotation1 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("GetAnnotation1_a"); + Class clazz2 = Class.forName("GetAnnotation1_b"); + if (clazz1.getAnnotation(Zzz1.class) != null && clazz2.getAnnotation(Zzz1.class) == null) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..97f14563a4ff4981b724676736bc50ab2f68230a --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0209-rt-reflection-ReflectiongetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectionGetAnnotation1) +run(ReflectionGetAnnotation1) diff --git a/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/HelloWorld.java b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/HelloWorld.java new file mode 100644 index 0000000000000000000000000000000000000000..5403827efedd6f43ecdb6fc11842b74642ede2c9 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/HelloWorld.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. + */ + +import java.lang.annotation.*; +import java.lang.reflect.*; + +@Retention(RetentionPolicy.RUNTIME) +@interface HarmonyStaticStringVis { + +} + +@HarmonyStaticStringVis +class HelloWorldAnnotation { + @HarmonyStaticStringVis + private int numVis; + + @HarmonyStaticStringVis + public void funcVis(@HarmonyStaticStringVis String str, int num, @HarmonyStaticStringVis String str2) { + for (int i = 0; i < num; ++i) { + System.out.println(str); + System.out.println(str2); + } + } +} + +public class HelloWorld { + public static void main(String[] args) { + funcVisTest(); + } + + public static void funcVisTest() { + try { + Class klass = Class.forName("HelloWorldAnnotation"); + Method[] methods = klass.getMethods(); + Method funcVis = null; + for (int i = 0; i < methods.length; i++) { + if (methods[i].getName().equals("funcVis")) { + funcVis = methods[i]; + break; + } + } + Parameter[] parameters = funcVis.getParameters(); + Parameter p0 = parameters[0]; + Parameter p1 = parameters[1]; + Parameter p2 = parameters[2]; + if ((p0.getAnnotation(HarmonyStaticStringVis.class) != null) && + (p1.getAnnotation(HarmonyStaticStringVis.class) == null) && + (p2.getAnnotation(HarmonyStaticStringVis.class) != null)) { + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} diff --git a/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/expected.txt b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/test.cfg b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2e75536c83593b42d88ec96a160b4fcb8627ef13 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0210-rt-reflection-ReflectiongetAnnotation1/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(HelloWorld) +run(HelloWorld) diff --git a/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..f569c71353c44a493a720a22703160511bc660f3 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/ClassInitFieldSetCharInterface.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetCharInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiChar"); + if (result.toString().compareTo("") == 0) { + f.setChar(null, (char)46); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + } else { + System.out.println(2); + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetCharInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetCharInterface.result.append("One").toString(); + char hiChar = (char)45; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetCharInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetCharInterface.result.append("Annotation").toString(); +} \ No newline at end of file diff --git a/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/expected.txt b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/test.cfg b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d2311cd9cb889cda5f4c30c5ef0457db7412d6f5 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0893-rt-Reflection-ClinitFieldSetCharInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetCharInterface) +run(ClassInitFieldSetCharInterface) diff --git a/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java new file mode 100755 index 0000000000000000000000000000000000000000..8393ae0c666e7455f424cef1e1b589ca8318051d --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/ClassInitFieldSetDoubleInterface.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.Field; +public class ClassInitFieldSetDoubleInterface { + static StringBuffer result = new StringBuffer(""); + public static void main(String[] args) { + try { + Class clazz = Class.forName("OneInterface", false, OneInterface.class.getClassLoader()); + Field f = clazz.getField("hiDouble"); + if (result.toString().compareTo("") == 0) { + f.setDouble(null, 0.265874); + } + }catch (IllegalAccessException e){ + result.append("IllegalAccessException"); + }catch (Exception e) { + System.out.println(e); + } + if (result.toString().compareTo("OneIllegalAccessException") == 0) { + System.out.println(0); + return; + } else { + System.out.println(2); + return; + } + } +} +interface SuperInterface{ + String aSuper = ClassInitFieldSetDoubleInterface.result.append("Super").toString(); +} +@A +interface OneInterface extends SuperInterface{ + String aOne = ClassInitFieldSetDoubleInterface.result.append("One").toString(); + double hiDouble = 0.1532; +} +interface TwoInterface extends OneInterface{ + String aTwo = ClassInitFieldSetDoubleInterface.result.append("Two").toString(); +} +@interface A { + String aA = ClassInitFieldSetDoubleInterface.result.append("Annotation").toString(); +} diff --git a/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/expected.txt b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/test.cfg b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..16f5d899c026f7f0ff4da48152a8ebf83740be20 --- /dev/null +++ b/testsuite/java_test/reflection_test/issue-RT0894-rt-Reflection-ClinitFieldSetDoubleInterface/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ClassInitFieldSetDoubleInterface) +run(ClassInitFieldSetDoubleInterface) diff --git a/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/StmtTest01.java b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/StmtTest01.java new file mode 100755 index 0000000000000000000000000000000000000000..b2117b5a47dc6e217c8729e50aa8c02a4d7e1322 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/StmtTest01.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest01 { + public static void main(String[] args) { + if (test()) { + System.out.println("ExpectResult"); // 1 + } else { + String string = "ExpectResult" + "ExpectResult"; // 2 + System.out.println(string); + } + } + // 基础的测试 + private static boolean test() { + String string = "A"; // 3 + for (int ii = 0; ii < 100; ii++) { + string += "A"; + } + return string.length() == 101; //true; + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/expected.txt b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/test.cfg b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b41eabc2f5a4f91c3b9c70d31d6e6bd0ea09ac94 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0001-rt-String-StmtTest01/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest01,EXPECTNUM=2) +run(StmtTest01) diff --git a/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/StmtTest02.java b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/StmtTest02.java new file mode 100755 index 0000000000000000000000000000000000000000..92e6235baaa7cf239e5eae6c58ffd743ba6939c0 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/StmtTest02.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest02 { + public static void main(String[] args) { + if (test1()) { + System.out.println("ExpectResult"); // 1 + } else { + System.out.println("ExpectResult " + "ExpectResult"); // 2 + } + } + // 基础的测试 + private static boolean test() { + String string = "A"; // 3 + for (int ii = 0; ii < 100; ii++) { + string += "A"; + } + return string.length() == 101; //true; + } + // 有函数调用,确认 + private static boolean test1() { + String str1 = "A" + "A"; // 4 + String str2 = "A" + "A"; + if (test() == true) { + str2 = str1; + } + return str1 == str1; //true + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/expected.txt b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/test.cfg b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..06c9a347263c1abaeacbc32de387ae3cbb67c142 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0002-rt-String-StmtTest02/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest02,EXPECTNUM=2) +run(StmtTest02) diff --git a/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/StmtTest03.java b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/StmtTest03.java new file mode 100755 index 0000000000000000000000000000000000000000..5f2a2b274386edc77f2de3b19a43b4b0d7f4f2a1 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/StmtTest03.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +interface Interface { + boolean test(); +} +public class StmtTest03 implements Interface { + public static void main(String[] args) { + if (new StmtTest03().test()) { + System.out.println("ExpectResult"); // 1 + } else { + System.out.println("ExpectResult " + "ExpectResult"); // 2 + } + } + // 实现接口 + public boolean test() { + String str1 = "A" + "A"; // 3 + String str2 = "A" + "A"; + return str1 == str2; + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/expected.txt b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/test.cfg b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0ab34863fe84cb517c52bc0369f37429791bab95 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0003-rt-String-StmtTest03/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest03,EXPECTNUM=2) +run(StmtTest03) diff --git a/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/StmtTest04.java b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/StmtTest04.java new file mode 100755 index 0000000000000000000000000000000000000000..2d8fe7bf1db15d8c6da7ab25825b1d2766e2df3c --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/StmtTest04.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +class Father { + public String name; + public boolean test1() { + String str1 = "A" + "A"; // 1 + String str2 = "A" + "A"; + return str1 == str2; // false; + } +} +public class StmtTest04 extends Father { + public String name; + public static void main(String[] args) { + Father father = new StmtTest04(); + father.name = "ExpectResult"; // 2 + if (father.test1()) { + System.out.println("ExpectResult"); + } else { + System.out.println("ExpectResult" + " " + "ExpectResult"); // 4 + } + } + // 集成父类 + @Override + public boolean test1() { + String str1 = "A" + "A"; // 3 + String str2 = "A" + "A"; + return str1.equals(str2); // true; + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/expected.txt b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/test.cfg b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8df3437c401999c596bbc67b393cfeb1e9437096 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0004-rt-String-StmtTest04/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest04,EXPECTNUM=2) +run(StmtTest04) diff --git a/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/StmtTest05.java b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/StmtTest05.java new file mode 100755 index 0000000000000000000000000000000000000000..ea6fe2e0c6cc70eb8d908ec2171d4ee6ef7888b0 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/StmtTest05.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest05 { + public static void main(String[] args) { + String test = "TestStringForStmt"; // 1 + switch (test) { + case "TestStringForStmt33": // 6 + test = "TestStringForStmt01"; // 2 + break; + case "TestStringForStmt55": // 3 + test += "TestStringForStmt01"; // 4 + break; + default: + test = "TestStringForStmt"; + break; + } + String output = "ExpectResult"; // 5 + if (test == "TestStringForStmt") { + System.out.println(output); + } else { + System.out.print("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/expected.txt b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/test.cfg b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..94dfdb475f8f77aed5cfc2edbfb188a2bdd87aac --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0005-rt-String-StmtTest05/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest05,EXPECTNUM=6) +run(StmtTest05) diff --git a/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/StmtTest06.java b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/StmtTest06.java new file mode 100755 index 0000000000000000000000000000000000000000..c83db23a9900546cec0ecd14faf707b0a2191416 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/StmtTest06.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest06 { + public static void main(String[] argv) { + int result = 2; + boolean check; + String str = "123#"; // 1 + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + str = "123#456"; // 2 + result--; + } catch (NullPointerException e) { + str = "123456"; // 3 + result = 2; + } catch (OutOfMemoryError e) { + str += "123#456"; // 被外提 + result = 2; + } finally { + check = str == "123#456"; + result--; + } + if (check == true && result == 0) { + System.out.println("123#"); + } + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/expected.txt b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c975d3f1f41dd28ef5ef470f83f6dd7f073bbab2 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/expected.txt @@ -0,0 +1 @@ +123# diff --git a/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/test.cfg b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4c2e550945ea99efa3f975356d736a386d6b357f --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0006-rt-String-StmtTest06/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest06,EXPECTNUM=3) +run(StmtTest06) diff --git a/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/StmtTest07.java b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/StmtTest07.java new file mode 100755 index 0000000000000000000000000000000000000000..50687107c4665e4eb37341ad27c91c4a17a373be --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/StmtTest07.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest07 { + public static void main(String[] args) { + if (test()) { + System.out.println("ExpectResult"); // 1 + } else { + String string = "ExpectResult" + "ExpectResult"; // 2 + System.out.println(string); + } + } + // 基础的测试for循环嵌套 + private static boolean test() { + String string = "AA"; // 3 + for (int ii = 0; ii < 10; ii++) { + string = "AA"; + for (int jj = 0; jj < 10; jj++) { + for (int kk = 0; kk < 2; kk++) { + string += "AA"; + } + } + } + try { + string = "AA"; + for (int jj = 0; jj < 10; jj++) { + for (int ii = 0; ii < getInt(); ii++) { + string += "123"; // 4 + } + } + } catch (ArithmeticException a) { + System.out.println(string); + } + return string.length() == 2; //true; + } + private static int getInt() { + return 1 / 0; + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/expected.txt b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c0bf27b29f1da971e6059be7ee14c0e3eccece57 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/expected.txt @@ -0,0 +1,2 @@ +AA +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/test.cfg b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5fa7dc87269edbf853bee97a5515a54338bd30fa --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0007-rt-String-StmtTest07/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest07,EXPECTNUM=3) +run(StmtTest07) diff --git a/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/StmtTest08.java b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/StmtTest08.java new file mode 100755 index 0000000000000000000000000000000000000000..723e73769e5c28a2abd13397b3bf613f0f92833d --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/StmtTest08.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest08 { + public static void main(String[] args) { + if (test1() == false) { + System.out.println("ExpectResult"); // 1 + } else { + System.out.println("ExpectResult " + "ExpectResult"); // 2 + } + } + // 基础的测试 + private static boolean test() { + String string = "A"; // 3 + for (int ii = 0; ii < 100; ii++) { + string += "A"; + } + return string.length() == 101; //true; + } + // 有函数调用,确认 + private static boolean test1() { + String str1 = "AA"; // 4 + String str2; + if (test() == true) { + str2 = str1; + if (str2 == "AA") { + str2 = str2.substring(0, 1); + } else { + str1 = "AAA"; // 5 + } + } else { + str2 = "A"; // 6 + if (str2.equals("AA")) { + str2 = str2.substring(0, 1); + } else { + str1 = "AAA"; // 7 + } + } + return str2 == str1; //true + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/expected.txt b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/test.cfg b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f20e9db8092705e47e188adf0373e179c7e04bd9 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0008-rt-String-StmtTest08/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest08,EXPECTNUM=4) +run(StmtTest08) diff --git a/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/StmtTest09.java b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/StmtTest09.java new file mode 100755 index 0000000000000000000000000000000000000000..922ac86118646d971d67ef6f1bcc8e1b564b40b2 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/StmtTest09.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest09 { + public static void main(String[] args) { + String test = "TestStringForStmt"; // 1 + switch (test) { + case "TestStringForStmt33": // 2 + test = "TestStringForStmt01"; // 3 + break; + case "TestStringForStmt55": // 4 + test += "TestStringForStmt01"; // 其他优化导致"TestStringForStmt01"的地址调用外提到22行,所以与33行合用。 + break; + default: + switch (test) { + case "TestStringForStmt34": // 5 + test = "TestStringForStmt01"; // 其他优化导致"TestStringForStmt01"的地址调用外提到22行,所以与33行合用 + break; + case "TestStringForStmt35": // 6 + test += "TestStringForStmt01"; // 7 + break; + default: + test = "TestStringForStmt"; + break; + } + } + String output = "ExpectResult"; // 8、 + if (test == "TestStringForStmt") { + System.out.println(output); + } else { + System.out.print("ExpectResult"); + } + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/expected.txt b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/test.cfg b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..58cd099bc585360fb976ba7bad2a9afa473bf98d --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0009-rt-String-StmtTest09/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest09,EXPECTNUM=8) +run(StmtTest09) diff --git a/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/StmtTest10.java b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/StmtTest10.java new file mode 100755 index 0000000000000000000000000000000000000000..3d0d876179706af3dc08c2cd8c425e2a8c3b191d --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/StmtTest10.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest10 { + public static void main(String[] argv) { + int result = 2; + boolean check; + String str = "123#"; // 1 + try { + str = "123456"; // 2 + try { + Integer.parseInt(str); + } catch (NumberFormatException e) { + str = "123#456"; // 3 + result--; + } catch (NullPointerException e) { + str = "123456#"; // 4 + result = 2; + } catch (OutOfMemoryError e) { + str += "123#456"; // 与32行被其他优化了 + result = 2; + } finally { + str = "123#456"; + } + Integer.parseInt(str); + } catch (NumberFormatException e) { + str = "123#456"; + result--; + } catch (NullPointerException e) { + str = "123456"; + result = 2; + } catch (OutOfMemoryError e) { + str += "123#456"; + result = 2; + } finally { + check = str == "123#456"; + result--; + } + if (check == true && result == 0) { + System.out.println("123#"); + } + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/expected.txt b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c975d3f1f41dd28ef5ef470f83f6dd7f073bbab2 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/expected.txt @@ -0,0 +1 @@ +123# diff --git a/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/test.cfg b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d557686a25b4296e00fe5db16fc4cbf0e25ef4c9 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0010-rt-String-StmtTest10/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest10,EXPECTNUM=4) +run(StmtTest10) diff --git a/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/StmtTest11.java b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/StmtTest11.java new file mode 100755 index 0000000000000000000000000000000000000000..fd27c0b05081bce5feb46c402ee1a16c7012e35a --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/StmtTest11.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest11 { + public static void main(String[] args) { + if (test()) { + System.out.println("ExpectResult"); // 1 + } else { + String string = "ExpectResultExpectResult"; // 2 + System.out.println(string); + } + } + // 基础的测试for循环嵌套 + private static boolean test() { + String string = "AA"; // 3 + try { + string = "AB"; // 4 + if (string.length() == 2) { + for (int jj = 0; jj < 10; jj++) { + for (int ii = 0; ii < getInt(); ii++) { + string += "123"; // 5,被外提 + } + } + } else { + switch (string) { + case "A": // 6 + string = "123"; //被外提 + break; + case "AA": + string = "A"; + break; + default: + break; + } + } + } catch (ArithmeticException a) { + System.out.println(string); + } + return string.length() == 2; //true; + } + private static int getInt() { + return 1 / 0; + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/expected.txt b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..17a21b86e2ac532f92e106ab41303470a222db92 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/expected.txt @@ -0,0 +1,2 @@ +AB +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/test.cfg b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7dbe7cbf3fc6f99550149de627ada60e200162f1 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0011-rt-String-StmtTest11/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest11,EXPECTNUM=3) +run(StmtTest11) diff --git a/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/StmtTest12.java b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/StmtTest12.java new file mode 100755 index 0000000000000000000000000000000000000000..5645dc8d6b1ad6f78d253bf8379769af256e858b --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/StmtTest12.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.annotation.*; +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@interface Zzz1 { + int i() default 0; + String t() default " "; +} +@Zzz1(i = 333, t = "getAnnotation") +class GetAnnotation1_a { +} +class GetAnnotation1_b { +} +public class StmtTest12 { + public static void main(String[] args) { + try { + Class clazz1 = Class.forName("StmtTest12"); // 3 + Class clazz2 = Class.forName("StmtTest12"); + for (int ii = 0; ii < 100; ii++) { + clazz1 = Class.forName("GetAnnotation1_a"); // 4 + clazz2 = Class.forName("GetAnnotation1_b"); // 5 + } + if (clazz1.getAnnotation(Zzz1.class).toString().indexOf("t=getAnnotation") != -1 // 1 + && clazz1.getAnnotation(Zzz1.class).toString().indexOf("i=333") != -1 // 2 + && clazz2.getAnnotation(Zzz1.class) == null) { // 7 + System.out.println(0); + } + } catch (ClassNotFoundException e) { + System.out.println(2); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/expected.txt b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/test.cfg b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3509af58b088305594f4201aac7a529719328cc4 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0012-rt-String-StmtTest12/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest12,EXPECTNUM=5) +run(StmtTest12) diff --git a/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/StmtTest13.java b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/StmtTest13.java new file mode 100755 index 0000000000000000000000000000000000000000..9afd62bc293686848e918acb8bcac41b0b3faeaf --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/StmtTest13.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +public class StmtTest13 { + private String outOfMethod = "AB"; //3 + public static void main(String[] args) { + String string = "AB"; // 1 + for (int ii = 0; ii < 10; ii++) { + string += "A" + "B"; + } + if (string.length() == 22) { + string = "AB"; //此处在堆上分配内存,不会用第22行的伪寄存器地址 + } else { + char[] chars = {'A', 'B'}; + string = chars.toString(); + } + if (string.equals(new StmtTest13().outOfMethod)) { + System.out.println("ExpectResult"); // 2 + } else { + System.out.print("ExpectResult"); //优化外提,这边不会再取一次。 + } + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/expected.txt b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..6eec045e116acc8368bb44d7d46330bb25fbb63e --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/expected.txt @@ -0,0 +1 @@ +ExpectResult diff --git a/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/test.cfg b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5443743bbe593d5d44ed273397a4dca8f6dfc100 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0013-rt-String-StmtTest13/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest13,EXPECTNUM=1) +run(StmtTest13) diff --git a/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/StmtTest14.java b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/StmtTest14.java new file mode 100755 index 0000000000000000000000000000000000000000..1cfb0800a14366ba27a6224f082c4cfd6706775c --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/StmtTest14.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.nio.charset.StandardCharsets; +public class StmtTest14 { + public static void main(String[] args) { + String string = "AB"; // 1 + for (int ii = 0; ii < 10; ii++) { + string += "A" + "B"; // +号拼接场景 + } + if (string.length() == 22) { + string = "AB"; // 作为入参 + } else { + char[] chars = "AB".toCharArray(); // 作为函数调用主体 + string = chars.toString(); + } + byte[] bs = string.getBytes(); + string = new String(bs, StandardCharsets.US_ASCII); + System.out.println(string); + } +} diff --git a/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/expected.txt b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3bd504ceced4f54589dad30001d4393cf1243efc --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/expected.txt @@ -0,0 +1 @@ +AB diff --git a/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/test.cfg b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d99cefac7b1d3a6e6dc9996aabcc7577211384f8 --- /dev/null +++ b/testsuite/java_test/stmtpre_test/RT0014-rt-String-StmtTest14/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StmtTest14,EXPECTNUM=0) +run(StmtTest14) diff --git a/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/ReflectString.java b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/ReflectString.java new file mode 100644 index 0000000000000000000000000000000000000000..abd3921d4e66ccc3a578537a097a412593b02c0f --- /dev/null +++ b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/ReflectString.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class ReflectString { + static int res = 99; + public static void main(String argv[]) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 2/*STATUS_FAILED*/; + try { + ReflectString_1(); + } catch (Exception e) { + res -= 10; + } + if (result == 2 && res == 95) { + result = 0; + } + return result; + } + public static void ReflectString_1() { + int result1 = 4; /*STATUS_FAILED*/ + Object test1 = null; + try { + test1 = String.class.newInstance(); + res -= 4; + } catch (InstantiationException e1) { + System.err.println(e1); + } catch (IllegalAccessException e2) { + System.err.println(e2); + } +// System.out.println("test1:"+ test1); + } +} diff --git a/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/expected.txt b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/test.cfg b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6a21637e2fa1699e4cf33c87f0b1a13975d64d8e --- /dev/null +++ b/testsuite/java_test/string_test/RT0001-rt-string-ReflectString/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(ReflectString) +run(ReflectString) diff --git a/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/StringBufferConstructorsTest.java b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/StringBufferConstructorsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..30eb0ffc3bdb6eefde9c61cb70148b5bcbd9ddde --- /dev/null +++ b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/StringBufferConstructorsTest.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferConstructorsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferConstructorsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferConstructorsTest_1() { + String str1_1 = new String("abc123abc"); + String str1_2 = new String(" @!.&%()*"); + String str1_3 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "abc123ABC"; + String str2_2 = " @!.&%()*"; + String str2_3 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZX" + + "CVBNM0x96"; + String str2_4 = ""; + test1_1(str1_1); + test1_1(str1_2); + test1_1(str1_3); + test1_1(str1_4); + test1_1(str1_5); + test1_1(str2_1); + test1_1(str2_2); + test1_1(str2_3); + test1_1(str2_4); + StringBuffer strBuffer1_1 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=" + + "!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test1_2(strBuffer1_1); + test1_2(strBuffer1_2); + test1_2(strBuffer1_3); + test1_2(strBuffer1_4); + test1_2(strBuffer1_5); + test1_3(); + test1_4(); + test1_5(); + } + private static void test1_1(String str) { + System.out.println(new StringBuffer(str)); + } + private static void test1_2(StringBuffer strBuffer) { + System.out.println(strBuffer.toString()); + } + // Test new StringBuffer(). + private static void test1_3() { + StringBuffer strBuffer1_6 = new StringBuffer(); + System.out.println(strBuffer1_6.capacity()); + } + // Test new StringBuffer(int capacity). + private static void test1_4() { + int capacity = 20; + StringBuffer strBuffer1_6 = new StringBuffer(capacity); + System.out.println(strBuffer1_6.capacity()); + int capacityMin = 0; + strBuffer1_6 = new StringBuffer(capacityMin); + System.out.println(strBuffer1_6.capacity()); + } + // Test new StringBuffer(CharSequence seq). + private static void test1_5() { + CharSequence chs1_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTY" + + "UIOPZXCVBNM0x96"; + StringBuffer strBuffer1_7 = new StringBuffer(chs1_1); + test1_2(strBuffer1_7); + } +} diff --git a/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/expected.txt b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..447cded52dfc998c7cdb9f730f6cd8cbc05445ac --- /dev/null +++ b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/expected.txt @@ -0,0 +1,19 @@ +abc123abc + @!.&%()* +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +abc123ABC + @!.&%()* +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + +abc123abc + @!.&%()* +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +16 +20 +0 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +0 diff --git a/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/test.cfg b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d0ba3fe92d2c398139f180d85ea274307dd623c9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0002-rt-String-BufferConstructorsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferConstructorsTest) +run(StringBufferConstructorsTest) diff --git a/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/StringBufferAppendAndAppendCodePointTest.java b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/StringBufferAppendAndAppendCodePointTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4588a2093d0611ebbcd032df7a95e3e773147cf1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/StringBufferAppendAndAppendCodePointTest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferAppendAndAppendCodePointTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferAppendAndAppendCodePointTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferAppendAndAppendCodePointTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test1(strBuffer1_4); + test1(strBuffer1_5); + } + private static void test1(StringBuffer strBuffer) { + char c = 'C'; + char[] data = {'A', 'B', 'C'}; + CharSequence chs1_1 = "xyz"; + double d = 8888.8888; + double dMin = 0; + float f = 99999999; + float fMin = 0; + int i = 77777777; + int iMin = 0; + long lng = 66666666; + long lngMin = 0; + Object obj = new String("object"); + String str = "string"; + StringBuffer sb = new StringBuffer("stringbuffer"); + int codePoint = 74; // unicode 74 is J + System.out.println(strBuffer.append("-").append(true).append("-").append(false).append("-").append(c) + .append("-").append(data).append("-").append(chs1_1).append("-").append(chs1_1, 1, 2).append("-") + .append(chs1_1, 0, 3).append("-").append(chs1_1, 3, 3).append("-").append(chs1_1, 0, 0).append("-") + .append(d).append("-").append(dMin).append("-").append(f).append("-").append(fMin).append("-").append(i) + .append("-").append(iMin).append("-").append(lng).append("-").append(lngMin).append("-").append(obj) + .append("-").append(str).append("-").append(sb).append("-").appendCodePoint(codePoint)); + System.out.println(strBuffer.subSequence(2, 8)); + } +} diff --git a/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/expected.txt b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..00bcf56b049bfb85bfe321d76a53dfcaa7a486a8 --- /dev/null +++ b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/expected.txt @@ -0,0 +1,11 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-stringbuffer-J +ertyui + @!.&%()*-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-stringbuffer-J +!.&%() +abc123abc-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-stringbuffer-J +c123ab +-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-stringbuffer-J +rue-fa +-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-stringbuffer-J +rue-fa +0 diff --git a/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/test.cfg b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8be8ea89dd4404be9ec4987ab67f650061b2f4a7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0003-rt-String-BufferAppendAndAppendCodePointTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferAppendAndAppendCodePointTest) +run(StringBufferAppendAndAppendCodePointTest) diff --git a/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/StringBufferInsertTest.java b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/StringBufferInsertTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3baa7476a5d564b6841b997e1e2aabdd638d53e8 --- /dev/null +++ b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/StringBufferInsertTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferInsertTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferInsertTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferInsertTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test1(strBuffer1_4); + test1(strBuffer1_5); + } + private static void test1(StringBuffer strBuffer) { + boolean b = true; + char c = 'C'; + char[] data = {'A', 'B', 'C'}; + CharSequence chs1_1 = "xyz"; + double d = 8888.8888; + double dMin = 0; + float f = 99999999; + float fMin = 0; + int i = 77777777; + int iMin = 0; + long lng = 66666666; + long lngMin = 0; + Object obj = new String("object"); + String str = "-"; + System.out.println(strBuffer.insert(0, str).insert(0, b).insert(strBuffer.length(), str) + .insert(strBuffer.length(), b).insert(0, str).insert(0, false).insert(strBuffer.length(), str) + .insert(strBuffer.length(), false).insert(0, str).insert(0, c).insert(strBuffer.length(), str) + .insert(strBuffer.length(), c).insert(0, str).insert(0, data).insert(strBuffer.length(), str) + .insert(strBuffer.length(), data).insert(0, str).insert(0, chs1_1).insert(strBuffer.length(), str) + .insert(strBuffer.length(), chs1_1).insert(0, str).insert(0, chs1_1, 1, 2) + .insert(strBuffer.length(), str).insert(strBuffer.length(), chs1_1, 1, 2).insert(0, str) + .insert(0, chs1_1, 0, 3).insert(strBuffer.length(), str).insert(strBuffer.length(), chs1_1, 0, 3) + .insert(0, str).insert(0, chs1_1, 3, 3).insert(strBuffer.length(), str) + .insert(strBuffer.length(), chs1_1, 3, 3).insert(0, str).insert(0, chs1_1, 0, 0) + .insert(strBuffer.length(), str).insert(strBuffer.length(), chs1_1, 0, 0).insert(0, str).insert(0, d) + .insert(strBuffer.length(), str).insert(strBuffer.length(), d).insert(0, str).insert(0, dMin) + .insert(0, str).insert(0, f).insert(strBuffer.length(), str).insert(strBuffer.length(), f) + .insert(0, str).insert(0, fMin).insert(0, str).insert(0, i).insert(strBuffer.length(), str) + .insert(strBuffer.length(), i).insert(0, str).insert(0, iMin).insert(0, str).insert(0, lng) + .insert(strBuffer.length(), str).insert(strBuffer.length(), lng).insert(0, str) + .insert(0, lngMin).insert(0, str).insert(0, obj).insert(strBuffer.length(), str) + .insert(strBuffer.length(), obj)); + System.out.println(strBuffer.subSequence(2, 8)); + } +} diff --git a/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/expected.txt b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..7a8d1cbdb637c566e93c2c8c6377e8fd95f068b7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/expected.txt @@ -0,0 +1,11 @@ +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false-true-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false-true- @!.&%()*-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false-true-abc123abc-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false-true--true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false-true--true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +0 diff --git a/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/test.cfg b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d12b945018144985c07dfd114b4191d15c3b2ba8 --- /dev/null +++ b/testsuite/java_test/string_test/RT0004-rt-String-BufferInsertTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferInsertTest) +run(StringBufferInsertTest) diff --git a/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/StringBufferDeleteAndDeleteCharAtTest.java b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/StringBufferDeleteAndDeleteCharAtTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ceb70a1de8bcfa805895e2f2593d637d2befef36 --- /dev/null +++ b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/StringBufferDeleteAndDeleteCharAtTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferDeleteAndDeleteCharAtTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferDeleteAndDeleteCharAtTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferDeleteAndDeleteCharAtTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer2_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer2_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer2_3 = new StringBuffer("abc123abc"); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test2(strBuffer2_1); + test2(strBuffer2_2); + test2(strBuffer2_3); + } + // Test method delete(int start, int end). + private static void test1(StringBuffer strBuffer) { + // Test 0 < start < end, end < strBuffer.length(). + System.out.println(strBuffer.delete(3, 5)); + // Test start = 0. + System.out.println(strBuffer.delete(0, 1)); + // Test end = 0. + System.out.println(strBuffer.delete(0, 0)); + // Test start=strBuffer.length(). + System.out.println(strBuffer.delete(strBuffer.length(), strBuffer.length())); + // Test end=strBuffer.length(). + System.out.println(strBuffer.delete(2, strBuffer.length())); + } + // Test method deleteCharAt(int index). + private static void test2(StringBuffer strBuffer) { + // Test 0 < index < strBuffer.length(). + System.out.println(strBuffer.deleteCharAt(1)); + // Test index = 0. + System.out.println(strBuffer.deleteCharAt(0)); + // Test index = strBuffer.length() - 1. + System.out.println(strBuffer.deleteCharAt(strBuffer.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/expected.txt b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eddc3aea49e0fce935a0956369a14d37ad1740c1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/expected.txt @@ -0,0 +1,25 @@ +qweyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +we + @!%()* +@!%()* +@!%()* +@!%()* +@! +abc3abc +bc3abc +bc3abc +bc3abc +bc +qertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x9 + !.&%()* +!.&%()* +!.&%() +ac123abc +c123abc +c123ab +0 diff --git a/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/test.cfg b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a3ee57d0f4e409c6672c7f89c859d540705b123b --- /dev/null +++ b/testsuite/java_test/string_test/RT0005-rt-String-BufferDeleteAndDeleteCharAtTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferDeleteAndDeleteCharAtTest) +run(StringBufferDeleteAndDeleteCharAtTest) diff --git a/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/StringBufferCodePointExceptionTest.java b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/StringBufferCodePointExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a8b6c9c3947680eee904bb013b91f4b799217dba --- /dev/null +++ b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/StringBufferCodePointExceptionTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferCodePointExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferCodePointExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferCodePointExceptionTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-" + + "=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123"); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test2(strBuffer1_1); + test2(strBuffer1_2); + test2(strBuffer1_3); + test3(strBuffer1_1); + test3(strBuffer1_2); + test3(strBuffer1_3); + test4(strBuffer1_1); + test4(strBuffer1_2); + test4(strBuffer1_3); + } + // Test method codePointAt(int index). + private static void test1(StringBuffer strBuffer) { + int codePoint = 0; + for (int i = 0; i < 6; i++) { + try { + codePoint = strBuffer.codePointAt(i); + System.out.println("i=" + i + " " + "codePointAt=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointAt(): " + i + "out of length"); + } finally { + try { + System.out.println(strBuffer.charAt(i) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method codePointBefore(int index). + private static void test2(StringBuffer strBuffer) { + int codePoint = 0; + for (int i = 0; i < 6; i++) { + try { + codePoint = strBuffer.codePointBefore(i); + System.out.println("i=" + i + " " + "codePointBefore=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointBefore(): " + i + "out of length"); + } finally { + try { + System.out.println(strBuffer.charAt(i - 1) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method codePointCount(int beginIndex, int endIndex). + private static void test3(StringBuffer strBuffer) { + int codePoint = 0; + for (int i = 0; i < 4; i++) { + try { + codePoint = strBuffer.codePointCount(i, i + 3); + System.out.println("i=" + i + " " + "codePointCount=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("codePointCount(): " + i + " out of length"); + } finally { + try { + System.out.println(strBuffer.charAt(i) + "~" + strBuffer.charAt(i + 3) + + " codePointCount is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method int offsetByCodePoints(int index, int codePointOffset). + private static void test4(StringBuffer strBuffer) { + int codePoint = 0; + for (int i = 0; i < 4; i++) { + try { + codePoint = strBuffer.offsetByCodePoints(i, i + 3); + System.out.println("i=" + i + " " + "offsetByCodePoints=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("offsetByCodePoints(): " + i + "+3 out of length"); + } finally { + try { + System.out.println(strBuffer.charAt(i) + " offsetByCodePoints +3 is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd0e884408537cba05c2fe7bf7455a5266848862 --- /dev/null +++ b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/expected.txt @@ -0,0 +1,121 @@ +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=113 +q Unicode is:113 +i=2 codePointBefore=119 +w Unicode is:119 +i=3 codePointBefore=101 +e Unicode is:101 +i=4 codePointBefore=114 +r Unicode is:114 +i=5 codePointBefore=116 +t Unicode is:116 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=32 + Unicode is:32 +i=2 codePointBefore=64 +@ Unicode is:64 +i=3 codePointBefore=33 +! Unicode is:33 +i=4 codePointBefore=46 +. Unicode is:46 +i=5 codePointBefore=38 +& Unicode is:38 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=97 +a Unicode is:97 +i=2 codePointBefore=98 +b Unicode is:98 +i=3 codePointBefore=99 +c Unicode is:99 +i=4 codePointBefore=49 +1 Unicode is:49 +i=5 codePointBefore=50 +2 Unicode is:50 +i=0 codePointCount=3 +q~r codePointCount is :3 +i=1 codePointCount=3 +w~t codePointCount is :3 +i=2 codePointCount=3 +e~y codePointCount is :3 +i=3 codePointCount=3 +r~u codePointCount is :3 +i=0 codePointCount=3 + ~. codePointCount is :3 +i=1 codePointCount=3 +@~& codePointCount is :3 +i=2 codePointCount=3 +!~% codePointCount is :3 +i=3 codePointCount=3 +3 out of length +i=0 codePointCount=3 +a~1 codePointCount is :3 +i=1 codePointCount=3 +b~2 codePointCount is :3 +i=2 codePointCount=3 +c~3 codePointCount is :3 +i=3 codePointCount=3 +3 out of length +i=0 offsetByCodePoints=3 +q offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints +3 is :5 +i=2 offsetByCodePoints=7 +e offsetByCodePoints +3 is :7 +i=3 offsetByCodePoints=9 +r offsetByCodePoints +3 is :9 +i=0 offsetByCodePoints=3 + offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints +3 is :5 +offsetByCodePoints(): 2+3 out of length +! offsetByCodePoints +3 is :5 +offsetByCodePoints(): 3+3 out of length +. offsetByCodePoints +3 is :5 +i=0 offsetByCodePoints=3 +a offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints +3 is :5 +offsetByCodePoints(): 2+3 out of length +c offsetByCodePoints +3 is :5 +offsetByCodePoints(): 3+3 out of length +1 offsetByCodePoints +3 is :5 +0 diff --git a/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..debbc36e4365fcae733a36430a10f3d3a3cf6dca --- /dev/null +++ b/testsuite/java_test/string_test/RT0006-rt-String-BufferCodePointExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferCodePointExceptionTest) +run(StringBufferCodePointExceptionTest) diff --git a/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/StringBufferCapacityAndEnsureCapacityTest.java b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/StringBufferCapacityAndEnsureCapacityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2382933242e43547715d406ee9ed8869353e1dbd --- /dev/null +++ b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/StringBufferCapacityAndEnsureCapacityTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferCapacityAndEnsureCapacityTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferCapacityAndEnsureCapacityTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferCapacityAndEnsureCapacityTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=" + + "!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test1(strBuffer1_4); + test1(strBuffer1_5); + } + private static void test1(StringBuffer strBuffer) { + System.out.println("1-capacity: " + strBuffer.capacity()); + System.out.println("1-lent: " + strBuffer.length()); + strBuffer = strBuffer.append("01234567890123456789"); + System.out.println("2-capacity: " + strBuffer.capacity()); + System.out.println("2-lent: " + strBuffer.length()); + strBuffer.ensureCapacity(80); + System.out.println("3-capacity: " + strBuffer.capacity()); + System.out.println("3-lent: " + strBuffer.length()); + strBuffer.setLength(100); + System.out.println("4-capacity: " + strBuffer.capacity()); + System.out.println("4-lent: " + strBuffer.length()); + strBuffer.trimToSize(); + System.out.println("5-capacity: " + strBuffer.capacity()); + System.out.println("5-lent: " + strBuffer.length()); + // Test minimumCapacity < 0. + strBuffer.ensureCapacity(-2); + System.out.println("6-capacity: " + strBuffer.capacity()); + System.out.println("6-lent: " + strBuffer.length()); + // Test minimumCapacity = 0. + strBuffer.ensureCapacity(0); + System.out.println("7-capacity: " + strBuffer.capacity()); + System.out.println("7-lent: " + strBuffer.length()); + // Test minimumCapacity > 0. + strBuffer.ensureCapacity(2); + System.out.println("8-capacity: " + strBuffer.capacity()); + System.out.println("8-lent: " + strBuffer.length()); + } +} diff --git a/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/expected.txt b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c48dadafe4dd4162136bb019b7323b25c8c9e36d --- /dev/null +++ b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/expected.txt @@ -0,0 +1,81 @@ +1-capacity: 115 +1-lent: 99 +2-capacity: 232 +2-lent: 119 +3-capacity: 232 +3-lent: 119 +4-capacity: 232 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 25 +1-lent: 9 +2-capacity: 52 +2-lent: 29 +3-capacity: 106 +3-lent: 29 +4-capacity: 106 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 22 +1-lent: 6 +2-capacity: 46 +2-lent: 26 +3-capacity: 94 +3-lent: 26 +4-capacity: 190 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 16 +1-lent: 0 +2-capacity: 34 +2-lent: 20 +3-capacity: 80 +3-lent: 20 +4-capacity: 162 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 16 +1-lent: 0 +2-capacity: 34 +2-lent: 20 +3-capacity: 80 +3-lent: 20 +4-capacity: 162 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +0 diff --git a/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/test.cfg b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..39c009b467a8d53ddc3cb37a9a6872411e70f85a --- /dev/null +++ b/testsuite/java_test/string_test/RT0007-rt-String-BufferCapacityAndEnsureCapacityTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferCapacityAndEnsureCapacityTest) +run(StringBufferCapacityAndEnsureCapacityTest) diff --git a/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/StringBufferCharAtAndSetCharAtExceptionTest.java b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/StringBufferCharAtAndSetCharAtExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f33b1ac2fbea53f3a5cf8ab59a86dc23a9d5c817 --- /dev/null +++ b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/StringBufferCharAtAndSetCharAtExceptionTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferCharAtAndSetCharAtExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferCharAtAndSetCharAtExceptionTest_1(); + StringBufferCharAtAndSetCharAtExceptionTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferCharAtAndSetCharAtExceptionTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=" + + "!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test1(strBuffer1_4); + } + public static void StringBufferCharAtAndSetCharAtExceptionTest_2() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + test2(strBuffer1_1); + test2(strBuffer1_2); + test2(strBuffer1_3); + test2(strBuffer1_4); + } + // Test method char charAt(int index). + private static void test1(StringBuffer strBuffer) { + int charAt = 0; + for (int i = -1; i < 8; i++) { + try { + charAt = strBuffer.charAt(i); + System.out.println("i=" + i + " " + "charAt=" + charAt); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("index: " + i + " String index out of range"); + } + } + } + // Test Method void setCharAt(int index, char ch). + private static void test2(StringBuffer strBuffer) { + char ch = 'A'; + for (int i = -1; i < 8; i++) { + try { + strBuffer.setCharAt(i, ch); + System.out.println("i=" + i + " " + "setcharAt=" + strBuffer); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("index: " + i + " String index out of range"); + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..840ff10d47566081b5877e2c900fcd39fa274d8d --- /dev/null +++ b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/expected.txt @@ -0,0 +1,73 @@ +index: -1 String index out of range +i=0 charAt=113 +i=1 charAt=119 +i=2 charAt=101 +i=3 charAt=114 +i=4 charAt=116 +i=5 charAt=121 +i=6 charAt=117 +i=7 charAt=105 +index: -1 String index out of range +i=0 charAt=32 +i=1 charAt=64 +i=2 charAt=33 +i=3 charAt=46 +i=4 charAt=38 +i=5 charAt=37 +i=6 charAt=40 +i=7 charAt=41 +index: -1 String index out of range +i=0 charAt=97 +i=1 charAt=98 +i=2 charAt=99 +i=3 charAt=49 +i=4 charAt=50 +i=5 charAt=51 +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +index: 0 String index out of range +index: 1 String index out of range +index: 2 String index out of range +index: 3 String index out of range +index: 4 String index out of range +index: 5 String index out of range +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +i=0 setcharAt=Awertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=1 setcharAt=AAertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=2 setcharAt=AAArtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=3 setcharAt=AAAAtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=4 setcharAt=AAAAAyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=5 setcharAt=AAAAAAuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=6 setcharAt=AAAAAAAiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=7 setcharAt=AAAAAAAAop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +index: -1 String index out of range +i=0 setcharAt=A@!.&%()* +i=1 setcharAt=AA!.&%()* +i=2 setcharAt=AAA.&%()* +i=3 setcharAt=AAAA&%()* +i=4 setcharAt=AAAAA%()* +i=5 setcharAt=AAAAAA()* +i=6 setcharAt=AAAAAAA)* +i=7 setcharAt=AAAAAAAA* +index: -1 String index out of range +i=0 setcharAt=Abc123 +i=1 setcharAt=AAc123 +i=2 setcharAt=AAA123 +i=3 setcharAt=AAAA23 +i=4 setcharAt=AAAAA3 +i=5 setcharAt=AAAAAA +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +index: 0 String index out of range +index: 1 String index out of range +index: 2 String index out of range +index: 3 String index out of range +index: 4 String index out of range +index: 5 String index out of range +index: 6 String index out of range +index: 7 String index out of range +0 diff --git a/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6f15b02827d6ca20e00eedafe0618a67eb372a25 --- /dev/null +++ b/testsuite/java_test/string_test/RT0008-rt-String-BufferCharAtAndSetCharAtExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferCharAtAndSetCharAtExceptionTest) +run(StringBufferCharAtAndSetCharAtExceptionTest) diff --git a/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/StringBufferGetCharsTest.java b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/StringBufferGetCharsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..add48d677d4f0aa6fce4cef2ce1cb8dbe5af5096 --- /dev/null +++ b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/StringBufferGetCharsTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferGetCharsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferGetCharsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferGetCharsTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123"); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + } + private static void test1(StringBuffer strBuffer) { + // Test srcBegin < srcEnd < instance.length, dstBegin < dst(char[]).length. + char[] dst = {'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(2, 5, dst, 2); + System.out.println(dst); + // Test srcBegin = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(0, 3, dst, 2); + System.out.println(dst); + // Test srcEnd = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(0, 0, dst, 2); + System.out.println(dst); + // Test dstBegin = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(2, 5, dst, 0); + System.out.println(dst); + // Test srcBegin = srcEnd. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(2, 2, dst, 0); + System.out.println(dst); + // Test srcBegin = strBuffer.length() - 1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + int index = strBuffer.length() - 1; + strBuffer.getChars(index, index, dst, 0); + System.out.println(dst); + // Test srcEnd = strBuffer.length() - 1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(index - 2, index, dst, 0); + System.out.println(dst); + // Test dstBegin = dst.length - 1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuffer.getChars(0, 1, dst, dst.length - 1); + System.out.println(dst); + } +} diff --git a/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/expected.txt b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c54226f3fc5f75d4cc44f30c2c2f705e3ac7dca5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/expected.txt @@ -0,0 +1,25 @@ +ABertF +ABqweF +ABCDEF +ertDEF +ABCDEF +ABCDEF +x9CDEF +ABCDEq +AB!.&F +AB @!F +ABCDEF +!.&DEF +ABCDEF +ABCDEF +()CDEF +ABCDE +ABc12F +ABabcF +ABCDEF +c12DEF +ABCDEF +ABCDEF +12CDEF +ABCDEa +0 diff --git a/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/test.cfg b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bf178b988c67fe70b352e24d3df75d1712ea9349 --- /dev/null +++ b/testsuite/java_test/string_test/RT0009-rt-String-BufferGetCharsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferGetCharsTest) +run(StringBufferGetCharsTest) diff --git a/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/StringBufferIndexOfAndLastIndexOfTest.java b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/StringBufferIndexOfAndLastIndexOfTest.java new file mode 100644 index 0000000000000000000000000000000000000000..849969450f3f4a8fc5c888ec7acb5c68242fa06a --- /dev/null +++ b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/StringBufferIndexOfAndLastIndexOfTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferIndexOfAndLastIndexOfTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferIndexOfAndLastIndexOfTest_1(); + StringBufferIndexOfAndLastIndexOfTest_2(); + StringBufferIndexOfAndLastIndexOfTest_3(); + StringBufferIndexOfAndLastIndexOfTest_4(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferIndexOfAndLastIndexOfTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test1(strBuffer1_4); + test1(strBuffer1_5); + } + public static void StringBufferIndexOfAndLastIndexOfTest_2() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test2(strBuffer1_1); + test2(strBuffer1_2); + test2(strBuffer1_3); + test2(strBuffer1_4); + test2(strBuffer1_5); + } + public static void StringBufferIndexOfAndLastIndexOfTest_3() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test3(strBuffer1_1); + test3(strBuffer1_2); + test3(strBuffer1_3); + test3(strBuffer1_4); + test3(strBuffer1_5); + } + public static void StringBufferIndexOfAndLastIndexOfTest_4() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test4(strBuffer1_1); + test4(strBuffer1_2); + test4(strBuffer1_3); + test4(strBuffer1_4); + test4(strBuffer1_5); + } + // Test method indexOf(String str). + private static void test1(StringBuffer strBuffer) { + System.out.println(strBuffer.indexOf("b")); + // Test empty String. + System.out.println(strBuffer.indexOf("")); + } + // Test method indexOf(String str, int fromIndex). + private static void test2(StringBuffer strBuffer) { + System.out.println(strBuffer.indexOf("b", 2)); + // Test fromIndex = 0. + System.out.println(strBuffer.indexOf("b", 0)); + // Test fromIndex = strBuffer.length() - 1. + System.out.println(strBuffer.indexOf("6", strBuffer.length() - 1)); + } + // Test method lastIndexOf(String str). + private static void test3(StringBuffer strBuffer) { + System.out.println(strBuffer.lastIndexOf("b")); + // Test empty String. + System.out.println(strBuffer.lastIndexOf("")); + } + // Test method lastIndexOf(String str, int fromIndex). + private static void test4(StringBuffer strBuffer) { + System.out.println(strBuffer.lastIndexOf("b", 1)); + // Test fromIndex = 0. + System.out.println(strBuffer.lastIndexOf("b", 0)); + // Test fromIndex = strBuffer.length() - 1. + System.out.println(strBuffer.lastIndexOf("6", strBuffer.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/expected.txt b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0066aba90dfe722d59df5941108f3589aeeff117 --- /dev/null +++ b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/expected.txt @@ -0,0 +1,51 @@ +33 +0 +-1 +0 +1 +0 +-1 +0 +-1 +0 +33 +33 +98 +-1 +-1 +-1 +7 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +33 +99 +-1 +9 +7 +9 +-1 +0 +-1 +0 +-1 +-1 +98 +-1 +-1 +-1 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/test.cfg b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..973172e393ab91a1eb165b5a70dd2081121a71a7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0010-rt-String-BufferIndexOfAndLastIndexOfTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferIndexOfAndLastIndexOfTest) +run(StringBufferIndexOfAndLastIndexOfTest) diff --git a/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/StringBufferReplaceAndReverseTest.java b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/StringBufferReplaceAndReverseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f9fde8db642b27a82adc26413b29242ec97c2199 --- /dev/null +++ b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/StringBufferReplaceAndReverseTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferReplaceAndReverseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferReplaceAndReverseTest_1(); + StringBufferReplaceAndReverseTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferReplaceAndReverseTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + } + public static void StringBufferReplaceAndReverseTest_2() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test2(strBuffer1_1); + test2(strBuffer1_2); + test2(strBuffer1_3); + test2(strBuffer1_4); + test2(strBuffer1_5); + } + // Test method replace(int start, int end, String str). + private static void test1(StringBuffer strBuffer) { + System.out.println(strBuffer.replace(2, 6, "xyz")); + // end = 0 + System.out.println(strBuffer.replace(0, 0, "xyz")); + // start = 0 & end = strBuffer.length() + System.out.println(strBuffer.replace(0, strBuffer.length(), "xyz")); + // start = strBuffer.length() & end = strBuffer.length() + System.out.println(strBuffer.replace(strBuffer.length(), strBuffer.length(), "xyz")); + } + // Test method reverse(). + private static void test2(StringBuffer strBuffer) { + strBuffer.reverse(); + System.out.println(strBuffer); + } +} diff --git a/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/expected.txt b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..92a847590bc368b34e8fc0ea0eeeac29ed5fa3b3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/expected.txt @@ -0,0 +1,18 @@ +qwxyzuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +xyzqwxyzuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +xyz +xyzxyz + @xyz +xyz @xyz +xyz +xyzxyz +abxyzabc +xyzabxyzabc +xyz +xyzxyz +69x0MNBVCXZPOIUYTREWQLKJHGFDSA +_)(*&^%$#@!=-0987654321`~?/><.,mnbvcxz"':;lkjhgfdsa|\][}{poiuytrewq +%&.!@ +cba321cba + + +0 diff --git a/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/test.cfg b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9f38ad34c330aa85f79e3858bb649d9bab457fc4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0011-rt-String-BufferReplaceAndReverseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferReplaceAndReverseTest) +run(StringBufferReplaceAndReverseTest) diff --git a/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/StringBufferSubstringAndToStringTest.java b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/StringBufferSubstringAndToStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2fb41a8665066a79453c1a8ac353270998e48ac1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/StringBufferSubstringAndToStringTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferSubstringAndToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBufferSubstringAndToStringTest_1(); + StringBufferSubstringAndToStringTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBufferSubstringAndToStringTest_1() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%()*"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + test1(strBuffer1_1); + test1(strBuffer1_2); + test1(strBuffer1_3); + test2(strBuffer1_1); + test2(strBuffer1_2); + test2(strBuffer1_3); + } + public static void StringBufferSubstringAndToStringTest_2() { + StringBuffer strBuffer1_1 = new StringBuffer("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuffer strBuffer1_2 = new StringBuffer(" @!.&%"); + StringBuffer strBuffer1_3 = new StringBuffer("abc123abc"); + StringBuffer strBuffer1_4 = new StringBuffer(""); + StringBuffer strBuffer1_5 = new StringBuffer(); + test3(strBuffer1_1); + test3(strBuffer1_2); + test3(strBuffer1_3); + test3(strBuffer1_4); + test3(strBuffer1_5); + } + // Test method substring(int start, int end). + private static void test1(StringBuffer strBuffer) { + System.out.println(strBuffer.substring(2, 7)); + // Test start = 0 & end = strBuffer.length(). + System.out.println(strBuffer.substring(0, strBuffer.length())); + // Test start = strBuffer.length(). + System.out.println(strBuffer.substring(strBuffer.length(), strBuffer.length())); + // Test end = 0. + System.out.println(strBuffer.substring(0, 0)); + } + // Test method substring(int start). + private static void test2(StringBuffer strBuffer) { + System.out.println(strBuffer.substring(3)); + // Test start = 0. + System.out.println(strBuffer.substring(0)); + // Test start = strBuffer.length(). + System.out.println(strBuffer.substring(strBuffer.length())); + } + // Test method toString(). + private static void test3(StringBuffer strBuffer) { + System.out.println(strBuffer.toString()); + } +} diff --git a/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/expected.txt b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..341d348f0ed007510ecf6f11c43ef25541d860fa --- /dev/null +++ b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/expected.txt @@ -0,0 +1,27 @@ +ertyu +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +!.&%( + @!.&%()* + + +c123a +abc123abc + + +rtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + +.&%()* + @!.&%()* + +123abc +abc123abc + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123abc + + +0 diff --git a/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/test.cfg b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2cbc723ff4be5b400e2f96bc686f06c6076de928 --- /dev/null +++ b/testsuite/java_test/string_test/RT0012-rt-String-BufferSubstringAndToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferSubstringAndToStringTest) +run(StringBufferSubstringAndToStringTest) diff --git a/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/StringBuilderConstructorsTest.java b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/StringBuilderConstructorsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..83a349411cbaec12ea27562c28b7e256efc1902d --- /dev/null +++ b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/StringBuilderConstructorsTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderConstructorsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderConstructorsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderConstructorsTest_1() { + String str1_1 = new String("abc123abc"); + String str1_2 = new String(" @!.&%()*"); + String str1_3 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "abc123ABC"; + String str2_2 = " @!.&%()*"; + String str2_3 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZX" + + "CVBNM0x96"; + String str2_4 = ""; + test1_1(str1_1); + test1_1(str1_2); + test1_1(str1_3); + test1_1(str1_4); + test1_1(str1_5); + test1_1(str2_1); + test1_1(str2_2); + test1_1(str2_3); + test1_1(str2_4); + StringBuilder strBuilder1_1 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%"); + StringBuilder strBuilder1_3 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=" + + "!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test1_2(strBuilder1_1); + test1_2(strBuilder1_2); + test1_2(strBuilder1_3); + test1_2(strBuilder1_4); + test1_2(strBuilder1_5); + // Test new StringBuilder() + test1_3(); + // Test new StringBuilder(int capacity) + test1_4(); + // Test new StringBuilder(CharSequence seq) + test1_5(); + } + private static void test1_1(String str) { + System.out.println(new StringBuilder(str)); + } + private static void test1_2(StringBuilder strBuilder) { + System.out.println(strBuilder.toString()); + } + private static void test1_3() { + StringBuilder strBuilder1_6 = new StringBuilder(); + System.out.println(strBuilder1_6.capacity()); + } + private static void test1_4() { + int capacity = 20; + StringBuilder strBuilder1_6 = new StringBuilder(capacity); + System.out.println(strBuilder1_6.capacity()); + int capacityMin = 0; + strBuilder1_6 = new StringBuilder(capacityMin); + System.out.println(strBuilder1_6.capacity()); + } + private static void test1_5() { + CharSequence chs1_1 = "xyz"; + StringBuilder strBuilder1_7 = new StringBuilder(chs1_1); + test1_2(strBuilder1_7); + } +} diff --git a/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/expected.txt b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..3e4668a77c4583366eaca1433e269af55aaa2a74 --- /dev/null +++ b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/expected.txt @@ -0,0 +1,19 @@ +abc123abc + @!.&%()* +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +abc123ABC + @!.&%()* +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + +abc123abc + @!.&% +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +16 +20 +0 +xyz +0 diff --git a/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/test.cfg b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5b8aa53c3bb4a0e994400d4e4fd91d2ebe7beefd --- /dev/null +++ b/testsuite/java_test/string_test/RT0013-rt-String-BuilderConstructorsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderConstructorsTest) +run(StringBuilderConstructorsTest) diff --git a/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/StringBuilderAppendAndAppendCodePointTest.java b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/StringBuilderAppendAndAppendCodePointTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f2a3340f7b0746b3ca9f27852ae27df65f373092 --- /dev/null +++ b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/StringBuilderAppendAndAppendCodePointTest.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderAppendAndAppendCodePointTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderAppendAndAppendCodePointTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderAppendAndAppendCodePointTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_2 = new StringBuilder(" "); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test1(strBuilder1_4); + test1(strBuilder1_5); + } + private static void test1(StringBuilder strBuilder) { + char c = 'C'; + char[] data = {'A', 'B', 'C'}; + CharSequence chs1_1 = "xyz"; + Object obj = new String("object"); + String str = "string"; + double d = 8888.8888; + double dMin = 0; + float f = 99999999; + float fMin = 0; + int i = 77777777; + int iMin = 0; + long lng = 66666666; + long lngMin = 0; + StringBuilder sb = new StringBuilder("StringBuilder"); + int codePoint = 74; // unicode 74 is J + System.out.println(strBuilder.append("-").append(true).append("-").append(false).append("-").append(c) + .append("-").append(data).append("-").append(chs1_1).append("-").append(chs1_1, 1, 2).append("-") + .append(chs1_1, 0, 3).append("-").append(chs1_1, 3, 3).append("-").append(chs1_1, 0, 0).append("-") + .append(d).append("-").append(dMin).append("-").append(f).append("-").append(fMin).append("-").append(i) + .append("-").append(iMin).append("-").append(lng).append("-").append(lngMin).append("-").append(obj) + .append("-").append(str).append("-").append(sb).append("-").appendCodePoint(codePoint)); + System.out.println(strBuilder.subSequence(2, 8)); + } +} diff --git a/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/expected.txt b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c28af3e1c59ffb4f1d04a49920f6164eb43ced44 --- /dev/null +++ b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/expected.txt @@ -0,0 +1,11 @@ +abc123abc-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-StringBuilder-J +c123ab + -true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-StringBuilder-J + -t +abc123abc-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-StringBuilder-J +c123ab +-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-StringBuilder-J +rue-fa +-true-false-C-ABC-xyz-y-xyz---8888.8888-0.0-1.0E8-0.0-77777777-0-66666666-0-object-string-StringBuilder-J +rue-fa +0 diff --git a/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/test.cfg b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0f388de347bb1e12af11ab268740abac863e2ff4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0014-rt-String-BuilderAppendAndAppendCodePointTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderAppendAndAppendCodePointTest) +run(StringBuilderAppendAndAppendCodePointTest) diff --git a/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/StringBuilderInsertTest.java b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/StringBuilderInsertTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d6b10e5e8c711fa4bd8c96f813fd04d811245bdf --- /dev/null +++ b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/StringBuilderInsertTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderInsertTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderInsertTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderInsertTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test1(strBuilder1_4); + test1(strBuilder1_5); + } + private static void test1(StringBuilder strBuilder) { + char c = 'C'; + char[] data = {'A', 'B', 'C'}; + CharSequence chs1_1 = "xyz"; + double d = 8888.8888; + double dMin = 0; + float f = 99999999; + float fMin = 0; + int i = 77777777; + int iMin = 0; + long lng = 66666666; + long lngMin = 0; + Object obj = new String("object"); + String str = "-"; + System.out.println(strBuilder.insert(0, str).insert(1, true).insert(strBuilder.length(), str) + .insert(strBuilder.length(), true).insert(0, str).insert(0, false).insert(strBuilder.length(), str) + .insert(strBuilder.length(), false).insert(0, str).insert(0, c).insert(strBuilder.length(), str) + .insert(strBuilder.length(), c).insert(0, str).insert(0, data).insert(strBuilder.length(), str) + .insert(strBuilder.length(), data).insert(0, str).insert(0, chs1_1).insert(strBuilder.length(), str) + .insert(strBuilder.length(), chs1_1).insert(0, str).insert(0, chs1_1, 1, 2) + .insert(strBuilder.length(), str).insert(strBuilder.length(), chs1_1, 1, 2).insert(0, str) + .insert(0, chs1_1, 0, 3).insert(strBuilder.length(), str).insert(strBuilder.length(), chs1_1, 0, 3) + .insert(0, str).insert(0, chs1_1, 3, 3).insert(strBuilder.length(), str) + .insert(strBuilder.length(), chs1_1, 3, 3).insert(0, str).insert(0, chs1_1, 0, 0) + .insert(strBuilder.length(), str).insert(strBuilder.length(), chs1_1, 0, 0).insert(0, str).insert(0, d) + .insert(strBuilder.length(), str).insert(strBuilder.length(), d).insert(0, str).insert(0, dMin) + .insert(0, str).insert(0, f).insert(strBuilder.length(), str).insert(strBuilder.length(), f) + .insert(0, str).insert(0, fMin).insert(0, str).insert(0, i).insert(strBuilder.length(), str) + .insert(strBuilder.length(), i).insert(0, str).insert(0, iMin).insert(0, str).insert(0, lng) + .insert(strBuilder.length(), str).insert(strBuilder.length(), lng).insert(0, str).insert(0, lngMin) + .insert(0, str).insert(0, obj).insert(strBuilder.length(), str).insert(strBuilder.length(), obj)); + System.out.println(strBuilder.subSequence(2, 8)); + } +} diff --git a/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/expected.txt b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eabd3a35ca68e31a58d9ad14bbb76bf74921e3e6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/expected.txt @@ -0,0 +1,11 @@ +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false--trueqwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false--true @!.&%()*-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false--trueabc123abc-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false--true-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +object-0-66666666-0-77777777-0.0-1.0E8-0.0-8888.8888---xyz-y-xyz-ABC-C-false--true-true-false-C-ABC-xyz-y-xyz---8888.8888-1.0E8-77777777-66666666-object +ject-0 +0 diff --git a/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/test.cfg b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c52b096bf9560a22e126aecda12ad8319516457f --- /dev/null +++ b/testsuite/java_test/string_test/RT0015-rt-String-BuilderInsertTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderInsertTest) +run(StringBuilderInsertTest) diff --git a/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/StringBuilderDeleteAndDeleteCharAtTest.java b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/StringBuilderDeleteAndDeleteCharAtTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a165f56886639d9c0ba3c421efa60fff9fac18c6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/StringBuilderDeleteAndDeleteCharAtTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderDeleteAndDeleteCharAtTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderDeleteAndDeleteCharAtTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderDeleteAndDeleteCharAtTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder2_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder2_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder2_3 = new StringBuilder("abc123abc"); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test2(strBuilder2_1); + test2(strBuilder2_2); + test2(strBuilder2_3); + } + // Test method delete(int start, int end). + private static void test1(StringBuilder strBuilder) { + // Test 0 < start < end, end < strBuffer.length(). + System.out.println(strBuilder.delete(3, 5)); + // Test start = 0. + System.out.println(strBuilder.delete(0, 1)); + // Test end = 0. + System.out.println(strBuilder.delete(0, 0)); + // Test start=strBuffer.length(). + System.out.println(strBuilder.delete(strBuilder.length(), strBuilder.length())); + // Test end=strBuffer.length(). + System.out.println(strBuilder.delete(2, strBuilder.length())); + } + // Test method deleteCharAt(int index). + private static void test2(StringBuilder strBuilder) { + // Test 0 < index < strBuffer.length(). + System.out.println(strBuilder.deleteCharAt(1)); + // Test index = 0. + System.out.println(strBuilder.deleteCharAt(0)); + // Test index = strBuffer.length()-1. + System.out.println(strBuilder.deleteCharAt(strBuilder.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/expected.txt b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..eddc3aea49e0fce935a0956369a14d37ad1740c1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/expected.txt @@ -0,0 +1,25 @@ +qweyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +weyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +we + @!%()* +@!%()* +@!%()* +@!%()* +@! +abc3abc +bc3abc +bc3abc +bc3abc +bc +qertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x9 + !.&%()* +!.&%()* +!.&%() +ac123abc +c123abc +c123ab +0 diff --git a/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/test.cfg b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..7e28eeb076ed7f3ef566040cbbd1d567696b5d50 --- /dev/null +++ b/testsuite/java_test/string_test/RT0016-rt-String-BuilderDeleteAndDeleteCharAtTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderDeleteAndDeleteCharAtTest) +run(StringBuilderDeleteAndDeleteCharAtTest) diff --git a/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/StringBuilderCodePointExceptionTest.java b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/StringBuilderCodePointExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cdd2c55a64d0e8e905f956e6a891f19b0ff1bb68 --- /dev/null +++ b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/StringBuilderCodePointExceptionTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderCodePointExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderCodePointExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderCodePointExceptionTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`123456789" + + "0-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123"); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test2(strBuilder1_1); + test2(strBuilder1_2); + test2(strBuilder1_3); + test3(strBuilder1_1); + test3(strBuilder1_2); + test3(strBuilder1_3); + test4(strBuilder1_1); + test4(strBuilder1_2); + test4(strBuilder1_3); + } + // Test method codePointAt(int index). + private static void test1(StringBuilder strBuilder) { + int codePoint = 0; + for (int i = 0; i < 6; i++) { + try { + codePoint = strBuilder.codePointAt(i); + System.out.println("i=" + i + " " + "codePointAt=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointAt(): " + i + "out of length"); + } finally { + try { + System.out.println(strBuilder.charAt(i) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method codePointBefore(int index). + private static void test2(StringBuilder strBuilder) { + int codePoint = 0; + for (int i = 0; i < 6; i++) { + try { + codePoint = strBuilder.codePointBefore(i); + System.out.println("i=" + i + " " + "codePointBefore=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointBefore(): " + i + "out of length"); + } finally { + try { + System.out.println(strBuilder.charAt(i - 1) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method codePointCount(int beginIndex, int endIndex). + private static void test3(StringBuilder strBuilder) { + int codePoint = 0; + for (int i = 0; i < 4; i++) { + try { + codePoint = strBuilder.codePointCount(i, i + 3); + System.out.println("i=" + i + " " + "codePointCount=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("codePointCount(): " + i + " out of length"); + } finally { + try { + System.out.println(strBuilder.charAt(i) + "~" + strBuilder.charAt(i + 3) + + " codePointCount is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println(i + " out of length"); + } + } + } + } + // Test method int offsetByCodePoints(int index, int codePointOffset). + private static void test4(StringBuilder strBuilder) { + int codePoint = 0; + for (int i = 0; i < 4; i++) { + try { + codePoint = strBuilder.offsetByCodePoints(i, i + 3); + System.out.println("i=" + i + " " + "offsetByCodePoints=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("offsetByCodePoints(): " + i + "+3 out of length"); + } finally { + try { + System.out.println(strBuilder.charAt(i) + " offsetByCodePoints +3 is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd0e884408537cba05c2fe7bf7455a5266848862 --- /dev/null +++ b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/expected.txt @@ -0,0 +1,121 @@ +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=113 +q Unicode is:113 +i=2 codePointBefore=119 +w Unicode is:119 +i=3 codePointBefore=101 +e Unicode is:101 +i=4 codePointBefore=114 +r Unicode is:114 +i=5 codePointBefore=116 +t Unicode is:116 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=32 + Unicode is:32 +i=2 codePointBefore=64 +@ Unicode is:64 +i=3 codePointBefore=33 +! Unicode is:33 +i=4 codePointBefore=46 +. Unicode is:46 +i=5 codePointBefore=38 +& Unicode is:38 +codePointBefore(): 0out of length +0 out of length +i=1 codePointBefore=97 +a Unicode is:97 +i=2 codePointBefore=98 +b Unicode is:98 +i=3 codePointBefore=99 +c Unicode is:99 +i=4 codePointBefore=49 +1 Unicode is:49 +i=5 codePointBefore=50 +2 Unicode is:50 +i=0 codePointCount=3 +q~r codePointCount is :3 +i=1 codePointCount=3 +w~t codePointCount is :3 +i=2 codePointCount=3 +e~y codePointCount is :3 +i=3 codePointCount=3 +r~u codePointCount is :3 +i=0 codePointCount=3 + ~. codePointCount is :3 +i=1 codePointCount=3 +@~& codePointCount is :3 +i=2 codePointCount=3 +!~% codePointCount is :3 +i=3 codePointCount=3 +3 out of length +i=0 codePointCount=3 +a~1 codePointCount is :3 +i=1 codePointCount=3 +b~2 codePointCount is :3 +i=2 codePointCount=3 +c~3 codePointCount is :3 +i=3 codePointCount=3 +3 out of length +i=0 offsetByCodePoints=3 +q offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints +3 is :5 +i=2 offsetByCodePoints=7 +e offsetByCodePoints +3 is :7 +i=3 offsetByCodePoints=9 +r offsetByCodePoints +3 is :9 +i=0 offsetByCodePoints=3 + offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints +3 is :5 +offsetByCodePoints(): 2+3 out of length +! offsetByCodePoints +3 is :5 +offsetByCodePoints(): 3+3 out of length +. offsetByCodePoints +3 is :5 +i=0 offsetByCodePoints=3 +a offsetByCodePoints +3 is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints +3 is :5 +offsetByCodePoints(): 2+3 out of length +c offsetByCodePoints +3 is :5 +offsetByCodePoints(): 3+3 out of length +1 offsetByCodePoints +3 is :5 +0 diff --git a/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..315b15ddf3f389c4b0f3f1addcd99a6a75661158 --- /dev/null +++ b/testsuite/java_test/string_test/RT0017-rt-String-BuilderCodePointExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderCodePointExceptionTest) +run(StringBuilderCodePointExceptionTest) diff --git a/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/StringBuilderCapacityAndEnsureCapacityTest.java b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/StringBuilderCapacityAndEnsureCapacityTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a8000bd6dae178779e200636d77b7ab22678a032 --- /dev/null +++ b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/StringBuilderCapacityAndEnsureCapacityTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderCapacityAndEnsureCapacityTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderCapacityAndEnsureCapacityTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderCapacityAndEnsureCapacityTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test1(strBuilder1_4); + test1(strBuilder1_5); + } + private static void test1(StringBuilder strBuilder) { + System.out.println("1-capacity: " + strBuilder.capacity()); + System.out.println("1-lent: " + strBuilder.length()); + strBuilder = strBuilder.append("01234567890123456789"); + System.out.println("2-capacity: " + strBuilder.capacity()); + System.out.println("2-lent: " + strBuilder.length()); + strBuilder.ensureCapacity(80); + System.out.println("3-capacity: " + strBuilder.capacity()); + System.out.println("3-lent: " + strBuilder.length()); + strBuilder.setLength(100); + System.out.println("4-capacity: " + strBuilder.capacity()); + System.out.println("4-lent: " + strBuilder.length()); + strBuilder.trimToSize(); + System.out.println("5-capacity: " + strBuilder.capacity()); + System.out.println("5-lent: " + strBuilder.length()); + strBuilder.ensureCapacity(-2); + System.out.println("6-capacity: " + strBuilder.capacity()); + System.out.println("6-lent: " + strBuilder.length()); + strBuilder.ensureCapacity(0); + System.out.println("7-capacity: " + strBuilder.capacity()); + System.out.println("7-lent: " + strBuilder.length()); + strBuilder.ensureCapacity(2); + System.out.println("8-capacity: " + strBuilder.capacity()); + System.out.println("8-lent: " + strBuilder.length()); + } +} diff --git a/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/expected.txt b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c48dadafe4dd4162136bb019b7323b25c8c9e36d --- /dev/null +++ b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/expected.txt @@ -0,0 +1,81 @@ +1-capacity: 115 +1-lent: 99 +2-capacity: 232 +2-lent: 119 +3-capacity: 232 +3-lent: 119 +4-capacity: 232 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 25 +1-lent: 9 +2-capacity: 52 +2-lent: 29 +3-capacity: 106 +3-lent: 29 +4-capacity: 106 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 22 +1-lent: 6 +2-capacity: 46 +2-lent: 26 +3-capacity: 94 +3-lent: 26 +4-capacity: 190 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 16 +1-lent: 0 +2-capacity: 34 +2-lent: 20 +3-capacity: 80 +3-lent: 20 +4-capacity: 162 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +1-capacity: 16 +1-lent: 0 +2-capacity: 34 +2-lent: 20 +3-capacity: 80 +3-lent: 20 +4-capacity: 162 +4-lent: 100 +5-capacity: 100 +5-lent: 100 +6-capacity: 100 +6-lent: 100 +7-capacity: 100 +7-lent: 100 +8-capacity: 100 +8-lent: 100 +0 diff --git a/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/test.cfg b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..18a16e140202fd1f77a38d7833b0ca2dc7c4c048 --- /dev/null +++ b/testsuite/java_test/string_test/RT0018-rt-String-BuilderCapacityAndEnsureCapacityTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderCapacityAndEnsureCapacityTest) +run(StringBuilderCapacityAndEnsureCapacityTest) diff --git a/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/StringBuilderCharAtAndSetCharAtExceptionTest.java b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/StringBuilderCharAtAndSetCharAtExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..42d5f22deb94e0787d2fbcbcd1df4a2d29e3b198 --- /dev/null +++ b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/StringBuilderCharAtAndSetCharAtExceptionTest.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderCharAtAndSetCharAtExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderCharAtAndSetCharAtExceptionTest_1(); + StringBuilderCharAtAndSetCharAtExceptionTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderCharAtAndSetCharAtExceptionTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test1(strBuilder1_4); + } + public static void StringBuilderCharAtAndSetCharAtExceptionTest_2() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + test2(strBuilder1_1); + test2(strBuilder1_2); + test2(strBuilder1_3); + test2(strBuilder1_4); + } + // Test method char charAt(int index). + private static void test1(StringBuilder strBuilder) { + int charAt = 0; + for (int i = -1; i < 8; i++) { + try { + charAt = strBuilder.charAt(i); + System.out.println("i=" + i + " " + "charAt=" + charAt); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("index: " + i + " String index out of range"); + } + } + } + // Test Method void setCharAt(int index, char ch). + private static void test2(StringBuilder strBuilder) { + char ch = 'A'; + for (int i = -1; i < 8; i++) { + try { + strBuilder.setCharAt(i, ch); + System.out.println("i=" + i + " " + "setcharAt=" + strBuilder); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("index: " + i + " String index out of range"); + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..840ff10d47566081b5877e2c900fcd39fa274d8d --- /dev/null +++ b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/expected.txt @@ -0,0 +1,73 @@ +index: -1 String index out of range +i=0 charAt=113 +i=1 charAt=119 +i=2 charAt=101 +i=3 charAt=114 +i=4 charAt=116 +i=5 charAt=121 +i=6 charAt=117 +i=7 charAt=105 +index: -1 String index out of range +i=0 charAt=32 +i=1 charAt=64 +i=2 charAt=33 +i=3 charAt=46 +i=4 charAt=38 +i=5 charAt=37 +i=6 charAt=40 +i=7 charAt=41 +index: -1 String index out of range +i=0 charAt=97 +i=1 charAt=98 +i=2 charAt=99 +i=3 charAt=49 +i=4 charAt=50 +i=5 charAt=51 +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +index: 0 String index out of range +index: 1 String index out of range +index: 2 String index out of range +index: 3 String index out of range +index: 4 String index out of range +index: 5 String index out of range +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +i=0 setcharAt=Awertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=1 setcharAt=AAertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=2 setcharAt=AAArtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=3 setcharAt=AAAAtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=4 setcharAt=AAAAAyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=5 setcharAt=AAAAAAuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=6 setcharAt=AAAAAAAiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +i=7 setcharAt=AAAAAAAAop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +index: -1 String index out of range +i=0 setcharAt=A@!.&%()* +i=1 setcharAt=AA!.&%()* +i=2 setcharAt=AAA.&%()* +i=3 setcharAt=AAAA&%()* +i=4 setcharAt=AAAAA%()* +i=5 setcharAt=AAAAAA()* +i=6 setcharAt=AAAAAAA)* +i=7 setcharAt=AAAAAAAA* +index: -1 String index out of range +i=0 setcharAt=Abc123 +i=1 setcharAt=AAc123 +i=2 setcharAt=AAA123 +i=3 setcharAt=AAAA23 +i=4 setcharAt=AAAAA3 +i=5 setcharAt=AAAAAA +index: 6 String index out of range +index: 7 String index out of range +index: -1 String index out of range +index: 0 String index out of range +index: 1 String index out of range +index: 2 String index out of range +index: 3 String index out of range +index: 4 String index out of range +index: 5 String index out of range +index: 6 String index out of range +index: 7 String index out of range +0 diff --git a/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..120b7e0546bb8825f1813a0159197db388763063 --- /dev/null +++ b/testsuite/java_test/string_test/RT0019-rt-String-BuilderCharAtAndSetCharAtExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderCharAtAndSetCharAtExceptionTest) +run(StringBuilderCharAtAndSetCharAtExceptionTest) diff --git a/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/StringBuilderGetCharsTest.java b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/StringBuilderGetCharsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..32a6ddaf29dbe84a743b9e435080d0480094af60 --- /dev/null +++ b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/StringBuilderGetCharsTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderGetCharsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderGetCharsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderGetCharsTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123"); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + } + private static void test1(StringBuilder strBuilder) { + // Test srcBegin < srcEnd < instance.length, dstBegin < dst(char[]).length. + char[] dst = {'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(2, 5, dst, 2); + System.out.println(dst); + // Test srcBegin = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(0, 3, dst, 2); + System.out.println(dst); + // Test srcEnd = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(0, 0, dst, 2); + System.out.println(dst); + // Test dstBegin = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(2, 5, dst, 0); + System.out.println(dst); + // Test strBuilder = srcEnd. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(2, 2, dst, 0); + System.out.println(dst); + // Test srcBegin = strBuffer.length() - 1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + int index = strBuilder.length() - 1; + strBuilder.getChars(index, index, dst, 0); + System.out.println(dst); + // Test srcEnd = strBuffer.length() - 1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(index - 2, index, dst, 0); + System.out.println(dst); + // Test dstBegin = dst.length-1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + strBuilder.getChars(0, 1, dst, dst.length - 1); + System.out.println(dst); + } +} diff --git a/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/expected.txt b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c54226f3fc5f75d4cc44f30c2c2f705e3ac7dca5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/expected.txt @@ -0,0 +1,25 @@ +ABertF +ABqweF +ABCDEF +ertDEF +ABCDEF +ABCDEF +x9CDEF +ABCDEq +AB!.&F +AB @!F +ABCDEF +!.&DEF +ABCDEF +ABCDEF +()CDEF +ABCDE +ABc12F +ABabcF +ABCDEF +c12DEF +ABCDEF +ABCDEF +12CDEF +ABCDEa +0 diff --git a/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/test.cfg b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bd3e110a2c7b73dd3b00edaa5b08119a6029cb29 --- /dev/null +++ b/testsuite/java_test/string_test/RT0020-rt-String-BuilderGetCharsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderGetCharsTest) +run(StringBuilderGetCharsTest) diff --git a/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/StringBuilderIndexOfAndLastIndexOfTest.java b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/StringBuilderIndexOfAndLastIndexOfTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e7cd4b75cabc72cf1996a2c946a2038fd216d2d --- /dev/null +++ b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/StringBuilderIndexOfAndLastIndexOfTest.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderIndexOfAndLastIndexOfTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderIndexOfAndLastIndexOfTest_1(); + StringBuilderIndexOfAndLastIndexOfTest_2(); + StringBuilderIndexOfAndLastIndexOfTest_3(); + StringBuilderIndexOfAndLastIndexOfTest_4(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderIndexOfAndLastIndexOfTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test1(strBuilder1_4); + test1(strBuilder1_5); + } + public static void StringBuilderIndexOfAndLastIndexOfTest_2() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test2(strBuilder1_1); + test2(strBuilder1_2); + test2(strBuilder1_3); + test2(strBuilder1_4); + test2(strBuilder1_5); + } + public static void StringBuilderIndexOfAndLastIndexOfTest_3() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test3(strBuilder1_1); + test3(strBuilder1_2); + test3(strBuilder1_3); + test3(strBuilder1_4); + test3(strBuilder1_5); + } + public static void StringBuilderIndexOfAndLastIndexOfTest_4() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test4(strBuilder1_1); + test4(strBuilder1_2); + test4(strBuilder1_3); + test4(strBuilder1_4); + test4(strBuilder1_5); + } + // Test method indexOf(String str). + private static void test1(StringBuilder strBuilder) { + System.out.println(strBuilder.indexOf("b")); + // Test empty String. + System.out.println(strBuilder.indexOf("")); + } + // Test method indexOf(String str, int fromIndex). + private static void test2(StringBuilder strBuilder) { + System.out.println(strBuilder.indexOf("b", 2)); + // Test fromIndex = 0. + System.out.println(strBuilder.indexOf("b", 0)); + // Test fromIndex = strBuilder.length() - 1. + System.out.println(strBuilder.indexOf("6", strBuilder.length() - 1)); + } + // Test method lastIndexOf(String str). + private static void test3(StringBuilder strBuilder) { + System.out.println(strBuilder.lastIndexOf("b")); + // Test empty String. + System.out.println(strBuilder.lastIndexOf("")); + } + // Test method lastIndexOf(String str, int fromIndex). + private static void test4(StringBuilder strBuilder) { + System.out.println(strBuilder.lastIndexOf("b", 1)); + // Test fromIndex = 0. + System.out.println(strBuilder.lastIndexOf("b", 0)); + // Test fromIndex = strBuilder.length() - 1. + System.out.println(strBuilder.lastIndexOf("6", strBuilder.length() - 1)); + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/expected.txt b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0066aba90dfe722d59df5941108f3589aeeff117 --- /dev/null +++ b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/expected.txt @@ -0,0 +1,51 @@ +33 +0 +-1 +0 +1 +0 +-1 +0 +-1 +0 +33 +33 +98 +-1 +-1 +-1 +7 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +33 +99 +-1 +9 +7 +9 +-1 +0 +-1 +0 +-1 +-1 +98 +-1 +-1 +-1 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/test.cfg b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..23202bae5f774d38f5f1e74bc9e69fcccca9cc13 --- /dev/null +++ b/testsuite/java_test/string_test/RT0021-rt-String-BuilderIndexOfAndLastIndexOfTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderIndexOfAndLastIndexOfTest) +run(StringBuilderIndexOfAndLastIndexOfTest) diff --git a/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/StringBuilderReplaceAndReverseTest.java b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/StringBuilderReplaceAndReverseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..0f5d0798dd3462fdf10cc4f8011b07449c0ee4a1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/StringBuilderReplaceAndReverseTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderReplaceAndReverseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderReplaceAndReverseTest_1(); + StringBuilderReplaceAndReverseTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderReplaceAndReverseTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + } + public static void StringBuilderReplaceAndReverseTest_2() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test2(strBuilder1_1); + test2(strBuilder1_2); + test2(strBuilder1_3); + test2(strBuilder1_4); + test2(strBuilder1_5); + } + // Test method replace(int start, int end, String str). + private static void test1(StringBuilder strBuilder) { + System.out.println(strBuilder.replace(2, 6, "xyz")); + // end = 0 + System.out.println(strBuilder.replace(0, 0, "xyz")); + // start = 0 & end = strBuffer.length() + System.out.println(strBuilder.replace(0, strBuilder.length(), "xyz")); + // start = strBuffer.length() & end = strBuffer.length() + System.out.println(strBuilder.replace(strBuilder.length(), strBuilder.length(), "xyz")); + } + // Test method reverse(). + private static void test2(StringBuilder strBuilder) { + strBuilder.reverse(); + System.out.println(strBuilder); + } +} diff --git a/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/expected.txt b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..92a847590bc368b34e8fc0ea0eeeac29ed5fa3b3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/expected.txt @@ -0,0 +1,18 @@ +qwxyzuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +xyzqwxyzuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +xyz +xyzxyz + @xyz +xyz @xyz +xyz +xyzxyz +abxyzabc +xyzabxyzabc +xyz +xyzxyz +69x0MNBVCXZPOIUYTREWQLKJHGFDSA +_)(*&^%$#@!=-0987654321`~?/><.,mnbvcxz"':;lkjhgfdsa|\][}{poiuytrewq +%&.!@ +cba321cba + + +0 diff --git a/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/test.cfg b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ef1088707d205c3db2cbaacd9c9bf921e93f1df5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0022-rt-String-BuilderReplaceAndReverseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderReplaceAndReverseTest) +run(StringBuilderReplaceAndReverseTest) diff --git a/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/StringBuilderSubstringAndToStringTest.java b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/StringBuilderSubstringAndToStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..81b210bd4a50f6fd1d08acb62183174914b78a21 --- /dev/null +++ b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/StringBuilderSubstringAndToStringTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderSubstringAndToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringBuilderSubstringAndToStringTest_1(); + StringBuilderSubstringAndToStringTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringBuilderSubstringAndToStringTest_1() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%()*"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + test1(strBuilder1_1); + test1(strBuilder1_2); + test1(strBuilder1_3); + test2(strBuilder1_1); + test2(strBuilder1_2); + test2(strBuilder1_3); + } + public static void StringBuilderSubstringAndToStringTest_2() { + StringBuilder strBuilder1_1 = new StringBuilder("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890" + + "-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + StringBuilder strBuilder1_2 = new StringBuilder(" @!.&%"); + StringBuilder strBuilder1_3 = new StringBuilder("abc123abc"); + StringBuilder strBuilder1_4 = new StringBuilder(""); + StringBuilder strBuilder1_5 = new StringBuilder(); + test3(strBuilder1_1); + test3(strBuilder1_2); + test3(strBuilder1_3); + test3(strBuilder1_4); + test3(strBuilder1_5); + } + // Test method substring(int start, int end). + private static void test1(StringBuilder strBuilder) { + System.out.println(strBuilder.substring(2, 7)); + // Test start = 0 & end = strBuffer.length(). + System.out.println(strBuilder.substring(0, strBuilder.length())); + // Test start = strBuffer.length(). + System.out.println(strBuilder.substring(strBuilder.length(), strBuilder.length())); + // Test end = 0. + System.out.println(strBuilder.substring(0, 0)); + } + // Test method substring(int start). + private static void test2(StringBuilder strBuilder) { + System.out.println(strBuilder.substring(3)); + // Test start = 0. + System.out.println(strBuilder.substring(0)); + // Test start = strBuffer.length(). + System.out.println(strBuilder.substring(strBuilder.length())); + } + // Test method toString(). + private static void test3(StringBuilder strBuilder) { + System.out.println(strBuilder.toString()); + } +} diff --git a/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/expected.txt b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..341d348f0ed007510ecf6f11c43ef25541d860fa --- /dev/null +++ b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/expected.txt @@ -0,0 +1,27 @@ +ertyu +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +!.&%( + @!.&%()* + + +c123a +abc123abc + + +rtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + +.&%()* + @!.&%()* + +123abc +abc123abc + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123abc + + +0 diff --git a/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/test.cfg b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e92616a67ba98794382fc57a8895de728825c250 --- /dev/null +++ b/testsuite/java_test/string_test/RT0023-rt-String-BuilderSubstringAndToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderSubstringAndToStringTest) +run(StringBuilderSubstringAndToStringTest) diff --git a/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..95525144409d491d53f442cda1c32a5e17545600 --- /dev/null +++ b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsBytesIntIntIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringConsBytesIntIntIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 96) { + result = 0; + } + return result; + } + public static int StringConsBytesIntIntIndexOutOfBoundsExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - If the offset and length arguments index characters outside the bounds of the + // bytes array + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + try { + String str1 = new String(str1_1, -1, 3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 3, -1); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 3, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c51df8fdbb8793766bc7d43572b66eb2c6b7d7da --- /dev/null +++ b/testsuite/java_test/string_test/RT0024-rt-String-ConsBytesIntIntIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntIntIndexOutOfBoundsExceptionTest) +run(StringConsBytesIntIntIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/StringConsCharArrayIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/StringConsCharArrayIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5c5f86ee5164100c776604bebbd088167aa1eb73 --- /dev/null +++ b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/StringConsCharArrayIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsCharArrayIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringConsCharArrayIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 97) { + result = 0; + } + return result; + } + public static int StringConsCharArrayIndexOutOfBoundsExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - If the offset and length arguments index characters outside the bounds of the + // bytes array + char[] str1_1 = {'a', 'b', 'c', '1', '2', '3'}; + try { + String str1 = new String(str1_1, -1, 3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str2 = new String(str1_1, 0, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..2a8665ca6046d5d6ebee254973330b90b66f2e27 --- /dev/null +++ b/testsuite/java_test/string_test/RT0025-rt-String-ConsCharArrayIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsCharArrayIndexOutOfBoundsExceptionTest) +run(StringConsCharArrayIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/StringConsIntArrayExceptionsTest.java b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/StringConsIntArrayExceptionsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b46cc9f41094723dadc1991c624a1c06be7af76b --- /dev/null +++ b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/StringConsIntArrayExceptionsTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsIntArrayExceptionsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringConsIntArrayExceptionsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 96) { + result = 0; + } + return result; + } + public static int StringConsIntArrayExceptionsTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - If the offset and count arguments index characters outside the bounds of the + // codePoints array + int[] str1_1 = new int[]{97, 98, 99, 49, 50, 51}; + try { + String str1 = new String(str1_1, -1, str1_1.length); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 0, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + //IllegalArgumentException - If any invalid Unicode code point is found in codePoints + int[] str1_2 = new int[]{0xFFFFFFF, 0x62, 0x63, 0x31, 0x32, 0x33}; + try { + String str2 = new String(str1_2, 0, str1_2.length); + processResult -= 10; + } catch (IllegalArgumentException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/expected.txt b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/test.cfg b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b9778cc2a794be64b3b08a5637d8587b64c3a0ae --- /dev/null +++ b/testsuite/java_test/string_test/RT0026-rt-String-ConsIntArrayExceptionsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsIntArrayExceptionsTest) +run(StringConsIntArrayExceptionsTest) diff --git a/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c823688f582bd301bb947a81341f7e039e06d9a6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 97) { + result = 0; + } + return result; + } + public static int StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - If the offset and count arguments index characters outside the bounds of the + // codePoints array + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + try { + String str1 = new String(str1_1, 0, -1, 2); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 0, 0, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..dfa052c5e43bb91058c11dca52ca83925392f1c4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0027-rt-String-ConsBytesIntIntIntIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest) +run(StringConsBytesIntIntIntIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/StringConsBytesIntIntCharsetExceptionTest.java b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/StringConsBytesIntIntCharsetExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a8eeb9ee07e883aa4e0d0989d43fad4a97968b79 --- /dev/null +++ b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/StringConsBytesIntIntCharsetExceptionTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.charset.Charset; +public class StringConsBytesIntIntCharsetExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringConsBytesIntIntCharsetExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 96) { + result = 0; + } + return result; + } + public static int StringConsBytesIntIntCharsetExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - If the offset and length arguments index characters outside the bounds of the + // bytes array + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + try { + String str1 = new String(str1_1, -1, 3, Charset.forName("ASCII")); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 3, -1, Charset.forName("ASCII")); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String str1 = new String(str1_1, 3, 10, Charset.forName("ASCII")); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f2eb7674f28b2b699702cee60d3c71e93ad53054 --- /dev/null +++ b/testsuite/java_test/string_test/RT0028-rt-String-ConsBytesIntIntCharsetExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntIntCharsetExceptionTest) +run(StringConsBytesIntIntCharsetExceptionTest) diff --git a/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/StringCharAtIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/StringCharAtIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..11262f28df1e3a737cda9fe905fce84808d1508b --- /dev/null +++ b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/StringCharAtIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCharAtIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringCharAtIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 97) { + result = 0; + } + return result; + } + public static int StringCharAtIndexOutOfBoundsExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + // IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string. + String str1_1 = new String("abc123"); + String str1_4 = new String(""); + try { + char ch = str1_1.charAt(-2); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + char ch = str1_4.charAt(2); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a6c62a96982fe67f7cfed79daec85f5e81f08250 --- /dev/null +++ b/testsuite/java_test/string_test/RT0029-rt-String-CharAtIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCharAtIndexOutOfBoundsExceptionTest) +run(StringCharAtIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/StringCodePointAtStringIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/StringCodePointAtStringIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3ddccd14c64afc14609629fe57967455f237043d --- /dev/null +++ b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/StringCodePointAtStringIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointAtStringIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointAtStringIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointAtStringIndexOutOfBoundsExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + int codePoint = 0; + for (int i = -1; i < 7; i++) { + try { + codePoint = str.codePointAt(i); + System.out.println("i=" + i + " " + "codePointAt=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointAt(): " + i + " StringIndexOutOfBounds"); + } finally { + try { + System.out.println(str.charAt(i) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " StringIndexOutOfBounds"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..82c4ad5c5b198fa0b76395ea3353e6d091fd4a04 --- /dev/null +++ b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1,145 @@ +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=6 codePointAt=117 +u Unicode is:117 +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointAt(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointAt(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointAt(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointAt(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointAt(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointAt(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointAt(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointAt(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointAt(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointAt(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointAt(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointAt(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=6 codePointAt=117 +u Unicode is:117 +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointAt(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointAt(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointAt(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointAt(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointAt(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointAt(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointAt(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointAt(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +0 diff --git a/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5094d90fd415ab38903b4d4bdc83fef3ae4031eb --- /dev/null +++ b/testsuite/java_test/string_test/RT0030-rt-String-CodePointAtStringIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointAtStringIndexOutOfBoundsExceptionTest) +run(StringCodePointAtStringIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/StringCodePointBeforeExceptionTest.java b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/StringCodePointBeforeExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7355cfd0152d48354fd553f33163973d975c1ee3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/StringCodePointBeforeExceptionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointBeforeExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointBeforeExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointBeforeExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + int codePoint = 0; + for (int i = -1; i < 7; i++) { + try { + codePoint = str.codePointBefore(i); + System.out.println("i=" + i + " " + "codePointBefore=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointBefore(): " + i + " StringIndexOutOfBounds"); + } finally { + try { + System.out.println(str.charAt(i) + " codePointBefore is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " StringIndexOutOfBounds"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f8b265104192824f2dcf322aa848e9c27c2359b1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/expected.txt @@ -0,0 +1,145 @@ +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +q codePointBefore is:0 +i=1 codePointBefore=113 +w codePointBefore is:113 +i=2 codePointBefore=119 +e codePointBefore is:119 +i=3 codePointBefore=101 +r codePointBefore is:101 +i=4 codePointBefore=114 +t codePointBefore is:114 +i=5 codePointBefore=116 +y codePointBefore is:116 +i=6 codePointBefore=121 +u codePointBefore is:121 +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds + codePointBefore is:0 +i=1 codePointBefore=32 +@ codePointBefore is:32 +i=2 codePointBefore=64 +! codePointBefore is:64 +i=3 codePointBefore=33 +. codePointBefore is:33 +i=4 codePointBefore=46 +& codePointBefore is:46 +i=5 codePointBefore=38 +% codePointBefore is:38 +i=6 codePointBefore=37 +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +a codePointBefore is:0 +i=1 codePointBefore=97 +b codePointBefore is:97 +i=2 codePointBefore=98 +c codePointBefore is:98 +i=3 codePointBefore=99 +1 codePointBefore is:99 +i=4 codePointBefore=49 +2 codePointBefore is:49 +i=5 codePointBefore=50 +3 codePointBefore is:50 +i=6 codePointBefore=51 +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointBefore(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointBefore(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointBefore(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointBefore(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointBefore(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointBefore(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointBefore(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointBefore(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointBefore(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointBefore(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointBefore(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointBefore(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +q codePointBefore is:0 +i=1 codePointBefore=113 +w codePointBefore is:113 +i=2 codePointBefore=119 +e codePointBefore is:119 +i=3 codePointBefore=101 +r codePointBefore is:101 +i=4 codePointBefore=114 +t codePointBefore is:114 +i=5 codePointBefore=116 +y codePointBefore is:116 +i=6 codePointBefore=121 +u codePointBefore is:121 +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds + codePointBefore is:0 +i=1 codePointBefore=32 +@ codePointBefore is:32 +i=2 codePointBefore=64 +! codePointBefore is:64 +i=3 codePointBefore=33 +. codePointBefore is:33 +i=4 codePointBefore=46 +& codePointBefore is:46 +i=5 codePointBefore=38 +% codePointBefore is:38 +i=6 codePointBefore=37 +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +a codePointBefore is:0 +i=1 codePointBefore=97 +b codePointBefore is:97 +i=2 codePointBefore=98 +c codePointBefore is:98 +i=3 codePointBefore=99 +1 codePointBefore is:99 +i=4 codePointBefore=49 +2 codePointBefore is:49 +i=5 codePointBefore=50 +3 codePointBefore is:50 +i=6 codePointBefore=51 +charAt(): 6 StringIndexOutOfBounds +codePointBefore(): -1 StringIndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointBefore(): 0 StringIndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointBefore(): 1 StringIndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointBefore(): 2 StringIndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointBefore(): 3 StringIndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointBefore(): 4 StringIndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointBefore(): 5 StringIndexOutOfBounds +charAt(): 5 StringIndexOutOfBounds +codePointBefore(): 6 StringIndexOutOfBounds +charAt(): 6 StringIndexOutOfBounds +0 diff --git a/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..43d1a94bb4b277671ea335e9ad95c888e42bd1b1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0031-rt-String-CodePointBeforeExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointBeforeExceptionTest) +run(StringCodePointBeforeExceptionTest) diff --git a/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/StringCodePointCountIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/StringCodePointCountIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..359f688ca56d546e5ba638bf5233d5ea6f52bb54 --- /dev/null +++ b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/StringCodePointCountIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointCountIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointCountIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointCountIndexOutOfBoundsExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + int codePoint = 0; + for (int i = -1; i < 5; i++) { + try { + codePoint = str.codePointCount(i, i + 3); + System.out.println("i=" + i + " " + "codePointCount=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("codePointCount(): " + i + " IndexOutOfBounds"); + } finally { + try { + System.out.println(str.charAt(i) + " codePointCount is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " StringIndexOutOfBounds"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..70bb71f70ea846d68f87bbe6c1a50969e6f89c09 --- /dev/null +++ b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1,109 @@ +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 +q codePointCount is :3 +i=1 codePointCount=3 +w codePointCount is :3 +i=2 codePointCount=3 +e codePointCount is :3 +i=3 codePointCount=3 +r codePointCount is :3 +i=4 codePointCount=3 +t codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 + codePointCount is :3 +i=1 codePointCount=3 +@ codePointCount is :3 +i=2 codePointCount=3 +! codePointCount is :3 +i=3 codePointCount=3 +. codePointCount is :3 +codePointCount(): 4 IndexOutOfBounds +& codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 +a codePointCount is :3 +i=1 codePointCount=3 +b codePointCount is :3 +i=2 codePointCount=3 +c codePointCount is :3 +i=3 codePointCount=3 +1 codePointCount is :3 +codePointCount(): 4 IndexOutOfBounds +2 codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointCount(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointCount(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointCount(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointCount(): 3 IndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointCount(): 4 IndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointCount(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointCount(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointCount(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointCount(): 3 IndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointCount(): 4 IndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 +q codePointCount is :3 +i=1 codePointCount=3 +w codePointCount is :3 +i=2 codePointCount=3 +e codePointCount is :3 +i=3 codePointCount=3 +r codePointCount is :3 +i=4 codePointCount=3 +t codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 + codePointCount is :3 +i=1 codePointCount=3 +@ codePointCount is :3 +i=2 codePointCount=3 +! codePointCount is :3 +i=3 codePointCount=3 +. codePointCount is :3 +codePointCount(): 4 IndexOutOfBounds +& codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 codePointCount=3 +a codePointCount is :3 +i=1 codePointCount=3 +b codePointCount is :3 +i=2 codePointCount=3 +c codePointCount is :3 +i=3 codePointCount=3 +1 codePointCount is :3 +codePointCount(): 4 IndexOutOfBounds +2 codePointCount is :3 +codePointCount(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +codePointCount(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +codePointCount(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +codePointCount(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +codePointCount(): 3 IndexOutOfBounds +charAt(): 3 StringIndexOutOfBounds +codePointCount(): 4 IndexOutOfBounds +charAt(): 4 StringIndexOutOfBounds +0 diff --git a/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..668373cc6e519ac52bf28e78a3d611506365be90 --- /dev/null +++ b/testsuite/java_test/string_test/RT0032-rt-String-CodePointCountIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointCountIndexOutOfBoundsExceptionTest) +run(StringCodePointCountIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/StringOffsetByCodePointsIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/StringOffsetByCodePointsIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4acc5aa5b561e50c4de6649ce0f31e8321514949 --- /dev/null +++ b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/StringOffsetByCodePointsIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringOffsetByCodePointsIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringOffsetByCodePointsIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringOffsetByCodePointsIndexOutOfBoundsExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + int codePoint = 0; + for (int i = -1; i < 3; i++) { + try { + codePoint = str.offsetByCodePoints(i, i + 3); + System.out.println("i=" + i + " " + "offsetByCodePoints=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("offsetByCodePoints(): " + i + " IndexOutOfBounds"); + } finally { + try { + System.out.println(str.charAt(i) + " offsetByCodePoints is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " StringIndexOutOfBounds"); + } + } + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4851ab144186d741bfd946f7b072b33da962a988 --- /dev/null +++ b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1,73 @@ +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 +q offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints is :5 +i=2 offsetByCodePoints=7 +e offsetByCodePoints is :7 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 + offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints is :5 +offsetByCodePoints(): 2 IndexOutOfBounds +! offsetByCodePoints is :5 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 +a offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints is :5 +offsetByCodePoints(): 2 IndexOutOfBounds +c offsetByCodePoints is :5 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +offsetByCodePoints(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +offsetByCodePoints(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +offsetByCodePoints(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +offsetByCodePoints(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +offsetByCodePoints(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +offsetByCodePoints(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 +q offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints is :5 +i=2 offsetByCodePoints=7 +e offsetByCodePoints is :7 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 + offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints is :5 +offsetByCodePoints(): 2 IndexOutOfBounds +! offsetByCodePoints is :5 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +i=0 offsetByCodePoints=3 +a offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints is :5 +offsetByCodePoints(): 2 IndexOutOfBounds +c offsetByCodePoints is :5 +offsetByCodePoints(): -1 IndexOutOfBounds +charAt(): -1 StringIndexOutOfBounds +offsetByCodePoints(): 0 IndexOutOfBounds +charAt(): 0 StringIndexOutOfBounds +offsetByCodePoints(): 1 IndexOutOfBounds +charAt(): 1 StringIndexOutOfBounds +offsetByCodePoints(): 2 IndexOutOfBounds +charAt(): 2 StringIndexOutOfBounds +0 diff --git a/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..af963b4534088b48c7a97717d7ed4a4442b0b867 --- /dev/null +++ b/testsuite/java_test/string_test/RT0033-rt-String-OffsetByCodePointsIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringOffsetByCodePointsIndexOutOfBoundsExceptionTest) +run(StringOffsetByCodePointsIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/StringGetCharsExceptionsTest.java b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/StringGetCharsExceptionsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..14a9afb1530209abeeeb507f4d9f5c7e985fe06a --- /dev/null +++ b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/StringGetCharsExceptionsTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetCharsExceptionsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetCharsExceptionsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetCharsExceptionsTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + char dst1_1[] = null; + try { + str.getChars(2, 5, dst1_1, 2); + } catch (NullPointerException e1) { + System.out.println("EXCEPTION 1_1"); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_2"); + } finally { + try { + System.out.println(dst1_1); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 1_3"); + } + } + char dst1_2[] = {'A', 'B', 'C', 'D', 'E'}; + try { + str.getChars(-1, 5, dst1_2, 2); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 2_1"); + } finally { + try { + System.out.println(dst1_2); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 2_2"); + } + } + char dst1_3[] = {'A', 'B', 'C', 'D', 'E'}; + try { + str.getChars(2, 6, dst1_3, 2); + } catch (ArrayIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 3_1"); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 3_2"); + } finally { + try { + System.out.println(dst1_3); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 3_3"); + } + } + char dst1_4[] = {'A', 'B', 'C', 'D', 'E'}; + try { + str.getChars(4, 3, dst1_4, 2); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 4_1"); + } finally { + try { + System.out.println(dst1_4); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 4_2"); + } + } + char dst1_5[] = {'A', 'B', 'C', 'D', 'E'}; + try { + str.getChars(4, 3, dst1_5, -1); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 5_1"); + } finally { + try { + System.out.println(dst1_5); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 5_2"); + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/expected.txt b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f3481b4151c8b6fcff2576b898b08b4aa05d4e92 --- /dev/null +++ b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/expected.txt @@ -0,0 +1,81 @@ +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_2 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_2 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +EXCEPTION 1_1 +EXCEPTION 1_3 +EXCEPTION 2_1 +ABCDE +EXCEPTION 3_1 +ABCDE +EXCEPTION 4_1 +ABCDE +EXCEPTION 5_1 +ABCDE +0 diff --git a/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/test.cfg b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ca08dab4d92a274dbcc00b3ceeb1d693ff965596 --- /dev/null +++ b/testsuite/java_test/string_test/RT0034-rt-String-GetCharsExceptionsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetCharsExceptionsTest) +run(StringGetCharsExceptionsTest) diff --git a/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/StringGetBytesExceptionTest.java b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/StringGetBytesExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f0f87ac91bcb98291e24bb3f8be0a47f2ec2ca49 --- /dev/null +++ b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/StringGetBytesExceptionTest.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetBytesExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetBytesExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetBytesExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + byte[] dst1_1 = null; + try { + str.getBytes(2, 5, dst1_1, 2); + String str_new = new String(dst1_1); + } catch (NullPointerException e1) { + System.out.println("EXCEPTION 1_1"); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_2"); + } + byte[] dst1_2 = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + try { + str.getBytes(-1, 5, dst1_2, 2); + String str_new = new String(dst1_2); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 2_1"); + } + // if (srcEnd > length()) ...throw new StringIndexOutOfBoundsException(this, srcEnd); + byte[] dst1_3 = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + try { + str.getBytes(2, 6, dst1_3, 2); + String str_new = new String(dst1_3); + } catch (ArrayIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 3_1"); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 3_2"); + } + byte[] dst1_4 = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + try { + str.getBytes(4, 3, dst1_4, 2); + String str_new = new String(dst1_4); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 4_1"); + } + byte[] dst1_5 = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + try { + str.getBytes(4, 3, dst1_5, -1); + String str_new = new String(dst1_5); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 5_1"); + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ec7e3e161a58aa1192b6551316e696977428e13 --- /dev/null +++ b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/expected.txt @@ -0,0 +1,35 @@ +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_2 +EXCEPTION 2_1 +EXCEPTION 3_2 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_2 +EXCEPTION 2_1 +EXCEPTION 3_2 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +EXCEPTION 1_1 +EXCEPTION 2_1 +EXCEPTION 4_1 +EXCEPTION 5_1 +0 diff --git a/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d722290098fd48099bcbf7647b9f7edf83dcdb71 --- /dev/null +++ b/testsuite/java_test/string_test/RT0035-rt-String-GetBytesExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetBytesExceptionTest) +run(StringGetBytesExceptionTest) diff --git a/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/StringSubstringStringIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/StringSubstringStringIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..3bbbe894120c37b3ed8e637e03020865c150c32a --- /dev/null +++ b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/StringSubstringStringIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubstringStringIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSubstringStringIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSubstringStringIndexOutOfBoundsExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + for (int i = -1; i < 8; i++) { + try { + System.out.println("beginIndex= " + i); + String dst1_1 = str.substring(i); + System.out.println(dst1_1); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("StringIndexOutOfBounds 1_1"); + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..07168492e8d762a7f1d5f3de9b3a8125df9bacc4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1,163 @@ +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 1 +wertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 2 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 3 +rtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 4 +tyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 5 +yuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 6 +uiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 7 +iop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 + @!.&% +beginIndex= 1 +@!.&% +beginIndex= 2 +!.&% +beginIndex= 3 +.&% +beginIndex= 4 +&% +beginIndex= 5 +% +beginIndex= 6 + +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 +abc123 +beginIndex= 1 +bc123 +beginIndex= 2 +c123 +beginIndex= 3 +123 +beginIndex= 4 +23 +beginIndex= 5 +3 +beginIndex= 6 + +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 + +beginIndex= 1 +StringIndexOutOfBounds 1_1 +beginIndex= 2 +StringIndexOutOfBounds 1_1 +beginIndex= 3 +StringIndexOutOfBounds 1_1 +beginIndex= 4 +StringIndexOutOfBounds 1_1 +beginIndex= 5 +StringIndexOutOfBounds 1_1 +beginIndex= 6 +StringIndexOutOfBounds 1_1 +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 + +beginIndex= 1 +StringIndexOutOfBounds 1_1 +beginIndex= 2 +StringIndexOutOfBounds 1_1 +beginIndex= 3 +StringIndexOutOfBounds 1_1 +beginIndex= 4 +StringIndexOutOfBounds 1_1 +beginIndex= 5 +StringIndexOutOfBounds 1_1 +beginIndex= 6 +StringIndexOutOfBounds 1_1 +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 1 +wertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 2 +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 3 +rtyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 4 +tyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 5 +yuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 6 +uiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= 7 +iop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 + @!.&% +beginIndex= 1 +@!.&% +beginIndex= 2 +!.&% +beginIndex= 3 +.&% +beginIndex= 4 +&% +beginIndex= 5 +% +beginIndex= 6 + +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 +abc123 +beginIndex= 1 +bc123 +beginIndex= 2 +c123 +beginIndex= 3 +123 +beginIndex= 4 +23 +beginIndex= 5 +3 +beginIndex= 6 + +beginIndex= 7 +StringIndexOutOfBounds 1_1 +beginIndex= -1 +StringIndexOutOfBounds 1_1 +beginIndex= 0 + +beginIndex= 1 +StringIndexOutOfBounds 1_1 +beginIndex= 2 +StringIndexOutOfBounds 1_1 +beginIndex= 3 +StringIndexOutOfBounds 1_1 +beginIndex= 4 +StringIndexOutOfBounds 1_1 +beginIndex= 5 +StringIndexOutOfBounds 1_1 +beginIndex= 6 +StringIndexOutOfBounds 1_1 +beginIndex= 7 +StringIndexOutOfBounds 1_1 +0 diff --git a/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..428b4e21fb483bd1dee0c0b87733a144f2536e64 --- /dev/null +++ b/testsuite/java_test/string_test/RT0036-rt-String-SubstringStringIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubstringStringIndexOutOfBoundsExceptionTest) +run(StringSubstringStringIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/StringSubstringIntIntExceptionTest.java b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/StringSubstringIntIntExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c79c0aa1c6e3cd9b3f0e49f72085a41d0acf8a6f --- /dev/null +++ b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/StringSubstringIntIntExceptionTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubstringIntIntExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSubstringIntIntExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSubstringIntIntExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ " + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%()*"); + String str1_3 = new String("abc123abc"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZ" + + "XCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + try { + System.out.println(str.substring(2, 6)); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_1"); + } + try { + System.out.println(str.substring(-1, 6)); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_2"); + } + try { + System.out.println(str.substring(2, 1)); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_3"); + } + try { + System.out.println(str.substring(2, 9)); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("EXCEPTION 1_4"); + } + } +} diff --git a/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..81f7d8659040eca7eab0ef976f40363c5a1c2def --- /dev/null +++ b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/expected.txt @@ -0,0 +1,25 @@ +erty +EXCEPTION 1_2 +EXCEPTION 1_3 +ertyuio +!.&% +EXCEPTION 1_2 +EXCEPTION 1_3 +!.&%()* +c123 +EXCEPTION 1_2 +EXCEPTION 1_3 +c123abc +erty +EXCEPTION 1_2 +EXCEPTION 1_3 +ertyuio +!.&% +EXCEPTION 1_2 +EXCEPTION 1_3 +EXCEPTION 1_4 +c123 +EXCEPTION 1_2 +EXCEPTION 1_3 +c123ABC +0 diff --git a/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..03361266502140e609849d1a42f96497b3c886db --- /dev/null +++ b/testsuite/java_test/string_test/RT0037-rt-String-SubstringIntIntExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubstringIntIntExceptionTest) +run(StringSubstringIntIntExceptionTest) diff --git a/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/StringSubSequenceIndexOutOfBoundsExceptionTest.java b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/StringSubSequenceIndexOutOfBoundsExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a90bcdd0a7288381e74b4d7105ad272770253744 --- /dev/null +++ b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/StringSubSequenceIndexOutOfBoundsExceptionTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubSequenceIndexOutOfBoundsExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = StringSubSequenceIndexOutOfBoundsExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 95) { + result = 0; + } + return result; + } + public static int StringSubSequenceIndexOutOfBoundsExceptionTest_1() { + int result1 = 4; /*STATUS_FAILED*/ + //IndexOutOfBoundsException - if the index argument is negative or not less than the length of this string. + String str1_1 = new String("abc123"); + try { + str1_1.subSequence(-2, 6); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + str1_1.subSequence(2, -6); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + str1_1.subSequence(2, 1); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + str1_1.subSequence(2, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..792f82b790ff7d2749dd26cae48945ab746349e3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0038-rt-String-SubSequenceIndexOutOfBoundsExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubSequenceIndexOutOfBoundsExceptionTest) +run(StringSubSequenceIndexOutOfBoundsExceptionTest) diff --git a/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/StringReplaceNullPointerExceptionTest.java b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/StringReplaceNullPointerExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5524f0350a706bdb3594720e8e2f006526dba272 --- /dev/null +++ b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/StringReplaceNullPointerExceptionTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringReplaceNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringReplaceNullPointerExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringReplaceNullPointerExceptionTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ " + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ " + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + String str2_5 = null; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + test(str2_5); + } + private static void test(String str) { + String target = null; + try { + System.out.println(str.replace(target, "@")); + } catch (NullPointerException e1) { + System.out.println("EXCEPTION 1_1"); + } + String replacement = null; + try { + System.out.println(str.replace("a", replacement)); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 1_2"); + } + try { + System.out.println(str.replace("a", "@")); + } catch (NullPointerException e2) { + System.out.println("EXCEPTION 1_3"); + } + } +} diff --git a/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bcbe8784bc9785dc397f8f2503c9feef3c483d15 --- /dev/null +++ b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/expected.txt @@ -0,0 +1,31 @@ +EXCEPTION 1_1 +EXCEPTION 1_2 +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +EXCEPTION 1_1 +EXCEPTION 1_2 + @!.&% +EXCEPTION 1_1 +EXCEPTION 1_2 +@bc123@bc +EXCEPTION 1_1 +EXCEPTION 1_2 + +EXCEPTION 1_1 +EXCEPTION 1_2 + +EXCEPTION 1_1 +EXCEPTION 1_2 +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +EXCEPTION 1_1 +EXCEPTION 1_2 + @!.&% +EXCEPTION 1_1 +EXCEPTION 1_2 +@bc123ABC +EXCEPTION 1_1 +EXCEPTION 1_2 + +EXCEPTION 1_1 +EXCEPTION 1_2 +EXCEPTION 1_3 +0 diff --git a/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..20b492b05716f601ad7ab3a7bec36dba2b5d7c80 --- /dev/null +++ b/testsuite/java_test/string_test/RT0039-rt-String-ReplaceNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringReplaceNullPointerExceptionTest) +run(StringReplaceNullPointerExceptionTest) diff --git a/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/StringValueOfAndCopyValueOfExceptionTest.java b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/StringValueOfAndCopyValueOfExceptionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..94020893d66f90aa3c12b76d2a134d1e4943244a --- /dev/null +++ b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/StringValueOfAndCopyValueOfExceptionTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfAndCopyValueOfExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringValueOfAndCopyValueOfExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 93) { + result = 0; + } + return result; + } + public static int StringValueOfAndCopyValueOfExceptionTest_1() { + int result1 = 2; /* STATUS_Success*/ + + char[] ch1_1 = {'a', 'b', 'c', '1', '2', '3'}; + /* IndexOutOfBoundsException - if offset is negative, or count is negative, or offset+count is larger than + data.length*/ + + try { + String.valueOf(ch1_1, -1, 3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String.valueOf(ch1_1, 1, -3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String.valueOf(ch1_1, 1, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String.copyValueOf(ch1_1, -1, 3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String.copyValueOf(ch1_1, 1, -3); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + try { + String.copyValueOf(ch1_1, 1, 10); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4fc9d20887a200493fd36cc99b0428c621878160 --- /dev/null +++ b/testsuite/java_test/string_test/RT0040-rt-String-ValueOfAndCopyValueOfExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfAndCopyValueOfExceptionTest) +run(StringValueOfAndCopyValueOfExceptionTest) diff --git a/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/StringGetClassTest.java b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/StringGetClassTest.java new file mode 100644 index 0000000000000000000000000000000000000000..032565baf9b5974234f73a8661bd119a1fe32f41 --- /dev/null +++ b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/StringGetClassTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetClassTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetClassTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetClassTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.getClass()); + } +} diff --git a/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/expected.txt b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..ad466046a29a97ecb37ac083eb51853b5713fc98 --- /dev/null +++ b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/expected.txt @@ -0,0 +1,10 @@ +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +class java.lang.String +0 diff --git a/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/test.cfg b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..27d3921a1cf1decef27e4f1ca04ce434cffeaee5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0041-rt-String-GetClassTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetClassTest) +run(StringGetClassTest) diff --git a/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/StringEqualsAndEqualsIgnoreCaseAndLengthTest.java b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/StringEqualsAndEqualsIgnoreCaseAndLengthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ba69d96a26496f2c3e34450f430730becbb8a5df --- /dev/null +++ b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/StringEqualsAndEqualsIgnoreCaseAndLengthTest.java @@ -0,0 +1,184 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringEqualsAndEqualsIgnoreCaseAndLengthTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 3; /* STATUS_Failed*/ + + result = StringEqualsAndEqualsIgnoreCaseAndLengthTest_1(); + if (result == 2 && processResult == 87) { + result = 0; + } + return result; + } + public static int StringEqualsAndEqualsIgnoreCaseAndLengthTest_1() { + test1(); + test2(); + test3(); + test4(); + test5(); + test6(); + test7(); + test8(); + test9(); + test10(); + test11(); + test12(); + return 2; + } + public static int test_equals(String str1, String str2) { + if (str1.equals(str2)) { + return 1; // right result + } + return 30; // wrong result + } + public static int test_not_equals(String str1, String str2) { + if (!str1.equals(str2)) { + return 1; // right result + } + return 30; // wrong result + } + public static int test_equalsIgnoreCase(String str1, String str2) { + if (str1.equalsIgnoreCase(str2)) { + return 1; // right result + } + return 30; // wrong result + } + public static int test_length(String str1, int a) { + if (str1.length() == a) { + return 1; // right result + } + return 30; // wrong result + } + private static void test1() { + String str1_1 = "{"; + String str1_2 = "{"; + if (test_equals(str1_1, str1_2) == 1 && test_length(str1_1, 1) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test2() { + String str2_1 = "{12ab"; + String str2_2 = "{12ab"; + if (test_equals(str2_1, str2_2) == 1 && test_length(str2_1, 5) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test3() { + String str2_1 = "{12ab"; + String str2_3 = "{12AB"; + if (test_equalsIgnoreCase(str2_1, str2_3) == 1 && test_not_equals(str2_1, str2_3) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test4() { + String str3_1 = " abc "; + String str3_3 = " "; + if (test_not_equals(str3_1, str3_3) == 1 && test_length(str3_1, 5) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test5() { + String str3_2 = "null"; + String str3_3 = " "; + if (test_not_equals(str3_2, str3_3) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test6() { + String str3_2 = "null"; + String str3_4 = "NULL"; + if (test_not_equals(str3_2, str3_4) == 1 && test_equalsIgnoreCase(str3_2, str3_4) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test7() { + String str3_1 = " abc "; + String str3_5 = " abc"; + if (test_not_equals(str3_1, str3_5) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test8() { + String str4_1 = "$"; + String str4_2 = "¥"; + if (test_not_equals(str4_1, str4_2) == 1 && test_length(str4_1, 1) == 1 && test_length(str4_2, 1) == 1) + { + processResult--; + } else { + processResult -= 10; + } + } + private static void test9() { + String str5_1 = "abc\n"; + String str5_2 = "abc\t"; + if (test_not_equals(str5_1, str5_2) == 1 && test_length(str5_1, 4) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test10() { + String str6_1 = "‘OR‘1’=’1"; + String str6_2 = "<‘script’>alter(“Test,Bom~~~”)<‘/script’>"; + if (test_equals(str6_1, "‘OR‘1’=’1") == 1 && test_equals(str6_2, "<‘script’>alter(“Test,Bom~~~”)" + + "<‘/script’>") == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test11() { + String str7_1 = "``_+-=asdfadfqwerqwz!@##$%&#*^%^&(&*^()*&^*)^&%^~@#%@#$%^sdfgrw5646843131324fshst{}|[]]:,\\," + + "dkd d/.';,;'mmm:\"<>?;',./"; + String str7_2 = "``_+-=asdfadfqwerqwz!@##$%&#*^%^&(&*^()*&^*)^&%^~@#%@#$%^sdfgrw5646843131324fshst{}|[]]:,\\," + + "dkd d/.';,;'mmm:\"<>?;',./"; + if (test_equals(str7_1, str7_2) == 1 && test_length(str7_1, 116) == 1) { + processResult--; + } else { + processResult -= 10; + } + } + private static void test12() { + String str7_1 = "``_+-=asdfadfqwerqwz!@##$%&#*^%^&(&*^()*&^*)^&%^~@#%@#$%^sdfgrw5646843131324fshst{}|[]]:,\\," + + "dkd d/.';,;'mmm:\"<>?;',./"; + String str7_3 = "``_+-=asdfadfqwerqwz!@##$%&#*^%^&(&*^()*&^*)^&%^~@#%@#$%^sdfgrw5646843131324fshst{}|[]]:,\\," + + "dkd d/.';,;'mmm:\"<>?;',./123"; + if (test_not_equals(str7_1, str7_3) == 1) { + processResult--; + } else { + processResult -= 10; + } + } +} diff --git a/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/expected.txt b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/test.cfg b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e1185761a2e5a3fd4acfcdf2bbca65920a8b0bd6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0042-rt-String-EqualsAndEqualsIgnoreCaseAndLengthTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringEqualsAndEqualsIgnoreCaseAndLengthTest) +run(StringEqualsAndEqualsIgnoreCaseAndLengthTest) diff --git a/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/StringNoParamConstructorTest.java b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/StringNoParamConstructorTest.java new file mode 100644 index 0000000000000000000000000000000000000000..389f7e07148990025387b38bef889cbe12fee3ba --- /dev/null +++ b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/StringNoParamConstructorTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringNoParamConstructorTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringNoParamConstructorTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringNoParamConstructorTest_1() { + String str1 = new String(); + System.out.println(str1); + } +} diff --git a/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/expected.txt b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d9cf16b9d2ab4ea90edc9f640db7382804fd8def --- /dev/null +++ b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/expected.txt @@ -0,0 +1,2 @@ + +0 diff --git a/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/test.cfg b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bea5a1a06afaa8cb577280317f1c9363bd795dc5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0043-rt-String-NoParamConstructorTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringNoParamConstructorTest) +run(StringNoParamConstructorTest) diff --git a/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/StringConsStringTest.java b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/StringConsStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b2d6d8074de0d6c81d107b3d1b1e3d72c27e2db2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/StringConsStringTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsStringTest_1() { + String str1_1 = new String("abc123"); + String str1 = new String(str1_1); + System.out.println(str1); + String str1_2 = new String(" @!.&%"); + String str2 = new String(str1_2); + System.out.println(str2); + String str1_3 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str3 = new String(str1_3); + System.out.println(str3); + String str1_4 = new String(""); + String str4 = new String(str1_4); + System.out.println(str4); + } +} diff --git a/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/expected.txt b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..723815547df6192c87cc5bf1208cf86c7686704b --- /dev/null +++ b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/expected.txt @@ -0,0 +1,5 @@ +abc123 + @!.&% +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + +0 diff --git a/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/test.cfg b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cb6f42f7115948c5e934942f8402924d4dc37d7d --- /dev/null +++ b/testsuite/java_test/string_test/RT0044-rt-String-ConsStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsStringTest) +run(StringConsStringTest) diff --git a/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/StringConsCharTest.java b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/StringConsCharTest.java new file mode 100644 index 0000000000000000000000000000000000000000..119abf7224769cfb1867dbcee37cd359d9dfbc7b --- /dev/null +++ b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/StringConsCharTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsCharTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsCharTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsCharTest_1() { + char[] value1_1 = {'a', 'b', 'c', '1', '2', '3'}; + String str1 = new String(value1_1); + System.out.println(str1); + char[] value1_2 = {}; + String str2 = new String(value1_2); + System.out.println(str2); + } +} diff --git a/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/expected.txt b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..dba8a5761f9d604942da1e70b641eb94b7bc75f6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/expected.txt @@ -0,0 +1,3 @@ +abc123 + +0 diff --git a/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/test.cfg b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..93194d204a74dd68f36a9296397845ddb4474276 --- /dev/null +++ b/testsuite/java_test/string_test/RT0045-rt-String-ConsCharTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsCharTest) +run(StringConsCharTest) diff --git a/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/StringConsCharIntIntTest.java b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/StringConsCharIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9a4b6b4ec3f1ed4e292cef253407164060b93ca5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/StringConsCharIntIntTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsCharIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsCharIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsCharIntIntTest_1() { + char[] value1_1 = {'a', 'b', 'c', '1', '2', '3'}; + String str1 = new String(value1_1, 0, 3); + String str1_1 = new String(value1_1, 0, 0); + String str1_2 = new String(value1_1, 0, 6); + String str1_3 = new String(value1_1, 5, 1); + String str1_4 = new String(value1_1, 5, 0); + System.out.println(str1); + System.out.println(str1_1); + System.out.println(str1_2); + System.out.println(str1_3); + System.out.println(str1_4); + } +} diff --git a/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bf6c075620da540ae87520515145a2f302d39ccc --- /dev/null +++ b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/expected.txt @@ -0,0 +1,6 @@ +abc + +abc123 +3 + +0 diff --git a/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0f1c8ec261f7b977cda3eed54fa1d2912ded427b --- /dev/null +++ b/testsuite/java_test/string_test/RT0046-rt-String-ConsCharIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsCharIntIntTest) +run(StringConsCharIntIntTest) diff --git a/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/StringConsIntsIntIntTest.java b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/StringConsIntsIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d419ec81e19c55195732063526f2270f7fcfc909 --- /dev/null +++ b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/StringConsIntsIntIntTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsIntsIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsIntsIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsIntsIntIntTest_1() { + int[] charIntArray1_1 = new int[]{97, 98, 99, 49, 50, 51}; + String str1_1 = new String(charIntArray1_1, 0, charIntArray1_1.length); + String str1_2 = new String(charIntArray1_1, charIntArray1_1.length - 1, 1); + String str1_3 = new String(charIntArray1_1, charIntArray1_1.length - 1, 0); + System.out.println(str1_1); + System.out.println(str1_2); + System.out.println(str1_3); + int[] charIntArray2_1 = new int[]{0x61, 0x62, 0x63, 0x31, 0x32, 0x33}; + String str2_1 = new String(charIntArray2_1, 0, charIntArray2_1.length); + String str2_2 = new String(charIntArray2_1, charIntArray2_1.length - 1, 1); + String str2_3 = new String(charIntArray2_1, charIntArray2_1.length - 1, 0); + System.out.println(str2_1); + System.out.println(str2_2); + System.out.println(str2_3); + } +} diff --git a/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a849e2f86cf443742c530ebf97603244cfe195c6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/expected.txt @@ -0,0 +1,7 @@ +abc123 +3 + +abc123 +3 + +0 diff --git a/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c777b2109d37292b6e69a57c005b877b7900456c --- /dev/null +++ b/testsuite/java_test/string_test/RT0047-rt-String-ConsIntsIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsIntsIntIntTest) +run(StringConsIntsIntIntTest) diff --git a/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/StringConsBytesIntTest.java b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/StringConsBytesIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..04ac4e83ad2b89daa9a7d13cac12755641a2f4bc --- /dev/null +++ b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/StringConsBytesIntTest.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsBytesIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesIntTest_1() { + byte[] ascii1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1 = new String(ascii1_1, 0); + String str0 = new String(ascii1_1); + System.out.println(str0); + System.out.println(str1); + } +} diff --git a/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/expected.txt b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bb9b8668f693b05b2c8ad793db5c8cd5c51376b1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/expected.txt @@ -0,0 +1,3 @@ +abc123 +abc123 +0 diff --git a/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/test.cfg b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5aec7e6b5b9580706ada4a066a3f47f0ee2c5071 --- /dev/null +++ b/testsuite/java_test/string_test/RT0048-rt-String-ConsBytesIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntTest) +run(StringConsBytesIntTest) diff --git a/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/StringConsBytesIntIntStringTest.java b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/StringConsBytesIntIntStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..85f249fd70c595da961bc853e277070b664f078d --- /dev/null +++ b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/StringConsBytesIntIntStringTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +public class StringConsBytesIntIntStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesIntIntStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesIntIntStringTest_1() throws UnsupportedEncodingException { + byte[] str1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1_1 = new String(str1, 0, 3, "ASCII"); + String str1_2 = new String(str1, 0, 6, "ASCII"); + String str1_3 = new String(str1, 0, 0, "ASCII"); + String str1_4 = new String(str1, 5, 1, "ASCII"); + System.out.println(str1_1); + System.out.println(str1_2); + System.out.println(str1_3); + System.out.println(str1_4); + } +} diff --git a/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/expected.txt b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..998e0e398734cbdd2d70209c735c2f06ec2aab71 --- /dev/null +++ b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/expected.txt @@ -0,0 +1,5 @@ +abc +abc123 + +3 +0 diff --git a/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/test.cfg b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1df6f8f9da2cf62e14d69a8481582806e1b6309a --- /dev/null +++ b/testsuite/java_test/string_test/RT0049-rt-String-ConsBytesIntIntStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntIntStringTest) +run(StringConsBytesIntIntStringTest) diff --git a/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/StringCosBytesIntIntCharsetTest.java b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/StringCosBytesIntIntCharsetTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fc27a4e01bfc95dbb02b732a224d2c76b3d09938 --- /dev/null +++ b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/StringCosBytesIntIntCharsetTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +public class StringCosBytesIntIntCharsetTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCosBytesIntIntCharsetTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCosBytesIntIntCharsetTest_1() throws UnsupportedEncodingException { + byte[] str1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1_1 = new String(str1, 3, 3, Charset.forName("ASCII")); + String str1_2 = new String(str1, 0, 6, Charset.forName("ASCII")); + String str1_3 = new String(str1, 0, 0, Charset.forName("ASCII")); + String str1_4 = new String(str1, 5, 1, Charset.forName("ASCII")); + System.out.println(str1_1); + System.out.println(str1_2); + System.out.println(str1_3); + System.out.println(str1_4); + } +} diff --git a/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/expected.txt b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..10339116d2af65b585d9d38cf28f7a07f0a63044 --- /dev/null +++ b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/expected.txt @@ -0,0 +1,5 @@ +123 +abc123 + +3 +0 diff --git a/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/test.cfg b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..109184029767b114ecb40110e64c3238a6638544 --- /dev/null +++ b/testsuite/java_test/string_test/RT0050-rt-String-CosBytesIntIntCharsetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCosBytesIntIntCharsetTest) +run(StringCosBytesIntIntCharsetTest) diff --git a/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/StringConsBytesStringTest.java b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/StringConsBytesStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e4bd21fcb255159333e826aceeb9e11798c00060 --- /dev/null +++ b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/StringConsBytesStringTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +public class StringConsBytesStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesStringTest_1() throws UnsupportedEncodingException { + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1 = new String(str1_1, "ASCII"); + System.out.println(str1); + } +} diff --git a/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/expected.txt b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a5d15a74f46fd795cf53dd9f7f6696b6385a714 --- /dev/null +++ b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/expected.txt @@ -0,0 +1,2 @@ +abc123 +0 diff --git a/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/test.cfg b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..40c2888cfd828470a53d80091055439e9c3b9953 --- /dev/null +++ b/testsuite/java_test/string_test/RT0051-rt-String-ConsBytesStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesStringTest) +run(StringConsBytesStringTest) diff --git a/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/StringConsBytesCharsetTest.java b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/StringConsBytesCharsetTest.java new file mode 100644 index 0000000000000000000000000000000000000000..663c17eac3eb5683ddb2996e1d3e071894c108d4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/StringConsBytesCharsetTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.nio.charset.Charset; +public class StringConsBytesCharsetTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesCharsetTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesCharsetTest_1() { + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1 = new String(str1_1, Charset.forName("ASCII")); + System.out.println(str1); + } +} diff --git a/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/expected.txt b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a5d15a74f46fd795cf53dd9f7f6696b6385a714 --- /dev/null +++ b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/expected.txt @@ -0,0 +1,2 @@ +abc123 +0 diff --git a/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/test.cfg b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..8337bf02a915776299ca9e954bddb9bddc057343 --- /dev/null +++ b/testsuite/java_test/string_test/RT0052-rt-String-ConsBytesCharsetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesCharsetTest) +run(StringConsBytesCharsetTest) diff --git a/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/StringConsBytesIntIntTest.java b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/StringConsBytesIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..22ce2646fe2cdd3363e49f6215b54fa36be29b31 --- /dev/null +++ b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/StringConsBytesIntIntTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsBytesIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesIntIntTest_1() { + byte[] str1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1_1 = new String(str1, 3, 3); + String str1_2 = new String(str1, 0, 6); + String str1_3 = new String(str1, 0, 0); + String str1_4 = new String(str1, 5, 1); + System.out.println(str1_1); + System.out.println(str1_2); + System.out.println(str1_3); + System.out.println(str1_4); + } +} diff --git a/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..10339116d2af65b585d9d38cf28f7a07f0a63044 --- /dev/null +++ b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/expected.txt @@ -0,0 +1,5 @@ +123 +abc123 + +3 +0 diff --git a/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6c5c06b56bf95598039f5bbd3c20b19278500f65 --- /dev/null +++ b/testsuite/java_test/string_test/RT0053-rt-String-ConsBytesIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesIntIntTest) +run(StringConsBytesIntIntTest) diff --git a/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/StringConsBytesTest.java b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/StringConsBytesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..588404b73da1134154f35a666eb6c2838829a377 --- /dev/null +++ b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/StringConsBytesTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsBytesTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsBytesTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsBytesTest_1() { + byte[] str1_1 = new byte[]{(byte) 0x61, (byte) 0x62, (byte) 0x63, (byte) 0x31, (byte) 0x32, (byte) 0x33}; + String str1 = new String(str1_1); + byte[] str1_2 = new byte[]{97, 98, 99, 49, 50, 51}; + String str1_3 = new String(str1_2); + System.out.println(str1); + System.out.println(str1_3); + } +} diff --git a/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/expected.txt b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..bb9b8668f693b05b2c8ad793db5c8cd5c51376b1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/expected.txt @@ -0,0 +1,3 @@ +abc123 +abc123 +0 diff --git a/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/test.cfg b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..d5d7a46209bfd951cd648c14338dbc83702e9e97 --- /dev/null +++ b/testsuite/java_test/string_test/RT0054-rt-String-ConsBytesTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsBytesTest) +run(StringConsBytesTest) diff --git a/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/StringConsStringBufferTest.java b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/StringConsStringBufferTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7718d38fd890f0d28ec204365401206f6a7e4ffa --- /dev/null +++ b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/StringConsStringBufferTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsStringBufferTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsStringBufferTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsStringBufferTest_1() { + String str1 = "These " + "are " + "abcdefghijklmnopqrstuvwxyz"; + String str2_1 = "These "; + String str2_2 = "are "; + String str2_3 = "abcdefghijklmnopqrstuvwxyz"; + String str2 = str2_1 + str2_2 + str2_3; + StringBuffer str_b_1 = new StringBuffer("These ").append("are ").append("abcdefghijklmnopqrstuvwxyz"); + String str3 = new String(str_b_1); + System.out.println(str1); + System.out.println(str2); + System.out.println(str3); + } +} diff --git a/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/expected.txt b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d1e7254e889c3f0be8e4c33a811eab851c69bdb9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/expected.txt @@ -0,0 +1,4 @@ +These are abcdefghijklmnopqrstuvwxyz +These are abcdefghijklmnopqrstuvwxyz +These are abcdefghijklmnopqrstuvwxyz +0 diff --git a/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/test.cfg b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..32cf856ce8ce2d7278b3a11a48c7c9d5f5a8cb00 --- /dev/null +++ b/testsuite/java_test/string_test/RT0055-rt-String-ConsStringBufferTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsStringBufferTest) +run(StringConsStringBufferTest) diff --git a/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/StringConsStringBuilderTest.java b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/StringConsStringBuilderTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f35cbef2077e8cf0a1f05b4795479a2c01af3e89 --- /dev/null +++ b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/StringConsStringBuilderTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConsStringBuilderTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConsStringBuilderTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConsStringBuilderTest_1() { + String str1 = "These " + "are " + "abcdefghijklmnopqrstuvwxyz"; + String str2_1 = "These "; + String str2_2 = "are "; + String str2_3 = "abcdefghijklmnopqrstuvwxyz"; + String str2 = str2_1 + str2_2 + str2_3; + StringBuilder str_b_1 = new StringBuilder("These ").append("are ").append("abcdefghijklmnopqrstuvwxyz"); + String str3 = new String(str_b_1); + System.out.println(str1); + System.out.println(str2); + System.out.println(str3); + } +} diff --git a/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/expected.txt b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d1e7254e889c3f0be8e4c33a811eab851c69bdb9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/expected.txt @@ -0,0 +1,4 @@ +These are abcdefghijklmnopqrstuvwxyz +These are abcdefghijklmnopqrstuvwxyz +These are abcdefghijklmnopqrstuvwxyz +0 diff --git a/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/test.cfg b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a56f6cb9f40bfbda6ff66aaa6f4859bf5b8927ef --- /dev/null +++ b/testsuite/java_test/string_test/RT0056-rt-String-ConsStringBuilderTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConsStringBuilderTest) +run(StringConsStringBuilderTest) diff --git a/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/StringLengthTest.java b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/StringLengthTest.java new file mode 100644 index 0000000000000000000000000000000000000000..12e621fdc3226e0ef1236bb1430d5b7238838b94 --- /dev/null +++ b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/StringLengthTest.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringLengthTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringLengthTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringLengthTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + int strLength = str1_1.length(); + System.out.println(strLength); + test(str1_1); + System.out.println(str1_2.length()); + test(str1_2); + System.out.println(str1_3.length()); + test(str1_3); + System.out.println(str1_4.length()); + test(str1_4); + System.out.println(str1_5.length()); + test(str1_5); + System.out.println(str2_1.length()); + test(str2_1); + System.out.println(str2_2.length()); + test(str2_2); + System.out.println(str2_3.length()); + test(str2_3); + System.out.println(str2_4.length()); + test(str2_4); + } + private static void test(String str) { + if (str == null) { + System.out.println(str + " is:null"); + } + if (str.isEmpty()) { + System.out.println(str + " is:isEmpty"); + } + if (str.equals("")) { + System.out.println(str + " is:\"\""); + } + System.out.println("*****"); + } +} diff --git a/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/expected.txt b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..45339697f7df4728e62915047620999320d43762 --- /dev/null +++ b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/expected.txt @@ -0,0 +1,25 @@ +99 +***** +6 +***** +6 +***** +0 + is:isEmpty + is:"" +***** +0 + is:isEmpty + is:"" +***** +99 +***** +6 +***** +6 +***** +0 + is:isEmpty + is:"" +***** +0 diff --git a/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/test.cfg b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0026b4d9a046733b8a728de88dfce6a2320b3c8f --- /dev/null +++ b/testsuite/java_test/string_test/RT0057-rt-String-LengthTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringLengthTest) +run(StringLengthTest) diff --git a/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/StringIsEmptyTest.java b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/StringIsEmptyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..05962d171f153b0dd859435120582ead5614db43 --- /dev/null +++ b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/StringIsEmptyTest.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringIsEmptyTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringIsEmptyTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringIsEmptyTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + System.out.println(str1_1.isEmpty()); + test(str1_1); + System.out.println(str1_2.isEmpty()); + test(str1_2); + System.out.println(str1_3.isEmpty()); + test(str1_3); + System.out.println(str1_4.isEmpty()); + test(str1_4); + System.out.println(str1_5.isEmpty()); + test(str1_5); + System.out.println(str2_1.isEmpty()); + test(str2_1); + System.out.println(str2_2.isEmpty()); + test(str2_2); + System.out.println(str2_3.isEmpty()); + test(str2_3); + System.out.println(str2_4.isEmpty()); + test(str2_4); + } + private static void test(String str) { + if (str == null) { + System.out.println(str + " is:null"); + } + if (str.isEmpty()) { + System.out.println(str + " is:isEmpty"); + } + if (str.equals("")) { + System.out.println(str + " is:\"\""); + } + System.out.println("*****"); + } +} diff --git a/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/expected.txt b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..1a30f6213d2b7856dfa29272e086369ebf2a7e99 --- /dev/null +++ b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/expected.txt @@ -0,0 +1,25 @@ +false +***** +false +***** +false +***** +true + is:isEmpty + is:"" +***** +true + is:isEmpty + is:"" +***** +false +***** +false +***** +false +***** +true + is:isEmpty + is:"" +***** +0 diff --git a/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/test.cfg b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..016d9c1e3f97f5ed9e7d33a1caaf17cb59d1b9b9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0058-rt-String-IsEmptyTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringIsEmptyTest) +run(StringIsEmptyTest) diff --git a/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/StringCharAtTest.java b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/StringCharAtTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7a9d701993a94c2678699b1af9b561f98c21196d --- /dev/null +++ b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/StringCharAtTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCharAtTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCharAtTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCharAtTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test1(str1_1); + test(str1_1); + test1(str1_2); + test(str1_2); + test1(str1_3); + test(str1_3); + test(str1_4); + test(str1_5); + test1(str2_1); + test(str2_1); + test1(str2_2); + test(str2_2); + test1(str2_3); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + if (str == null) { + System.out.println(str + " is:null"); + } + if (str.isEmpty()) { + System.out.println(str + " is:isEmpty"); + } + if (str.equals("")) { + System.out.println(str + " is:\"\""); + } + System.out.println("*****"); + } + private static void test1(String str) { + char ch = str.charAt(0); + System.out.println(ch); + System.out.println(str.charAt(str.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/expected.txt b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..fc8ce751656308dbe9699865dfc89d66e9575816 --- /dev/null +++ b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/expected.txt @@ -0,0 +1,28 @@ +q +6 +***** + +% +***** +a +3 +***** + is:isEmpty + is:"" +***** + is:isEmpty + is:"" +***** +q +6 +***** + +% +***** +a +3 +***** + is:isEmpty + is:"" +***** +0 diff --git a/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/test.cfg b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..5e081163b5b3ef27e2456727457e000605d6e3ec --- /dev/null +++ b/testsuite/java_test/string_test/RT0059-rt-String-CharAtTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCharAtTest) +run(StringCharAtTest) diff --git a/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/StringCodePointAtTest.java b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/StringCodePointAtTest.java new file mode 100644 index 0000000000000000000000000000000000000000..21d3d1308467fbc9d38bd87ceddcebc54f0ec4ff --- /dev/null +++ b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/StringCodePointAtTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointAtTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointAtTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointAtTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + int codePoint = 0; + for (int i = 0; i < 6; i++) { + try { + codePoint = str.codePointAt(i); + System.out.println("i=" + i + " " + "codePointAt=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointAt(): " + i + "out of length"); + } finally { + try { + System.out.println(str.charAt(i) + " Unicode is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/expected.txt b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..61c76889b7c6643e0005e2f448146fdf7de1c9d5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/expected.txt @@ -0,0 +1,73 @@ +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +i=0 codePointAt=113 +q Unicode is:113 +i=1 codePointAt=119 +w Unicode is:119 +i=2 codePointAt=101 +e Unicode is:101 +i=3 codePointAt=114 +r Unicode is:114 +i=4 codePointAt=116 +t Unicode is:116 +i=5 codePointAt=121 +y Unicode is:121 +i=0 codePointAt=32 + Unicode is:32 +i=1 codePointAt=64 +@ Unicode is:64 +i=2 codePointAt=33 +! Unicode is:33 +i=3 codePointAt=46 +. Unicode is:46 +i=4 codePointAt=38 +& Unicode is:38 +i=5 codePointAt=37 +% Unicode is:37 +i=0 codePointAt=97 +a Unicode is:97 +i=1 codePointAt=98 +b Unicode is:98 +i=2 codePointAt=99 +c Unicode is:99 +i=3 codePointAt=49 +1 Unicode is:49 +i=4 codePointAt=50 +2 Unicode is:50 +i=5 codePointAt=51 +3 Unicode is:51 +0 diff --git a/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/test.cfg b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0026c9f6e91c7c8a8f335e41dfb452a01fd42e8c --- /dev/null +++ b/testsuite/java_test/string_test/RT0060-rt-String-CodePointAtTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointAtTest) +run(StringCodePointAtTest) diff --git a/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/StringCodePointBeforeTest.java b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/StringCodePointBeforeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..825033ce59d7d7f59d13fe76aebefe6d707dd946 --- /dev/null +++ b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/StringCodePointBeforeTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointBeforeTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointBeforeTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointBeforeTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + int codePoint = 0; + for (int i = 1; i < 6; i++) { + try { + codePoint = str.codePointBefore(i); + System.out.println("i=" + i + " " + "codePointBefore=" + codePoint); + } catch (StringIndexOutOfBoundsException e1) { + System.out.println("codePointBefore(): " + i + " out of length"); + } finally { + try { + System.out.println(str.charAt(i) + " codePointBefore is" + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/expected.txt b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..89900c3dc014d5ca07219670e07f29b001963fc7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/expected.txt @@ -0,0 +1,61 @@ +i=1 codePointBefore=113 +w codePointBefore is:113 +i=2 codePointBefore=119 +e codePointBefore is:119 +i=3 codePointBefore=101 +r codePointBefore is:101 +i=4 codePointBefore=114 +t codePointBefore is:114 +i=5 codePointBefore=116 +y codePointBefore is:116 +i=1 codePointBefore=32 +@ codePointBefore is:32 +i=2 codePointBefore=64 +! codePointBefore is:64 +i=3 codePointBefore=33 +. codePointBefore is:33 +i=4 codePointBefore=46 +& codePointBefore is:46 +i=5 codePointBefore=38 +% codePointBefore is:38 +i=1 codePointBefore=97 +b codePointBefore is:97 +i=2 codePointBefore=98 +c codePointBefore is:98 +i=3 codePointBefore=99 +1 codePointBefore is:99 +i=4 codePointBefore=49 +2 codePointBefore is:49 +i=5 codePointBefore=50 +3 codePointBefore is:50 +i=1 codePointBefore=113 +w codePointBefore is:113 +i=2 codePointBefore=119 +e codePointBefore is:119 +i=3 codePointBefore=101 +r codePointBefore is:101 +i=4 codePointBefore=114 +t codePointBefore is:114 +i=5 codePointBefore=116 +y codePointBefore is:116 +i=1 codePointBefore=32 +@ codePointBefore is:32 +i=2 codePointBefore=64 +! codePointBefore is:64 +i=3 codePointBefore=33 +. codePointBefore is:33 +i=4 codePointBefore=46 +& codePointBefore is:46 +i=5 codePointBefore=38 +% codePointBefore is:38 +i=1 codePointBefore=97 +b codePointBefore is:97 +i=2 codePointBefore=98 +c codePointBefore is:98 +i=3 codePointBefore=99 +1 codePointBefore is:99 +i=4 codePointBefore=49 +2 codePointBefore is:49 +i=5 codePointBefore=50 +3 codePointBefore is:50 +0 diff --git a/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/test.cfg b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..0a5ca654bfaf76c60096b660e80c3c368830d6f5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0061-rt-String-CodePointBeforeTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointBeforeTest) +run(StringCodePointBeforeTest) diff --git a/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/StringCodePointCountTest.java b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/StringCodePointCountTest.java new file mode 100644 index 0000000000000000000000000000000000000000..04109e875013784f1c52b463af545a5250c1b10a --- /dev/null +++ b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/StringCodePointCountTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCodePointCountTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCodePointCountTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCodePointCountTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + int codePoint = 0; + for (int i = 0; i < 4; i++) { + try { + codePoint = str.codePointCount(i, i + 3); + System.out.println("i=" + i + " " + "codePointCount=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("codePointCount(): " + i + " out of length"); + } finally { + try { + System.out.println(str.charAt(i) + " codePointCount is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/expected.txt b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8a36e8278b14184605281942e25b6630e92c0a82 --- /dev/null +++ b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/expected.txt @@ -0,0 +1,49 @@ +i=0 codePointCount=3 +q codePointCount is :3 +i=1 codePointCount=3 +w codePointCount is :3 +i=2 codePointCount=3 +e codePointCount is :3 +i=3 codePointCount=3 +r codePointCount is :3 +i=0 codePointCount=3 + codePointCount is :3 +i=1 codePointCount=3 +@ codePointCount is :3 +i=2 codePointCount=3 +! codePointCount is :3 +i=3 codePointCount=3 +. codePointCount is :3 +i=0 codePointCount=3 +a codePointCount is :3 +i=1 codePointCount=3 +b codePointCount is :3 +i=2 codePointCount=3 +c codePointCount is :3 +i=3 codePointCount=3 +1 codePointCount is :3 +i=0 codePointCount=3 +q codePointCount is :3 +i=1 codePointCount=3 +w codePointCount is :3 +i=2 codePointCount=3 +e codePointCount is :3 +i=3 codePointCount=3 +r codePointCount is :3 +i=0 codePointCount=3 + codePointCount is :3 +i=1 codePointCount=3 +@ codePointCount is :3 +i=2 codePointCount=3 +! codePointCount is :3 +i=3 codePointCount=3 +. codePointCount is :3 +i=0 codePointCount=3 +a codePointCount is :3 +i=1 codePointCount=3 +b codePointCount is :3 +i=2 codePointCount=3 +c codePointCount is :3 +i=3 codePointCount=3 +1 codePointCount is :3 +0 diff --git a/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/test.cfg b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b8e5905f5a2c9bd831761080cc671ed4bdba373a --- /dev/null +++ b/testsuite/java_test/string_test/RT0062-rt-String-CodePointCountTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCodePointCountTest) +run(StringCodePointCountTest) diff --git a/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/StringOffsetByCodePointsTest.java b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/StringOffsetByCodePointsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a36d4a2a292b1fb0846902fcfffa61980aaf8524 --- /dev/null +++ b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/StringOffsetByCodePointsTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringOffsetByCodePointsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringOffsetByCodePointsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringOffsetByCodePointsTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + int codePoint = 0; + for (int i = 0; i < 2; i++) { + try { + codePoint = str.offsetByCodePoints(i, i + 3); + System.out.println("i=" + i + " " + "offsetByCodePoints=" + codePoint); + } catch (IndexOutOfBoundsException e1) { + System.out.println("offsetByCodePoints(): " + i + " out of length"); + } finally { + try { + System.out.println(str.charAt(i) + " offsetByCodePoints is " + ":" + codePoint); + } catch (StringIndexOutOfBoundsException e2) { + System.out.println("charAt(): " + i + " out of length"); + } + } + } + } +} diff --git a/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/expected.txt b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..7563ccb0164299745ebea1e601f06e8a8eb89c21 --- /dev/null +++ b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/expected.txt @@ -0,0 +1,25 @@ +i=0 offsetByCodePoints=3 +q offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints is :5 +i=0 offsetByCodePoints=3 + offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints is :5 +i=0 offsetByCodePoints=3 +a offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints is :5 +i=0 offsetByCodePoints=3 +q offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +w offsetByCodePoints is :5 +i=0 offsetByCodePoints=3 + offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +@ offsetByCodePoints is :5 +i=0 offsetByCodePoints=3 +a offsetByCodePoints is :3 +i=1 offsetByCodePoints=5 +b offsetByCodePoints is :5 +0 diff --git a/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/test.cfg b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1c4cdfa663ac05c11de86a21c1ca6992c675208e --- /dev/null +++ b/testsuite/java_test/string_test/RT0063-rt-String-OffsetByCodePointsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringOffsetByCodePointsTest) +run(StringOffsetByCodePointsTest) diff --git a/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/StringGetCharsTest.java b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/StringGetCharsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..958d7e87ca7068f28d1d5e2f232c46d1e18f73dd --- /dev/null +++ b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/StringGetCharsTest.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetCharsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetCharsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetCharsTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + // 0 < srcBegin < srcEnd, srcEnd < instance.length. 0 =< dstBegin < dst.length -1. + char[] dst = {'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(2, 5, dst, 2); + System.out.println(dst); + // srcBegin = 0, srcEnd < instance.length. 0 =< dstBegin < dst.length -1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(0, 3, dst, 2); + System.out.println(dst); + // srcBegin = instance.length, srcEnd = instance.length, 0 =< dstBegin < dst.length -1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(str.length(), str.length(), dst, 2); + System.out.println(dst); + // srcBegin = 0, srcEnd = 0, 0 =< dstBegin < dst.length -1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(0, 0, dst, 2); + System.out.println(dst); + // 0 < srcBegin < srcEnd, srcEnd < instance.length, dstBegin = 0. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(2, 3, dst, 0); + System.out.println(dst); + // 0 < srcBegin < srcEnd, srcEnd < instance.length, dstBegin = dst.length -1. + dst = new char[]{'A', 'B', 'C', 'D', 'E', 'F'}; + str.getChars(2, 3, dst, 5); + System.out.println(dst); + } +} diff --git a/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/expected.txt b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..614bebbf5e536458f0b8e3e4489808880148f6c9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/expected.txt @@ -0,0 +1,37 @@ +ABertF +ABqweF +ABCDEF +ABCDEF +eBCDEF +ABCDEe +AB!.&F +AB @!F +ABCDEF +ABCDEF +!BCDEF +ABCDE! +ABc12F +ABabcF +ABCDEF +ABCDEF +cBCDEF +ABCDEc +ABertF +ABqweF +ABCDEF +ABCDEF +eBCDEF +ABCDEe +AB!.&F +AB @!F +ABCDEF +ABCDEF +!BCDEF +ABCDE! +ABc12F +ABabcF +ABCDEF +ABCDEF +cBCDEF +ABCDEc +0 diff --git a/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/test.cfg b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ea4644922a93baba2bd955e45e3fb28626261d7a --- /dev/null +++ b/testsuite/java_test/string_test/RT0064-rt-String-GetCharsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetCharsTest) +run(StringGetCharsTest) diff --git a/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/StringGetBytesIntIntBytesIntTest.java b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/StringGetBytesIntIntBytesIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5db38a83ac4c4ec135fa7c73d5d1a0d364b0a4dc --- /dev/null +++ b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/StringGetBytesIntIntBytesIntTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetBytesIntIntBytesIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetBytesIntIntBytesIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetBytesIntIntBytesIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + // Test 0 < srcBegin < srcEnd, srcEnd < instance.length. 0 =< dstBegin < dst.length -1. + byte[] dst = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(2, 5, dst, 2); + String str_new = new String(dst); + System.out.println(str_new); + // Test srcBegin = 0, srcEnd < instance.length. 0 =< dstBegin < dst.length -1. + dst = new byte[]{0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(0, 3, dst, 2); + str_new = new String(dst); + System.out.println(str_new); + // Test srcBegin = instance.length, srcEnd = instance.length, 0 =< dstBegin < dst.length -1. + dst = new byte[]{0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(str.length(), str.length(), dst, 2); + str_new = new String(dst); + System.out.println(str_new); + // Test srcBegin = 0, srcEnd = 0, 0 =< dstBegin < dst.length -1. + dst = new byte[]{0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(0, 0, dst, 2); + str_new = new String(dst); + System.out.println(str_new); + // Test 0 < srcBegin < srcEnd, srcEnd < instance.length, dstBegin = 0. + dst = new byte[]{0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(2, 3, dst, 0); + str_new = new String(dst); + System.out.println(str_new); + // Test 0 < srcBegin < srcEnd, srcEnd < instance.length, dstBegin = dst.length -1. + dst = new byte[]{0x41, 0x42, 0x43, 0x44, 0x45, 0x46}; + str.getBytes(2, 3, dst, 5); + str_new = new String(dst); + System.out.println(str_new); + } +} diff --git a/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/expected.txt b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..614bebbf5e536458f0b8e3e4489808880148f6c9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/expected.txt @@ -0,0 +1,37 @@ +ABertF +ABqweF +ABCDEF +ABCDEF +eBCDEF +ABCDEe +AB!.&F +AB @!F +ABCDEF +ABCDEF +!BCDEF +ABCDE! +ABc12F +ABabcF +ABCDEF +ABCDEF +cBCDEF +ABCDEc +ABertF +ABqweF +ABCDEF +ABCDEF +eBCDEF +ABCDEe +AB!.&F +AB @!F +ABCDEF +ABCDEF +!BCDEF +ABCDE! +ABc12F +ABabcF +ABCDEF +ABCDEF +cBCDEF +ABCDEc +0 diff --git a/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/test.cfg b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..1654b0d76c8d51a76085e6e794fdaea8145649d2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0065-rt-String-GetBytesIntIntBytesIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetBytesIntIntBytesIntTest) +run(StringGetBytesIntIntBytesIntTest) diff --git a/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/StringGetBytesStringTest.java b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/StringGetBytesStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..47c6e508dcd6c7914de0d47094a383e88019c254 --- /dev/null +++ b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/StringGetBytesStringTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +public class StringGetBytesStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetBytesStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetBytesStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + try { + byte[] test1_1 = str.getBytes("UTF-8"); + for (int i = 0; i < test1_1.length; i++) { + System.out.println(test1_1[i]); + } + } catch (UnsupportedEncodingException e) { + System.out.println("Unsupported character set"); + } + } +} diff --git a/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/expected.txt b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aabfa112362d9c34a4ef36106314310ab2201249 --- /dev/null +++ b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/expected.txt @@ -0,0 +1,223 @@ +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +0 diff --git a/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/test.cfg b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a269aa09fd310b09a1057bd96b8bbb1751028b44 --- /dev/null +++ b/testsuite/java_test/string_test/RT0066-rt-String-GetBytesStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetBytesStringTest) +run(StringGetBytesStringTest) diff --git a/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/StringGetBytesCharsetTest.java b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/StringGetBytesCharsetTest.java new file mode 100644 index 0000000000000000000000000000000000000000..08c1d45fdf6f8ad5428399b3dad5e7acda19fb1d --- /dev/null +++ b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/StringGetBytesCharsetTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; +public class StringGetBytesCharsetTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetBytesCharsetTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetBytesCharsetTest_1() throws UnsupportedEncodingException { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) throws UnsupportedEncodingException { + Charset charset = Charset.defaultCharset(); + byte[] test1 = str.getBytes(charset); + for (int i = 0; i < test1.length; i++) { + System.out.println(test1[i]); + } + } +} diff --git a/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/expected.txt b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aabfa112362d9c34a4ef36106314310ab2201249 --- /dev/null +++ b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/expected.txt @@ -0,0 +1,223 @@ +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +0 diff --git a/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/test.cfg b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f2b86415ab96dbaa476be805c7f4c641aa87081f --- /dev/null +++ b/testsuite/java_test/string_test/RT0067-rt-String-GetBytesCharsetTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetBytesCharsetTest) +run(StringGetBytesCharsetTest) diff --git a/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/StringGetBytesTest.java b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/StringGetBytesTest.java new file mode 100644 index 0000000000000000000000000000000000000000..827edffc57d493fcb2a6f488e1f6dc3f7f1123b2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/StringGetBytesTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringGetBytesTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGetBytesTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGetBytesTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + byte[] test1_1 = str.getBytes(); + for (int i = 0; i < test1_1.length; i++) { + System.out.println(test1_1[i]); + } + } +} diff --git a/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/expected.txt b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..aabfa112362d9c34a4ef36106314310ab2201249 --- /dev/null +++ b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/expected.txt @@ -0,0 +1,223 @@ +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +113 +119 +101 +114 +116 +121 +117 +105 +111 +112 +123 +125 +91 +93 +92 +124 +97 +115 +100 +102 +103 +104 +106 +107 +108 +59 +58 +39 +34 +122 +120 +99 +118 +98 +110 +109 +44 +46 +60 +62 +47 +63 +126 +96 +49 +50 +51 +52 +53 +54 +55 +56 +57 +48 +45 +61 +33 +64 +35 +36 +37 +94 +38 +42 +40 +41 +95 +43 +32 +65 +83 +68 +70 +71 +72 +74 +75 +76 +81 +87 +69 +82 +84 +89 +85 +73 +79 +80 +90 +88 +67 +86 +66 +78 +77 +48 +120 +57 +54 +32 +64 +33 +46 +38 +37 +97 +98 +99 +49 +50 +51 +0 diff --git a/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/test.cfg b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..68c0f9c847e1ad3128d263fbdb621e5ac8c74146 --- /dev/null +++ b/testsuite/java_test/string_test/RT0068-rt-String-GetBytesTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGetBytesTest) +run(StringGetBytesTest) diff --git a/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/StringEqualsTest.java b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/StringEqualsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..9bbe54279945a7b0ecc077d5102dc0623ef37218 --- /dev/null +++ b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/StringEqualsTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringEqualsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringEqualsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringEqualsTest_1() { + String str1_1 = new String("abc123"); + String str1_2 = new String("******"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str1_6 = new String("ABc123"); + String str2_1 = "abc123"; + String str2_2 = "******"; + String str2_3 = "abc123"; + String str2_4 = ""; + String str2_5 = null; + System.out.println(str1_1 + " equals " + str1_2 + " : " + str1_1.equals(str1_2)); + System.out.println(str1_1 + " equals " + str1_3 + " : " + str1_1.equals(str1_3)); + System.out.println(str1_1 + " equals " + str1_4 + " : " + str1_1.equals(str1_4)); + System.out.println(str1_1 + " equals " + str1_5 + " : " + str1_1.equals(str1_5)); + System.out.println(str1_1 + " equals " + str1_6 + " : " + str1_1.equals(str1_6)); + System.out.println(str1_2 + " equals " + str2_2 + " : " + str1_2.equals(str2_2)); + System.out.println(str2_1 + " equals " + str2_2 + " : " + str2_1.equals(str2_2)); + System.out.println(str2_1 + " equals " + str2_3 + " : " + str2_1.equals(str2_3)); + System.out.println(str2_1 + " equals " + str2_4 + " : " + str2_1.equals(str2_4)); + System.out.println(str2_1 + " equals " + str2_5 + " : " + str2_1.equals(str2_5)); + System.out.println(str1_1 + " equals " + str2_1 + " : " + str1_1.equals(str2_1)); + } +} diff --git a/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/expected.txt b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6363bce3275098d42d9d04c8c5fc961d3376bf92 --- /dev/null +++ b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/expected.txt @@ -0,0 +1,12 @@ +abc123 equals ****** : false +abc123 equals abc123 : true +abc123 equals : false +abc123 equals : false +abc123 equals ABc123 : false +****** equals ****** : true +abc123 equals ****** : false +abc123 equals abc123 : true +abc123 equals : false +abc123 equals null : false +abc123 equals abc123 : true +0 diff --git a/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/test.cfg b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e079bb628be65f66e87a9fc2ab225988022592fd --- /dev/null +++ b/testsuite/java_test/string_test/RT0069-rt-String-EqualsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringEqualsTest) +run(StringEqualsTest) diff --git a/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/StringContentEqualsTest.java b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/StringContentEqualsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ce5cabb03230b26a8c2847ca08196f991ec74b06 --- /dev/null +++ b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/StringContentEqualsTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringContentEqualsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringContentEqualsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringContentEqualsTest_1() { + String str1_1 = new String("abc123"); + String str1_2 = new String("******"); + String str1_3 = new String("ABc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "abc123"; + String str2_2 = "******"; + String str2_3 = "ABc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "abc123"; + StringBuffer test1_1 = new StringBuffer(str); + boolean result = test.contentEquals(test1_1); + System.out.println(result); + } +} diff --git a/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/expected.txt b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0855059d4e8645ff018fdf2833d9f49f6f18ca75 --- /dev/null +++ b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/expected.txt @@ -0,0 +1,10 @@ +true +false +false +false +false +true +false +false +false +0 diff --git a/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/test.cfg b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..73e66ded1a1637130b0cc66d00db5433f085742b --- /dev/null +++ b/testsuite/java_test/string_test/RT0070-rt-String-ContentEqualsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringContentEqualsTest) +run(StringContentEqualsTest) diff --git a/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/StringContentEqualsCharSequenceTest.java b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/StringContentEqualsCharSequenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bc0ed0738eb3e1dd0b9ae5489a0d78039aef9bdd --- /dev/null +++ b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/StringContentEqualsCharSequenceTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringContentEqualsCharSequenceTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringContentEqualsCharSequenceTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringContentEqualsCharSequenceTest_1() { + String str1_1 = new String("ABC123"); + String str1_2 = new String("******"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "ABC123"; + String str2_2 = "******"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "abc123"; + CharSequence test1_1 = str; + boolean result = test.contentEquals(test1_1); + System.out.println(result); + } +} diff --git a/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/expected.txt b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..8038664d316487bea29806129916d26079483557 --- /dev/null +++ b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/expected.txt @@ -0,0 +1,10 @@ +false +false +true +false +false +false +false +true +false +0 diff --git a/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/test.cfg b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cd1c16040fb5e477c5cd89808688cbf67503ac9e --- /dev/null +++ b/testsuite/java_test/string_test/RT0071-rt-String-ContentEqualsCharSequenceTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringContentEqualsCharSequenceTest) +run(StringContentEqualsCharSequenceTest) diff --git a/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/StringEqualsIgnoreCaseTest.java b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/StringEqualsIgnoreCaseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..95eece5fed6801a1150009fd1133ff9a5495d9bc --- /dev/null +++ b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/StringEqualsIgnoreCaseTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringEqualsIgnoreCaseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringEqualsIgnoreCaseTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringEqualsIgnoreCaseTest_1() { + String str1_1 = new String("ABC123"); + String str1_2 = new String("******"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "ABC123"; + String str2_2 = "******"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "ABC123"; + boolean result = test.equalsIgnoreCase(str); + System.out.println(result); + } +} diff --git a/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/expected.txt b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c998cb111606bd2d7b210b7a0ea32f0941c4ce3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/expected.txt @@ -0,0 +1,10 @@ +true +false +true +false +false +true +false +true +false +0 diff --git a/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/test.cfg b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..340aa008b5786b9b4852f5899419e07234820550 --- /dev/null +++ b/testsuite/java_test/string_test/RT0072-rt-String-EqualsIgnoreCaseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringEqualsIgnoreCaseTest) +run(StringEqualsIgnoreCaseTest) diff --git a/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/StringCompareToTest.java b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/StringCompareToTest.java new file mode 100644 index 0000000000000000000000000000000000000000..73ad50dfa753d18783acfe69048ba07537a33c78 --- /dev/null +++ b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/StringCompareToTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCompareToTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCompareToTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCompareToTest_1() { + String str1_1 = new String("ABC123"); + String str1_2 = new String("******"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "ABC123"; + String str2_2 = "******"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "ABC123"; + int result = test.compareTo(str); + System.out.println(result); + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/expected.txt b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..cbafb34a604dddae9b2494b3f476e752b7a14c0e --- /dev/null +++ b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/expected.txt @@ -0,0 +1,10 @@ +0 +23 +-32 +6 +6 +0 +23 +-32 +6 +0 diff --git a/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/test.cfg b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..141446b7c4f1503d3c4fc5ef8077993a423c9dbf --- /dev/null +++ b/testsuite/java_test/string_test/RT0073-rt-String-CompareToTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCompareToTest) +run(StringCompareToTest) diff --git a/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/StringCompareToIgnoreCaseTest.java b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/StringCompareToIgnoreCaseTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e601e6f965af151dd28cad3bd8dd4283655ad92 --- /dev/null +++ b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/StringCompareToIgnoreCaseTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCompareToIgnoreCaseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCompareToIgnoreCaseTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCompareToIgnoreCaseTest_1() { + String str1_1 = new String("ABC123"); + String str1_2 = new String("******"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "ABC123"; + String str2_2 = "******"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "ABC123"; + int result = test.compareToIgnoreCase(str); + System.out.println(result); + } +} diff --git a/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/expected.txt b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9b39601567cb2c93ec435fe2253c8387dbd6543d --- /dev/null +++ b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/expected.txt @@ -0,0 +1,10 @@ +0 +55 +0 +6 +6 +0 +55 +0 +6 +0 diff --git a/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/test.cfg b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..74055ea90f7a8457dcd28e97a506d583e8a99963 --- /dev/null +++ b/testsuite/java_test/string_test/RT0074-rt-String-CompareToIgnoreCaseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCompareToIgnoreCaseTest) +run(StringCompareToIgnoreCaseTest) diff --git a/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/StringRegionMatchesIntStringIntIntTest.java b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/StringRegionMatchesIntStringIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..5bf547a06e890e5281f448e9040d095d329ef463 --- /dev/null +++ b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/StringRegionMatchesIntStringIntIntTest.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringRegionMatchesIntStringIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringRegionMatchesIntStringIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringRegionMatchesIntStringIntIntTest_1() { + String str1_1 = new String("abc123_SAME"); + String str1_2 = new String(" _same"); + String str1_3 = new String("abc123_same"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "abc123_SAME"; + String str2_2 = " _same"; + String str2_3 = "abc123_same"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "same"; + // Test 0 =< toffset < instance.length, 0 =< ooffset < other.length, + // 0 =< len < 0 =< len < Min value of other.length - ooffset -1 and instance.length - toffset - 1 + System.out.println(str.regionMatches(7, test, 0, 4)); + System.out.println(str.regionMatches(7, test, 0, 5)); + System.out.println(str.regionMatches(8, test, 1, 3)); + // Test toffset < 0. + System.out.println(str.regionMatches(-2, test, 0, 2)); + // Test toffset = 0. + System.out.println(str.regionMatches(0, test, 1, 1)); + // Test toffset < instance.length - 1. + System.out.println(str.regionMatches(10, test, 1, 1)); + // Test ooffset = other.length - 1. + System.out.println(str.regionMatches(10, test, 3, 1)); + // Test len = 0. + System.out.println(str.regionMatches(7, test, 0, 0)); + // Test len = str.length(). + System.out.println(str.regionMatches(7, test, 0, str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c3a47ba638d964e4c2ca5fb6470eccfe8b73a7dc --- /dev/null +++ b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/expected.txt @@ -0,0 +1,82 @@ +false +false +false +false +true +false +false +true +false +true +false +true +false +false +false +true +true +false +true +false +true +false +true +false +true +true +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +true +false +false +true +false +true +false +true +false +false +false +true +true +false +true +false +true +false +true +false +true +true +false +false +false +false +false +false +false +false +false +false +0 diff --git a/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..120a8339531a9b763d62fd8559148327c0348017 --- /dev/null +++ b/testsuite/java_test/string_test/RT0075-rt-String-RegionMatchesIntStringIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringRegionMatchesIntStringIntIntTest) +run(StringRegionMatchesIntStringIntIntTest) diff --git a/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/StringRegionMatchesBooleanIntStringIntIntTest.java b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/StringRegionMatchesBooleanIntStringIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..891df17ebe069097e3d6b927bc6b61c3c09391de --- /dev/null +++ b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/StringRegionMatchesBooleanIntStringIntIntTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringRegionMatchesBooleanIntStringIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringRegionMatchesBooleanIntStringIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringRegionMatchesBooleanIntStringIntIntTest_1() { + String str1_1 = new String("abc123_SAME"); + String str1_2 = new String(" _same"); + String str1_3 = new String("abc123_same"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "abc123_SAME"; + String str2_2 = " _same"; + String str2_3 = "abc123_same"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test = "SAME"; + // Test ooffset = 0, len = Min value of other.length - ooffset and instance.length - toffset. + System.out.println(str.regionMatches(true, 7, test, 0, 4)); + System.out.println(str.regionMatches(false, 7, test, 0, 4)); + // Test toffset = 0. + System.out.println(str.regionMatches(true, 0, test, 1, 1)); + System.out.println(str.regionMatches(false, 0, test, 1, 1)); + // Test toffset = str.length() - 1, ooffset = test.length() - 1. + System.out.println(str.regionMatches(true, str.length() - 1, test, 3, 1)); + System.out.println(str.regionMatches(false, str.length() - 1, test, 3, 1)); + // Test len = 0. + System.out.println(str.regionMatches(true, 7, test, 0, 0)); + System.out.println(str.regionMatches(false, 7, test, 0, 0)); + } +} diff --git a/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..01aa99dbd8495ca06d76a758ac967e73d50e280f --- /dev/null +++ b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/expected.txt @@ -0,0 +1,73 @@ +true +true +true +false +true +true +true +true +true +false +false +false +true +false +true +true +true +false +true +false +true +false +true +true +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +false +true +true +true +false +true +true +true +true +true +false +false +false +true +false +true +true +true +false +true +false +true +false +true +true +false +false +false +false +false +false +false +false +0 diff --git a/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c64ec8ebe275d4481b50e5db091fc1eb8c461f5d --- /dev/null +++ b/testsuite/java_test/string_test/RT0076-rt-String-RegionMatchesBooleanIntStringIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringRegionMatchesBooleanIntStringIntIntTest) +run(StringRegionMatchesBooleanIntStringIntIntTest) diff --git a/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/StringStartsWithStringIntTest.java b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/StringStartsWithStringIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2418c451b5ca146f6fd883629fd4982ee12822c2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/StringStartsWithStringIntTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringStartsWithStringIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringStartsWithStringIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringStartsWithStringIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.startsWith("123", 3)); + // Test toffset = 0. + System.out.println(str.startsWith("abc", 0)); + // Test toffset = str.length() - 1. + System.out.println(str.startsWith("%", str.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/expected.txt b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4f7039c3c8fc5127fa90780983fabb7cca54ff35 --- /dev/null +++ b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/expected.txt @@ -0,0 +1,28 @@ +false +false +false +false +false +true +true +true +false +false +false +false +false +false +false +false +false +false +false +false +true +true +true +false +false +false +false +0 diff --git a/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/test.cfg b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..6969578b0286efc883d9ea1a86b87f595ab5eb15 --- /dev/null +++ b/testsuite/java_test/string_test/RT0077-rt-String-StartsWithStringIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringStartsWithStringIntTest) +run(StringStartsWithStringIntTest) diff --git a/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/StringStartsWithStringTest.java b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/StringStartsWithStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..453e87e501051be127b2431a24515d0ece3361d1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/StringStartsWithStringTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringStartsWithStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringStartsWithStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringStartsWithStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.startsWith("ab")); + System.out.println(str.startsWith("")); + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/expected.txt b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..a2db6b6d1f3d6840bebf81ac4481246806db72a7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/expected.txt @@ -0,0 +1,19 @@ +false +true +false +true +true +true +false +true +false +true +false +true +false +true +true +true +false +true +0 diff --git a/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/test.cfg b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..cfe96ef936ff90a2d6dff7beb9ee1bcf3a1c6813 --- /dev/null +++ b/testsuite/java_test/string_test/RT0078-rt-String-StartsWithStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringStartsWithStringTest) +run(StringStartsWithStringTest) diff --git a/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/StringEndsWithTest.java b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/StringEndsWithTest.java new file mode 100644 index 0000000000000000000000000000000000000000..85a8f819fccdf8a19de872b29f236505a1ec5550 --- /dev/null +++ b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/StringEndsWithTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringEndsWithTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringEndsWithTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringEndsWithTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.endsWith("bc")); + System.out.println(str.endsWith("")); + } +} diff --git a/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/expected.txt b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..577184267278d54682752a15828022684c907320 --- /dev/null +++ b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/expected.txt @@ -0,0 +1,19 @@ +false +true +false +true +true +true +false +true +false +true +false +true +false +true +false +true +false +true +0 diff --git a/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/test.cfg b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ec1b768f540747830936e186af9d687ae07c082b --- /dev/null +++ b/testsuite/java_test/string_test/RT0079-rt-String-EndsWithTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringEndsWithTest) +run(StringEndsWithTest) diff --git a/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/StringHashCodeTest.java b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/StringHashCodeTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c4044da7bd52a9eac845bc836e34a18db1bd7793 --- /dev/null +++ b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/StringHashCodeTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringHashCodeTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringHashCodeTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringHashCodeTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!" + + "@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.hashCode()); + } +} diff --git a/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/expected.txt b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..c089f1d2a52c8fd145e45c7614c56ccd79621dde --- /dev/null +++ b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/expected.txt @@ -0,0 +1,10 @@ +-736345066 +976266700 +-1113531438 +0 +0 +-736345066 +976266700 +-1113563214 +0 +0 diff --git a/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/test.cfg b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..f9865781cdfbf0f75507f8976aa06c4325329cae --- /dev/null +++ b/testsuite/java_test/string_test/RT0080-rt-String-HashCodeTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringHashCodeTest) +run(StringHashCodeTest) diff --git a/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/StringIndexOfIntTest.java b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/StringIndexOfIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d3d24e58695bc4923f25518131a733ce0e3b91ad --- /dev/null +++ b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/StringIndexOfIntTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringIndexOfIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringIndexOfIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringIndexOfIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ " + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUI" + + "OPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.indexOf(98)); + } +} diff --git a/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/expected.txt b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b56ed492965d96f08976b7a08931896b8ebb9845 --- /dev/null +++ b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/expected.txt @@ -0,0 +1,10 @@ +33 +-1 +1 +-1 +-1 +33 +-1 +1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/test.cfg b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..20a7251e039077fff90fabb3e8a32e211a729c31 --- /dev/null +++ b/testsuite/java_test/string_test/RT0081-rt-String-IndexOfIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringIndexOfIntTest) +run(StringIndexOfIntTest) diff --git a/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/StringIndexOfIntIntTest.java b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/StringIndexOfIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c976eb6962962ac8340ecf45af1a56c9a372c47a --- /dev/null +++ b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/StringIndexOfIntIntTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringIndexOfIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringIndexOfIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringIndexOfIntIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ " + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZX" + + "CVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + // Test 0 < fromIndex < str.length(). + System.out.println(str.indexOf(98, 2)); + // Test fromIndex = 0. + System.out.println(str.indexOf(98, 0)); + // Test fromIndex = str.length(). + System.out.println(str.indexOf(98, str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..0912c373865b82992e36d1dfa8d5aca8cfee8a3c --- /dev/null +++ b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/expected.txt @@ -0,0 +1,28 @@ +33 +33 +-1 +-1 +-1 +-1 +7 +1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +33 +33 +-1 +-1 +-1 +-1 +-1 +1 +-1 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..fa7ab269631e95904d67fa99e62f3848b8139823 --- /dev/null +++ b/testsuite/java_test/string_test/RT0082-rt-String-IndexOfIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringIndexOfIntIntTest) +run(StringIndexOfIntIntTest) diff --git a/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/StringLastIndexOfIntTest.java b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/StringLastIndexOfIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..1c81df65a737735a9a3833e3a4c7cff110dfe1d1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/StringLastIndexOfIntTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringLastIndexOfIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringLastIndexOfIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringLastIndexOfIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+" + + "ASDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZ" + + "XCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.lastIndexOf(98)); + } +} diff --git a/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/expected.txt b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6b5bbe12663416eb93ea651d00f4761ace2e9080 --- /dev/null +++ b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/expected.txt @@ -0,0 +1,10 @@ +33 +-1 +7 +-1 +-1 +33 +-1 +1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/test.cfg b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b005cc894b1515adc1ee737beec68b27510230a4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0083-rt-String-LastIndexOfIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringLastIndexOfIntTest) +run(StringLastIndexOfIntTest) diff --git a/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/StringLastIndexOfIntIntTest.java b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/StringLastIndexOfIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..019fd05796d3d7c9bf4577aa00aa91747eff9bbe --- /dev/null +++ b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/StringLastIndexOfIntIntTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringLastIndexOfIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringLastIndexOfIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringLastIndexOfIntIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASD" + + "FGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + // Test fromIndex = 0. + System.out.println(str.lastIndexOf(49, 0)); + // Test 0 < fromIndex < str.length(). + System.out.println(str.lastIndexOf(49, 3)); + // Test fromIndex = str.length(). + System.out.println(str.lastIndexOf(49, str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..75e36f1003377a59c846c5ed56e1abb110487fca --- /dev/null +++ b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/expected.txt @@ -0,0 +1,28 @@ +-1 +-1 +44 +-1 +-1 +-1 +-1 +3 +3 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +44 +-1 +-1 +-1 +-1 +3 +3 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..93b8108edb2427b6d50bb02c4f86eee722a47624 --- /dev/null +++ b/testsuite/java_test/string_test/RT0084-rt-String-LastIndexOfIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringLastIndexOfIntIntTest) +run(StringLastIndexOfIntIntTest) diff --git a/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/StringIndexOfStringTest.java b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/StringIndexOfStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..b7c09231a5f984c088dc84cf205aed3aa0a7ce6e --- /dev/null +++ b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/StringIndexOfStringTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringIndexOfStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringIndexOfStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringIndexOfStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOP" + + "ZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.indexOf("c")); + } +} diff --git a/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/expected.txt b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..4cd324151992770f1456789108d66da46b9bbdfe --- /dev/null +++ b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/expected.txt @@ -0,0 +1,10 @@ +31 +-1 +2 +-1 +-1 +31 +-1 +2 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/test.cfg b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..af7873588b11155d5245f774bfc013c496fa806f --- /dev/null +++ b/testsuite/java_test/string_test/RT0085-rt-String-IndexOfStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringIndexOfStringTest) +run(StringIndexOfStringTest) diff --git a/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/StringIndexOfStringIntTest.java b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/StringIndexOfStringIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8ff3b9cc17729040eaaf5dd504a27bb322054c3e --- /dev/null +++ b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/StringIndexOfStringIntTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringIndexOfStringIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringIndexOfStringIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringIndexOfStringIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOP" + + "ZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + // Test fromIndex = 0. + System.out.println(str.indexOf("c", 0)); + // Test 0 < fromIndex < str.length(). + System.out.println(str.indexOf("c", 4)); + // Test fromIndex = str.length(). + System.out.println(str.indexOf("c", str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/expected.txt b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..acc42d0ef598673481940e9673a4d0e60ae12d6b --- /dev/null +++ b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/expected.txt @@ -0,0 +1,28 @@ +31 +31 +-1 +-1 +-1 +-1 +2 +8 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +31 +31 +-1 +-1 +-1 +-1 +2 +-1 +-1 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/test.cfg b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..53d3c9f10760b8791e0df878cae0575fa60ddf18 --- /dev/null +++ b/testsuite/java_test/string_test/RT0086-rt-String-IndexOfStringIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringIndexOfStringIntTest) +run(StringIndexOfStringIntTest) diff --git a/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/StringLastIndexOfStringTest.java b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/StringLastIndexOfStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..eb859bb68c9204c3e9f047bd8ca2771a4cc58864 --- /dev/null +++ b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/StringLastIndexOfStringTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringLastIndexOfStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringLastIndexOfStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringLastIndexOfStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZX" + + "CVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.lastIndexOf("c")); + } +} diff --git a/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/expected.txt b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..281178c31338f274e6392c87e28515b83fe66a58 --- /dev/null +++ b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/expected.txt @@ -0,0 +1,10 @@ +31 +-1 +8 +-1 +-1 +31 +-1 +2 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/test.cfg b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..a738ef478c2fc9ae4f60a84ec7ff00669abd3e7d --- /dev/null +++ b/testsuite/java_test/string_test/RT0087-rt-String-LastIndexOfStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringLastIndexOfStringTest) +run(StringLastIndexOfStringTest) diff --git a/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/StringLastIndexOfStringIntTest.java b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/StringLastIndexOfStringIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..bca656539083215922c6e69d4fec532da7bf2f1f --- /dev/null +++ b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/StringLastIndexOfStringIntTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringLastIndexOfStringIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringLastIndexOfStringIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringLastIndexOfStringIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASD" + + "FGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZX" + + "CVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + // Test fromIndex = 0. + System.out.println(str.lastIndexOf("c", 0)); + // Test 0 < fromIndex < str.length(). + System.out.println(str.lastIndexOf("c", 2)); + // Test fromIndex = str.length(). + System.out.println(str.lastIndexOf("c", str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/expected.txt b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9f6913e71feaad39582925c9fd1524fec9e44818 --- /dev/null +++ b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/expected.txt @@ -0,0 +1,28 @@ +-1 +-1 +31 +-1 +-1 +-1 +-1 +2 +8 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +-1 +31 +-1 +-1 +-1 +-1 +2 +2 +-1 +-1 +-1 +0 diff --git a/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/test.cfg b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..41a9b2f9226fd7415602a227f2114967072da1a3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0088-rt-String-LastIndexOfStringIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringLastIndexOfStringIntTest) +run(StringLastIndexOfStringIntTest) diff --git a/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/StringSubstringIntTest.java b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/StringSubstringIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..e78b93a63c7431700b363a7317610a48521091f2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/StringSubstringIntTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubstringIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSubstringIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSubstringIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTY" + + "UIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + // Test beginIndex = 0. + System.out.println(str.substring(0)); + // Test 0 < beginIndex < str.length(). + System.out.println(str.substring(4)); + // Test beginIndex = str.length(). + System.out.println(str.substring(str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/expected.txt b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6d38016df308e4ae74e832fb3cf816d431f9a16d --- /dev/null +++ b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/expected.txt @@ -0,0 +1,19 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +tyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + @!.&% +&% + +abc123abc +23abc + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +tyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + @!.&% +&% + +abc123ABC +23ABC + +0 diff --git a/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/test.cfg b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..bbd3a782b48fb9a7d7a5a1be2fd244d8af394014 --- /dev/null +++ b/testsuite/java_test/string_test/RT0089-rt-String-SubstringIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubstringIntTest) +run(StringSubstringIntTest) diff --git a/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/StringSubstringIntIntTest.java b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/StringSubstringIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..47231b53622d521a090f856c261e8da14161f353 --- /dev/null +++ b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/StringSubstringIntIntTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubstringIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSubstringIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSubstringIntIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXC" + + "VBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + // Test 0 < beginIndex < endIndex < str.length(). + System.out.println(str.substring(2, 5)); + // Test beginIndex = 0. + System.out.println(str.substring(0, str.length() - 1)); + // Test endIndex = 0. + System.out.println(str.substring(0, 0)); + // Test beginIndex = str.length() - 1. + System.out.println(str.substring(str.length() - 1, str.length() - 1)); + // Test endIndex = str.length. + System.out.println(str.substring(2, str.length() - 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..5b074fbcd1246ebe5bbde78e961fdb6f503712ce --- /dev/null +++ b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/expected.txt @@ -0,0 +1,31 @@ +ert +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x9 + + +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x9 +!.& + @!.& + + +!.& +c12 +abc123ab + + +c123ab +ert +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x9 + + +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ASDFGHJKLQWERTYUIOPZXCVBNM0x9 +!.& + @!.& + + +!.& +c12 +abc123AB + + +c123AB +0 diff --git a/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..317a824fa097483bfb44b234094a639adc278c81 --- /dev/null +++ b/testsuite/java_test/string_test/RT0090-rt-String-SubstringIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubstringIntIntTest) +run(StringSubstringIntIntTest) diff --git a/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/StringSubSequenceIntIntTest.java b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/StringSubSequenceIntIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d2397ebf93097919d4e6f113a735d79e4025af7d --- /dev/null +++ b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/StringSubSequenceIntIntTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSubSequenceIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSubSequenceIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSubSequenceIntIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZ" + + "XCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + test(str1_1); + test(str1_2); + test(str1_3); + test(str2_1); + test(str2_2); + test(str2_3); + } + private static void test(String str) { + // Test 0 < beginIndex < endIndex < str.length(). + System.out.println(str.subSequence(2, 6)); + // Test beginIndex = 0. + System.out.println(str.subSequence(0, str.length())); + // Test enfIndex = 0. + System.out.println(str.subSequence(0, 0)); + // Test beginIndex = str.length(). + System.out.println(str.subSequence(str.length(), str.length())); + // Test endIndex = str.length(). + System.out.println(str.subSequence(2, str.length())); + } +} diff --git a/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..b35a562f9155bb3569da97604713068ed6c1034a --- /dev/null +++ b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/expected.txt @@ -0,0 +1,31 @@ +erty +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +!.&% + @!.&% + + +!.&% +c123 +abc123abc + + +c123abc +erty +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + + +ertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +!.&% + @!.&% + + +!.&% +c123 +abc123ABC + + +c123ABC +0 diff --git a/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..9702e5f718d9a75a735545cf8a6e54dba03c9cc4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0091-rt-String-SubSequenceIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSubSequenceIntIntTest) +run(StringSubSequenceIntIntTest) diff --git a/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/StringConcatTest.java b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/StringConcatTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2250adc386f806b31a9a99e69e82104ca7e7d297 --- /dev/null +++ b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/StringConcatTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConcatTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConcatTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringConcatTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test1_1 = ""; + String test1_2 = ""; + System.out.println(test1_1.concat(str).concat(test1_2)); + } +} diff --git a/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/expected.txt b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..f860c1e6730cb4d652e9db27a4163bf1361fd47d --- /dev/null +++ b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/expected.txt @@ -0,0 +1,10 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123abc + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123ABC + +0 diff --git a/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/test.cfg b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..61f3ee7954afe757340abac2c221cf7e95eb65cd --- /dev/null +++ b/testsuite/java_test/string_test/RT0092-rt-String-ConcatTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConcatTest) +run(StringConcatTest) diff --git a/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/StringReplaceCharCharTest.java b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/StringReplaceCharCharTest.java new file mode 100644 index 0000000000000000000000000000000000000000..17cdef354b493951420a85f1fef70566775695f6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/StringReplaceCharCharTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringReplaceCharCharTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringReplaceCharCharTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringReplaceCharCharTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOP" + + "ZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.replace("a", "@").replace("1", "!")); + } +} diff --git a/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/expected.txt b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..2f4e1e3771720e455316c1ebb7d71e4ee64b9211 --- /dev/null +++ b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/expected.txt @@ -0,0 +1,10 @@ +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`!234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +@bc!23@bc + + +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`!234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +@bc!23ABC + +0 diff --git a/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/test.cfg b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..e041ab26894050c9a62584188d5e4441083663be --- /dev/null +++ b/testsuite/java_test/string_test/RT0093-rt-String-ReplaceCharCharTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringReplaceCharCharTest) +run(StringReplaceCharCharTest) diff --git a/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/StringContainsTest.java b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/StringContainsTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c66759f326af34e0bb85e4dc9174bb89aa7bf9dc --- /dev/null +++ b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/StringContainsTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringContainsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringContainsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringContainsTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOP" + + "ZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.contains("c123A")); + } +} diff --git a/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/expected.txt b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..9515db77b8254db14a3281f89d8981ed8fd26a2f --- /dev/null +++ b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/expected.txt @@ -0,0 +1,10 @@ +false +false +false +false +false +false +false +true +false +0 diff --git a/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/test.cfg b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..64fc26cd0dad11612233060d53fad44f5974edfa --- /dev/null +++ b/testsuite/java_test/string_test/RT0094-rt-String-ContainsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringContainsTest) +run(StringContainsTest) diff --git a/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/StringReplaceCharSequenceCharSequenceTest.java b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/StringReplaceCharSequenceCharSequenceTest.java new file mode 100644 index 0000000000000000000000000000000000000000..2e6354e81e17efb8f70009c52fab6c749f5ba360 --- /dev/null +++ b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/StringReplaceCharSequenceCharSequenceTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringReplaceCharSequenceCharSequenceTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringReplaceCharSequenceCharSequenceTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringReplaceCharSequenceCharSequenceTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYU" + + "IOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.replace("a", "@")); + System.out.println(str.replace("c123A", "@")); + } +} diff --git a/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/expected.txt b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..e61ca79d750df85823177fadafa2e7196c7d1a1d --- /dev/null +++ b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/expected.txt @@ -0,0 +1,19 @@ +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% +@bc123@bc +abc123abc + + + + +qwertyuiop{}[]\|@sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% +@bc123ABC +ab@BC + + +0 diff --git a/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/test.cfg b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..ed1d4b136cd19a68b436f7120055092f4a55f3de --- /dev/null +++ b/testsuite/java_test/string_test/RT0095-rt-String-ReplaceCharSequenceCharSequenceTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringReplaceCharSequenceCharSequenceTest) +run(StringReplaceCharSequenceCharSequenceTest) diff --git a/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/StringSplitStringIntTest.java b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/StringSplitStringIntTest.java new file mode 100644 index 0000000000000000000000000000000000000000..61c9c9ae5f7398d161837ce3486a26d78e8b5b64 --- /dev/null +++ b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/StringSplitStringIntTest.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSplitStringIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSplitStringIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSplitStringIntTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String[] result; + // Test 0 < limit < instance.length. + result = str.split("a", 3); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + // Test limit = instance.length. + result = str.split("a",str.length()); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + // Test limit = 0. + result = str.split("a",0); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + // Test regex is a special symbols. + result = str.split("\\.", 2); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + } +} diff --git a/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/expected.txt b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..def2b8556ca2d05be40f4dd7d3248bc19b2dddfd --- /dev/null +++ b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/expected.txt @@ -0,0 +1,58 @@ +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm, +<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% + @!.&% + @! +&% + +bc.123. +bc + +bc.123. +bc + +bc.123. +bc +abc +123.abc + + + + + + + + +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm, +<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% + @!.&% + @! +&% + +bc.123.ABC + +bc.123.ABC + +bc.123.ABC +abc +123.ABC + + + + +0 diff --git a/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/test.cfg b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..aa8769a7a1eae7282c375e398a0db312b7313e79 --- /dev/null +++ b/testsuite/java_test/string_test/RT0096-rt-String-SplitStringIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSplitStringIntTest) +run(StringSplitStringIntTest) diff --git a/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/StringSplitStringTest.java b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/StringSplitStringTest.java new file mode 100644 index 0000000000000000000000000000000000000000..57739491650698e4e0f4c4ce5bcce4dc4d5a56c6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/StringSplitStringTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSplitStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSplitStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSplitStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ A" + + "SDFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOP" + + "ZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String[] result; + result = str.split("a"); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + result = str.split("\\."); + for (int i = 0; i < result.length; i++) { + System.out.println(result[i]); + } + } +} diff --git a/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/expected.txt b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..6e7ba2c475f807a6197fbba226f3410413f39251 --- /dev/null +++ b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/expected.txt @@ -0,0 +1,32 @@ +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm, +<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @! +&% + +bc.123. +bc +abc +123 +abc + + + + +qwertyuiop{}[]\| +sdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm, +<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @! +&% + +bc.123.ABC +abc +123 +ABC + + +0 diff --git a/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/test.cfg b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..4974022d845a34231ec1ab7928bb45fa33909948 --- /dev/null +++ b/testsuite/java_test/string_test/RT0097-rt-String-SplitStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSplitStringTest) +run(StringSplitStringTest) diff --git a/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/StringJoinCharSequenceCharSequenceTest.java b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/StringJoinCharSequenceCharSequenceTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8a5de0acaa93d301ba987fa788534c93c4e81a8f --- /dev/null +++ b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/StringJoinCharSequenceCharSequenceTest.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringJoinCharSequenceCharSequenceTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringJoinCharSequenceCharSequenceTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringJoinCharSequenceCharSequenceTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String[] test = new String[]{str, str, str}; + System.out.println(String.join("-", test)); + } +} diff --git a/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/expected.txt b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..460fc604d3191a61cbb03d531b408def33f595c2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/expected.txt @@ -0,0 +1,10 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&%- @!.&%- @!.&% +abc123abc-abc123abc-abc123abc +-- +-- +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&%- @!.&%- @!.&% +abc123ABC-abc123ABC-abc123ABC +-- +0 diff --git a/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/test.cfg b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6bd486e9b25f9c86d413183198d08c16d07fa441 --- /dev/null +++ b/testsuite/java_test/string_test/RT0098-rt-String-JoinCharSequenceCharSequenceTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringJoinCharSequenceCharSequenceTest) +run(StringJoinCharSequenceCharSequenceTest) diff --git a/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/StringJoinCharSequenceIterableTest.java b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/StringJoinCharSequenceIterableTest.java new file mode 100755 index 0000000000000000000000000000000000000000..6dee3125904234bc641fe4c9d4333d53a54eff1d --- /dev/null +++ b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/StringJoinCharSequenceIterableTest.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +public class StringJoinCharSequenceIterableTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringJoinCharSequenceIterableTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringJoinCharSequenceIterableTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + List test1_1 = new LinkedList<>(); + test1_1.add(str); + test1_1.add(str); + test1_1.add(str); + System.out.println(String.join("-", test1_1)); + Set test1_2 = new LinkedHashSet<>(); + test1_2.add(str); + test1_2.add(str); + test1_2.add(str); + System.out.println(String.join("~", test1_2)); + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/expected.txt b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..34a67088806829cab3879b4c9698978b45919dd7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/expected.txt @@ -0,0 +1,19 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&%- @!.&%- @!.&% + @!.&% +abc123abc-abc123abc-abc123abc +abc123abc +-- + +-- + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96-qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&%- @!.&%- @!.&% + @!.&% +abc123ABC-abc123ABC-abc123ABC +abc123ABC +-- + +0 diff --git a/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/test.cfg b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b7bd8ca1a3ab7dcb1b5598e28f975e547a415913 --- /dev/null +++ b/testsuite/java_test/string_test/RT0099-rt-String-JoinCharSequenceIterableTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringJoinCharSequenceIterableTest) +run(StringJoinCharSequenceIterableTest) diff --git a/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/StringToLowerCaseLocaleTest.java b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/StringToLowerCaseLocaleTest.java new file mode 100755 index 0000000000000000000000000000000000000000..898c45a39610942994fbf0a29389650430abf615 --- /dev/null +++ b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/StringToLowerCaseLocaleTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Locale; +public class StringToLowerCaseLocaleTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToLowerCaseLocaleTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToLowerCaseLocaleTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc.~!@#$%^&*()_+;'/.?"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.toLowerCase(Locale.CHINESE)); + System.out.println(str.toLowerCase(Locale.ENGLISH)); + System.out.println(str.toLowerCase(Locale.FRENCH)); + } +} diff --git a/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/expected.txt b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..e53bc1a242c855ef9d49dd76d4cc83f0e3969eb6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/expected.txt @@ -0,0 +1,28 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 + @!.&% + @!.&% + @!.&% +abc.123.abc.~!@#$%^&*()_+;'/.? +abc.123.abc.~!@#$%^&*()_+;'/.? +abc.123.abc.~!@#$%^&*()_+;'/.? + + + + + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 + @!.&% + @!.&% + @!.&% +abc.123.abc +abc.123.abc +abc.123.abc + + + +0 diff --git a/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/test.cfg b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c17a02f2a78a2d1f50042333593c78972d462098 --- /dev/null +++ b/testsuite/java_test/string_test/RT0100-rt-String-ToLowerCaseLocaleTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToLowerCaseLocaleTest) +run(StringToLowerCaseLocaleTest) diff --git a/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/StringToLowerCaseTest.java b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/StringToLowerCaseTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8c4eff4697a9f192a58ccc7633bf564ad0728b04 --- /dev/null +++ b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/StringToLowerCaseTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringToLowerCaseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToLowerCaseTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToLowerCaseTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc.~!@#$%^&*()_+;'/.?"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.toLowerCase()); + } +} diff --git a/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/expected.txt b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..2927b543ba92f5165a45cf82146fc05940461049 --- /dev/null +++ b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/expected.txt @@ -0,0 +1,10 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 + @!.&% +abc.123.abc.~!@#$%^&*()_+;'/.? + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ asdfghjklqwertyuiopzxcvbnm0x96 + @!.&% +abc.123.abc + +0 diff --git a/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/test.cfg b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..266e6cdac3f1b73260359f5770d42763fefcca07 --- /dev/null +++ b/testsuite/java_test/string_test/RT0101-rt-String-ToLowerCaseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToLowerCaseTest) +run(StringToLowerCaseTest) diff --git a/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/StringToUpperCaseLocaleTest.java b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/StringToUpperCaseLocaleTest.java new file mode 100755 index 0000000000000000000000000000000000000000..68341774645c905d1f823c2b5ed80037033abe97 --- /dev/null +++ b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/StringToUpperCaseLocaleTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.util.Locale; +public class StringToUpperCaseLocaleTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToUpperCaseLocaleTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToUpperCaseLocaleTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc.~!@#$%^&*()_+;'/.?"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.toUpperCase(Locale.CHINESE)); + System.out.println(str.toUpperCase(Locale.ENGLISH)); + System.out.println(str.toUpperCase(Locale.FRENCH)); + } +} diff --git a/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/expected.txt b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..4f0d0a5886a42c0346e9533518ecb7db053b8535 --- /dev/null +++ b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/expected.txt @@ -0,0 +1,28 @@ +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 + @!.&% + @!.&% + @!.&% +ABC.123.ABC.~!@#$%^&*()_+;'/.? +ABC.123.ABC.~!@#$%^&*()_+;'/.? +ABC.123.ABC.~!@#$%^&*()_+;'/.? + + + + + + +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 + @!.&% + @!.&% + @!.&% +ABC.123.ABC +ABC.123.ABC +ABC.123.ABC + + + +0 diff --git a/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/test.cfg b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..71d5d8452e987f144a9743e6694e3ac608a779fb --- /dev/null +++ b/testsuite/java_test/string_test/RT0102-rt-String-ToUpperCaseLocaleTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToUpperCaseLocaleTest) +run(StringToUpperCaseLocaleTest) diff --git a/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/StringToUpperCaseTest.java b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/StringToUpperCaseTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8ab8ba6d48383309a27098749423fdc743796bc4 --- /dev/null +++ b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/StringToUpperCaseTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringToUpperCaseTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToUpperCaseTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToUpperCaseTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc.123.abc.~!@#$%^&*()_+;'/.?"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc.123.ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str.toUpperCase()); + } +} diff --git a/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/expected.txt b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..5fc4eb463636e958bb9ee5c1eb37c6e201180756 --- /dev/null +++ b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/expected.txt @@ -0,0 +1,10 @@ +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 + @!.&% +ABC.123.ABC.~!@#$%^&*()_+;'/.? + + +QWERTYUIOP{}[]\|ASDFGHJKL;:'"ZXCVBNM,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0X96 + @!.&% +ABC.123.ABC + +0 diff --git a/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/test.cfg b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7316e846653708cbed31cc293292a87c019d7c36 --- /dev/null +++ b/testsuite/java_test/string_test/RT0103-rt-String-ToUpperCaseTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToUpperCaseTest) +run(StringToUpperCaseTest) diff --git a/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/StringTrimTest.java b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/StringTrimTest.java new file mode 100755 index 0000000000000000000000000000000000000000..9caa7b903016f09ca610641077db56795a6f5d42 --- /dev/null +++ b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/StringTrimTest.java @@ -0,0 +1,85 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringTrimTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringTrimTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringTrimTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String(" abc.123.abc "); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = " abc.123.ABC "; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + char data3_1[] = {'\t', 'a', 'b', 'c', '\t'}; + String str3_1 = new String(data3_1); + test(str3_1); + char data3_2[] = {'\n', 'A', 'B', 'C', '\n'}; + String str3_2 = new String(data3_2); + test(str3_2); + char data3_3[] = {'\f', 'a', 'b', 'c', '\f'}; + String str3_3 = new String(data3_3); + test(str3_3); + char data3_4[] = {'\b', 'A', 'B', 'C', '\b'}; + String str3_4 = new String(data3_4); + test(str3_4); + char data3_5[] = {'\r', 'a', 'b', 'c', '\r'}; + String str3_5 = new String(data3_5); + test(str3_5); + char data3_6[] = {'\'', 'A', 'B', 'C', '\''}; + String str3_6 = new String(data3_6); + test(str3_6); + char data3_7[] = {'\\', 'a', 'b', 'c', '\\'}; + String str3_7 = new String(data3_7); + test(str3_7); + char data3_8[] = {'\"', 'A', 'B', 'C', '\"'}; + String str3_8 = new String(data3_8); + test(str3_8); + } + private static void test(String str) { + System.out.println(str); + System.out.println(str.trim()); + } +} diff --git a/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/expected.txt b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..56217b6f3ea24a8b95dec4a7953c6a8317bcb41a --- /dev/null +++ b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/expected.txt @@ -0,0 +1,37 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +@!.&% + abc.123.abc +abc.123.abc + + + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +@!.&% + abc.123.ABC +abc.123.ABC + + + abc +abc + +ABC + +ABC + abc +abc +ABC +ABC + abc +abc +'ABC' +'ABC' +\abc\ +\abc\ +"ABC" +"ABC" +0 diff --git a/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/test.cfg b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b07faa15734b077f3a7fde8903100c24cc4d40ed --- /dev/null +++ b/testsuite/java_test/string_test/RT0104-rt-String-TrimTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringTrimTest) +run(StringTrimTest) diff --git a/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/StringToStringTest.java b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/StringToStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..0a08c4fda1bea05c721630ceeacfc9f3a12ebdb2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/StringToStringTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + //new String() input : byte[], char[], StringBuffer, StringBuilder, String, int[](ASCII) + //byte[] char[] must USE new String + char data3_1[] = {0x61, 0x62, 0x63}; + String str3_1 = new String(data3_1); + System.out.println(str3_1); + System.out.println(str3_1.toString()); + } + private static void test(String str) { + System.out.println(str.toString()); + } +} diff --git a/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/expected.txt b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..68ff8cbcafc310af899f01ea4b38f710fd35a73e --- /dev/null +++ b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/expected.txt @@ -0,0 +1,12 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123abc + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123ABC + +abc +abc +0 diff --git a/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/test.cfg b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..42432854cbdec2a8483799ef924ae834de2e0f30 --- /dev/null +++ b/testsuite/java_test/string_test/RT0105-rt-String-ToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToStringTest) +run(StringToStringTest) diff --git a/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/StringToCharArrayTest.java b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/StringToCharArrayTest.java new file mode 100755 index 0000000000000000000000000000000000000000..6c33534c8222f00c6677f0ee61435f5930a06ec5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/StringToCharArrayTest.java @@ -0,0 +1,64 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringToCharArrayTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToCharArrayTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToCharArrayTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc\n123\nabc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + System.out.println(str); + char[] ch1 = str.toCharArray(); + System.out.println("ch1 length: " + ch1.length); + System.out.println(ch1); + System.out.println(new String(ch1)); + } +} diff --git a/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/expected.txt b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..a8548984cad0d27f8c32d20a6f77d4ee1dcf4be8 --- /dev/null +++ b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/expected.txt @@ -0,0 +1,43 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ch1 length: 99 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +ch1 length: 6 + @!.&% + @!.&% +abc +123 +abc +ch1 length: 11 +abc +123 +abc +abc +123 +abc + +ch1 length: 0 + + + +ch1 length: 0 + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +ch1 length: 99 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +ch1 length: 6 + @!.&% + @!.&% +abc123ABC +ch1 length: 9 +abc123ABC +abc123ABC + +ch1 length: 0 + + +0 diff --git a/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/test.cfg b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a9d17d4c92692ebe130831422351b96ab59e970d --- /dev/null +++ b/testsuite/java_test/string_test/RT0106-rt-String-ToCharArrayTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToCharArrayTest) +run(StringToCharArrayTest) diff --git a/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/StringFormatStringObjectTest.java b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/StringFormatStringObjectTest.java new file mode 100755 index 0000000000000000000000000000000000000000..da1da084b032f83214ccc3a3d7f2cd13aadc2643 --- /dev/null +++ b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/StringFormatStringObjectTest.java @@ -0,0 +1,70 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringFormatStringObjectTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringFormatStringObjectTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringFormatStringObjectTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + String str3_1 = null; + str3_1 = String.format("%c %n", 'A'); + System.out.println(str3_1); + str3_1 = String.format("%b %n", 3 > 7); + System.out.println(str3_1); + str3_1 = String.format("%b %n", 3 < 7); + System.out.println(str3_1); + } + private static void test(String str) { + String test1 = null; + test1 = String.format("%s", str); + System.out.println(test1); + test1 = String.format("%s %s %s", str, str, str); + System.out.println(test1); } +} diff --git a/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/expected.txt b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..9b5e03d89b69234871bf35bc9b5af0713f0574da --- /dev/null +++ b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/expected.txt @@ -0,0 +1,25 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% @!.&% @!.&% +abc123abc +abc123abc abc123abc abc123abc + + + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% + @!.&% @!.&% @!.&% +abc123ABC +abc123ABC abc123ABC abc123ABC + + +A + +false + +true + +0 diff --git a/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/test.cfg b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..45f08adeffe665051fc5ccb7d06e62b21780bbde --- /dev/null +++ b/testsuite/java_test/string_test/RT0107-rt-String-FormatStringObjectTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringFormatStringObjectTest) +run(StringFormatStringObjectTest) diff --git a/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/StringValueOfObjectTest.java b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/StringValueOfObjectTest.java new file mode 100755 index 0000000000000000000000000000000000000000..feacda7ff1ec915af8e530588233e69731c1acae --- /dev/null +++ b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/StringValueOfObjectTest.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfObjectTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfObjectTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfObjectTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + String str2_5 = null; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + test(str2_5); + } + private static void test(Object obj) { + System.out.println(String.valueOf(obj)); + } +} diff --git a/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/expected.txt b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..cbea9374e93f9c9421df5de7bd08fc1db0f1d77d --- /dev/null +++ b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/expected.txt @@ -0,0 +1,11 @@ +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123abc + + +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 + @!.&% +abc123ABC + +null +0 diff --git a/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/test.cfg b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..110b4e1239a8a2e797676f025d16c797478cac59 --- /dev/null +++ b/testsuite/java_test/string_test/RT0108-rt-String-ValueOfObjectTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfObjectTest) +run(StringValueOfObjectTest) diff --git a/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/StringValueOfCharsTest.java b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/StringValueOfCharsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..7e7ef966fe142219d9006cabe0df2de1cc3a11c2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/StringValueOfCharsTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfCharsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfCharsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfCharsTest_1() { + char[] ch1_1 = {'a', 'b', 'c', '1', '2', '3'}; + char[] ch1_2 = {0x61, 0x62, 0x63, 0x31, 0x32, 0x33}; + char[] ch1_3 = {'\u0061', '\u0062', '\u0063', '\u0031', '\u0032', '\u0033'}; + char[] ch1_4 = {0x0061, 0x0062, 0x0063, 0x0031, 0x0032, 0x0033}; + char[] ch1_5 = {}; + test(ch1_1); + test(ch1_2); + test(ch1_3); + test(ch1_4); + test(ch1_5); + } + private static void test(char[] ch1_1) { + System.out.println(String.valueOf(ch1_1)); + } +} diff --git a/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/expected.txt b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..10ea6c18025feffd435b8df28e753a49a4146060 --- /dev/null +++ b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/expected.txt @@ -0,0 +1,6 @@ +abc123 +abc123 +abc123 +abc123 + +0 diff --git a/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/test.cfg b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c451cb472e7f35255d760ea46c575a3ad0b5db10 --- /dev/null +++ b/testsuite/java_test/string_test/RT0109-rt-String-ValueOfCharsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfCharsTest) +run(StringValueOfCharsTest) diff --git a/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/StringValueOfCharIntIntTest.java b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/StringValueOfCharIntIntTest.java new file mode 100755 index 0000000000000000000000000000000000000000..414defb8192516ca6883a5c2e1118e5a058114bb --- /dev/null +++ b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/StringValueOfCharIntIntTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfCharIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfCharIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfCharIntIntTest_1() { + char ch1_1[] = {'a', 'b', 'c', '1', '2', '3'}; + char ch1_2[] = {0x61, 0x62, 0x63, 0x31, 0x32, 0x33}; + char ch1_3[] = {'\u0061', '\u0062', '\u0063', '\u0031', '\u0032', '\u0033'}; + char ch1_4[] = {0x0061, 0x0062, 0x0063, 0x0031, 0x0032, 0x0033}; + test(ch1_1); + test(ch1_2); + test(ch1_3); + test(ch1_4); + } + private static void test(char[] ch1_1) { + System.out.println(String.valueOf(ch1_1, 1, 3)); + // Test offset = 0. + System.out.println(String.valueOf(ch1_1, 0, 3)); + // Test count = 0. + System.out.println(String.valueOf(ch1_1, 1, 0)); + // Test count = ch1_1.length. + System.out.println(String.valueOf(ch1_1, 0, ch1_1.length)); + // Test offset = ch1_1.length - 1. + System.out.println(String.valueOf(ch1_1, ch1_1.length - 1, 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3a9ab8df3d0ec0ea65ff87319a0b96415262a696 --- /dev/null +++ b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/expected.txt @@ -0,0 +1,21 @@ +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +0 diff --git a/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7d3c29077bd323ee72410296985607a0265af637 --- /dev/null +++ b/testsuite/java_test/string_test/RT0110-rt-String-ValueOfCharIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfCharIntIntTest) +run(StringValueOfCharIntIntTest) diff --git a/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/StringCopyValueOfCharIntIntTest.java b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/StringCopyValueOfCharIntIntTest.java new file mode 100755 index 0000000000000000000000000000000000000000..dad07668591a0228ced28a20253f4def3090fd0b --- /dev/null +++ b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/StringCopyValueOfCharIntIntTest.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCopyValueOfCharIntIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCopyValueOfCharIntIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCopyValueOfCharIntIntTest_1() { + char ch1_1[] = {'a', 'b', 'c', '1', '2', '3'}; + char ch1_2[] = {0x61, 0x62, 0x63, 0x31, 0x32, 0x33}; + char ch1_3[] = {'\u0061', '\u0062', '\u0063', '\u0031', '\u0032', '\u0033'}; + char ch1_4[] = {0x0061, 0x0062, 0x0063, 0x0031, 0x0032, 0x0033}; + test(ch1_1); + test(ch1_2); + test(ch1_3); + test(ch1_4); + } + private static void test(char[] ch1_1) { + System.out.println(String.copyValueOf(ch1_1, 1, 3)); + // Test offset = 0. + System.out.println(String.copyValueOf(ch1_1, 0, 3)); + // Test count = 0. + System.out.println(String.copyValueOf(ch1_1, 1, 0)); + // Test count = ch1_1.length. + System.out.println(String.copyValueOf(ch1_1, 0, ch1_1.length)); + // Test offset = ch1_1.length - 1. + System.out.println(String.copyValueOf(ch1_1, ch1_1.length - 1, 1)); + } +} diff --git a/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/expected.txt b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3a9ab8df3d0ec0ea65ff87319a0b96415262a696 --- /dev/null +++ b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/expected.txt @@ -0,0 +1,21 @@ +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +bc1 +abc + +abc123 +3 +0 diff --git a/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/test.cfg b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..94cab0239c974ea567ef821862bc70bf18a64909 --- /dev/null +++ b/testsuite/java_test/string_test/RT0111-rt-String-CopyValueOfCharIntIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCopyValueOfCharIntIntTest) +run(StringCopyValueOfCharIntIntTest) diff --git a/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/StringCopyValueOfCharTest.java b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/StringCopyValueOfCharTest.java new file mode 100755 index 0000000000000000000000000000000000000000..69851cfec21a7f93c904f39770434f5ee1e4b560 --- /dev/null +++ b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/StringCopyValueOfCharTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCopyValueOfCharTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCopyValueOfCharTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCopyValueOfCharTest_1() { + char ch1_1[] = {'a', 'b', 'c', '1', '2', '3'}; + char ch1_2[] = {0x61, 0x62, 0x63, 0x31, 0x32, 0x33}; + char ch1_3[] = {'\u0061', '\u0062', '\u0063', '\u0031', '\u0032', '\u0033'}; + char ch1_4[] = {0x0061, 0x0062, 0x0063, 0x0031, 0x0032, 0x0033}; + test(ch1_1); + test(ch1_2); + test(ch1_3); + test(ch1_4); + } + private static void test(char[] ch) { + System.out.println(String.copyValueOf(ch)); + } +} diff --git a/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/expected.txt b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..4a6d8198002498c8797d1002d7d673f77e65887e --- /dev/null +++ b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/expected.txt @@ -0,0 +1,5 @@ +abc123 +abc123 +abc123 +abc123 +0 diff --git a/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/test.cfg b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..fe37cc7df30510c677cda68725e05b0c1527bc3c --- /dev/null +++ b/testsuite/java_test/string_test/RT0112-rt-String-CopyValueOfCharTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCopyValueOfCharTest) +run(StringCopyValueOfCharTest) diff --git a/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/StringValueOfBooleanTest.java b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/StringValueOfBooleanTest.java new file mode 100755 index 0000000000000000000000000000000000000000..03b551eb2b27e6182ebfea6ad413e29a0542b0ca --- /dev/null +++ b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/StringValueOfBooleanTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfBooleanTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfBooleanTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfBooleanTest_1() { + boolean bo1_1 = 3 > 7; + boolean bo1_2 = 9 > 7; + test(bo1_1); + test(bo1_2); + } + private static void test(boolean bo) { + System.out.println(String.valueOf(bo)); + } +} diff --git a/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/expected.txt b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c6f88a0905960e4938a3e6cc2213b532d30f66fb --- /dev/null +++ b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/expected.txt @@ -0,0 +1,3 @@ +false +true +0 diff --git a/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/test.cfg b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f45a7e639672d949141ec6e80cf8c2a3c52ca9ef --- /dev/null +++ b/testsuite/java_test/string_test/RT0113-rt-String-ValueOfBooleanTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfBooleanTest) +run(StringValueOfBooleanTest) diff --git a/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/StringValueOfCharTest.java b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/StringValueOfCharTest.java new file mode 100755 index 0000000000000000000000000000000000000000..2a3988a5f442dbe0d4b311391746e3d78d8a6f0f --- /dev/null +++ b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/StringValueOfCharTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfCharTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfCharTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfCharTest_1() { + char ch1_1 = 'a'; + char ch1_2 = 0x61; + char ch1_3 = '\u0061'; + char ch1_4 = 0x0061; + test(ch1_1); + test(ch1_2); + test(ch1_3); + test(ch1_4); + } + private static void test(char ch) { + System.out.println(String.valueOf(ch)); + } +} diff --git a/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/expected.txt b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..7ad67732e31836bfa31a4361afe57d9b17824e36 --- /dev/null +++ b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/expected.txt @@ -0,0 +1,5 @@ +a +a +a +a +0 diff --git a/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/test.cfg b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2fe52e0d324bf1e2644a45b2599692737717f42a --- /dev/null +++ b/testsuite/java_test/string_test/RT0114-rt-String-ValueOfCharTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfCharTest) +run(StringValueOfCharTest) diff --git a/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/StringValueOfIntTest.java b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/StringValueOfIntTest.java new file mode 100755 index 0000000000000000000000000000000000000000..e28dfd79ecaf1532fd620c5cf59adccfb968781f --- /dev/null +++ b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/StringValueOfIntTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfIntTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfIntTest_1() { + int in1_1 = 0; + int in1_2 = 12; + test(in1_1); + test(in1_2); + } + private static void test(int in) { + String test = String.valueOf(in); + System.out.println(test); + System.out.println(test + 13); + } +} diff --git a/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/expected.txt b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..0ff90c0699f35506001b4d048175f326e59be192 --- /dev/null +++ b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/expected.txt @@ -0,0 +1,5 @@ +0 +013 +12 +1213 +0 diff --git a/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/test.cfg b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..293c4f0b93d4a5ca3bf312e5efe5a7fcbcab1ee3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0115-rt-String-ValueOfIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfIntTest) +run(StringValueOfIntTest) diff --git a/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/StringValueOfLongTest.java b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/StringValueOfLongTest.java new file mode 100755 index 0000000000000000000000000000000000000000..a6348a062d7527adbba3faccc26d80617d0364f1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/StringValueOfLongTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfLongTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfLongTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfLongTest_1() { + long long1_1 = 0; + long long1_2 = 1234567890; + test(long1_1); + test(long1_2); + } + private static void test(long lo) { + String test = String.valueOf(lo); + System.out.println(test); + System.out.println(test + 13); + } +} diff --git a/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/expected.txt b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..58be843f411c3f47ccb2bb9d1f413149835eb68d --- /dev/null +++ b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/expected.txt @@ -0,0 +1,5 @@ +0 +013 +1234567890 +123456789013 +0 diff --git a/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/test.cfg b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d28467fc552ea6f9271048e5ec5ff8b0af989454 --- /dev/null +++ b/testsuite/java_test/string_test/RT0116-rt-String-ValueOfLongTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfLongTest) +run(StringValueOfLongTest) diff --git a/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/StringValueOfFloatTest.java b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/StringValueOfFloatTest.java new file mode 100755 index 0000000000000000000000000000000000000000..3d487022c831a91bb9bc061355165d481a53c8b2 --- /dev/null +++ b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/StringValueOfFloatTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfFloatTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfFloatTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfFloatTest_1() { + float fl1_1 = 0; + float fl1_2 = (float) 13.0; + test(fl1_1); + test(fl1_2); + } + private static void test(float fl) { + String test = String.valueOf(fl); + System.out.println(test); + System.out.println(test + 13); + } +} diff --git a/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/expected.txt b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3a7204cc9dfc92d4a7751fd56913325c4c8ad464 --- /dev/null +++ b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/expected.txt @@ -0,0 +1,5 @@ +0.0 +0.013 +13.0 +13.013 +0 diff --git a/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/test.cfg b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..25cfdd123855825332ac907ad189a844ac9a2587 --- /dev/null +++ b/testsuite/java_test/string_test/RT0117-rt-String-ValueOfFloatTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfFloatTest) +run(StringValueOfFloatTest) diff --git a/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/StringValueOfDoubleTest.java b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/StringValueOfDoubleTest.java new file mode 100755 index 0000000000000000000000000000000000000000..082072b45200d7ad3857216700a5a5555e0bf4c3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/StringValueOfDoubleTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringValueOfDoubleTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringValueOfDoubleTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringValueOfDoubleTest_1() { + double d1_1 = 0; + double d1_2 = 1.23; + test(d1_1); + test(d1_2); + } + private static void test(double d) { + String test = String.valueOf(d); + System.out.println(test); + System.out.println(test + 13); + } +} diff --git a/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/expected.txt b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..08add1eee7829b24a9e89be6d98bc2bc4a03cb2f --- /dev/null +++ b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/expected.txt @@ -0,0 +1,5 @@ +0.0 +0.013 +1.23 +1.2313 +0 diff --git a/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/test.cfg b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a3361e73606ebabb14935577122821960316199d --- /dev/null +++ b/testsuite/java_test/string_test/RT0118-rt-String-ValueOfDoubleTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringValueOfDoubleTest) +run(StringValueOfDoubleTest) diff --git a/testsuite/java_test/string_test/RT0119-rt-String-InternTest/StringInternTest.java b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/StringInternTest.java new file mode 100755 index 0000000000000000000000000000000000000000..7a53e9109396a07d13fb65071f46a866cc5580dc --- /dev/null +++ b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/StringInternTest.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringInternTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out){ + int result = 2; /* STATUS_Success*/ + + try { + result = result-StringInternTest_1(); // 2-1=1 + } catch(Exception e){ + System.out.println(e); + StringInternTest.processResult = StringInternTest.processResult - 10; + } + if (result == 1 && StringInternTest.processResult == 98){ + result = 0; + } + return result; + } + public static int StringInternTest_1() { + int result1 = 4; /* STATUS_FAILED*/ + + String str1 = "a"; + String str2 = "b"; + String str3 = "ab"; + String str4 = str1 + str2; + String str5 = new String("ab"); + String str6 = "a" + "b"; + String str7 = "a" + str2; + String str8 = new String("ab"); + if(str5.intern() == str3 && str5.intern() != str4 && str5.intern() == str6 && str5.intern() != str7 + && str5.intern() == str8.intern()) { + StringInternTest.processResult = StringInternTest.processResult - 1; + return 1; + } + StringInternTest.processResult = StringInternTest.processResult - 10; + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0119-rt-String-InternTest/expected.txt b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0119-rt-String-InternTest/test.cfg b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..9843dc296eadd766e980b6aa6288edcbd825b309 --- /dev/null +++ b/testsuite/java_test/string_test/RT0119-rt-String-InternTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringInternTest) +run(StringInternTest) diff --git a/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/StringVoluationTest.java b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/StringVoluationTest.java new file mode 100755 index 0000000000000000000000000000000000000000..ef763824fa152fe9cdbeb6d830b54337e8efc799 --- /dev/null +++ b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/StringVoluationTest.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringVoluationTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringVoluationTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringVoluationTest_1() { + String str1 = "abc"; + System.out.println(str1); + } +} diff --git a/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/expected.txt b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..645b0fa42721151efe255bdd64409979a8b76835 --- /dev/null +++ b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/expected.txt @@ -0,0 +1,2 @@ +abc +0 diff --git a/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/test.cfg b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6e5be6ace3250d88a44410b07aaa8f4e2cd3115d --- /dev/null +++ b/testsuite/java_test/string_test/RT0120-rt-String-VoluationTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringVoluationTest) +run(StringVoluationTest) diff --git a/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/StringVoluationCharsTest.java b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/StringVoluationCharsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..716fb8c668f2e4124432f2df0b1bd6bace74aa8b --- /dev/null +++ b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/StringVoluationCharsTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringVoluationCharsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringVoluationCharsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringVoluationCharsTest_1() { + char[] data2 = {'a', 'b', 'c'}; + String str2 = new String(data2); + char[] data3 = {0x61, 0x62, 0x63}; + String str3 = new String(data3); + String str4 = new String("abc"); + System.out.println(str2); + System.out.println(str3); + System.out.println(str4); + } +} diff --git a/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/expected.txt b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..62997c8d60f117b2a38c1b94a4294def91665efc --- /dev/null +++ b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/expected.txt @@ -0,0 +1,4 @@ +abc +abc +abc +0 diff --git a/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/test.cfg b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..95c9c4523f676f79f8ba98157fefc5ab65e0251d --- /dev/null +++ b/testsuite/java_test/string_test/RT0121-rt-String-VoluationCharsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringVoluationCharsTest) +run(StringVoluationCharsTest) diff --git a/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/StringSpliceStringTest.java b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/StringSpliceStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..1a865da27267664ccabb2e5b185f8f6c8195d387 --- /dev/null +++ b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/StringSpliceStringTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringSpliceStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringSpliceStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringSpliceStringTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123"; + String str2_4 = ""; + String str2_5 = null; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + test(str2_5); + } + private static void test(String str) { + String test1_1 = "test" + str; + String test1_2 = str + str; + System.out.println(test1_1); + System.out.println(test1_2); + } +} diff --git a/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/expected.txt b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..bf1c730d2b6a39571ed9d937713aa07eb527054e --- /dev/null +++ b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/expected.txt @@ -0,0 +1,21 @@ +testqwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +test @!.&% + @!.&% @!.&% +testabc123 +abc123abc123 +test + +test + +testqwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96qwertyuiop{}[]\|asdfghjkl;:'"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIOPZXCVBNM0x96 +test @!.&% + @!.&% @!.&% +testabc123 +abc123abc123 +test + +testnull +nullnull +0 diff --git a/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/test.cfg b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..208f9bea87f2fbd0bfb33295f153080dc318201c --- /dev/null +++ b/testsuite/java_test/string_test/RT0122-rt-String-SpliceStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringSpliceStringTest) +run(StringSpliceStringTest) diff --git a/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/StringCompareByDoubleEqualSignTest.java b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/StringCompareByDoubleEqualSignTest.java new file mode 100755 index 0000000000000000000000000000000000000000..53ca4a5c9ec45caa2a8fe1a3445a2a36346981be --- /dev/null +++ b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/StringCompareByDoubleEqualSignTest.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCompareByDoubleEqualSignTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCompareByDoubleEqualSignTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCompareByDoubleEqualSignTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + String str2_5 = null; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + test(str2_5); + } + private static void test(String str) { + String test1_1 = "abc123ABC"; + if (test1_1 == str) { + System.out.println("str == abc123abc"); + } else { + System.out.println("str1 !"); + } + } +} diff --git a/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/expected.txt b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..689a4f5de059d4911c21df414be2b3c80f9eb3cb --- /dev/null +++ b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/expected.txt @@ -0,0 +1,11 @@ +str1 ! +str1 ! +str1 ! +str1 ! +str1 ! +str1 ! +str1 ! +str == abc123abc +str1 ! +str1 ! +0 diff --git a/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/test.cfg b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..5c53bc1a5c00bb77fa737cf139250839f1ec64eb --- /dev/null +++ b/testsuite/java_test/string_test/RT0123-rt-String-CompareByDoubleEqualSignTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCompareByDoubleEqualSignTest) +run(StringCompareByDoubleEqualSignTest) diff --git a/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/StringCompareByEqualsTest.java b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/StringCompareByEqualsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..d805d95d505aabbc3bf0474258112990e81ee2ae --- /dev/null +++ b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/StringCompareByEqualsTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCompareByEqualsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCompareByEqualsTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCompareByEqualsTest_1() { + String str1_1 = new String("qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ AS" + + "DFGHJKLQWERTYUIOPZXCVBNM0x96"); + String str1_2 = new String(" @!.&%"); + String str1_3 = new String("abc123abc"); + String str1_4 = new String(""); + String str1_5 = new String(); + String str2_1 = "qwertyuiop{}[]\\|asdfghjkl;:'\"zxcvbnm,.<>/?~`1234567890-=!@#$%^&*()_+ ASDFGHJKLQWERTYUIO" + + "PZXCVBNM0x96"; + String str2_2 = " @!.&%"; + String str2_3 = "abc123ABC"; + String str2_4 = ""; + test(str1_1); + test(str1_2); + test(str1_3); + test(str1_4); + test(str1_5); + test(str2_1); + test(str2_2); + test(str2_3); + test(str2_4); + } + private static void test(String str) { + String test1_1 = "abc123abc"; + if (str.equals(test1_1)) { + System.out.println("str == abc123abc"); + } else { + System.out.println("str1 !"); + } + } +} diff --git a/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/expected.txt b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..3ae6ee349a0ffec66f925efee43d4b6b97a9728c --- /dev/null +++ b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/expected.txt @@ -0,0 +1,10 @@ +str1 ! +str1 ! +str == abc123abc +str1 ! +str1 ! +str1 ! +str1 ! +str1 ! +str1 ! +0 diff --git a/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/test.cfg b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..f23951aaa536e32c5c314c4235aceba68d799faa --- /dev/null +++ b/testsuite/java_test/string_test/RT0124-rt-String-CompareByEqualsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCompareByEqualsTest) +run(StringCompareByEqualsTest) diff --git a/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/StringConvertToByteTest.java b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/StringConvertToByteTest.java new file mode 100755 index 0000000000000000000000000000000000000000..1726d6cbce5bb79c6a21f32077eb12d6eab21a00 --- /dev/null +++ b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/StringConvertToByteTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToByteTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToByteTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test public static byte parseByte(String s). + public static void StringConvertToByteTest_1() { + // Create 2 byte primitives bt1, bt2. + byte b_1, b_2; + // Create and assign values to String's s1, s2. + String s1 = "123"; + String s2 = "-1a"; + // Create and assign values to int r1, r2. + int r1 = 8; // Represents octal. + int r2 = 16; // Represents hexadecimal. + b_1 = Byte.parseByte(s1, r1); + b_2 = Byte.parseByte(s2, r2); + String str1_1 = s1 + " convert(8) to Byte:" + b_1; + String str1_2 = s2 + " convert(16) to Byte:" + b_2; + System.out.println(str1_1); + System.out.println(str1_2); + } +} diff --git a/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/expected.txt b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..05e2eea429faf7fbc8db6bddeffacb57037c5889 --- /dev/null +++ b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/expected.txt @@ -0,0 +1,3 @@ +123 convert(8) to Byte:83 +-1a convert(16) to Byte:-26 +0 diff --git a/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/test.cfg b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..da410075b07a757b86286acfa346f09239e48262 --- /dev/null +++ b/testsuite/java_test/string_test/RT0125-rt-String-ConvertToByteTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToByteTest) +run(StringConvertToByteTest) diff --git a/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/StringConvertToShortTest.java b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/StringConvertToShortTest.java new file mode 100755 index 0000000000000000000000000000000000000000..6d84df016511c6432588dda4bb21b9ac8051b1cb --- /dev/null +++ b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/StringConvertToShortTest.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToShortTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToShortTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test public static short parseShort(String s). + public static void StringConvertToShortTest_1() { + String str1 = "04320"; + short s_1 = Short.parseShort(str1); + System.out.println(s_1); + } +} diff --git a/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/expected.txt b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..d79c07e480eb649a1cad2a78a30f7aa73ff43eac --- /dev/null +++ b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/expected.txt @@ -0,0 +1,2 @@ +4320 +0 diff --git a/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/test.cfg b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a3e18df431e673091bb8c87fce12e23e17c47c1a --- /dev/null +++ b/testsuite/java_test/string_test/RT0126-rt-String-ConvertToShortTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToShortTest) +run(StringConvertToShortTest) diff --git a/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/StringConvertToIntTest.java b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/StringConvertToIntTest.java new file mode 100755 index 0000000000000000000000000000000000000000..82b91439f3f43207b3bfaf2879acc8dcd032b6e6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/StringConvertToIntTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToIntTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToIntTest_1(); + StringConvertToIntTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test static int parseInt(String s). + public static void StringConvertToIntTest_1() { + int i_1 = Integer.parseInt("1234"); + System.out.println("convert(10) to int: " + i_1); + } + // Test static int parseInt(String s, int radix). + public static void StringConvertToIntTest_2() { + int i_2 = Integer.parseInt("1234", 8); + System.out.println("convert(8) to int: " + i_2); + } +} diff --git a/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/expected.txt b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c6f1150fd8cd8d145b526a4c8cbe0b3f4629b5a5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/expected.txt @@ -0,0 +1,3 @@ +convert(10) to int: 1234 +convert(8) to int: 668 +0 diff --git a/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/test.cfg b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..a2c23d5c2f2a1422530272755b04a9b6c26a44e3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0127-rt-String-ConvertToIntTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToIntTest) +run(StringConvertToIntTest) diff --git a/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/StringConvertToLongTest.java b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/StringConvertToLongTest.java new file mode 100755 index 0000000000000000000000000000000000000000..14cd3a2ccaa3bfc36b89488c441e161e93601709 --- /dev/null +++ b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/StringConvertToLongTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToLongTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToLongTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test public static long parseLong(String s, int radix). + public static void StringConvertToLongTest_1() { + long l_1 = Long.parseLong("1234", 10); + // Test parses the string with specified radix + System.out.println(l_1); + long l_a = Long.parseLong("0", 10); + System.out.println(l_a); + long l_b = Long.parseLong("111", 10); + System.out.println(l_b); + long l_c = Long.parseLong("-0", 10); + System.out.println(l_c); + long l_d = Long.parseLong("-BB", 16); + System.out.println(l_d); + long l_e = Long.parseLong("1010110", 2); + System.out.println(l_e); + long l_f = Long.parseLong("2147483647", 10); + System.out.println(l_f); + long l_g = Long.parseLong("-2147483648", 10); + System.out.println(l_g); + long l_h = Long.parseLong("ADMIN", 27); + System.out.println(l_h); + } +} diff --git a/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/expected.txt b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..633fa4a74a9d8b643ceba7d8bcb56d8c66e1b234 --- /dev/null +++ b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/expected.txt @@ -0,0 +1,10 @@ +1234 +0 +111 +0 +-187 +86 +2147483647 +-2147483648 +5586836 +0 diff --git a/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/test.cfg b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7994b0bc4ec0ef4ce80382dad52d862b991c6acf --- /dev/null +++ b/testsuite/java_test/string_test/RT0128-rt-String-ConvertToLongTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToLongTest) +run(StringConvertToLongTest) diff --git a/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/StringConvertToFloatTest.java b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/StringConvertToFloatTest.java new file mode 100755 index 0000000000000000000000000000000000000000..5637532fd89ae555b343bb71c5ceb2d7e6294632 --- /dev/null +++ b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/StringConvertToFloatTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToFloatTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToFloatTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test public static float parseFloat(String s). + public static void StringConvertToFloatTest_1() { + float f_1 = Float.parseFloat("12.34"); + System.out.println(f_1); + } +} diff --git a/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/expected.txt b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..af5f02a3a085d2943410406641ffec2e25c1ba69 --- /dev/null +++ b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/expected.txt @@ -0,0 +1,2 @@ +12.34 +0 diff --git a/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/test.cfg b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..bcbe5a1f1df7066b1557a4dc62c3ee919617be26 --- /dev/null +++ b/testsuite/java_test/string_test/RT0129-rt-String-ConvertToFloatTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToFloatTest) +run(StringConvertToFloatTest) diff --git a/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/StringConvertToDoubleTest.java b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/StringConvertToDoubleTest.java new file mode 100755 index 0000000000000000000000000000000000000000..4acd8a675d8743ea9553cda44e4bd0dc9dd6d0f0 --- /dev/null +++ b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/StringConvertToDoubleTest.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringConvertToDoubleTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringConvertToDoubleTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Test public static double parseDouble(String s). + public static void StringConvertToDoubleTest_1() { + double d_1 = Double.parseDouble("1.124"); + System.out.println(d_1); + } +} diff --git a/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/expected.txt b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..a5d817df2b469672f3381336cc7144e1284603b5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/expected.txt @@ -0,0 +1,2 @@ +1.124 +0 diff --git a/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/test.cfg b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..3e6674cff30be81a53aac3f9aee2048852dab397 --- /dev/null +++ b/testsuite/java_test/string_test/RT0130-rt-String-ConvertToDoubleTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringConvertToDoubleTest) +run(StringConvertToDoubleTest) diff --git a/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/LongToBinaryStringTest.java b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/LongToBinaryStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..cfe5b126effad285ab25beba45769e22dbc2799d --- /dev/null +++ b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/LongToBinaryStringTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class LongToBinaryStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + LongToBinaryStringTest_1(); + LongToBinaryStringTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Long.toBinaryString(long l) + public static void LongToBinaryStringTest_1() { + long l_a = 0L; + long l_b = 111L; + long l_c = 2147483647L; + test(l_a); + test(l_b); + test(l_c); + } + public static void LongToBinaryStringTest_2() { + Integer i_a = 0; + Integer i_b = 111; + Integer i_c = 2147483647; + test2(i_a); + test2(i_b); + test2(i_c); + } + private static void test(Long lo) { + System.out.println(Long.toBinaryString(lo)); + } + private static void test2(Integer i) { + System.out.println(Integer.toBinaryString(i)); + } +} diff --git a/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/expected.txt b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c72c64026081633301041dbe124bf51bc2822be3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/expected.txt @@ -0,0 +1,7 @@ +0 +1101111 +1111111111111111111111111111111 +0 +1101111 +1111111111111111111111111111111 +0 diff --git a/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/test.cfg b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..79ec58ebeb7833b2f25465030206a6e376c8e627 --- /dev/null +++ b/testsuite/java_test/string_test/RT0131-rt-String-LongToBinaryStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(LongToBinaryStringTest) +run(LongToBinaryStringTest) diff --git a/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/LongToOctalStringTest.java b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/LongToOctalStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..411ab642b9d90ee1b9e1cb5b6237c9537395463e --- /dev/null +++ b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/LongToOctalStringTest.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class LongToOctalStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + LongToOctalStringTest_1(); + LongToOctalStringTest_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Long.toOctalString(long l) + public static void LongToOctalStringTest_1() { + long l_a = 0L; + long l_b = 111L; + long l_c = 2147483647L; + test(l_a); + test(l_b); + test(l_c); + } + public static void LongToOctalStringTest_2() { + Integer i_a = 0; + Integer i_b = 111; + Integer i_c = 2147483647; + test2(i_a); + test2(i_b); + test2(i_c); + } + private static void test(Long lo) { + System.out.println(Long.toOctalString(lo)); + } + private static void test2(Integer i) { + System.out.println(Integer.toOctalString(i)); + } +} diff --git a/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/expected.txt b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c3a23566e8f359dbbdb41ed1097536171edf879a --- /dev/null +++ b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/expected.txt @@ -0,0 +1,7 @@ +0 +157 +17777777777 +0 +157 +17777777777 +0 diff --git a/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/test.cfg b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..579c4f6e01fec2bb170535030f371eef4ad9df01 --- /dev/null +++ b/testsuite/java_test/string_test/RT0132-rt-String-LongToOctalStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(LongToOctalStringTest) +run(LongToOctalStringTest) diff --git a/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/BasicToStringTest.java b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/BasicToStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..b6f4aab9dbed28bb793cc3a4af120fa4a0a7e903 --- /dev/null +++ b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/BasicToStringTest.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class BasicToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + BasicToStringTest_1(); + BasicToStringTest_2(); + BasicToStringTest_3(); + BasicToStringTest_4(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + // Long.toString(long l, int p) + public static void BasicToStringTest_1() { + long l_a = 0; + long l_b = 111; + long l_c = 2147483647; + test1(l_a); + test1(l_b); + test1(l_c); + } + public static void BasicToStringTest_2() { + Integer i_a = 0; + Integer i_b = 111; + Integer i_c = 2147483647; + test2(i_a); + test2(i_b); + test2(i_c); + } + public static void BasicToStringTest_3() { + float f_a = 0f; + float f_b = 11.1f; + float f_c = 2147483.647f; + test3(f_a); + test3(f_b); + test3(f_c); + } + public static void BasicToStringTest_4() { + double d_a = 0; + double d_b = 1.11d; + double d_c = 21474836.47; + test4(d_a); + test4(d_b); + test4(d_c); + } + private static void test1(Long lo) { + System.out.println(Long.toString(lo)); + } + private static void test2(Integer i) { + System.out.println(Integer.toString(i)); + } + private static void test3(float f) { + System.out.println(Float.toString(f)); + } + private static void test4(double f) { + System.out.println(Double.toString(f)); + } +} diff --git a/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/expected.txt b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..fac89281853f9b9138781b5920f547f3e4f42de1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/expected.txt @@ -0,0 +1,13 @@ +0 +111 +2147483647 +0 +111 +2147483647 +0.0 +11.1 +2147483.8 +0.0 +1.11 +2.147483647E7 +0 diff --git a/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/test.cfg b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..1de8f2d9bee718b4ff5b32c8c6ac400549f28afd --- /dev/null +++ b/testsuite/java_test/string_test/RT0133-rt-String-BasicToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(BasicToStringTest) +run(BasicToStringTest) diff --git a/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/NullToStringTest.java b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/NullToStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..1527bc8e0d80c0bfec9e1d523ef145a6ba7525de --- /dev/null +++ b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/NullToStringTest.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class NullToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + NullToStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void NullToStringTest_1() { + int i1_1 = 0; + test1(i1_1); + int i1_2 = 123; + test1(i1_2); + Integer i1_3 = (Integer) null; + test3(i1_3); + String str1_1 = ""; + test2(str1_1); + String str1_2 = "abc"; + test2(str1_2); + String str1_3 = null; + test2(str1_3); + System.out.println((String) null); + System.out.println("<" + (String) null + ">"); + } + private static void test1(int i) { + String str1 = "<" + i + ">"; + System.out.println("str1 : " + str1); + } + private static void test2(String str) { + String str2 = "<" + str + ">"; + System.out.println("str2 : " + str2); + } + private static void test3(final Integer i) { + String str1 = "<" + i + ">"; + System.out.println("str1 : " + str1); + } +} diff --git a/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/expected.txt b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..c3b5ca95a51343b0a1e1c82baf05c3989ee284f9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/expected.txt @@ -0,0 +1,9 @@ +str1 : <0> +str1 : <123> +str1 : +str2 : <> +str2 : +str2 : +null + +0 diff --git a/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/test.cfg b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..2c40cd6475f545bda59c8e075d362d6c2cbb141c --- /dev/null +++ b/testsuite/java_test/string_test/RT0134-rt-String-NullToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(NullToStringTest) +run(NullToStringTest) diff --git a/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/AsciiToStringTest.java b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/AsciiToStringTest.java new file mode 100755 index 0000000000000000000000000000000000000000..108bffba48e4d48913d8d289dcd1ccb78e7659c9 --- /dev/null +++ b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/AsciiToStringTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class AsciiToStringTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + AsciiToStringTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void AsciiToStringTest_1() { + String str1_1 = "a b^c~AB"; + //10 + char[] data1_2 = {97, 32, 98, 94, 99, 126, 65, 66}; + String str1_2 = new String(data1_2); + //16 + char[] data1_3 = {0x61, 0x20, 0x62, 0x5E, 0x63, 0x7E, 0x41, 0x42}; + String str1_3 = new String(data1_3); + test1(str1_1); + test1(str1_2); + test1(str1_3); + } + private static void test1(String str) { + System.out.println(str); + } +} diff --git a/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/expected.txt b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..66ad3b8c57e340046d7808a866ca6041e6b385c6 --- /dev/null +++ b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/expected.txt @@ -0,0 +1,4 @@ +a b^c~AB +a b^c~AB +a b^c~AB +0 diff --git a/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/test.cfg b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..62e6c6436bff062ce40883d8eff04a14065430a1 --- /dev/null +++ b/testsuite/java_test/string_test/RT0135-rt-String-AsciiToStringTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(AsciiToStringTest) +run(AsciiToStringTest) diff --git a/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/StringToHexStringCharTest.java b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/StringToHexStringCharTest.java new file mode 100755 index 0000000000000000000000000000000000000000..684a11e2d92389741d94cfbd3d8408e7fecb14e5 --- /dev/null +++ b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/StringToHexStringCharTest.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringToHexStringCharTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringToHexStringCharTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringToHexStringCharTest_1() { + // 0x00~0x7F. + String str1_1 = "a b^c~AB"; + //10 + char data1_2[] = {97, 32, 98, 94, 99, 126, 65, 66}; + String str1_2 = new String(data1_2); + //16 + char data1_3[] = {0x61, 0x20, 0x62, 0x5E, 0x63, 0x7E, 0x41, 0x42}; + String str1_3 = new String(data1_3); + String str2_1 = "中国"; + // Test unicode + char data2_2[] = {'\u4E2D', '\u56FD'}; + String str2_2 = new String(data2_2); + String str3_1 = "中国abc"; + //unicode + char data3_2[] = {'\u4E2D', '\u56FD', 97, 98, 99}; + String str3_2 = new String(data3_2); + test1(str1_1); + test1(str1_2); + test1(str1_3); + test1(str2_1); + test1(str2_2); + test1(str3_1); + test1(str3_2); + } + private static void test1(String str) { + for (int i = 0; i < str.length(); i++) { + char ch = str.charAt(i); + System.out.println(Integer.toHexString(ch)); + } + } +} diff --git a/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/expected.txt b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..79116ba1cde830b9881ebdf078e5df8e572b075e --- /dev/null +++ b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/expected.txt @@ -0,0 +1,39 @@ +61 +20 +62 +5e +63 +7e +41 +42 +61 +20 +62 +5e +63 +7e +41 +42 +61 +20 +62 +5e +63 +7e +41 +42 +4e2d +56fd +4e2d +56fd +4e2d +56fd +61 +62 +63 +4e2d +56fd +61 +62 +63 +0 diff --git a/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/test.cfg b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..8dd455db5cacd2809c869647b989475e2c2fb03d --- /dev/null +++ b/testsuite/java_test/string_test/RT0136-rt-String-ToHexStringCharTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringToHexStringCharTest) +run(StringToHexStringCharTest) diff --git a/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/StringAsVariableAndFieldAndParamTest.java b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/StringAsVariableAndFieldAndParamTest.java new file mode 100755 index 0000000000000000000000000000000000000000..0e86f981dfe80cac9e533a1955a001c2187b73cd --- /dev/null +++ b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/StringAsVariableAndFieldAndParamTest.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringAsVariableAndFieldAndParamTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringAsVariableAndFieldAndParamTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringAsVariableAndFieldAndParamTest_1() { + String str = null; + System.out.println(str); + System.out.println(StringAsVariableAndFieldAndParamTest_1.str1_1); + str = "abc"; + System.out.println(StringAsVariableAndFieldAndParamTest_1.test(str)); + } +} +class StringAsVariableAndFieldAndParamTest_1 { + static String str1_1 = "abc1_1"; + protected static String test(String str) { + String result = str + str; + System.out.println(result); + return result; + } +} diff --git a/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/expected.txt b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..650f8b1218e70868ebf39b3b0628345ebccc387b --- /dev/null +++ b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/expected.txt @@ -0,0 +1,5 @@ +null +abc1_1 +abcabc +abcabc +0 diff --git a/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/test.cfg b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..d80c72728fb9b65f376a7d23c3760bd16cba12bb --- /dev/null +++ b/testsuite/java_test/string_test/RT0137-rt-String-AsVariableAndFieldAndParamTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringAsVariableAndFieldAndParamTest) +run(StringAsVariableAndFieldAndParamTest) diff --git a/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/StringVariableOfInterfaceTest.java b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/StringVariableOfInterfaceTest.java new file mode 100755 index 0000000000000000000000000000000000000000..e530ce8186ac20bace947e9e1a278e4e0b9b5534 --- /dev/null +++ b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/StringVariableOfInterfaceTest.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringVariableOfInterfaceTest implements StringVariableOfInterfaceTest_1 { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringVariableOfInterfaceTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + static String test(String str) { + String result = str + str; + System.out.println(result); + return result; + } + public static void StringVariableOfInterfaceTest_1() { + String str = null; + System.out.println(str); + System.out.println(StringVariableOfInterfaceTest_1.str1_1); + str = "abc"; + System.out.println(StringVariableOfInterfaceTest.test(str)); + } +} +interface StringVariableOfInterfaceTest_1 { + static String str1_1 = "abc1_1"; + static void test(String str) { + } +} diff --git a/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/expected.txt b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..650f8b1218e70868ebf39b3b0628345ebccc387b --- /dev/null +++ b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/expected.txt @@ -0,0 +1,5 @@ +null +abc1_1 +abcabc +abcabc +0 diff --git a/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/test.cfg b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..487460118fc8cb73da04fdfb0dc5361680f81680 --- /dev/null +++ b/testsuite/java_test/string_test/RT0138-rt-String-VariableOfInterfaceTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringVariableOfInterfaceTest) +run(StringVariableOfInterfaceTest) diff --git a/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/StringCreateStringArrayTest.java b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/StringCreateStringArrayTest.java new file mode 100755 index 0000000000000000000000000000000000000000..45a3bcdc8fb472b7507e4e5d81b94e71afcdf988 --- /dev/null +++ b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/StringCreateStringArrayTest.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringCreateStringArrayTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringCreateStringArrayTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringCreateStringArrayTest_1() { + String[] strArray = {"a", "b", "c", "1", "2", "3"}; + System.out.println(strArray[1]); + System.out.println(test(strArray)[1]); + } + private static String[] test(String[] str) { + for (int i = 0; i < str.length; i++) { + System.out.println(str[i]); + } + str[1] = "B"; + return str; + } +} diff --git a/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/expected.txt b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..69c421418533d8f101fd70491266949261469321 --- /dev/null +++ b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/expected.txt @@ -0,0 +1,9 @@ +b +a +b +c +1 +2 +3 +B +0 diff --git a/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/test.cfg b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..b6ee6e2ece01faf2bd49511aa6ef8dc59da03840 --- /dev/null +++ b/testsuite/java_test/string_test/RT0139-rt-String-CreateStringArrayTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringCreateStringArrayTest) +run(StringCreateStringArrayTest) diff --git a/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/StringGenericTest.java b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/StringGenericTest.java new file mode 100755 index 0000000000000000000000000000000000000000..02408890639291c565747db0c8cf297d367adcf8 --- /dev/null +++ b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/StringGenericTest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.io.PrintStream; +public class StringGenericTest { + private static int processResult = 99; + public static void main(String[] argv) throws IllegalAccessException, IllegalArgumentException, + InvocationTargetException, NoSuchMethodException, SecurityException { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringGenericTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 99) { + result = 0; + } + return result; + } + public static void StringGenericTest_1() throws IllegalAccessException, IllegalArgumentException, + InvocationTargetException, NoSuchMethodException, SecurityException { + ArrayList arrayList1 = new ArrayList(); + arrayList1.add("abc"); + ArrayList arrayList2 = new ArrayList(); + arrayList2.add(123); + System.out.println(arrayList1.getClass() == arrayList2.getClass()); + String str = StringGenericTest.add("1", "2"); + System.out.println(str); + } + public static T add(T x, T y) { + return y; + } +} diff --git a/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/expected.txt b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..59d9b3852101dc4f1f78b72c7d406dd697d57054 --- /dev/null +++ b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/expected.txt @@ -0,0 +1,3 @@ +true +2 +0 diff --git a/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/test.cfg b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..7a420ebfb413aebcdcadf1fd2ede2feaf7a4c90e --- /dev/null +++ b/testsuite/java_test/string_test/RT0140-rt-String-GenericTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringGenericTest) +run(StringGenericTest) diff --git a/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/StringMultiThreadsTest.java b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/StringMultiThreadsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..44819d1dc3b7ca9e8526259afeea10eecb77abce --- /dev/null +++ b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/StringMultiThreadsTest.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringMultiThreadsTest extends Thread { + static int retu = 1; + static int threadCount = 10; + static int stringCount = 10; + static int count = 0; + public StringMultiThreadsTest(ThreadGroup group, String name) { + super(group, name); + } + public void run() { + String[] str = new String[stringCount]; + for (int i = 0; i < stringCount; i++) { + str[i] = "ABC"; + count++; + if (str[i] != "ABC") { + retu++; + } + } + } + public static void main(String[] args) { + System.out.println(test(args, System.out)); + } + public static int test(String[] args, PrintStream out) { + ThreadGroup thg = new ThreadGroup("threadg"); + String[] th = new String[threadCount]; + for (int i = 0; i < threadCount; i++) { + th[i] = "thread" + i; + new StringMultiThreadsTest(thg, th[i]).start(); + } + try { + sleep(200); + } catch (InterruptedException e) { + } + if (retu == 1) { + return 0; + } + return 2; + } +} diff --git a/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/expected.txt b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/test.cfg b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..230a87a4368630e075f52854782e9db61333744a --- /dev/null +++ b/testsuite/java_test/string_test/RT0141-rt-String-MultiThreadsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringMultiThreadsTest) +run(StringMultiThreadsTest) diff --git a/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/StringJoinNullPointerExceptionTest.java b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/StringJoinNullPointerExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..0a6c4625888571f62fc8013714c30419b01c0354 --- /dev/null +++ b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/StringJoinNullPointerExceptionTest.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringJoinNullPointerExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringJoinNullPointerExceptionTest_1(null); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 97) { + result = 0; + } + return result; + } + private static void StringJoinNullPointerExceptionTest_1(String str) { + try { + String[] test = new String[]{str, str, str}; + System.out.println(String.join(null, test)); + } catch (NullPointerException e) { + processResult -= 2; + } + } +} diff --git a/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..c5777b49091fd5669b82c6ade5d856abc191fcb3 --- /dev/null +++ b/testsuite/java_test/string_test/RT0142-rt-String-JoinNullPointerExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringJoinNullPointerExceptionTest) +run(StringJoinNullPointerExceptionTest) diff --git a/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/StringNullPointExceptionTest.java b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/StringNullPointExceptionTest.java new file mode 100755 index 0000000000000000000000000000000000000000..8c85612cb307a93900931e662998bb39340e11c7 --- /dev/null +++ b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/StringNullPointExceptionTest.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringNullPointExceptionTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringNullPointExceptionTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 83) { + result = 0; + } + return result; + } + public static void StringNullPointExceptionTest_1() { + String str2_1 = "abc123"; + String str2_5 = null; + test0(str2_1); + test1(str2_5); + test2(str2_5); + test3(str2_5); + test4(str2_5); + test5(str2_5); + test6(str2_5); + test7(str2_5); + } + private static void test0(String str) { + try { + char t0 = str.charAt(-2); + } catch (StringIndexOutOfBoundsException e) { + processResult -= 2; + } + } + private static void test1(String str) { + try { + char t1 = str.charAt(0); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test2(String str) { + char[] t2 = null; + try { + t2 = str.toCharArray(); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test3(String str) { + String t3 = null; + try { + t3 = str.substring(1); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test4(String str) { + try { + int t4 = str.compareTo("aaa"); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test5(String str) { + try { + String t5 = str.intern(); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test6(String str) { + try { + String t6 = str.replace("a", "b"); + } catch (NullPointerException e) { + processResult -= 2; + } + } + private static void test7(String str) { + try { + String t7 = str.concat("aaa"); + } catch (NullPointerException e) { + processResult -= 2; + } + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/expected.txt b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/test.cfg b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..4de788479d03ec1c154e61d5348398b32b7ac532 --- /dev/null +++ b/testsuite/java_test/string_test/RT0143-rt-String-NullPointExceptionTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringNullPointExceptionTest) +run(StringNullPointExceptionTest) diff --git a/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/StringBufferExceptionsTest.java b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/StringBufferExceptionsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..296759dd7e1f90b6e647f28b9e697203e312470a --- /dev/null +++ b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/StringBufferExceptionsTest.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBufferExceptionsTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + result = StringBufferGetCharsIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBufferReplaceStringIndexOutOfBoundsException_2(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBufferSubstringStringIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBufferSubstringStringIndexOutOfBoundsException_2(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 80) { + result = 0; + } + return result; + } + public static int StringBufferGetCharsIndexOutOfBoundsException_1() { + int result1 = 3; /*STATUS_FAILED*/ + // IndexOutOfBoundsException- If either off or len is negative, or if off + len is greater than b.length. + // Test public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin). + StringBuffer buff = new StringBuffer("java programming"); + char[] chArr = new char[]{'t', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's'}; + // Test dstBegin > dst.length. + try { + buff.getChars(5, 10, chArr, 30); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test dstBegin < 0. + try { + buff.getChars(5, 10, chArr, -2); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test dst.length - dstBegin < srcEnd - srcBegin. + try { + buff.getChars(5, 10, chArr, 7); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcBegin < 0. + try { + buff.getChars(-2, 10, chArr, 5); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcBegin > buff.length. + try { + buff.getChars(buff.length(), 10, chArr, 5); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcEnd < 0. + try { + buff.getChars(5, -2, chArr, 5); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcEnd < srcBegin. + try { + buff.getChars(5, 2, chArr, 5); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcEnd > buff.length. + try { + buff.getChars(5, buff.length(), chArr, 5); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + public static int StringBufferReplaceStringIndexOutOfBoundsException_2() { + int result1 = 3; /*STATUS_FAILED*/ + // StringIndexOutOfBoundsException- Access parameter range of index. + // Test public StringBuffer replace(int start, int end, String str). + StringBuffer buff1 = new StringBuffer("HelloWorld"); + // Test start > buff1.length. + try { + buff1.replace(20, 6, "QQQ"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + buff1.replace(-2, 6, "QQQ"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start > end. + try { + buff1.replace(7, 6, "QQQ"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < 0. + try { + buff1.replace(7, -2, "QQQ"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + public static int StringBufferSubstringStringIndexOutOfBoundsException_1() { + int result1 = 3; /*STATUS_FAILED*/ + // StringIndexOutOfBoundsException- Intercept character string specifying scope, exceed the range error. + // Test public String substring(int start, int end). + StringBuffer buff2 = new StringBuffer("HelloWorld"); + // Test end > buff2.length. + try { + String str = buff2.substring(9, 11); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < 0. + try { + String str = buff2.substring(9, 11); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start > buff2.length. + try { + String str = buff2.substring(11, 5); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start > end. + try { + String str = buff2.substring(8, 5); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + String str = buff2.substring(-2, 5); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + public static int StringBufferSubstringStringIndexOutOfBoundsException_2() { + int result1 = 3; /*STATUS_FAILED*/ + // StringIndexOutOfBoundsException- Intercept character string specifying scope, exceed the range error. + // Test public String substring(int start). + StringBuffer buff3 = new StringBuffer("HelloWorld"); + // Test start > buff3.length. + try { + String str = buff3.substring(15); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + String str = buff3.substring(-2); + System.out.println(str); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + result1 = 2; + processResult--; + } + return result1; + } +} \ No newline at end of file diff --git a/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/expected.txt b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/test.cfg b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..6fc22836967bee07b84c8b41af0ec53ef14c6ae0 --- /dev/null +++ b/testsuite/java_test/string_test/RT0144-rt-String-BufferExceptionsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBufferExceptionsTest) +run(StringBufferExceptionsTest) diff --git a/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/StringBuilderExceptionsTest.java b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/StringBuilderExceptionsTest.java new file mode 100755 index 0000000000000000000000000000000000000000..ff8d1df8806f5538f72d4a2a2e8b3f41849ea389 --- /dev/null +++ b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/StringBuilderExceptionsTest.java @@ -0,0 +1,387 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringBuilderExceptionsTest { + private static int processResult = 99; + public static void main(String argv[]) { + System.out.println(run(argv, System.out)); + } + public static int run(String argv[], PrintStream out) { + int result = 2; /*STATUS_FAILED*/ + try { + result = StringBuilderSubstringStringIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderSubstringStringIndexOutOfBoundsException_2(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderCodePointAtIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderCodePointBeforeIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderCodePointCountIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderReplaceStringIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderGetCharsIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + try { + result = StringBuilderOffsetByCodePointsIndexOutOfBoundsException_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 4 && processResult == 67) { + result = 0; + } + return result; + } + // Test StringIndexOutOfBoundsException in String substring(int start, int end). + public static int StringBuilderSubstringStringIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder str = new StringBuilder("java is boring"); + // Test end > str.length(). + try { + String test1 = str.substring(8, 20); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < 0. + try { + String test1 = str.substring(8, -2); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < start. + try { + String test1 = str.substring(8, 6); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start > str.length(). + try { + String test1 = str.substring(20, 6); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + String test1 = str.substring(-2, 6); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test StringIndexOutOfBoundsException in String substring(int start). + public static int StringBuilderSubstringStringIndexOutOfBoundsException_2() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder str = new StringBuilder("java is boring"); + // Test start > str.length. + try { + String test1 = str.substring(20); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + String test1 = str.substring(-2); + System.out.println(test1); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test IndexOutOfBoundsException in int codePointAt(int index). + public static int StringBuilderCodePointAtIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder buff = new StringBuilder("programming"); + // Test index >= stringBuilder.length. + try { + int str = buff.codePointAt(11); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test index < 0. + try { + int str = buff.codePointAt(-1); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test IndexOutOfBoundsException in int codePointBefore(int index). + public static int StringBuilderCodePointBeforeIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder buff = new StringBuilder("HelloWorld"); + // Test index > stringBuilder.length. + try { + int str = buff.codePointBefore(11); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test index < 0. + try { + int str = buff.codePointBefore(-3); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test IndexOutOfBoundsException in int codePointCount(int beginIndex, int endIndex). + public static int StringBuilderCodePointCountIndexOutOfBoundsException_1() { + int result1 = 4; /*STATUS_FAILED*/ + StringBuilder buff = new StringBuilder("HelloWorld"); + // Test endIndex > stringBuilder.length. + try { + int str = buff.codePointCount(5, 11); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test endIndex < beginIndex. + try { + int str = buff.codePointCount(5, 4); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test endIndex < 0. + try { + int str = buff.codePointCount(5, -2); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test beginIndex < 0. + try { + int str = buff.codePointCount(-1, 5); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test beginIndex > stringBuilder.length. + try { + int str = buff.codePointCount(11, 5); + System.out.println(str); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test StringIndexOutOfBoundsException in StringBuilder replace(int start, int end, String str). + public static int StringBuilderReplaceStringIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder str = new StringBuilder("Java Util Package"); + // Test end > stringBuilder.length. + try { + StringBuilder test1 = str.replace(18, 20, "Lang"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < start. + try { + StringBuilder test1 = str.replace(18, 16, "Lang"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test end < 0. + try { + StringBuilder test1 = str.replace(18, -2, "Lang"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start < 0. + try { + StringBuilder test1 = str.replace(-2, 16, "Lang"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + // Test start > stringBuilder.length. + try { + StringBuilder test1 = str.replace(20, 16, "Lang"); + processResult -= 10; + } catch (StringIndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test IndexOutOfBoundsException in void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin). + public static int StringBuilderGetCharsIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder str = new StringBuilder("java programming"); + char[] cArr = new char[]{'t', 'u', 't', 'o', 'r', 'i', 'a', 'l', 's'}; + // Test cArr.length - dstBegin < srcEnd - srcBegin + try { + str.getChars(5, 9, cArr, 6); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test dstBegin > cArr.length. + try { + str.getChars(0, 9, cArr, 10); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test dstBegin < 0. + try { + str.getChars(0, 9, cArr, -2); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcEnd < 0. + try { + str.getChars(0, -2, cArr, 0); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcBegin < 0. + try { + str.getChars(-2, 5, cArr, 0); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcBegin > srcEnd. + try { + str.getChars(5, 2, cArr, 0); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcBegin > stringBuilder.length. + try { + str.getChars(20, 2, cArr, 0); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test srcEnd > stringBuilder.length. + try { + str.getChars(2, 20, cArr, 0); + System.out.println(str); + System.out.println(cArr); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } + // Test IndexOutOfBoundsException in int offsetByCodePoints(int index, int codePointOffset). + public static int StringBuilderOffsetByCodePointsIndexOutOfBoundsException_1() { + int result1 = 4; /* STATUS_FAILED*/ + + StringBuilder str = new StringBuilder("abcdefg"); + // Test codePointOffset > stringBuilder.length - index. + try { + int result = str.offsetByCodePoints(1, 7); + System.out.println(str); + System.out.println(result); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test index < 0. + try { + int result = str.offsetByCodePoints(-1, 3); + System.out.println(str); + System.out.println(result); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + // Test index > stringBuilder.length. + try { + int result = str.offsetByCodePoints(8, 0); + System.out.println(str); + System.out.println(result); + processResult -= 10; + } catch (IndexOutOfBoundsException e1) { + processResult--; + } + return result1; + } +} diff --git a/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/expected.txt b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/test.cfg b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..128a1869b2085e63e2aa6202ed8734eb92a196ee --- /dev/null +++ b/testsuite/java_test/string_test/RT0145-rt-String-BuilderExceptionsTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringBuilderExceptionsTest) +run(StringBuilderExceptionsTest) diff --git a/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/StringClassNewInstanceTest.java b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/StringClassNewInstanceTest.java new file mode 100755 index 0000000000000000000000000000000000000000..7d76a36682d51bac641776c67b26f68be5109f3c --- /dev/null +++ b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/StringClassNewInstanceTest.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringClassNewInstanceTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv, PrintStream out) { + int result = 2; /* STATUS_Success*/ + + try { + StringClassNewInstanceTest_1(); + } catch (Exception e) { + processResult -= 10; + } + if (result == 2 && processResult == 98) { + result = 0; + } + return result; + } + public static void StringClassNewInstanceTest_1() { + Object test1 = null; + try { + test1 = String.class.newInstance(); + processResult--; + } catch (InstantiationException e1) { + System.err.println(e1); + } catch (IllegalAccessException e2) { + System.err.println(e2); + } + } +} diff --git a/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/expected.txt b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/test.cfg b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..343c708489935840c822c42d3c4077e245e72091 --- /dev/null +++ b/testsuite/java_test/string_test/RT0146-rt-String-ClassNewInstanceTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringClassNewInstanceTest) +run(StringClassNewInstanceTest) diff --git a/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/StringPoolEnlargeTest.java b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/StringPoolEnlargeTest.java new file mode 100755 index 0000000000000000000000000000000000000000..29fdb89c6785646b713662b7a6b0ca3112056d36 --- /dev/null +++ b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/StringPoolEnlargeTest.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +public class StringPoolEnlargeTest { + private static int processResult = 99; + public static void main(String[] argv) { + System.out.println(run(argv, System.out)); + } + public static int run(String[] argv,PrintStream out){ + int result = 2; /* STATUS_Success*/ + + try { + result = result - StringPoolEnlargeTest_1(47000); + result = result - StringPoolEnlargeTest_1(470000); + } catch(Exception e){ + System.out.println(e); + StringPoolEnlargeTest.processResult = StringPoolEnlargeTest.processResult - 10; + } + if (result == 0 && StringPoolEnlargeTest.processResult == 95){ + result = 0; + } + return result; + } + public static int StringPoolEnlargeTest_1(int len) { + int length = len; // 47 mapleStringPool/process, 1000 key-value/mapleStringPool + try { + String[] s; + s = new String[length]; + for (int i = 0; i < length; i++){ + s[i] = Integer.toHexString(i); + if (s[i].intern() == Integer.toHexString(func1(len-1)).intern()) { + StringPoolEnlargeTest.processResult = StringPoolEnlargeTest.processResult - 2; + return 1; + } + } + } catch (OutOfMemoryError e) { + return 114; + } + StringPoolEnlargeTest.processResult = StringPoolEnlargeTest.processResult - 10; + return 102; + } + public static int func1(int i){ + return i; + } +} diff --git a/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/expected.txt b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/expected.txt new file mode 100755 index 0000000000000000000000000000000000000000..573541ac9702dd3969c9bc859d2b91ec1f7e6e56 --- /dev/null +++ b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/expected.txt @@ -0,0 +1 @@ +0 diff --git a/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/test.cfg b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/test.cfg new file mode 100755 index 0000000000000000000000000000000000000000..0d1a43325654bd72418d87a13da722a4a6044085 --- /dev/null +++ b/testsuite/java_test/string_test/RT0147-rt-String-PoolEnlargeTest/test.cfg @@ -0,0 +1,3 @@ +clean() +compile(StringPoolEnlargeTest) +run(StringPoolEnlargeTest) diff --git a/testsuite/java_test/string_test/RT0148-rt-String-XByteTest/StringXByteTest.java b/testsuite/java_test/string_test/RT0148-rt-String-XByteTest/StringXByteTest.java new file mode 100755 index 0000000000000000000000000000000000000000..76874c2c4b832c2dbf7aff36150bbf1709c46b85 --- /dev/null +++ b/testsuite/java_test/string_test/RT0148-rt-String-XByteTest/StringXByteTest.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. + * + * OpenArkCompiler is licensed under Mulan PSL v2. + * You can use this software according to the terms and conditions of the Mulan PSL v2. + * + * http://license.coscl.org.cn/MulanPSL2 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the Mulan PSL v2 for more details. +*/ + + +import java.io.PrintStream; +import java.io.*; +import java.util.Random; +public class StringXByteTest { + static int seed = 20; + static Random random = new Random(seed); + public static void main(String[] args) { + System.out.println(run(args, System.out)); + } + public static int run(String[] args,PrintStream out) { + int result = 2; + try { + result = StringXByteTest1(); + } catch (Exception e) { + e.printStackTrace(); + } + if (result == 1 ) { + result = 0; + } + return result; + } + public static int StringXByteTest1() { + String string_byte1 = getByteString(1); + String string_byte2 = getByteString(2); + String string_byte3 = getByteString(3); + String string_byte4 = getByteString(4); + byte[] by = new byte[]{(byte) 0x59,(byte) 0xCF,(byte) 0xB9,(byte) 0xE2,(byte) 0xA2,(byte) 0xA4, + (byte) 0xF3,(byte) 0x90,(byte) 0xA2,(byte) 0x85}; + if ((string_byte1+string_byte2+string_byte3+string_byte4).equals(new String(by))) { + return 1; + } + return 3; + } + public static String getByteString(int lengthIn) { + String strCd = "CD"; + String str0f = "0123456789ABCDEF"; + String str8b = "89AB"; + String str07 = "01234567"; + String hexString = "0123456789ABCDEF"; + StringBuffer byte5= new StringBuffer(); + if (lengthIn == 1) { + // 1Byte: 0-7|0-F + byte5.append(str07.charAt( random.nextInt(8))); // 0-7 + byte5.append(str0f.charAt( random.nextInt(16))); // 0-F + }else if (lengthIn == 2) { + // 2Byte: C-D|0-F 8-B|0-F + byte5.append(strCd.charAt(random.nextInt(2))); + byte5.append(str0f.charAt(random.nextInt(16))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + }else if (lengthIn == 3) { + // 3Byte: E|0-F 8-B|0-F 8-B|0-F + byte5.append("E"); + byte5.append(str0f.charAt(random.nextInt(16))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + }else if (lengthIn == 4) { + // 4Byte: F|0-7 8-B|0-F 8-B|0-F 8-B|0-F + byte5.append("F"); + byte5.append(str07.charAt(random.nextInt(8))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + byte5.append(str8b.charAt(random.nextInt(4))); + byte5.append(str0f.charAt(random.nextInt(16))); + } + ByteArrayOutputStream scb=new ByteArrayOutputStream(byte5.length()/2); + for(int i=0;i