beanshell / beanshell

Beanshell scripting language
Apache License 2.0
819 stars 183 forks source link

After class not found cannot regenerate class #700

Closed nickl- closed 1 year ago

nickl- commented 1 year ago

After getting a class not found exception, during class generation, we cannot regenerate the class anymore.

BeanShell 3.0.0-SNAPSHOT.3577
class A {
    class B extends A {}
}
// Error: Evaluation Error: Class: A not found in namespace : at Line: 2 : in file: <unknown file> : A

class A {}
// Error: Internal Error: Defining class problem: A: BeanShell cannot yet simultaneously define two or more dependent classes of the same name.  Attempt to define: A while defining: A

This is because the class was never removed from the currently being defined classes cache, which amongst other things prevents the generation of a class currently being generated, because the exception prematurely aborts the process before it could be removed. One fix will be to wrap the remove in a finally block, but perhaps we can remove the currently defined cache workaround/hack all together.