Getting a `error: unresolved reference` with gradle

1.2k Views Asked by At

I am using rometools to parse a RSS feed and when I run the sample code here I get an unresolved error. The project is using Java 11 and Kotlin with gradle 7.1

fun parseRSSFeed(feed:String): SyndFeed? {
    val feed = SyndFeedInput().build(XmlReader(URL(feed)))
    println(feed.title)
    return feed
}

Error:

/Users/simon/Library/Java/JavaVirtualMachines/liberica-11.0.11/bin/java -javaagent:/Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/lib/idea_rt.jar=62778:/Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-compiler.jar:/Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-reflect.jar:/Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-stdlib.jar:/Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-script-runtime.jar org.jetbrains.kotlin.cli.jvm.K2JVMCompiler -kotlin-home /Applications/IntelliJ IDEA 2021.2 EAP.app/Contents/plugins/Kotlin/kotlinc -script /Users/simon/Library/Application Support/JetBrains/IntelliJIdea2021.2/scratches/scratch.kts
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil (file:/Applications/IntelliJ%20IDEA%202021.2%20EAP.app/Contents/plugins/Kotlin/kotlinc/lib/kotlin-compiler.jar) to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
error: unresolved reference: rometools (scratch.kts:1:12)
error: unresolved reference: rometools (scratch.kts:2:12)
error: unresolved reference: SyndFeedInput (scratch.kts:5:12)
error: unresolved reference: XmlReader (scratch.kts:5:34)
scratch.kts:1:12: error: unresolved reference: rometools
import com.rometools.rome.io.SyndFeedInput
           ^
scratch.kts:2:12: error: unresolved reference: rometools
import com.rometools.rome.io.XmlReader
           ^
scratch.kts:5:12: error: unresolved reference: SyndFeedInput
val feed = SyndFeedInput().build(XmlReader(URL("https://**.org/en/rss/blog.xml")))
           ^
scratch.kts:5:34: error: unresolved reference: XmlReader
val feed = SyndFeedInput().build(XmlReader(URL("https://**.org/en/rss/blog.xml")))

Any ideas?

1

There are 1 best solutions below

0
minchaej On

Incorrect use of Reflection in Java/Kotlin.

You are using Reflection to parse input feed. However, the contents of feed contain values undefined in the current Application, thus unable to be processed by Reflection.

To solve this issue, you have to strictly manage input feed so that only defined members could be allowed to be processed by Reflection.

PS: If you are unsure of what Reflection is, you can easily follow this friendly tutorial on Reflection.

Let me know if you have more questions. Thanks.