Skip to content

Commit

Permalink
Replace ModulesUtil in test
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Mar 16, 2021
1 parent 41d0e6c commit 036f319
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/org/eclipse/yasson/internal/model/ModulesUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/

package org.eclipse.yasson.internal.model;

import java.lang.invoke.MethodHandles;

/**
* Why is this class here?.
*
* This class is here to replace existing classes in test-runtime:
* - src/main/java/org/eclipse/yasson/internal/model/ModulesUtil.java
* - src/main/java9/org/eclipse/yasson/internal/model/ModulesUtil.java
*
* When tests are executed with maven-surefire-plugin the content of
* 'classes' is in a different module-path than 'test-classes'.
*
* This causes the MethodHandles#publicLookup to fail. The reason is that
* test classes to serialize/deserialize are coming from module 'test-classes'
* and the module 'classes' has no access to it. The 'publicLookup' makes some
* validations and because of this different modules, it fails.
*
* It should work if 'classes' and 'test-classes' are merged in one unique module.
*
*/
class ModulesUtil {

private ModulesUtil() {
}

static MethodHandles.Lookup lookup(){
return MethodHandles.lookup();
}
}

0 comments on commit 036f319

Please sign in to comment.