001 /* 002 * Copyright 2010-2013 JetBrains s.r.o. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017 package org.jetbrains.jet.lang.resolve.java; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.annotations.Nullable; 021 import org.jetbrains.jet.lang.resolve.name.FqName; 022 import org.jetbrains.jet.lang.resolve.name.Name; 023 024 public final class JvmAnnotationNames { 025 public static final FqName KOTLIN_CLASS = new FqName("kotlin.jvm.internal.KotlinClass"); 026 public static final FqName KOTLIN_PACKAGE = new FqName("kotlin.jvm.internal.KotlinPackage"); 027 028 public static final FqName KOTLIN_SIGNATURE = new FqName("kotlin.jvm.KotlinSignature"); 029 public static final FqName OLD_KOTLIN_SIGNATURE = new FqName("jet.runtime.typeinfo.KotlinSignature"); 030 031 public static final String ABI_VERSION_FIELD_NAME = "abiVersion"; 032 public static final String DATA_FIELD_NAME = "data"; 033 public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value"); 034 035 public static final FqName JETBRAINS_NOT_NULL_ANNOTATION = new FqName("org.jetbrains.annotations.NotNull"); 036 public static final FqName JETBRAINS_NULLABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Nullable"); 037 public static final FqName JETBRAINS_MUTABLE_ANNOTATION = new FqName("org.jetbrains.annotations.Mutable"); 038 public static final FqName JETBRAINS_READONLY_ANNOTATION = new FqName("org.jetbrains.annotations.ReadOnly"); 039 040 public static class KotlinSyntheticClass { 041 public static final JvmClassName CLASS_NAME = JvmClassName.byInternalName("kotlin/jvm/internal/KotlinSyntheticClass"); 042 public static final String KIND_INTERNAL_NAME = "kotlin/jvm/internal/KotlinSyntheticClass$Kind"; 043 044 public static final Name KIND_FIELD_NAME = Name.identifier("kind"); 045 046 /** 047 * This enum duplicates {@link kotlin.jvm.internal.KotlinSyntheticClass.Kind}, because this code can't depend on "runtime.jvm". 048 * Both places should be updated simultaneously 049 */ 050 public enum Kind { 051 PACKAGE_PART, 052 TRAIT_IMPL, 053 SAM_WRAPPER, 054 SAM_LAMBDA, 055 CALLABLE_REFERENCE_WRAPPER, 056 LOCAL_FUNCTION, 057 ANONYMOUS_FUNCTION, 058 LOCAL_CLASS, 059 ANONYMOUS_OBJECT, 060 ; 061 062 @Nullable 063 public static Kind valueOfOrNull(@NotNull String name) { 064 try { 065 return valueOf(name); 066 } 067 catch (IllegalArgumentException e) { 068 return null; 069 } 070 } 071 } 072 073 private KotlinSyntheticClass() { 074 } 075 } 076 077 @Deprecated 078 public static final FqName OLD_JET_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetClass"); 079 @Deprecated 080 public static final FqName OLD_JET_PACKAGE_CLASS_ANNOTATION = new FqName("jet.runtime.typeinfo.JetPackageClass"); 081 @Deprecated 082 public static final FqName OLD_JET_VALUE_PARAMETER_ANNOTATION = new FqName("jet.runtime.typeinfo.JetValueParameter"); 083 @Deprecated 084 public static final FqName OLD_KOTLIN_CLASS = new FqName("jet.KotlinClass"); 085 @Deprecated 086 public static final FqName OLD_KOTLIN_PACKAGE = new FqName("jet.KotlinPackage"); 087 @Deprecated 088 public static final FqName OLD_KOTLIN_PACKAGE_FRAGMENT = new FqName("jet.KotlinPackageFragment"); 089 @Deprecated 090 public static final FqName OLD_KOTLIN_TRAIT_IMPL = new FqName("jet.KotlinTraitImpl"); 091 092 @SuppressWarnings("deprecation") 093 public static boolean isSpecialAnnotation(@NotNull FqName fqName) { 094 return fqName.asString().startsWith("jet.runtime.typeinfo.") 095 || fqName.equals(KOTLIN_SIGNATURE) 096 || fqName.equals(JETBRAINS_NOT_NULL_ANNOTATION) 097 || fqName.equals(OLD_KOTLIN_CLASS) 098 || fqName.equals(OLD_KOTLIN_PACKAGE) 099 || fqName.equals(KOTLIN_CLASS) 100 || fqName.equals(KOTLIN_PACKAGE); 101 } 102 103 private JvmAnnotationNames() { 104 } 105 }