All Downloads are FREE. Search and download functionalities are using the official Maven repository.

groovy.lang.GrooidClassLoader.kt Maven / Gradle / Ivy

package groovy.lang

import groovy.lang.GroovyClassLoader
import org.codehaus.groovy.control.CompilationUnit
import org.codehaus.groovy.control.SourceUnit
import groovy.lang.GroovyClassLoader.ClassCollector
import groovyjarjarasm.asm.ClassWriter
import org.codehaus.groovy.ast.ClassNode
import org.codehaus.groovy.control.CompilerConfiguration
import java.lang.Exception
import java.security.AccessController
import java.security.PrivilegedAction

class GrooidClassLoader(loader: ClassLoader, config: CompilerConfiguration? = null) :
    GroovyClassLoader(loader, config) {
    override fun createCollector(unit: CompilationUnit, su: SourceUnit): ClassCollector {
        val loader = AccessController.doPrivileged(
            PrivilegedAction { InnerLoader(this@GrooidClassLoader) })
        return object : ClassCollector(loader, unit, su) {
            override fun onClassNode(classWriter: ClassWriter, classNode: ClassNode): Class<*>? {
                return runCatching {
                    super.onClassNode(classWriter, classNode)
                }.getOrNull()
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy