Skip to content

Commit 118a29f

Browse files
authored
fix: revert differences in ModuleEnvironment from v5 (#112)
1 parent 1fa1664 commit 118a29f

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

gestalt-module/src/main/java/org/terasology/gestalt/module/ModuleEnvironment.java

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
/*
2-
* Copyright 2019 MovingBlocks
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-
*/
1+
// Copyright 2021 The Terasology Foundation
2+
// SPDX-License-Identifier: Apache-2.0
163

174
package org.terasology.gestalt.module;
185

196
import android.support.annotation.NonNull;
20-
217
import com.google.common.collect.Collections2;
228
import com.google.common.collect.HashMultimap;
239
import com.google.common.collect.ImmutableList;
@@ -26,7 +12,6 @@
2612
import com.google.common.collect.Lists;
2713
import com.google.common.collect.Maps;
2814
import com.google.common.collect.SetMultimap;
29-
3015
import org.reflections.Reflections;
3116
import org.reflections.ReflectionsException;
3217
import org.reflections.scanners.SubTypesScanner;
@@ -118,10 +103,10 @@ public ModuleEnvironment(Iterable<Module> modules, final PermissionProviderFacto
118103
ImmutableList.Builder<ModuleClassLoader> managedClassLoaderListBuilder = ImmutableList.builder();
119104
ClassLoader lastClassLoader = apiClassLoader;
120105
List<Module> orderedModules = getModulesOrderedByDependencies();
121-
Predicate<Class<?>> classpathModuleClassesPredicate = orderedModules.stream().map(Module::getClassPredicate).reduce(x -> false, Predicate::or);
106+
122107
for (final Module module : orderedModules) {
123108
if (!module.getClasspaths().isEmpty() && !hasClassContent(module)) {
124-
ModuleClassLoader classLoader = buildModuleClassLoader(module, lastClassLoader, permissionProviderFactory, classLoaderSupplier, classpathModuleClassesPredicate);
109+
ModuleClassLoader classLoader = buildModuleClassLoader(module, lastClassLoader, permissionProviderFactory, classLoaderSupplier);
125110
managedClassLoaderListBuilder.add(classLoader);
126111
lastClassLoader = classLoader.getClassLoader();
127112
}
@@ -160,9 +145,8 @@ private ImmutableMap<Name, Module> buildModuleMap(Iterable<Module> moduleList) {
160145
*/
161146
private ModuleClassLoader buildModuleClassLoader(final Module module, final ClassLoader parent,
162147
final PermissionProviderFactory permissionProviderFactory,
163-
final ClassLoaderSupplier classLoaderSupplier,
164-
final Predicate<Class<?>> classpathModuleClassesPredicate) {
165-
PermissionProvider permissionProvider = permissionProviderFactory.createPermissionProviderFor(module, classpathModuleClassesPredicate);
148+
final ClassLoaderSupplier classLoaderSupplier) {
149+
PermissionProvider permissionProvider = permissionProviderFactory.createPermissionProviderFor(module, x -> false);
166150
return AccessController.doPrivileged((PrivilegedAction<ModuleClassLoader>) () -> classLoaderSupplier.create(module, parent, permissionProvider));
167151
}
168152

@@ -173,6 +157,7 @@ private ModuleClassLoader buildModuleClassLoader(final Module module, final Clas
173157
*/
174158
private Reflections buildFullReflections(Map<Name, Reflections> reflectionsByModule) {
175159
ConfigurationBuilder fullBuilder = new ConfigurationBuilder()
160+
.addClassLoader(apiClassLoader)
176161
.addClassLoader(finalClassLoader);
177162
Reflections reflections = new Reflections(fullBuilder);
178163
for (Reflections moduleReflection : reflectionsByModule.values()) {

0 commit comments

Comments
 (0)