Deprecate throws annotation in favor of Throws
This commit is contained in:
@@ -524,7 +524,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
|
public static String[] getThrownExceptions(@NotNull FunctionDescriptor function, @NotNull final JetTypeMapper mapper) {
|
||||||
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.throws"));
|
AnnotationDescriptor annotation = function.getAnnotations().findAnnotation(new FqName("kotlin.Throws"));
|
||||||
if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY;
|
if (annotation == null) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||||
|
|
||||||
Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
|
Collection<ConstantValue<?>> values = annotation.getAllValueArguments().values();
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ class E1: Exception()
|
|||||||
class E2: Exception()
|
class E2: Exception()
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
throws()
|
@Throws()
|
||||||
fun none() {}
|
fun none() {}
|
||||||
|
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one() {}
|
fun one() {}
|
||||||
|
|
||||||
throws(E1::class, E2::class)
|
@Throws(E1::class, E2::class)
|
||||||
fun two() {}
|
fun two() {}
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,8 @@ package test
|
|||||||
class E1: Exception()
|
class E1: Exception()
|
||||||
class E2: Exception()
|
class E2: Exception()
|
||||||
|
|
||||||
class None @throws() constructor() {}
|
class None @Throws() constructor() {}
|
||||||
class One @throws(E1::class) constructor()
|
class One @Throws(E1::class) constructor()
|
||||||
class Two @throws(E1::class, E2::class) constructor()
|
class Two @Throws(E1::class, E2::class) constructor()
|
||||||
|
|
||||||
class OneWithParam @throws(E1::class) constructor(a: Int)
|
class OneWithParam @Throws(E1::class) constructor(a: Int)
|
||||||
@@ -2,10 +2,10 @@ package test
|
|||||||
|
|
||||||
class E1: Exception()
|
class E1: Exception()
|
||||||
|
|
||||||
throws(E1::class) jvmOverloads
|
Throws(E1::class) jvmOverloads
|
||||||
fun one(a: Int = 1) {}
|
fun one(a: Int = 1) {}
|
||||||
|
|
||||||
class One @throws(E1::class) constructor(a: Int = 1) {
|
class One @Throws(E1::class) constructor(a: Int = 1) {
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one(a: Int = 1) {}
|
fun one(a: Int = 1) {}
|
||||||
}
|
}
|
||||||
@@ -4,13 +4,13 @@ class E1: Exception()
|
|||||||
class E2: Exception()
|
class E2: Exception()
|
||||||
|
|
||||||
interface Trait {
|
interface Trait {
|
||||||
throws()
|
@Throws()
|
||||||
fun none()
|
fun none()
|
||||||
|
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one()
|
fun one()
|
||||||
|
|
||||||
throws(E1::class, E2::class)
|
@Throws(E1::class, E2::class)
|
||||||
fun two()
|
fun two()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ package test
|
|||||||
class E1: Exception()
|
class E1: Exception()
|
||||||
|
|
||||||
interface Base<T> {
|
interface Base<T> {
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one(t: T) {}
|
fun one(t: T) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package test
|
|||||||
class E1: Exception()
|
class E1: Exception()
|
||||||
class E2: Exception()
|
class E2: Exception()
|
||||||
|
|
||||||
throws()
|
@Throws()
|
||||||
fun none() {}
|
fun none() {}
|
||||||
|
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one() {}
|
fun one() {}
|
||||||
|
|
||||||
throws(E1::class, E2::class)
|
@Throws(E1::class, E2::class)
|
||||||
fun two() {}
|
fun two() {}
|
||||||
@@ -4,13 +4,13 @@ class E1: Exception()
|
|||||||
class E2: Exception()
|
class E2: Exception()
|
||||||
|
|
||||||
interface Trait {
|
interface Trait {
|
||||||
throws()
|
@Throws()
|
||||||
fun none() {}
|
fun none() {}
|
||||||
|
|
||||||
throws(E1::class)
|
@Throws(E1::class)
|
||||||
fun one() {}
|
fun one() {}
|
||||||
|
|
||||||
throws(E1::class, E2::class)
|
@Throws(E1::class, E2::class)
|
||||||
fun two() {}
|
fun two() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ class Converter private constructor(
|
|||||||
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
|
val convertedType = typeConverter.convertType(types[index], Nullability.NotNull)
|
||||||
null to deferredElement<Expression> { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) }
|
null to deferredElement<Expression> { ClassLiteralExpression(convertedType.assignPrototype(refElements[index])) }
|
||||||
}
|
}
|
||||||
val annotation = Annotation(Identifier("throws").assignNoPrototype(), arguments, withAt = false, newLineAfter = true)
|
val annotation = Annotation(Identifier("Throws").assignNoPrototype(), arguments, withAt = false, newLineAfter = true)
|
||||||
return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList)
|
return Annotations(listOf(annotation.assignPrototype(throwsList))).assignPrototype(throwsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class Test : Base() {
|
|||||||
return super.equals(o)
|
return super.equals(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(CloneNotSupportedException::class)
|
Throws(CloneNotSupportedException::class)
|
||||||
override fun clone(): Any {
|
override fun clone(): Any {
|
||||||
return super.clone()
|
return super.clone()
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,7 @@ class Test : Base() {
|
|||||||
return super.toString()
|
return super.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(Throwable::class)
|
Throws(Throwable::class)
|
||||||
override fun finalize() {
|
override fun finalize() {
|
||||||
super.finalize()
|
super.finalize()
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ open class Base {
|
|||||||
return super.equals(o)
|
return super.equals(o)
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(CloneNotSupportedException::class)
|
Throws(CloneNotSupportedException::class)
|
||||||
protected open fun clone(): Any {
|
protected open fun clone(): Any {
|
||||||
return super.clone()
|
return super.clone()
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ open class Base {
|
|||||||
return super.toString()
|
return super.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(Throwable::class)
|
Throws(Throwable::class)
|
||||||
protected open fun finalize() {
|
protected open fun finalize() {
|
||||||
super.finalize()
|
super.finalize()
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -12,14 +12,14 @@ class X {
|
|||||||
return super.toString()
|
return super.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(CloneNotSupportedException::class)
|
Throws(CloneNotSupportedException::class)
|
||||||
protected fun clone(): Any {
|
protected fun clone(): Any {
|
||||||
return super.clone()
|
return super.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Y : Thread() {
|
class Y : Thread() {
|
||||||
throws(CloneNotSupportedException::class)
|
Throws(CloneNotSupportedException::class)
|
||||||
override fun clone(): Any {
|
override fun clone(): Any {
|
||||||
return super.clone()
|
return super.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ class X : Base() {
|
|||||||
return super.toString()
|
return super.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(CloneNotSupportedException::class)
|
Throws(CloneNotSupportedException::class)
|
||||||
protected fun clone(): Any {
|
protected fun clone(): Any {
|
||||||
return super.clone()
|
return super.clone()
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
throws(IOException::class, SerializationException::class)
|
Throws(IOException::class, SerializationException::class)
|
||||||
fun foo()
|
fun foo()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import java.lang.reflect.Constructor
|
import java.lang.reflect.Constructor
|
||||||
|
|
||||||
object X {
|
object X {
|
||||||
throws(Exception::class)
|
Throws(Exception::class)
|
||||||
fun <T> foo(constructor: Constructor<T>, args1: Array<Any>, args2: Array<Any>) {
|
fun <T> foo(constructor: Constructor<T>, args1: Array<Any>, args2: Array<Any>) {
|
||||||
constructor.newInstance(*args1)
|
constructor.newInstance(*args1)
|
||||||
constructor.newInstance(args1, args2)
|
constructor.newInstance(args1, args2)
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo() {
|
fun foo() {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||||
// reading something
|
// reading something
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo() {
|
fun foo() {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { input ->
|
ByteArrayInputStream(ByteArray(10)).use { input ->
|
||||||
ByteArrayOutputStream().use { output ->
|
ByteArrayOutputStream().use { output ->
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo() {
|
fun foo() {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
|
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo() {
|
fun foo() {
|
||||||
try {
|
try {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
interface I {
|
interface I {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
public fun doIt(stream: InputStream): Int
|
public fun doIt(stream: InputStream): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo() {
|
fun foo() {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||||
bar(object : I {
|
bar(object : I {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
override fun doIt(stream: InputStream): Int {
|
override fun doIt(stream: InputStream): Int {
|
||||||
return stream.available()
|
return stream.available()
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun bar(i: I, stream: InputStream): Int {
|
fun bar(i: I, stream: InputStream): Int {
|
||||||
return i.doIt(stream)
|
return i.doIt(stream)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import java.io.*
|
import java.io.*
|
||||||
|
|
||||||
interface I {
|
interface I {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
public fun doIt(stream: InputStream): Int
|
public fun doIt(stream: InputStream): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
public class C {
|
public class C {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun foo(): Int {
|
fun foo(): Int {
|
||||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||||
return bar(object : I {
|
return bar(object : I {
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
override fun doIt(stream: InputStream): Int {
|
override fun doIt(stream: InputStream): Int {
|
||||||
return stream.available()
|
return stream.available()
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throws(IOException::class)
|
Throws(IOException::class)
|
||||||
fun bar(i: I, stream: InputStream): Int {
|
fun bar(i: I, stream: InputStream): Int {
|
||||||
return i.doIt(stream)
|
return i.doIt(stream)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import kotlin.reflect.KClass
|
|||||||
*
|
*
|
||||||
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
|
* @property exceptionClasses the list of checked exception classes that may be thrown by the function.
|
||||||
*/
|
*/
|
||||||
public annotation(retention = AnnotationRetention.SOURCE) class throws(public vararg val exceptionClasses: KClass<out Throwable>)
|
public annotation(retention = AnnotationRetention.SOURCE) class Throws(public vararg val exceptionClasses: KClass<out Throwable>)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the runtime Java class of this object.
|
* Returns the runtime Java class of this object.
|
||||||
|
|||||||
Reference in New Issue
Block a user