Skip to content

Commit 036f319

Browse files
committed
Replace ModulesUtil in test
Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent 41d0e6c commit 036f319

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0 which is available at
6+
* http://www.eclipse.org/legal/epl-2.0,
7+
* or the Eclipse Distribution License v. 1.0 which is available at
8+
* http://www.eclipse.org/org/documents/edl-v10.php.
9+
*
10+
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
11+
*/
12+
13+
package org.eclipse.yasson.internal.model;
14+
15+
import java.lang.invoke.MethodHandles;
16+
17+
/**
18+
* Why is this class here?.
19+
*
20+
* This class is here to replace existing classes in test-runtime:
21+
* - src/main/java/org/eclipse/yasson/internal/model/ModulesUtil.java
22+
* - src/main/java9/org/eclipse/yasson/internal/model/ModulesUtil.java
23+
*
24+
* When tests are executed with maven-surefire-plugin the content of
25+
* 'classes' is in a different module-path than 'test-classes'.
26+
*
27+
* This causes the MethodHandles#publicLookup to fail. The reason is that
28+
* test classes to serialize/deserialize are coming from module 'test-classes'
29+
* and the module 'classes' has no access to it. The 'publicLookup' makes some
30+
* validations and because of this different modules, it fails.
31+
*
32+
* It should work if 'classes' and 'test-classes' are merged in one unique module.
33+
*
34+
*/
35+
class ModulesUtil {
36+
37+
private ModulesUtil() {
38+
}
39+
40+
static MethodHandles.Lookup lookup(){
41+
return MethodHandles.lookup();
42+
}
43+
}

0 commit comments

Comments
 (0)