Skip to content

Commit cc876d5

Browse files
Move service related tests to a separate package.
1 parent 2d1d7b5 commit cc876d5

13 files changed

+28
-16
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def native_image_func(args, **kwargs):
334334
yield native_image_func
335335

336336
native_image_context.hosted_assertions = ['-J-ea', '-J-esa']
337-
_native_unittest_features = '--features=com.oracle.svm.test.ImageInfoTest$TestFeature,com.oracle.svm.test.ServiceLoaderTest$TestFeature,com.oracle.svm.test.SecurityServiceTest$TestFeature,com.oracle.svm.test.ReflectionRegistrationTest$TestFeature'
337+
_native_unittest_features = '--features=com.oracle.svm.test.ImageInfoTest$TestFeature,com.oracle.svm.test.services.ServiceLoaderTest$TestFeature,com.oracle.svm.test.services.SecurityServiceTest$TestFeature,com.oracle.svm.test.ReflectionRegistrationTest$TestFeature'
338338

339339
IMAGE_ASSERTION_FLAGS = svm_experimental_options(['-H:+VerifyGraalGraphs', '-H:+VerifyPhases'])
340340

@@ -545,8 +545,8 @@ def native_unittests_task(extra_build_args=None):
545545
out.write(f"Simple file{i}" + '\n')
546546

547547
additional_build_args = svm_experimental_options([
548-
'-H:AdditionalSecurityProviders=com.oracle.svm.test.SecurityServiceTest$NoOpProvider',
549-
'-H:AdditionalSecurityServiceTypes=com.oracle.svm.test.SecurityServiceTest$JCACompliantNoOpService',
548+
'-H:AdditionalSecurityProviders=com.oracle.svm.test.services.SecurityServiceTest$NoOpProvider',
549+
'-H:AdditionalSecurityServiceTypes=com.oracle.svm.test.services.SecurityServiceTest$JCACompliantNoOpService',
550550
'-cp', cp_entry_name
551551
])
552552
if extra_build_args is not None:

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,20 @@ void handleServiceClassIsReachable(DuringAnalysisAccess access, Class<?> service
218218
if (nullaryConstructor != null || nullaryProviderMethod != null) {
219219
RuntimeReflection.register(providerClass);
220220
if (nullaryConstructor != null) {
221+
/*
222+
* Registering a constructor with
223+
* RuntimeReflection.registerConstructorLookup(providerClass) does not produce
224+
* the same behavior as using RuntimeReflection.register(nullaryConstructor). In
225+
* the first case, the constructor is marked for query purposes only, so this
226+
* if-statement cannot be eliminated.
227+
*
228+
*/
221229
RuntimeReflection.register(nullaryConstructor);
222230
} else {
231+
/*
232+
* If there's no nullary constructor, register it as negative lookup to avoid
233+
* throwing a MissingReflectionRegistrationError at run time.
234+
*/
223235
RuntimeReflection.registerConstructorLookup(providerClass);
224236
}
225237
if (nullaryProviderMethod != null) {

substratevm/src/com.oracle.svm.test/src/META-INF/native-image/com.oracle.svm.test/native-image.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ Args= \
22
--initialize-at-run-time=com.oracle.svm.test \
33
--initialize-at-build-time=com.oracle.svm.test.AbstractClassSerializationTest,com.oracle.svm.test.SerializationRegistrationTest,com.oracle.svm.test.SerializationRegistrationTest$SerializableTestClass,com.oracle.svm.test.SerializationRegistrationTest$AssociatedRegistrationTestClass,com.oracle.svm.test.LambdaClassSerializationTest,com.oracle.svm.test.LambdaClassDeserializationTest \
44
--features=com.oracle.svm.test.SerializationRegistrationTestFeature \
5-
--features=com.oracle.svm.test.AbstractServiceLoaderTest$TestFeature \
6-
--features=com.oracle.svm.test.NoProviderConstructorServiceLoaderTest$TestFeature \
5+
--features=com.oracle.svm.test.services.AbstractServiceLoaderTest$TestFeature \
6+
--features=com.oracle.svm.test.services.NoProviderConstructorServiceLoaderTest$TestFeature \
77
--features=com.oracle.svm.test.NativeImageResourceUtils$TestFeature \
88
--features=com.oracle.svm.test.jfr.JfrTestFeature \
99
--add-opens=java.base/java.lang=ALL-UNNAMED \

substratevm/src/com.oracle.svm.test/src/META-INF/services/com.oracle.svm.test.AbstractServiceLoaderTest$ServiceInterface

Lines changed: 0 additions & 2 deletions
This file was deleted.

substratevm/src/com.oracle.svm.test/src/META-INF/services/com.oracle.svm.test.NoProviderConstructorServiceLoaderTest$ServiceInterface

Lines changed: 0 additions & 2 deletions
This file was deleted.

substratevm/src/com.oracle.svm.test/src/META-INF/services/com.oracle.svm.test.ServiceLoaderTest$ServiceInterface

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
com.oracle.svm.test.services.AbstractServiceLoaderTest$ConcreteService
2+
com.oracle.svm.test.services.AbstractServiceLoaderTest$AbstractService
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
com.oracle.svm.test.services.NoProviderConstructorServiceLoaderTest$ProperService
2+
com.oracle.svm.test.services.NoProviderConstructorServiceLoaderTest$NoProviderConstructorService
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
com.oracle.svm.test.services.ServiceLoaderTest$ServiceA
2+
com.oracle.svm.test.services.ServiceLoaderTest$ServiceB
3+
com.oracle.svm.test.services.ServiceLoaderTest$ServiceHostedOnly

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/AbstractServiceLoaderTest.java renamed to substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/services/AbstractServiceLoaderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25-
package com.oracle.svm.test;
25+
package com.oracle.svm.test.services;
2626

2727
import java.util.HashSet;
2828
import java.util.ServiceConfigurationError;

0 commit comments

Comments
 (0)