<lambda>null1// Copyright 2021 Code Intelligence GmbH 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 @file:JvmName("Utils") 15 16 package com.code_intelligence.jazzer.utils 17 18 import java.lang.reflect.Executable 19 20 val Class<*>.readableDescriptor: String 21 get() = when { 22 isPrimitive -> { 23 when (this) { 24 Boolean::class.javaPrimitiveType -> "boolean" 25 Byte::class.javaPrimitiveType -> "byte" 26 Char::class.javaPrimitiveType -> "char" 27 Short::class.javaPrimitiveType -> "short" 28 Int::class.javaPrimitiveType -> "int" 29 Long::class.javaPrimitiveType -> "long" 30 Float::class.javaPrimitiveType -> "float" 31 Double::class.javaPrimitiveType -> "double" 32 java.lang.Void::class.javaPrimitiveType -> "void" 33 else -> throw IllegalStateException("Unknown primitive type: $name") 34 } 35 } 36 isArray -> "${componentType.readableDescriptor}[]" 37 java.lang.Object::class.java.isAssignableFrom(this) -> name 38 else -> throw IllegalArgumentException("Unknown class type: $name") 39 } 40 41 // This does not include the return type as the parameter descriptors already uniquely identify the executable. 42 val Executable.readableDescriptor: String parameterTypenull43 get() = parameterTypes.joinToString(separator = ",", prefix = "(", postfix = ")") { parameterType -> 44 parameterType.readableDescriptor 45 } 46