001 /* 002 * Copyright 2010-2015 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.kotlin.load.java; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.kotlin.name.ClassId; 021 import org.jetbrains.kotlin.name.FqName; 022 import org.jetbrains.kotlin.name.Name; 023 024 public final class JvmAbi { 025 /** 026 * This constant is used to identify binary format (class file) versions 027 * If you change class file metadata format and/or naming conventions, please increase this number 028 */ 029 public static final int VERSION = 22; 030 031 public static final String TRAIT_IMPL_CLASS_NAME = "$TImpl"; 032 public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME; 033 034 public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default"; 035 public static final String GETTER_PREFIX = "get"; 036 public static final String SETTER_PREFIX = "set"; 037 038 public static final String DELEGATED_PROPERTY_NAME_SUFFIX = "$delegate"; 039 public static final String PROPERTY_METADATA_ARRAY_NAME = "$propertyMetadata"; 040 public static final String ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX = "$annotations"; 041 042 public static final String INSTANCE_FIELD = "INSTANCE$"; 043 044 public static final String KOTLIN_CLASS_FIELD_NAME = "$kotlinClass"; 045 public static final String KOTLIN_PACKAGE_FIELD_NAME = "$kotlinPackage"; 046 public static final ClassId REFLECTION_FACTORY_IMPL = ClassId.topLevel(new FqName("kotlin.reflect.jvm.internal.ReflectionFactoryImpl")); 047 048 //TODO: To be removed after kotlin M11 049 @Deprecated 050 public static final String DEPRECATED_COMPANION_OBJECT_FIELD = "OBJECT$"; 051 052 @NotNull 053 public static String getSyntheticMethodNameForAnnotatedProperty(@NotNull Name propertyName) { 054 return propertyName.asString() + ANNOTATED_PROPERTY_METHOD_NAME_SUFFIX; 055 } 056 057 @NotNull 058 public static String getDefaultFieldNameForProperty(@NotNull Name propertyName, boolean isDelegated) { 059 return isDelegated ? propertyName.asString() + DELEGATED_PROPERTY_NAME_SUFFIX : propertyName.asString(); 060 } 061 062 public static boolean isAccessorName(String name) { 063 return name.startsWith(GETTER_PREFIX) || name.startsWith(SETTER_PREFIX); 064 } 065 066 private JvmAbi() { 067 } 068 }