• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 LSPosed
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package org.lsposed.hiddenapibypass;
18 
19 import java.lang.invoke.MethodHandleInfo;
20 import java.lang.invoke.MethodType;
21 import java.lang.reflect.Member;
22 
23 @SuppressWarnings("unused")
24 public class Helper {
25     static public class MethodHandle {
26         private final MethodType type = null;
27         private MethodType nominalType;
28         private MethodHandle cachedSpreadInvoker;
29         protected final int handleKind = 0;
30 
31         // The ArtMethod* or ArtField* associated with this method handle (used by the runtime).
32         protected final long artFieldOrMethod = 0;
33     }
34 
35     static final public class MethodHandleImpl extends MethodHandle {
36         private final MethodHandleInfo info = null;
37     }
38 
39     static final public class HandleInfo {
40         private final Member member = null;
41         private final MethodHandle handle = null;
42     }
43 
44     static final public class Class {
45         private transient ClassLoader classLoader;
46         private transient java.lang.Class<?> componentType;
47         private transient Object dexCache;
48         private transient Object extData;
49         private transient Object[] ifTable;
50         private transient String name;
51         private transient java.lang.Class<?> superClass;
52         private transient Object vtable;
53         private transient long iFields;
54         private transient long methods;
55         private transient long sFields;
56         private transient int accessFlags;
57         private transient int classFlags;
58         private transient int classSize;
59         private transient int clinitThreadId;
60         private transient int dexClassDefIndex;
61         private transient volatile int dexTypeIndex;
62         private transient int numReferenceInstanceFields;
63         private transient int numReferenceStaticFields;
64         private transient int objectSize;
65         private transient int objectSizeAllocFastPath;
66         private transient int primitiveType;
67         private transient int referenceInstanceOffsets;
68         private transient int status;
69         private transient short copiedMethodsOffset;
70         private transient short virtualMethodsOffset;
71     }
72 
73     static public class AccessibleObject {
74         private boolean override;
75     }
76 
77     static final public class Executable extends AccessibleObject {
78         private Class declaringClass;
79         private Class declaringClassOfOverriddenMethod;
80         private Object[] parameters;
81         private long artMethod;
82         private int accessFlags;
83     }
84 
85     @SuppressWarnings("EmptyMethod")
86     public static class NeverCall {
a()87         private static void a() {
88         }
89 
b()90         private static void b() {
91         }
92 
93         private static int s;
94         private static int t;
95         private int i;
96         private int j;
97     }
98 
99     public static class InvokeStub {
invoke(Object... args)100         private static Object invoke(Object... args) {
101             throw new IllegalStateException("Failed to invoke the method");
102         }
103 
InvokeStub(Object... args)104         private InvokeStub(Object... args) {
105             throw new IllegalStateException("Failed to new a instance");
106         }
107     }
108 }
109