Could I use AnonymousClassLoader?

Vladimir Ivanov vladimir.x.ivanov at oracle.com
Thu Mar 12 23:36:01 UTC 2015


Lev,

Have you tried passing -XDignore.symbol.file to javac?

Regarding the API, I'd "recommend" (if it's an appropriate word for 
implementation-specific API :-)) to experiment with 
Unsafe.defineAnonymousClass() instead.

Best regards,
Vladimir Ivanov

On 3/13/15 2:22 AM, Lev Serebryakov wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>
>
>   I'm writing to this mailing list because it seems, that
> AnonymousClassLoader was created in this project around 2008.
>
>   There are several blog posts mention AnonymousClassConstructor in the
> past, in context of dynamic languages support. But all these posts are
> rather old.
>
>   And now I see sun.invoke.anon.AnonymousClassLoader in rt.jar of JDK7
> and JDK8, and I want to use it to create small anonymous classes with
> ASM library.
>
>   I want to use AnonymousClassLoader because it allows me to extend
> package-private base classes. If I subclass ClassLoader and use its
> defneClass() it complains about unreachable base class! And I don't
> want to export my abstract base classes as public ones.
>
>   I've wrote code and it works perfectly under IDEA IDE with JDK 1.8.
> After that I tried to compile this code without IDE, with gradle,
> maven or by hands with "javac" and I get same error: javac doesn't see
> "sun.invoke.anon" package!
>
>   I could not compile minimal test case from command line:
>
> ======================================================
> import sun.invoke.anon.AnonymousClassLoader;
> public class Test {
> 	private final static AnonymousClassLoader acl;
> }
> ======================================================
>
>   What do I do wrong? Why IDEA could compile code with
> AnonymousClassLoader and all command line tools and build systems
> could not? Should I use AnonymousClassLoader or it is abandoned,
> unsupported and not recommended?
>
>   Thank you!
>
> - --
> // Black Lion AKA Lev Serebryakov
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.22 (MingW32)
>
> iQJ8BAEBCgBmBQJVAh/JXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
> ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGOTZEMUNBMEI1RjQzMThCNjc0QjMzMEFF
> QUIwM0M1OEJGREM0NzhGAAoJEOqwPFi/3EePnfkP+wTH4XMxGKpIjwb/CqyZtzAL
> pj3/J+0K5d7ycF5JOl3nZHeh4jqW5IvS8USVumzyb/NlbK6sVl12sU+U+EtpPnNo
> DiK5LJmp2J4eeKLo4Ci1SYu9H8AsOqDHehb/3vzDmRP4eHRsAvG0OOVQF7VeBlWQ
> vuEeyRvL2bb26vy9y/iVQQS5lTqMUoKNXKxrf5wbU6xrKJ6723rRXs55wgm8Y0TW
> VJaDNqhIZVOqTfT4e60zPlJiFf1QNFpARMRpdu9x5lXV4wurSFLiaRl42FwvlrKI
> GdgQvUxyZxrKNGqfZIvOyO3Tx9aB/PhJAePzfBHhpkKhcWJ94VGcTNwbA+QBIMk+
> 89vl2+nYRJ6OjIicHJXb7D8AH3sqsxKuowS1w+RDdUWSqfFri/OH7rCKbJesmtnc
> Aia7j3OL3x6ocqCdfoqWq79oeMIMdJ/GKgpxOOkQ62gPqKsvqp1toU16qqS4nsHn
> O/Hz8QcWEIyALE1QzkA9Z/LpYOTstS2XOKgr+Zbks3dHgLeyi6ddL95kW7QD+/e/
> Kg+Zn3gfJMPH5ITdR71YsYALDNxMesgfqwfMfjAEzmRV5ioV190JJeroH3wvMkEg
> o4c1lKwU/ox31dkVfSGHIenzIzdDL7wfkmjV9g99gexQm390QzFVZGR5PtDhOSZg
> 0zLCqapGHqkpz6nFl1yy
> =m8PD
> -----END PGP SIGNATURE-----
> _______________________________________________
> mlvm-dev mailing list
> mlvm-dev at openjdk.java.net
> http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev
>


More information about the mlvm-dev mailing list