From ffbae46e3cc1777c49a63b6258ccfb6e77ed2f5e Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Tue, 9 Dec 2014 17:03:48 +0300 Subject: [PATCH] Compile kotlin-runtime-minimal.jar, run proguard against it ProGuard complains if we're trying to shrink compiler with the full runtime in dependencies because for the compiler produced on the first step of bootstrap these two jars contain conflicting classes. This won't matter in the final distribution because we will strip 'core' modules from compiler.jar. But this matters in the first step because core will be different in the compiler (used to load compiled class files) and in the reflection (used to introspect symbols at runtime). kotlin-runtime-minimal.jar still contains the complete reflection API and some stub implementations in module 'reflection.stub.jvm', but doesn't have core, so it won't cause a proguard error --- .idea/compiler.xml | 1 + .idea/modules.xml | 1 + build.xml | 121 +++++++++++++----- .../reflection.stub.jvm.iml | 12 ++ .../KotlinReflectionNotSupportedError.java | 24 ++++ .../reflect/jvm/internal/InternalPackage.java | 33 +++++ .../reflect/jvm/internal/KClassImpl.java | 22 ++++ .../reflect/jvm/internal/KFunctionImpl.java | 22 ++++ .../reflect/jvm/internal/KPackageImpl.java | 22 ++++ resources/kotlinManifest.properties | 2 + 10 files changed, 231 insertions(+), 29 deletions(-) create mode 100644 core/reflection.stub.jvm/reflection.stub.jvm.iml create mode 100644 core/reflection.stub.jvm/src/kotlin/reflect/jvm/KotlinReflectionNotSupportedError.java create mode 100644 core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/InternalPackage.java create mode 100644 core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.java create mode 100644 core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.java create mode 100644 core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 1be8a5b2e25..13d6655cce8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -5,6 +5,7 @@ + diff --git a/.idea/modules.xml b/.idea/modules.xml index 4c80b02dfd9..b81f5f90b51 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -43,6 +43,7 @@ + diff --git a/build.xml b/build.xml index 89ef5929e3f..d3806597379 100644 --- a/build.xml +++ b/build.xml @@ -13,6 +13,7 @@ + @@ -402,6 +403,15 @@ + + + + + + + + + @@ -526,7 +536,7 @@ -libraryjars '${rtjar}' -libraryjars '${jssejar}' - -libraryjars '${bootstrap.runtime}' + -libraryjars '${bootstrap.runtime.minimal}' -target 1.6 -dontoptimize @@ -724,7 +734,6 @@ - @@ -741,43 +750,97 @@ + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - + + + + + + - - - - - + + + + + + + + + + + + + - - - - - - - - + + + + - - + + + + + + + + + - - - - - + + + + + + + + + + + + + - + + + + + + + + + + + + \ No newline at end of file diff --git a/core/reflection.stub.jvm/src/kotlin/reflect/jvm/KotlinReflectionNotSupportedError.java b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/KotlinReflectionNotSupportedError.java new file mode 100644 index 00000000000..5f7d347ff61 --- /dev/null +++ b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/KotlinReflectionNotSupportedError.java @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2014 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; + +public class KotlinReflectionNotSupportedError extends Error { + public KotlinReflectionNotSupportedError() { + super("Kotlin reflection implementation is not found at runtime. " + + "Make sure you do have kotlin-runtime.jar and do not have kotlin-runtime-minimal.jar in the classpath"); + } +} diff --git a/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/InternalPackage.java b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/InternalPackage.java new file mode 100644 index 00000000000..8c64f269f8d --- /dev/null +++ b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/InternalPackage.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010-2014 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; + +import kotlin.reflect.jvm.KotlinReflectionNotSupportedError; + +public class InternalPackage { + public static KClassImpl foreignKotlinClass(Class jClass) { + throw new KotlinReflectionNotSupportedError(); + } + + public static KClassImpl kClassFromKotlin(Class jClass) { + return null; + } + + public static KPackageImpl kPackage(Class c) { + return null; + } +} diff --git a/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.java b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.java new file mode 100644 index 00000000000..002ad2c46bd --- /dev/null +++ b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KClassImpl.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2014 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; + +import kotlin.reflect.KClass; + +public abstract class KClassImpl implements KClass { +} diff --git a/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.java b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.java new file mode 100644 index 00000000000..da07701c357 --- /dev/null +++ b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KFunctionImpl.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2014 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; + +import kotlin.jvm.internal.FunctionImpl; + +public abstract class KFunctionImpl extends FunctionImpl { +} diff --git a/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.java b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.java new file mode 100644 index 00000000000..6aa51dfee21 --- /dev/null +++ b/core/reflection.stub.jvm/src/kotlin/reflect/jvm/internal/KPackageImpl.java @@ -0,0 +1,22 @@ +/* + * Copyright 2010-2014 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; + +import kotlin.reflect.KPackage; + +public abstract class KPackageImpl implements KPackage { +} diff --git a/resources/kotlinManifest.properties b/resources/kotlinManifest.properties index c9e475c1fb7..5792eec70a4 100644 --- a/resources/kotlinManifest.properties +++ b/resources/kotlinManifest.properties @@ -7,7 +7,9 @@ manifest.impl.title.kotlin.compiler.sources=Kotlin Compiler Sources manifest.impl.title.kotlin.compiler.ant.task=Kotlin Compiler Ant Tasks manifest.impl.title.kotlin.jvm.runtime=Kotlin Runtime +manifest.impl.title.kotlin.jvm.runtime.minimal=Kotlin Runtime Minimal manifest.impl.title.kotlin.jvm.runtime.sources=Kotlin Runtime Sources +manifest.impl.title.kotlin.jvm.runtime.minimal.sources=Kotlin Runtime Minimal Sources manifest.impl.title.kotlin.javascript.stdlib=Kotlin JavaScript StdLib manifest.spec.title.kotlin.javascript.lib=Kotlin JavaScript Lib