Add module-info.java for kotlin-reflect

The standard way of loading resources with built-ins metadata from the
current class loader no longer works in the modular mode on Java 9
because the current class loader is for module 'kotlin.reflect', but the
metadata is located in the module 'kotlin.stdlib'. On Java 9, we now use
the class loader of 'kotlin.stdlib' to load these resources.

 #KT-21266 Fixed
This commit is contained in:
Alexander Udalov
2017-08-29 11:02:45 +03:00
parent 2d41c7d462
commit 828cc6dbf3
11 changed files with 122 additions and 18 deletions
@@ -0,0 +1,29 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect.jvm.internal.impl.builtins;
import kotlin.Unit;
import java.io.IOException;
import java.io.InputStream;
public class BuiltInsResourceLoader {
public InputStream loadResource(String path) throws IOException {
Module stdlib = Unit.class.getModule();
return stdlib != null ? stdlib.getResourceAsStream(path) : null;
}
}
@@ -0,0 +1,18 @@
module kotlin.reflect {
requires transitive kotlin.stdlib;
exports kotlin.reflect.full;
exports kotlin.reflect.jvm;
opens kotlin.reflect.jvm.internal to kotlin.stdlib;
uses org.jetbrains.kotlin.builtins.BuiltInsLoader;
uses org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition;
uses org.jetbrains.kotlin.util.ModuleVisibilityHelper;
provides org.jetbrains.kotlin.builtins.BuiltInsLoader with org.jetbrains.kotlin.builtins.BuiltInsLoaderImpl;
provides org.jetbrains.kotlin.resolve.ExternalOverridabilityCondition with
org.jetbrains.kotlin.load.java.FieldOverridabilityCondition,
org.jetbrains.kotlin.load.java.ErasedOverridabilityCondition,
org.jetbrains.kotlin.load.java.JavaIncompatibilityRulesOverridabilityCondition;
}