13
13
14
14
package org .eclipse .esmf .substitution ;
15
15
16
- import java .io .FileNotFoundException ;
17
16
import java .io .IOException ;
18
17
import java .io .InputStream ;
19
18
import java .util .List ;
20
19
import java .util .Map ;
21
20
import java .util .Properties ;
22
21
import java .util .Set ;
23
22
24
- import org .eclipse .esmf .buildtime .IoAdminShellAasClassSetup ;
23
+ import org .eclipse .digitaltwin .aas4j .v3 .dataformat .core .util .ReflectionHelper ;
24
+ import org .eclipse .esmf .buildtime .Aas4jClassSetup ;
25
25
26
26
import com .oracle .svm .core .annotate .Alias ;
27
27
import com .oracle .svm .core .annotate .KeepOriginal ;
28
28
import com .oracle .svm .core .annotate .RecomputeFieldValue ;
29
29
import com .oracle .svm .core .annotate .Substitute ;
30
30
import com .oracle .svm .core .annotate .TargetClass ;
31
31
32
- import org .eclipse .digitaltwin .aas4j .v3 .dataformat .core .util .ReflectionHelper ;
33
-
34
32
/**
35
33
* This is a <a href="https://build-native-java-apps.cc/developer-guide/substitution/">GraalVM substitution class</a>
36
34
* for {@link ReflectionHelper}, the central point of reflection information of the io.admin-shell.aas library. The original ReflectionHelper
37
35
* has a static constructor that initializes several maps and collections (using ClassGraph scans) that hold information about implementations
38
36
* of interfaces etc.. For the build of the native image, this logic is replaced by the following logic:
39
37
* <ol>
40
- * <li>At build time, the {@link IoAdminShellAasClassSetup } is ran (as a standalone program).
38
+ * <li>At build time, the {@link Aas4jClassSetup } is ran (as a standalone program).
41
39
* This creates an instance of {@link AdminShellConfig} which contains all the information extracted from the ClassGraph scans.</li>
42
40
* <li>The AdminShellConfig is serialized into a .properties file.</li>
43
41
* <li>The .properties file is then included as a regular resource in the build.</li>
53
51
@ TargetClass ( ReflectionHelper .class )
54
52
@ SuppressWarnings ( {
55
53
"unused" ,
56
- "squid:S00101" // Class name uses GraalVM substitution class naming schema, see
54
+ "squid:S00101" , "NewClassNamingConvention" // Class name uses GraalVM substitution class naming schema, see
57
55
// https://github.com/oracle/graal/tree/master/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk
58
56
} )
59
- public final class Target_io_adminshell_aas_v3_dataformat_core_ReflectionHelper {
57
+ public final class Target_org_eclipse_digitaltwin_aas4j_v3_dataformat_core_util_ReflectionHelper {
60
58
@ Alias
61
59
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
62
- private static final String ROOT_PACKAGE_NAME = "io.adminshell.aas .v3" ;
60
+ private static final String ROOT_PACKAGE_NAME = "org.eclipse.digitaltwin.aas4j .v3" ;
63
61
62
+ /**
63
+ * @see ReflectionHelper#MODEL_PACKAGE_NAME
64
+ */
65
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
64
66
@ Alias
65
67
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
66
68
public static String MODEL_PACKAGE_NAME = ROOT_PACKAGE_NAME + ".model" ;
67
69
70
+ /**
71
+ * @see ReflectionHelper#TYPES_WITH_MODEL_TYPE
72
+ */
73
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
68
74
@ Alias
69
75
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
70
76
public static Set <Class <?>> TYPES_WITH_MODEL_TYPE ;
71
77
78
+ /**
79
+ * @see ReflectionHelper#SUBTYPES
80
+ */
81
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
72
82
@ Alias
73
83
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
74
84
public static Map <Class <?>, Set <Class <?>>> SUBTYPES ;
75
85
86
+ /**
87
+ * @see ReflectionHelper#INTERFACES
88
+ */
89
+ @ SuppressWarnings ( { "NonConstantFieldWithUpperCaseName" , "rawtypes" } ) // Field name and signature must match substituted class
76
90
@ Alias
77
91
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
78
92
public static Set <Class > INTERFACES ;
79
93
94
+ /**
95
+ * @see ReflectionHelper#SUBTYPES
96
+ */
97
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
80
98
@ Alias
81
99
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
82
100
public static Map <Class <?>, Class <?>> JSON_MIXINS ;
83
101
102
+ /**
103
+ * @see ReflectionHelper#XML_MIXINS
104
+ */
105
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
84
106
@ Alias
85
107
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
86
108
public static Map <Class <?>, Class <?>> XML_MIXINS ;
87
109
110
+ /**
111
+ * @see ReflectionHelper#DEFAULT_IMPLEMENTATIONS
112
+ */
113
+ @ SuppressWarnings ( { "NonConstantFieldWithUpperCaseName" , "rawtypes" } ) // Field name and signature must match substituted class
88
114
@ Alias
89
115
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
90
116
public static List <ReflectionHelper .ImplementationInfo > DEFAULT_IMPLEMENTATIONS ;
91
117
118
+ /**
119
+ * @see ReflectionHelper#INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION
120
+ */
121
+ @ SuppressWarnings ( "NonConstantFieldWithUpperCaseName" ) // Field name must match substituted class
92
122
@ Alias
93
123
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
94
124
public static Set <Class <?>> INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION ;
95
125
126
+ /**
127
+ * @see ReflectionHelper#ENUMS
128
+ */
129
+ @ SuppressWarnings ( { "NonConstantFieldWithUpperCaseName" , "rawtypes" } ) // Field name and signature must match substituted class
96
130
@ Alias
97
131
@ RecomputeFieldValue ( kind = RecomputeFieldValue .Kind .FromAlias )
98
132
public static List <Class <Enum >> ENUMS ;
99
133
100
134
static {
101
- try ( final InputStream input = Target_io_adminshell_aas_v3_dataformat_core_ReflectionHelper .class .getResourceAsStream ( "/adminshell.properties" ) ) {
135
+ try ( final InputStream input = Target_org_eclipse_digitaltwin_aas4j_v3_dataformat_core_util_ReflectionHelper .class .getResourceAsStream (
136
+ "/adminshell.properties" ) ) {
102
137
final Properties properties = new Properties ();
103
138
properties .load ( input );
104
139
final AdminShellConfig config = AdminShellConfig .fromProperties ( properties );
@@ -110,40 +145,97 @@ public final class Target_io_adminshell_aas_v3_dataformat_core_ReflectionHelper
110
145
DEFAULT_IMPLEMENTATIONS = config .defaultImplementations ;
111
146
INTERFACES_WITHOUT_DEFAULT_IMPLEMENTATION = config .interfacesWithoutDefaultImplementation ;
112
147
ENUMS = config .enums ;
113
- } catch ( final FileNotFoundException e ) {
114
- throw new RuntimeException ( e );
115
148
} catch ( final IOException e ) {
116
149
throw new RuntimeException ( e );
117
150
}
118
151
}
119
152
153
+ /**
154
+ * @see ReflectionHelper#isModelInterface(Class)
155
+ * @param type see {@link ReflectionHelper#isModelInterface(Class)}
156
+ * @return see {@link ReflectionHelper#isModelInterface(Class)}
157
+ */
120
158
@ KeepOriginal
121
159
public static native boolean isModelInterface ( final Class <?> type );
122
160
161
+ /**
162
+ * @see ReflectionHelper#isDefaultImplementation(Class)
163
+ * @param type see {@link ReflectionHelper#isDefaultImplementation(Class)}
164
+ * @return see {@link ReflectionHelper#isDefaultImplementation(Class)}
165
+ */
123
166
@ KeepOriginal
124
167
public static native boolean isDefaultImplementation ( final Class <?> type );
125
168
169
+ /**
170
+ * @see ReflectionHelper#hasDefaultImplementation(Class)
171
+ * @param interfaceType see {@link ReflectionHelper#hasDefaultImplementation(Class)}
172
+ * @return see {@link ReflectionHelper#hasDefaultImplementation(Class)}
173
+ */
126
174
@ KeepOriginal
127
175
public static native boolean hasDefaultImplementation ( final Class <?> interfaceType );
128
176
177
+ /**
178
+ * @see ReflectionHelper#getDefaultImplementation(Class)
179
+ * @param <T> see {@link ReflectionHelper#getDefaultImplementation(Class)}
180
+ * @param interfaceType see {@link ReflectionHelper#getDefaultImplementation(Class)}
181
+ * @return see {@link ReflectionHelper#getDefaultImplementation(Class)}
182
+ */
129
183
@ KeepOriginal
130
184
public static native <T > Class <? extends T > getDefaultImplementation ( final Class <T > interfaceType );
131
185
186
+ /**
187
+ * @see ReflectionHelper#hasDefaultImplementation(Class)
188
+ * @param type see {@link ReflectionHelper#hasDefaultImplementation(Class)}
189
+ * @return see {@link ReflectionHelper#hasDefaultImplementation(Class)}
190
+ */
132
191
@ KeepOriginal
133
192
public static native boolean isModelInterfaceOrDefaultImplementation ( final Class <?> type );
134
193
194
+ /**
195
+ * @see ReflectionHelper#getAasInterface(Class)
196
+ * @param type see {@link ReflectionHelper#getAasInterface(Class)}
197
+ * @return see {@link ReflectionHelper#getAasInterface(Class)}
198
+ */
135
199
@ KeepOriginal
136
200
public static native Class <?> getAasInterface ( final Class <?> type );
137
201
202
+ /**
203
+ * @see ReflectionHelper#getAasInterfaces(Class)
204
+ * @param type see {@link ReflectionHelper#getAasInterfaces(Class)}
205
+ * @return see {@link ReflectionHelper#getAasInterfaces(Class)}
206
+ */
138
207
@ KeepOriginal
139
208
public static native Set <Class <?>> getAasInterfaces ( final Class <?> type );
140
209
210
+ /**
211
+ * @see ReflectionHelper#getModelType(Class)
212
+ * @param clazz see {@link ReflectionHelper#getModelType(Class)}
213
+ * @return see {@link ReflectionHelper#getModelType(Class)}
214
+ */
141
215
@ KeepOriginal
142
216
public static native String getModelType ( final Class <?> clazz );
143
217
218
+ /**
219
+ * @see ReflectionHelper#getMostSpecificTypeWithModelType(Class)
220
+ * @param clazz see {@link ReflectionHelper#getMostSpecificTypeWithModelType(Class)}
221
+ * @return see {@link ReflectionHelper#getMostSpecificTypeWithModelType(Class)}
222
+ */
144
223
@ KeepOriginal
145
224
public static native Class <?> getMostSpecificTypeWithModelType ( final Class <?> clazz );
146
225
226
+ /**
227
+ * @see ReflectionHelper#getSuperTypes(Class, boolean)
228
+ * @param clazz see {@link ReflectionHelper#getSuperTypes(Class, boolean)}
229
+ * @param recursive {@link ReflectionHelper#getSuperTypes(Class, boolean)}
230
+ * @return see {@link ReflectionHelper#getSuperTypes(Class, boolean)}
231
+ */
147
232
@ KeepOriginal
148
233
public static native Set <Class <?>> getSuperTypes ( final Class <?> clazz , final boolean recursive );
234
+
235
+ /**
236
+ * @see ReflectionHelper#setEmptyListsToNull(Object)
237
+ * @param element see {@link ReflectionHelper#setEmptyListsToNull(Object)}
238
+ */
239
+ @ KeepOriginal
240
+ public static native void setEmptyListsToNull ( Object element );
149
241
}
0 commit comments