Hi All,
Issue: It is imposible to extend/sub-class certain standard java library classes. Reason: NetRexxC does not check implemented interfaces when matching method signatures. Case in point: Trying to extend java.io.Writer or any of its sub-classes on java 1.5+. This will produce: Error: Class is not abstract, yet it does not implement method 'append(CharSequence) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Error: Class is not abstract, yet it does not implement method 'append(CharSequence,int,int) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Error: Class is not abstract, yet it does not implement method 'append(char) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Detail: From 1.5+ java.io.Writer implements the interface Appendable with the following method signatures: public Writer append(char c) public Writer append(CharSequence csq) public Writer append(CharSequence csq, int start, int end) These form a valid Appendable implementation in java as Writer implements Appendable. As NetRexxC does not check for implemented interfaces it deems these methods as not implementing the Appendable interface. Failed workaround (explicitly implementing Appendable): Error: Method has return type 'java.lang.Appendable', so cannot override or implement method of return type 'java.io.Writer' in class 'java.io.Writer' Returning java.io.Writer leads to same initial error. Bottom line: NetRexx is starting to badly show its age by not remaining compatible with newer versions of the java platform. And getting to my nerves too.. General plea: Any one can think of a workaround? I really need to extend PipedWriter to get next NetRexxDE version out. I'd hate being forced to include just one non NetRexx class in a product geared to help generalize the use of the language. Sample code: -- This is needed to prevent delays up to 1 second on every netrexx output class TacitFlushPipedWriter - extends PipedWriter method TacitFlushPipedWriter(sink=PipedReader) - signals IOException super(sink) method TacitFlushPipedWriter() super() method write(b=int) - signals IOException super.write(b) flush() method write(b=char[], offset=int, len=int) - signals IOException super.write(b, offset, len) flush() Many thanks for any help an comments! -- --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Why do you make everything so difficult.
From: [hidden email] <[hidden email]> To: IBM Netrexx <[hidden email]> Sent: Tue Aug 17 09:11:52 2010 Subject: [Ibm-netrexx] Another issue with current NetRexxC (sorry to say...) Issue: It is imposible to extend/sub-class certain standard java library classes. Reason: NetRexxC does not check implemented interfaces when matching method signatures. Case in point: Trying to extend java.io.Writer or any of its sub-classes on java 1.5+. This will produce: Error: Class is not abstract, yet it does not implement method 'append(CharSequence) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Error: Class is not abstract, yet it does not implement method 'append(CharSequence,int,int) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Error: Class is not abstract, yet it does not implement method 'append(char) returns java.lang.Appendable' from abstract class 'java.lang.Appendable' Detail: From 1.5+ java.io.Writer implements the interface Appendable with the following method signatures: public Writer append(char c) public Writer append(CharSequence csq) public Writer append(CharSequence csq, int start, int end) These form a valid Appendable implementation in java as Writer implements Appendable. As NetRexxC does not check for implemented interfaces it deems these methods as not implementing the Appendable interface. Failed workaround (explicitly implementing Appendable): Error: Method has return type 'java.lang.Appendable', so cannot override or implement method of return type 'java.io.Writer' in class 'java.io.Writer' Returning java.io.Writer leads to same initial error. Bottom line: NetRexx is starting to badly show its age by not remaining compatible with newer versions of the java platform. And getting to my nerves too.. General plea: Any one can think of a workaround? I really need to extend PipedWriter to get next NetRexxDE version out. I'd hate being forced to include just one non NetRexx class in a product geared to help generalize the use of the language. Sample code: -- This is needed to prevent delays up to 1 second on every netrexx output class TacitFlushPipedWriter - extends PipedWriter method TacitFlushPipedWriter(sink=PipedReader) - signals IOException super(sink) method TacitFlushPipedWriter() super() method write(b=int) - signals IOException super.write(b) flush() method write(b=char[], offset=int, len=int) - signals IOException super.write(b, offset, len) flush() Many thanks for any help an comments! -- --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by David Requena
Hi David ;
I reported this one a while back I think. The solution, if I recall correctly, was to make your extension an "adapter" class to allow NetRexx to generate the missing methods, then tell Ant to remove them. I will try to find that thread and repost the solution I used. -- Kermit On 8/17/2010 6:11 AM, David Requena wrote: Hi All, _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by measel
El 17/08/2010 16:04, Measel, Mike escribió:
A really bad case of too high expectations for the audience I suspect... --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
If you only wrote this in Rexx and used the Rexx to NetRexx converter
it would probably work. From: [hidden email]
[mailto:[hidden email]] On Behalf Of David Requena
Why do you make everything so difficult.
--- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by Kermit Kiser
El 17/08/2010 17:16, Kermit Kiser escribió:
I reported this one a while back I think. The solution, if I recall correctly, was to make your extension an "adapter" class to allow NetRexx to generate the missing methods, then tell Ant to remove them. Ah, very clever! So the compiler itself is allowed to override un-matching methods the user is not :-) I will try to find that thread and repost the solution I used. Please, do so. I'm most interested in knowing how to get ant to remove the methods. Does it involve the <replace> ant task? I've been thinking in something along the lines but making the class abstract. --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by measel
El 17/08/2010 17:28, Measel, Mike escribió:
That would surely be far simpler :-) --- Saludos / Kind regards. David Requena _______________________________________________ Ibm-netrexx mailing list [hidden email] |
In reply to this post by David Requena
OK - here is the section of the Ant build for NetRexxScript which fixes
the appendable problem. Cumbersome, but works until we can get open
source NetRexx and fix the real problem. René said he would look at it
but I imagine he is quite busy with other things right now. This fix
just sticks a "replace" task between the NetRexx translate task and the
javac task to rename the append methods to something else so the Java
compile can run.
-- Kermit ------- <target name="TeeCheck" description="Checks if Java version of TeeStream class is uptodate"> <uptodate property="TeeStream.isUpToDate" srcfile="src/javasrc/nrx/TeeStream.nrx" targetfile="src/javasrc/java/TeeStream.java"/> </target> <target name="TeeBuild" depends="TeeCheck" unless="TeeStream.isUpToDate" description="Compiles NetRexx version of TeeStream class (Java output has an error)"> <netrexxc srcDir="src/javasrc/nrx" destDir="src/javasrc/java" classpath=".${path.separator}${project.netrexx.libdir}/NetRexxC.jar" comments="true" savelog="false" time="true" compact="false" compile="false" java="true" format="true" verbose='verbose0' crossref="false" replace="true" /> </target> <target name="keepJava" depends="TeeBuild" unless="TeeStream.isUpToDate" description="Copies Java output from TeeStream compile"> <copy file="src/javasrc/java/TeeStream.java.keep" tofile="src/javasrc/java/TeeStream.java" preservelastmodified="true" verbose="true"/> </target> <target name="fixJava" depends="keepJava" unless="TeeStream.isUpToDate" description="Patches Java file for TeeStream class"> <replace file="src/javasrc/java/TeeStream.java" token="Appendable append(" value="Appendable noappend(" /> </target> <target name="compileJava" depends="fixJava" description="Compile Java temp file for TeeStream class"> <javac srcDir="src/javasrc/java" destDir="." verbose="true" classpath=".${path.separator}${project.netrexx.libdir}/NetRexxC.jar"/> </target> On 8/17/2010 8:35 AM, David Requena wrote: El 17/08/2010 17:16, Kermit Kiser escribió:I reported this one a while back I think. The solution, if I recall correctly, was to make your extension an "adapter" class to allow NetRexx to generate the missing methods, then tell Ant to remove them. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Many thanks Kermit,
Yes, it's a bit of a kludge but it'll work for the time being. --- Saludos / Kind regards. David Requena El 17/08/2010 18:13, Kermit Kiser escribió: OK - here is the section of the Ant build for NetRexxScript which fixes the appendable problem. Cumbersome, but works until we can get open source NetRexx and fix the real problem. René said he would look at it but I imagine he is quite busy with other things right now. This fix just sticks a "replace" task between the NetRexx translate task and the javac task to rename the append methods to something else so the Java compile can run. _______________________________________________ Ibm-netrexx mailing list [hidden email] |
Free forum by Nabble | Edit this page |