summaryrefslogtreecommitdiff
path: root/test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java
diff options
context:
space:
mode:
author David Brazdil <dbrazdil@google.com> 2019-02-02 20:08:44 +0000
committer David Brazdil <dbrazdil@google.com> 2019-02-04 15:00:20 +0000
commit4bcd65753c1e49ceba2c41983f26af81ae319670 (patch)
tree3fc7bd53d37448621726dc508f173490807af9c7 /test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java
parent2da3cbb4af20a64108e474c0bbbe0cc5d3af2aa2 (diff)
Take hidden API into account during getDeclaredMethod()
Generics make it possible for two methods to have the same name and list of parameters but differ in their return type. Class.getDeclaredMethod() does not allow callers to specify the type, so either of the matching methods can be returned (ART will prefer the non-synthetic one). However, Class::GetDeclaredMethodInternal() did not use to take hidden API into account and could return a hidden method, despite a non-hidden one being available. The reflective call would then reject the method and throw NoSuchMethodException. This patch modifies Class:GetDeclaredMethodInternal() to consider: (a) hidden/non-hidden (b) virtual/direct (c) synthetic/non-synthetic in that decreasing order of importance and pick the best matching method. The hiddenness checks are performed with AccessMethod::kNone so as to not trigger warnings. A hidden method may still be returned and the caller should do the access check again with the appropriate AccessMethod. Bug: 122291025 Test: art/test.py -r -t 690-hiddenapi-same-name-methods Change-Id: Iaee780c1e87f5587f51e24b517b2b37101c729e3
Diffstat (limited to 'test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java')
-rw-r--r--test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java b/test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java
new file mode 100644
index 0000000000..c404402288
--- /dev/null
+++ b/test/690-hiddenapi-same-name-methods/src-ex/GenericInterface.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2019 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 interface GenericInterface<T extends Number> {
+ public T foo();
+}