Can't set Integer value to int,How I can Fix it by Kotlin?


#1

When using Java reflect API, happened this error

Exception in thread "main" java.lang.IllegalArgumentException: Can not set final int field XXX.ABC.abc to java.lang.Integer
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
	at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.set(UnsafeQualifiedObjectFieldAccessorImpl.java:83)
	at java.lang.reflect.Field.set(Field.java:764)

Although I know we can fix it by using java code ,But I wan’t know is there any way to solve it by Kotlin


#2

Sorry,It my problem ,nothing has problem with Kotlin
just remove the final modifier then it runs OK