Is there any way in Oracle to determine whether a package has state or is stateless? I'm not aware of any view in the data dictionary that contains that information.
The "ORA-04068: existing state of packages string has been discarded" error is rather annoying. It can be eliminated by removing package variables from the package. 11g introduced the feature that a package with variables that are all compile-time constants will be treated as stateless.
I could have two sessions and compile the package in one and call it in the other and see if it throws an exception, but that requires calling a procedure in the package, which may not be desirable.