Re: Dynamically extends a class with java.lang.reflect.Proxy or similar
Stefan Ram wrote:
Andrea Francia <andrea.francia@REMOVE-FROM-HERE.ohoihihoihoih.TO-HERE.gmx.it> writes:
The JSP pages are translated in a Java source file that define a class
that extends HTTPServlet and compiled and loaded at runtime.
There is another way instead creating a source file and compiling it?
No.
Here, the point is that there is a system running (the server),
which should not be terminated and recompiled.
Smalltalk and Squeak have even more dynamic of this type.
But in the case of JSP, each JSP (usually) is written by a /human/.
I thought that you had asked about programs that create
new classes at runtime that are generated solely by the
program - not (indirectly) by a human being like a JSP.
The process of transmuting a JSP to a Java class is source-code based, not
bytecode based as implicitly required by the OP. The built-in compiler
classes in the Java API surely would allow one to build any sort of
source-code based solution.
I'm somewhat frightened of bytecode rewriters. I've heard war stories of
peculiar bugs, thankfully fixed by that time, caused by trouble in a bytecode
modifier. I realize that the technology is stable now, and that it allows
better maintenance practices operationally, done right. But how much can you
rely on it being right?
Many frameworks have seemed good at first blush but introduced too many
operational difficulties in practice, or were ill-conceived in implementation,
or were too easily misused by all but the most careful developers.
A certain dubiety towards hot, new buzzwords is a survival technique.
Acceptance is based on a certain fuddy-duddiness. That's why I like generics.
Generics may be new, and run-time erasure sure seems kludgey at times, but
generics serve an old-fashioned, conservative goal - source-code correctness
through strict control. The syntax sure isn't concise, but it buys safety and
buys it early.
Run-time code alteration is scary because it's harder, or seems harder to
control. How would you test such a system? How does the sysadmin detect,
understand and deal with any anomalous behaviors? What emergent behaviors
could arise?
--
Lew