summaryrefslogtreecommitdiff
path: root/test/626-const-class-linking/src-multidex/Test.java
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2016-11-11 11:40:40 +0000
committer Vladimir Marko <vmarko@google.com> 2016-11-21 19:11:31 +0000
commit19886dbeced9430579a27979beb92b09c95197b4 (patch)
tree33c85aada415308d8207d63bce903262ea7504fe /test/626-const-class-linking/src-multidex/Test.java
parentbb4366d2b0b56f2cc66041243bd93de4b8e4d15a (diff)
Make sure that const-class linkage is preserved.
After calling loadClass() on the initiating loader, insert the Class to the ClassTable. Check that the returned class has the correct name and that the ClassTable does not yet contain a different Class for the same name. If either check fails, follow the RI behavior for parallel capable class loaders, i.e. throw NoClassDefFoundError for name mismatch (with more descriptive message than RI) or return the Class already present in the ClassTable. This ensures that the const-class instruction for a given name always gives the same result as the first time it succeeded for the same initiating loader, even for non-well-behaved loader. Inserting the Class to the ClassTable is also a necessary step for changing to hash-based dex cache type array when the DexCache will not necessarily keep the Class and therefore the defining loader alive while the initiating loader stays alive, so the ClassTable entry is necessary to keep the dependecy. Add tests that a const-class instruction always returns the same Class<?> as it returned the first time, i.e. when it was "linked", even for class loaders that are not well-behaved, even if the dex cache type array is cleared. Also test the edge cases, i.e. NoClassDefFoundError and returning old entry from ClassTable when already inserted by another thread. Bug: 30627598 Test: 626-const-class-linking Test: m test-art-host Change-Id: Ie9b721464b4e9a5dcce8df8095548e983bba1fe8
Diffstat (limited to 'test/626-const-class-linking/src-multidex/Test.java')
-rw-r--r--test/626-const-class-linking/src-multidex/Test.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/626-const-class-linking/src-multidex/Test.java b/test/626-const-class-linking/src-multidex/Test.java
new file mode 100644
index 0000000000..1b0cc2a791
--- /dev/null
+++ b/test/626-const-class-linking/src-multidex/Test.java
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class Test {
+}