Discussion:
Compatibility between methods returning different types
Ted Yu
2013-04-05 03:43:06 UTC
Permalink
Hi,
I am looking for a way for the following methods to co-exist in the same class:

  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {

The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.

Maybe expert on this forum can give me some advice.

Thanks
Dennis Sosnoski
2013-04-06 09:29:35 UTC
Permalink
That's either an ingenious or a really ugly idea, depending on how you
want to look at it. :-)

But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return method
call working off an interface reference, rather than the reference to
the implementation class. Given your original problem description I
don't see how that could work... the existing compiled code will be
going direct to the class.

AFAIK there's also no guarantee that this approach will be compatible
with future versions of the Java runtime. I don't think it's likely to
be a problem, but I wouldn't want to bet one of my projects on that.

- Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two
interfaces. One for rev-1 method signatures, one for rev-2 method
signatures. There is one to one correspondence between the methods in
the two interfaces.
New implementation would implement both interfaces, using the
technique shown above.
I know this is not beautiful but it should work.
Cheers
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 9:19 PM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is that the method
signatures (including return type) are actually included in the
referencing class - so if the return type has changed the method will
no longer be found and the classloader will report an error. Change a
class's inheritance won't break anything in and of itself (as long as
the same methods are available) because that inheritance structure is
not in the binary class files.
If you want to try modifying class files your best bet is probably to
use ASM: http://asm.ow2.org/
- Dennis
Here is another question.
public class A {
public void a(int i) {
}
}
Client compiles against above code.
public interface B {
public void a(int i);
}
public class A implements B {
public void a(int i) {
}
}
Now without re-compilation, would the client jar generated earlier
still run on top of new jar with the new class A ?
Thanks
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 6:46 PM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 8:09 AM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the
(open-source) project.
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 7:34 AM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same
arguments by changing only the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you
can always manipulate bytecodes, as described in
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another
argument.
Never forget that the person maintaining your code is a violent
psychopath who knows where you live.
Hi,
public void setValue(byte[] key, byte[] value) {
public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was
changed from first form to second form. I am trying to maintain
binary compatibility for the clients which were compiled against
first form.
The above code doesn't compile. If the parameter type were int, I
can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Ted Yu
2013-04-06 14:17:37 UTC
Permalink
bq. this approach will be compatible with future versions of the Java runtime

I thought of the this aspect as well.

So far this has been an exercise that taught me several things.

I appreciate the feedback I got from this group.


________________________________
From: Dennis Sosnoski <dms-WAiJhE/vqclWk0Htik3J/***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types


 
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)

But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.

AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.

  - Dennis


On 04/06/2013 05:33 PM, Ted Yu wrote:
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
 
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/
  - Dennis
Here is another question.
public class A {
  public void a(int i) {
  }
}
Client compiles against above code.
public interface B {
  public void a(int i);
}
public class A implements B {
  public void a(int i) {
  }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
 
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in 
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
 
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Paul Z. Wu
2013-04-11 17:53:51 UTC
Permalink
 For a reason I won't explain here, I need to link some files using "mklink" on windows in a project with Maven.  If I use soft links, maven cannot read the content of the files so it won't work.  I tried to use "more" to see the file, I cannot see the content either.  It seems windows soft link's implementation is strange...

 Now I have to use hard links, which is not exactly I wanted.
 
Paul Z. Wu
 
http://www.elookinto.com

 
  
 
David Karr
2013-04-11 18:05:50 UTC
Permalink
Have you tried using "junction" instead?
Post by Paul Z. Wu
**
For a reason I won't explain here, I need to link some files using
"mklink" on windows in a project with Maven. If I use soft links, maven
cannot read the content of the files so it won't work. I tried to use
"more" to see the file, I cannot see the content either. It seems windows
soft link's implementation is strange...
Now I have to use hard links, which is not exactly I wanted.
Paul Z. Wu
http://www.elookinto.com
Paul Z. Wu
2013-04-11 18:13:02 UTC
Permalink
"Junction" only works for folders, not files.

 
 
Paul Z. Wu
 
http://www.elookinto.com


________________________________
From: David Karr <davidmichaelkarr-***@public.gmane.org>
To: seajug <seajug-***@public.gmane.org>
Sent: Thursday, April 11, 2013 11:05 AM
Subject: Re: [seajug] Maven and File Symbolic Link on Windows....



 
Have you tried using "junction" instead?
 
 For a reason I won't explain here, I need to link some files using "mklink" on windows in a project with Maven.  If I use soft links, maven cannot read the content of the files so it won't work.  I tried to use "more" to see the file, I cannot see the content either.  It seems windows soft link's implementation is strange...
 Now I have to use hard links, which is not exactly I wanted.
 
Paul Z. Wu
 
http://www.elookinto.com/
 
  
 
Nimret Sandhu
2013-04-11 18:13:29 UTC
Permalink
use *nix? symlinks work just fine for stuff like this, among other
advantages :)

you may want to try to use cygwin which does create *nix style symlinks
under windows. you would have to run maven from within the terminal though
(that's better for automation anyways). unfortunately the '\' instead of
'/' in the pathnames on windows can cause all kinds of other problems
(among other side effects while trying to use cygwin/windows). probably
worth a try though.

see http://cygwin.com/cygwin-ug-net/using-effectively.html

cheers,
nimret
Post by Paul Z. Wu
For a reason I won't explain here, I need to link some files using
"mklink" on windows in a project with Maven. If I use soft links, maven
cannot read the content of the files so it won't work. I tried to use
"more" to see the file, I cannot see the content either. It seems windows
soft link's implementation is strange...
Now I have to use hard links, which is not exactly I wanted.
Paul Z. Wu
http://www.elookinto.com
Paul Z. Wu
2013-04-11 18:44:49 UTC
Permalink
Working with some "seniors" that never heard of maven...(probably only know clicking some buttons on the IDEs) ...  the life is hard.
 
 
Paul Z. Wu
 
http://www.elookinto.com


________________________________
From: Nimret Sandhu <nimret-rf+Eeaps6PzQT0dZR+***@public.gmane.org>
To: "seajug-***@public.gmane.org" <seajug-***@public.gmane.org>
Sent: Thursday, April 11, 2013 11:13 AM
Subject: Re: [seajug] Maven and File Symbolic Link on Windows....



 
use *nix? symlinks work just fine for stuff like this, among other advantages :)

you may want to try to use cygwin which does create *nix style symlinks under windows. you would have to run maven from within the terminal though (that's better for automation anyways). unfortunately the '\' instead of '/' in the pathnames on windows can cause all kinds of other problems (among other side effects while trying to use cygwin/windows). probably worth a try though.

see http://cygwin.com/cygwin-ug-net/using-effectively.html

cheers,
nimret 
 For a reason I won't explain here, I need to link some files using "mklink" on windows in a project with Maven.  If I use soft links, maven cannot read the content of the files so it won't work.  I tried to use "more" to see the file, I cannot see the content either.  It seems windows soft link's implementation is strange...
 Now I have to use hard links, which is not exactly I wanted.
 
Paul Z. Wu
 
http://www.elookinto.com/
Douglas Pearson
2013-04-11 18:47:26 UTC
Permalink
For the whole "/" vs "\" thing a useful but little known fact is that
Windows generally accepts "/" in most situations. They just don't like to
publicize it.

E.g. more "../external/games.xml"

is valid on Windows from the command line - but you need the quotes.

Doug
Post by Nimret Sandhu
**
use *nix? symlinks work just fine for stuff like this, among other
advantages :)
you may want to try to use cygwin which does create *nix style symlinks
under windows. you would have to run maven from within the terminal though
(that's better for automation anyways). unfortunately the '\' instead of
'/' in the pathnames on windows can cause all kinds of other problems
(among other side effects while trying to use cygwin/windows). probably
worth a try though.
see http://cygwin.com/cygwin-ug-net/using-effectively.html
cheers,
nimret
Post by Paul Z. Wu
For a reason I won't explain here, I need to link some files using
"mklink" on windows in a project with Maven. If I use soft links, maven
cannot read the content of the files so it won't work. I tried to use
"more" to see the file, I cannot see the content either. It seems windows
soft link's implementation is strange...
Now I have to use hard links, which is not exactly I wanted.
Paul Z. Wu
http://www.elookinto.com
Nimret Sandhu
2013-04-11 19:39:55 UTC
Permalink
yeah, I'm not going to beat m$ too much over it - sometimes decisions are
made outside your control:
http://en.wikipedia.org/wiki/Backslash

just rather silly :)


On Thu, Apr 11, 2013 at 11:47 AM, Douglas Pearson
Post by Douglas Pearson
For the whole "/" vs "\" thing a useful but little known fact is that
Windows generally accepts "/" in most situations. They just don't like to
publicize it.
E.g. more "../external/games.xml"
is valid on Windows from the command line - but you need the quotes.
Doug
Post by Nimret Sandhu
**
use *nix? symlinks work just fine for stuff like this, among other
advantages :)
you may want to try to use cygwin which does create *nix style symlinks
under windows. you would have to run maven from within the terminal though
(that's better for automation anyways). unfortunately the '\' instead of
'/' in the pathnames on windows can cause all kinds of other problems
(among other side effects while trying to use cygwin/windows). probably
worth a try though.
see http://cygwin.com/cygwin-ug-net/using-effectively.html
cheers,
nimret
Post by Paul Z. Wu
For a reason I won't explain here, I need to link some files using
"mklink" on windows in a project with Maven. If I use soft links, maven
cannot read the content of the files so it won't work. I tried to use
"more" to see the file, I cannot see the content either. It seems windows
soft link's implementation is strange...
Now I have to use hard links, which is not exactly I wanted.
Paul Z. Wu
http://www.elookinto.com
--
Nimret Sandhu
http://www.nimret.org
Curt Allred
2013-04-12 18:11:39 UTC
Permalink
<head>

<style type="text/css">
<!--

/* start of attachment style */
.ygrp-photo-title{
clear: both;
font-size: smaller;
height: 15px;
overflow: hidden;
text-align: center;
width: 75px;
}
div.ygrp-photo{
background-position: center;
background-repeat: no-repeat;
background-color: white;
border: 1px solid black;
height: 62px;
width: 62px;
}

div.photo-title
a,
div.photo-title a:active,
div.photo-title a:hover,
div.photo-title a:visited {
text-decoration: none;
}

div.attach-table div.attach-row {
clear: both;
}

div.attach-table div.attach-row div {
float: left;
/* margin: 2px;*/
}

p {
clear: both;
padding: 15px 0 3px 0;
overflow: hidden;
}

div.ygrp-file {
width: 30px;
valign: middle;
}
div.attach-table div.attach-row div div a {
text-decoration: none;
}

div.attach-table div.attach-row div div span {
font-weight: normal;
}

div.ygrp-file-title {
font-weight: bold;
}
/* end of attachment style */
-->
</style>
</head>
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#f8fff9">


<!-- |**|begin egp html banner|**| -->

<br><br>

<!-- |**|end egp html banner|**| -->



Not sure what type of files youre trying to link into your maven
project, but this test using symlinks worked for me:<br>
<br>
Go to any maven project directory<br> <tt>&gt; move pom.xml x:\tmp\</tt><tt><br> </tt><tt>&gt; mklink pom.xml x:\tmp\pom.xml</tt><tt><br> </tt><tt>&nbsp; symbolic link created for pom.xml &lt;&lt;===&gt;&gt;
x:\tmp\pom.xml</tt><tt><br> </tt><tt>&gt; dir</tt><tt><br> </tt><tt>&nbsp; 04/12/2013&nbsp; 10:03 AM&nbsp;&nbsp;&nbsp; &lt;DIR&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .</tt><tt><br> </tt><tt>&nbsp; 04/12/2013&nbsp; 10:03 AM&nbsp;&nbsp;&nbsp; &lt;DIR&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ..</tt><tt><br> </tt><tt>&nbsp; 04/12/2013&nbsp; 10:03 AM&nbsp;&nbsp;&nbsp; &lt;SYMLINK&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pom.xml
[x:\tmp\pom.xml]</tt><tt><br> </tt><tt>&nbsp; 04/12/2013&nbsp; 09:51 AM&nbsp;&nbsp;&nbsp; &lt;DIR&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; src</tt><tt><br> </tt><tt>&nbsp; 04/12/2013&nbsp; 10:03 AM&nbsp;&nbsp;&nbsp; &lt;DIR&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; target</tt><tt><br> </tt><tt>&gt; cat pom.xml</tt><tt><br> </tt><tt>&gt; mvn clean compile</tt><tt><br>
</tt><tt>&nbsp; [INFO]
------------------------------------------------------------------------</tt><tt><br>
</tt><tt>&nbsp; [INFO] BUILD SUCCESSFUL</tt><tt><br>
</tt><tt>&nbsp; [INFO]
------------------------------------------------------------------------</tt><tt><br>
</tt><br>
The default for mklink is a symbolic link.&nbsp; It will also make hard
links and junctions.<br>
<br>
<br>
<br>
<br>
<br>
<div class="moz-cite-prefix">On 4/11/2013 12:39 PM, Nimret Sandhu
wrote:<br>
</div>
<blockquote
cite="mid:CAK_q8Cc2ZcD209j=849khvB7unk6ne2+Ga5047Hi6Nj4_Y_TVA-JsoAwUIsXosN+***@public.gmane.org"
type="cite">
<span style="display:none">&nbsp;</span>

<div id="ygrp-text">
<div dir="ltr">yeah, I'm not going to beat m$ too much over
it - sometimes decisions are made outside your control:
<div><a moz-do-not-send="true"
href="http://en.wikipedia.org/wiki/Backslash">http://en.wikipedia.org/wiki/Backslash</a><br>
</div>
<div><br>
</div>
<div>just rather silly :)</div>
</div>
<div class="gmail_extra"><br>
<br>
<div class="gmail_quote">On Thu, Apr 11, 2013 at 11:47 AM,
Douglas Pearson <span dir="ltr">&lt;<a
moz-do-not-send="true"
href="mailto:doug-list-S/***@public.gmane.org"
target="_blank">doug-list-S/***@public.gmane.org</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px
#ccc solid;">
<div>
<br>
<br>
<div dir="ltr">For the whole "/" vs "\" thing a
useful but little known fact is that Windows
generally accepts "/" in most situations. &nbsp;They
just don't like to publicize it.
<div><br>
</div>
<div>E.g. more "../external/games.xml"&nbsp;</div>
<div><br>
</div>
<div>is valid on Windows from the command line -
but you need the quotes.</div>
<div><br>
</div>
<div>Doug</div>
<div>
<div class="h5">
<div>
<div class="gmail_extra">
<br>
<div class="gmail_quote">
On Thu, Apr 11, 2013 at 11:13 AM, Nimret
Sandhu <span dir="ltr">&lt;<a
moz-do-not-send="true"
href="mailto:nimret-rf+Eeaps6PzQT0dZR+***@public.gmane.org"
target="_blank">nimret-rf+Eeaps6PzQT0dZR+***@public.gmane.org</a>&gt;</span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;">
<div>
<span>&nbsp;</span>
<div>
<div>
<div>
<div dir="ltr">use *nix?
symlinks work just fine for
stuff like this, among other
advantages :)
<div><br>
</div>
<div>you may want to try to
use cygwin which does
create *nix style symlinks
under windows. you would
have to run maven from
within the terminal though
(that's better for
automation anyways).
unfortunately the '\'
instead of '/' in the
pathnames on windows can
cause all kinds of other
problems (among other side
effects while trying to
use cygwin/windows).
probably worth a try
though.</div>
<div><br>
</div>
<div>see&nbsp;<a
moz-do-not-send="true"
href="http://cygwin.com/cygwin-ug-net/using-effectively.html"
target="_blank">http://cygwin.com/cygwin-ug-net/using-effectively.html</a></div>
<div><br>
</div>
<div>cheers,</div>
<div>nimret&nbsp;</div>
<div class="gmail_extra">
<br>
<br>
<div class="gmail_quote">
<div>
On Thu, Apr 11, 2013
at 10:53 AM, Paul Z.
Wu <span dir="ltr">&lt;<a
moz-do-not-send="true" href="mailto:zwu_net-/***@public.gmane.org" target="_blank">zwu_net-/***@public.gmane.org</a>&gt;</span>
wrote:<br>
</div>
<div>
<blockquote
class="gmail_quote"
style="border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;">
<div>
<br>
<br>
<div
style="font-size:12pt;font-family:arial,helvetica,sans-serif;">
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;"><span><br>
</span></div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">
</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">&nbsp;For
a reason I
won't explain
here, I need
to link some
files using
"mklink" on
windows in a
project with
Maven. &nbsp;If I
use soft
links, maven
cannot read
the content of
the files so
it won't work.
&nbsp;I tried to
use "more" to
see the file,
I cannot see
the content
either. &nbsp;It
seems windows
soft link's
implementation
is strange...</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;"><br>
</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">&nbsp;Now
I have to use
hard links,
which is not
exactly I
wanted.</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">
&nbsp;</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">Paul
Z. Wu</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">&nbsp;</div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;">
<a
moz-do-not-send="true"
rel="nofollow"
href="http://www.elookinto.com/" target="_blank">http://www.elookinto.com</a></div>
<div
style="font-family:arial,helvetica,sans-serif;font-size:12pt;"><br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</div>
<br>
<br>
</div>
</blockquote>
</div>
</div>
<br>
<br clear="all">
<div><br>
</div>
-- <br>
Nimret Sandhu<br>
<a moz-do-not-send="true" href="http://www.nimret.org"
target="_blank">http://www.nimret.org</a>
</div>


<!-- end group email -->
</blockquote>
<br>




<!-- |**|begin egp html banner|**| -->

<br>



<br>

<!-- |**|end egp html banner|**| -->


<div width="1" style="color: white; clear: both;"/>__._,_.___</div>

<!-- Start Recommendations -->
<!-- End Recommendations -->



<!-- |**|begin egp html banner|**| -->

<img src="http://geo.yahoo.com/serv?s=97476590/grpId=2267342/grpspId=1705006905/msgId=19662/stime=1365790306" width="1" height="1"> <br>

<!-- |**|end egp html banner|**| -->


<!-- |**|begin egp html banner|**| -->

<br>
<div style="font-family: verdana; font-size: 77%; border-top: 1px solid #666; padding: 5px 0;" >
Your email settings: Individual Email|Traditional <br>
<a href="http://groups.yahoo.com/group/seajug/join;_ylc=X3oDMTJmcDZwdDhwBF9TAzk3NDc2NTkwBGdycElkAzIyNjczNDIEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA3N0bmdzBHN0aW1lAzEzNjU3OTAzMDY-">Change settings via the Web</a> (Yahoo! ID required) <br>
Change settings via email: <a href="mailto:seajug-digest-***@public.gmane.org?subject=Email Delivery: Digest">Switch delivery to Daily Digest</a> | <a href = "mailto:seajug-fullfeatured-***@public.gmane.org?subject=Change Delivery Format: Fully Featured">Switch to Fully Featured</a> <br>
<a href="http://groups.yahoo.com/group/seajug;_ylc=X3oDMTJkNXYydGNvBF9TAzk3NDc2NTkwBGdycElkAzIyNjczNDIEZ3Jwc3BJZAMxNzA1MDA2OTA1BHNlYwNmdHIEc2xrA2hwZgRzdGltZQMxMzY1NzkwMzA2">
Visit Your Group
</a> |
<a href="http://docs.yahoo.com/info/terms/">
Yahoo! Groups Terms of Use
</a> |
<a href="mailto:seajug-unsubscribe-***@public.gmane.org?subject=Unsubscribe">
Unsubscribe
</a>
<br>
</div>
<br>

<!-- |**|end egp html banner|**| -->


<div style="color: white; clear: both;"/>__,_._,___</div>
</body>
</html>
Paul Z. Wu
2013-04-12 19:20:17 UTC
Permalink
It is a source file "struts.xml". The problem happens when maven tries to copy from the link in resources folder to packaging folder.
 
 
Paul Z. Wu
 
http://www.elookinto.com


________________________________
From: Curt Allred <curt.allred-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Friday, April 12, 2013 11:11 AM
Subject: Re: [seajug] Maven and File Symbolic Link on Windows....



 
Not sure what type of files youre trying to link into your maven project, but this test using symlinks worked for me:

Go to any maven project directory
Post by Curt Allred
move pom.xml x:\tmp\
mklink pom.xml x:\tmp\pom.xml
  symbolic link created for pom.xml <<===>> x:\tmp\pom.xml
Post by Curt Allred
dir
  04/12/2013  10:03 AM    <DIR>          .
  04/12/2013  10:03 AM    <DIR>          ..
  04/12/2013  10:03 AM    <SYMLINK>      pom.xml [x:\tmp\pom.xml]
  04/12/2013  09:51 AM    <DIR>          src
  04/12/2013  10:03 AM    <DIR>          target
Post by Curt Allred
cat pom.xml
mvn clean compile
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESSFUL
  [INFO] ------------------------------------------------------------------------

The default for mklink is a symbolic link.  It will also make hard
links and junctions.






On 4/11/2013 12:39 PM, Nimret Sandhu wrote:

 
Post by Curt Allred
http://en.wikipedia.org/wiki/Backslash
just rather silly :)
For the whole "/" vs "\" thing a useful but little known fact is that Windows generally accepts "/" in most situations.  They just don't like to publicize it.
E.g. more "../external/games.xml" 
is valid on Windows from the command line - but you need the quotes.
Doug
 
Post by Paul Z. Wu
use *nix? symlinks work just fine for stuff like this, among other advantages :)
you may want to try to use cygwin which does create *nix style symlinks under windows. you would have to run maven from within the terminal though (that's better for automation anyways). unfortunately the '\' instead of '/' in the pathnames on windows can cause all kinds of other problems (among other side effects while trying to use cygwin/windows). probably worth a try though.
see http://cygwin.com/cygwin-ug-net/using-effectively.html
cheers,
nimret 
 For a reason I won't explain here, I need to link some files using "mklink" on windows in a project with Maven.  If I use soft links, maven cannot read the content of the files so it won't work.  I tried to use "more" to see the file, I cannot see the content either.  It seems windows soft link's implementation is strange...
 Now I have to use hard links, which is not exactly I wanted.
 
Paul Z. Wu
 
http://www.elookinto.com/
--
Post by Curt Allred
Nimret Sandhu
http://www.nimret.org
Joe Bowbeer
2013-04-12 20:58:03 UTC
Permalink
If you want a link to a folder then a junction should work:

mklink /J ...

http://en.wikipedia.org/wiki/NTFS_junction_point
Post by Paul Z. Wu
For a reason I won't explain here, I need to link some files using
"mklink" on windows in a project with Maven. If I use soft links, maven
cannot read the content of the files so it won't work. I tried to use
"more" to see the file, I cannot see the content either. It seems windows
soft link's implementation is strange...
Now I have to use hard links, which is not exactly I wanted.
Paul Z. Wu
http://www.elookinto.com
couldy_cloudy_cloud
2013-08-30 04:10:58 UTC
Permalink
In your byte code post-compile stage, you could add a bridge method:

http://bridge-method-injector.infradna.com
bq. this approach will be compatible with future versions of the Java runtime
I thought of the this aspect as well.
So far this has been an exercise that taught me several things.
I appreciate the feedback I got from this group.
________________________________
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)
But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.
AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.
  - Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
 
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/
  - Dennis
Here is another question.
public class A {
  public void a(int i) {
  }
}
Client compiles against above code.
public interface B {
  public void a(int i);
}
public class A implements B {
  public void a(int i) {
  }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
 
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in 
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
 
Post by Ted Yu
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
------------------------------------
Jason Marshall
2013-08-31 06:53:38 UTC
Permalink
I'm reasonably sure that several obfuscators use(d) this quirk of the JVM to shorten their method signatures. The vendors really can't change that behavior now, if it's true.
Post by couldy_cloudy_cloud
http://bridge-method-injector.infradna.com
bq. this approach will be compatible with future versions of the Java runtime
I thought of the this aspect as well.
So far this has been an exercise that taught me several things.
I appreciate the feedback I got from this group.
________________________________
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)
But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.
AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.
- Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/
- Dennis
Here is another question.
public class A {
public void a(int i) {
}
}
Client compiles against above code.
public interface B {
public void a(int i);
}
public class A implements B {
public void a(int i) {
}
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
Hi,
public void setValue(byte[] key, byte[] value) {
public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
k***@u.washington.edu
2013-10-16 17:41:08 UTC
Permalink
Just to add to the conversation, if you're following up on using the
byte code enhancement and annotations suggested within the
project http://bridge-method-injector.infradna.com http://bridge-method-injector.infradna.com/
you might want to use it differently than their test examples. just read
through their code now and one way to use it effectively for a
return type change for forward versions and backwards compatibility is
to use the following pattern for source code and builds:


if one wanted to keep a single source version (not v1 and v2 separate sources) and want a method's
return type to change from a build version forward, yet still be possible to
build for past versions and maintain compatibility,
one could use the bridge annotation on the "changed" method.
Then build for v1 and v2 binaries.
Note that one would have to add to the annotation processor a recognition for
the latest version that it shouldn't be rewritten to change the return type.
Also note that such a design decision, that is to change the return type for
future versions and to handle the difference at build time in this way has
to be consistent with other dependencies introduced.


---In ***@yahoogroups.com, <***@...> wrote:

In your byte code post-compile stage, you could add a bridge method:

http://bridge-method-injector.infradna.com http://bridge-method-injector.infradna.com
bq. this approach will be compatible with future versions of the Java runtime
I thought of the this aspect as well.
So far this has been an exercise that taught me several things.
I appreciate the feedback I got from this group.
________________________________
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)
But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.
AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.
 - Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/ http://asm.ow2.org/
 - Dennis
Here is another question.
public class A {
 public void a(int i) {
 }
}
Client compiles against above code.
public interface B {
 public void a(int i);
}
public class A implements B {
 public void a(int i) {
 }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
http://jasmin.sourceforge.net/ http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/ http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described inÂ
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
Â
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
k***@u.washington.edu
2013-10-16 17:55:08 UTC
Permalink
Looks like the replying to a yahoo groups message earlier in the conversation can lead to a chaotic read so here's the url for the source again (given
in another message in this conversation that appears out of order):




https://github.com/infradna/ bridge-method-injector https://github.com/infradna/bridge-method-injector





---In ***@yahoogroups.com, <***@...> wrote:

Just to add to the conversation, if you're following up on using the
byte code enhancement and annotations suggested within the
project http://bridge-method-injector.infradna.com http://bridge-method-injector.infradna.com/
you might want to use it differently than their test examples. just read
through their code now and one way to use it effectively for a
return type change for forward versions and backwards compatibility is
to use the following pattern for source code and builds:


if one wanted to keep a single source version (not v1 and v2 separate sources) and want a method's
return type to change from a build version forward, yet still be possible to
build for past versions and maintain compatibility,
one could use the bridge annotation on the "changed" method.
Then build for v1 and v2 binaries.
Note that one would have to add to the annotation processor a recognition for
the latest version that it shouldn't be rewritten to change the return type.
Also note that such a design decision, that is to change the return type for
future versions and to handle the difference at build time in this way has
to be consistent with other dependencies introduced.


---In ***@yahoogroups.com, <***@...> wrote:

In your byte code post-compile stage, you could add a bridge method:

http://bridge-method-injector.infradna.com http://bridge-method-injector.infradna.com
bq. this approach will be compatible with future versions of the Java runtime
I thought of the this aspect as well.
So far this has been an exercise that taught me several things.
I appreciate the feedback I got from this group.
________________________________
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)
But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.
AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.
 - Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/ http://asm.ow2.org/
 - Dennis
Here is another question.
public class A {
 public void a(int i) {
 }
}
Client compiles against above code.
public interface B {
 public void a(int i);
}
public class A implements B {
 public void a(int i) {
 }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
http://jasmin.sourceforge.net/ http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/ http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described inÂ
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
Â
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
k***@u.washington.edu
2013-10-16 17:50:30 UTC
Permalink
the source code for the bridge project is not easily findable from the
project web site, so here it is:
https://github.com/infradna/bridge-method-injector





---In ***@yahoogroups.com, <***@...> wrote:

In your byte code post-compile stage, you could add a bridge method:

http://bridge-method-injector.infradna.com http://bridge-method-injector.infradna.com
bq. this approach will be compatible with future versions of the Java runtime
I thought of the this aspect as well.
So far this has been an exercise that taught me several things.
I appreciate the feedback I got from this group.
________________________________
Sent: Saturday, April 6, 2013 2:29 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
That's either an ingenious or a really ugly idea, depending on how you want to look at it. :-)
But I don't think it would do you any good in this case. To use this
kludg^H^H^H^H^H elegant workaround for the limitations of the Java
language and compiler you'd need to have at least the void return
method call working off an interface reference, rather than the
reference to the implementation class. Given your original problem
description I don't see how that could work... the existing compiled
code will be going direct to the class.
AFAIK there's also no guarantee that this approach will be
compatible with future versions of the Java runtime. I don't think
it's likely to be a problem, but I wouldn't want to bet one of my
projects on that.
 - Dennis
Thanks for the quick response, Dennis.
For ASM, it is not Apache license.
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful
And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.
I know this is not beautiful but it should work.
Cheers
________________________________
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Hi Ted,
AFAIK that should work without a problem.
The difficulty with the method return type change is
that the method signatures (including return type)
are actually included in the referencing class - so
if the return type has changed the method will no
longer be found and the classloader will report an
error. Change a class's inheritance won't break
anything in and of itself (as long as the same
methods are available) because that inheritance
structure is not in the binary class files.
If you want to try modifying class files your best
bet is probably to use ASM: http://asm.ow2.org/ http://asm.ow2.org/
 - Dennis
Here is another question.
public class A {
 public void a(int i) {
 }
}
Client compiles against above code.
public interface B {
 public void a(int i);
}
public class A implements B {
 public void a(int i) {
 }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
http://jasmin.sourceforge.net/ http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/ http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
Â
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described inÂ
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
Â
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Paul Hill
2013-04-06 00:44:48 UTC
Permalink
I'm thinking the change was to get more DSL-like (domain specific language).
so that a user could chain calls like:
myCol.setValue(newKey1, data).setValue(newKey2, data2);

I would have gone with a new name like
with(String key, String data)

or withProperty or whatever the "keys" are supposed to be ("value"
provides no information to make the API informative).

I am now thinking your friend made an upward compatible change.

1: What bit of already _compiled_ Java code can't call a method which
adds a return type after previously calling something that didn't return
anything?

2: What bit of Java existing _source_ code compiled against a new
library with a return type will now have an error?

The solution is NOT to attempt to have _two_ methods, but just have
_one_ method that in the newer release does return the this pointer.

I assume the old one was the equivalent of:
public void set(String key, String value) {
this.map.put(key, value);
}

And the new one now looks like

public HColumnDescriptor set(String key, String value) {
this.map.put(key, value);
return this;
}

I tried this. I put HColumnDescriptor in a separate project that didn't
auto build used by another project that didn't auto build.
The using project looked like

public static void main(String[] args) {
HColumnDescriptor a = new HColumnDescriptor();
String key = "key";
String value = "the value";
a.set(key, value);
System.out.println("The value of key [" + key + "] is: [" +
a.get(key) + "]");
}

That is the only way set (your setValue) would be allowed to be called
under the old API.

I change from one version of set to another, re-build the
HColumnDescriptor project and the project using it works fine.

Either variation of HColumnDescriptor.set works fine as far as my little
experiment was concerned (assuming the helpful feature of my IDE didn't
get in my way.

If the original intent was not to chain setting calls in a builder
pattern, then maybe I'd object to the change, but ADDing (but not
removing) the returning of the object works great.

-Paul
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the
(open-source) project.
Hi,
public void setValue(byte[] key, byte[] value) {
public HColumnDescriptor setValue(byte[] key, byte[] value) {
Ted Yu
2013-04-06 01:01:28 UTC
Permalink
bq. re-build the HColumnDescriptor project

I should have been clearer in my first email: I was seeking binary compatibility. No re-build should be involved.

Cheers


________________________________
From: Paul Hill <parehill1-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Friday, April 5, 2013 5:44 PM
Subject: Re: [seajug] Compatibility between methods returning different types


 
I'm thinking the change was to get more DSL-like (domain specific language).
so that a user could chain calls like:
myCol.setValue(newKey1, data).setValue(newKey2, data2);

I would have gone with a new name like
with(String key, String data)

or withProperty or whatever the "keys" are supposed to be ("value"
provides no information to make the API informative).

I am now thinking your friend made an upward compatible change.

1: What bit of already _compiled_ Java code can't call a method
which adds a return type after previously calling something that
didn't return anything?

2: What bit of Java existing _source_ code compiled against a new
library with a return type will now have an error?

The solution is NOT to attempt to have _two_ methods, but just
have _one_ method that in the newer release does return the this
pointer.

I assume the old one was the equivalent of:
    public void  set(String key, String value) {
        this.map.put(key, value);
    }

And the new one now looks like

    public HColumnDescriptor  set(String key, String value) {
        this.map.put(key, value);
        return this;
    }

I tried this.  I put HColumnDescriptor in a separate project that
didn't auto build used by another project that didn't auto build.
The using project looked like

    public static void main(String[] args) {
        HColumnDescriptor a = new HColumnDescriptor();
        String key = "key";
        String value = "the value";
        a.set(key, value);
        System.out.println("The value of key [" + key + "] is: ["
+ a.get(key) + "]");
    }

That is the only way set (your setValue) would be allowed to be
called under the old API.

I change from one version of set to another, re-build the
HColumnDescriptor project and the project using it works fine.

Either variation of HColumnDescriptor.set works fine as far as my
little experiment was concerned (assuming the helpful feature of
my IDE didn't get in my way.

If the original intent was not to chain setting calls in a builder
pattern, then maybe I'd object to the change, but ADDing (but not
removing) the returning of the object works great.

-Paul

On 4/5/2013 8:09 AM, Ted Yu wrote:

 
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
 
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
Dennis Sosnoski
2013-04-06 04:19:12 UTC
Permalink
Hi Ted,

AFAIK that should work without a problem.

The difficulty with the method return type change is that the method
signatures (including return type) are actually included in the
referencing class - so if the return type has changed the method will no
longer be found and the classloader will report an error. Change a
class's inheritance won't break anything in and of itself (as long as
the same methods are available) because that inheritance structure is
not in the binary class files.

If you want to try modifying class files your best bet is probably to
use ASM: http://asm.ow2.org/

- Dennis
Here is another question.
public class A {
public void a(int i) {
}
}
Client compiles against above code.
public interface B {
public void a(int i);
}
public class A implements B {
public void a(int i) {
}
}
Now without re-compilation, would the client jar generated earlier
still run on top of new jar with the new class A ?
Thanks
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 6:46 PM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 8:09 AM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the
(open-source) project.
------------------------------------------------------------------------
*Sent:* Friday, April 5, 2013 7:34 AM
*Subject:* Re: [seajug] Compatibility between methods returning
different types
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same
arguments by changing only the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you
can always manipulate bytecodes, as described in
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent
psychopath who knows where you live.
Hi,
public void setValue(byte[] key, byte[] value) {
public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was
changed from first form to second form. I am trying to maintain
binary compatibility for the clients which were compiled against
first form.
The above code doesn't compile. If the parameter type were int, I
can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Ted Yu
2013-04-06 04:33:12 UTC
Permalink
Thanks for the quick response, Dennis.

For ASM, it is not Apache license.

I read this:
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html#is-this-useful


And got the idea in my previous email.
Basically change of return type can be accommodated by introducing two interfaces. One for rev-1 method signatures, one for rev-2 method signatures. There is one to one correspondence between the methods in the two interfaces.
New implementation would implement both interfaces, using the technique shown above.

I know this is not beautiful but it should work.

Cheers


________________________________
From: Dennis Sosnoski <dms-WAiJhE/vqclWk0Htik3J/***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Friday, April 5, 2013 9:19 PM
Subject: Re: [seajug] Compatibility between methods returning different types


 
Hi Ted,

AFAIK that should work without a problem.

The difficulty with the method return type change is that the method
signatures (including return type) are actually included in the
referencing class - so if the return type has changed the method
will no longer be found and the classloader will report an error.
Change a class's inheritance won't break anything in and of itself
(as long as the same methods are available) because that inheritance
structure is not in the binary class files.

If you want to try modifying class files your best bet is probably
to use ASM: http://asm.ow2.org/

  - Dennis


On 04/06/2013 05:06 PM, Ted Yu wrote:
Here is another question.
public class A {
  public void a(int i) {
  }
}
Client compiles against above code.
public interface B {
  public void a(int i);
}
public class A implements B {
  public void a(int i) {
  }
}
Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?
Thanks
________________________________
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types
 
http://jasmin.sourceforge.net/
I also found http://www.eg.bucknell.edu/~cs360/java-assembler/
I wonder if anyone knows of other, more recent assembler(s).
Thanks
________________________________
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
Thanks for the pointer.
In hindsight, new method name should have been used.
The change was done by a friend who no longer actively works on the (open-source) project.
________________________________
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types
 
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in 
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html
I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
 
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Ted Yu
2013-04-06 01:46:02 UTC
Permalink
I was looking at:
http://jasmin.sourceforge.net/


I also found http://www.eg.bucknell.edu/~cs360/java-assembler/

I wonder if anyone knows of other, more recent assembler(s).

Thanks


________________________________
From: Ted Yu <ted_yu-/***@public.gmane.org>
To: "seajug-***@public.gmane.org" <seajug-***@public.gmane.org>
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types


 
Thanks for the pointer.

In hindsight, new method name should have been used.

The change was done by a friend who no longer actively works on the (open-source) project.


________________________________
From: Neilson Ramalho <neilsoncarlos-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types


 
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in 
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html

I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
 
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Ted Yu
2013-04-06 04:06:28 UTC
Permalink
Here is another question.

Suppose I had:
public class A {
  public void a(int i) {
  }
}

Client compiles against above code.

In next release, I change the class this way:
public interface B {
  public void a(int i);
}
public class A implements B {
  public void a(int i) {
  }
}

Now without re-compilation, would the client jar generated earlier still run on top of new jar with the new class A ?

Thanks


________________________________
From: Ted Yu <ted_yu-/***@public.gmane.org>
To: "seajug-***@public.gmane.org" <seajug-***@public.gmane.org>
Sent: Friday, April 5, 2013 6:46 PM
Subject: Re: [seajug] Compatibility between methods returning different types


 
I was looking at:
http://jasmin.sourceforge.net/


I also found http://www.eg.bucknell.edu/~cs360/java-assembler/

I wonder if anyone knows of other, more recent assembler(s).

Thanks


________________________________
From: Ted Yu <ted_yu-/***@public.gmane.org>
To: "seajug-***@public.gmane.org" <seajug-***@public.gmane.org>
Sent: Friday, April 5, 2013 8:09 AM
Subject: Re: [seajug] Compatibility between methods returning different types


 
Thanks for the pointer.

In hindsight, new method name should have been used.

The change was done by a friend who no longer actively works on the (open-source) project.


________________________________
From: Neilson Ramalho <neilsoncarlos-***@public.gmane.org>
To: seajug-***@public.gmane.org
Sent: Friday, April 5, 2013 7:34 AM
Subject: Re: [seajug] Compatibility between methods returning different types


 
You are trying to break the overloading rule.
There is no way to have two methods with the same name and same arguments by changing only  the return type. The compiler will complain.
However, if this back compatibility is such a strong requirement, you can always manipulate bytecodes, as described in 
http://today.java.net/pub/a/today/2008/07/31/return-type-based-method-overloading.html

I did not try that and I will never do.
I would rather change the name of the method or just add another argument.
Never forget that the person maintaining your code is a violent psychopath who knows where you live.
 
Hi,
  public void setValue(byte[] key, byte[] value) {
  public HColumnDescriptor setValue(byte[] key, byte[] value) {
The background is that in recent release, method signature was changed from first form to second form. I am trying to maintain binary compatibility for the clients which were compiled against first form.
The above code doesn't compile. If the parameter type were int, I can introduce a new method with same name and Integer type parameter.
Maybe expert on this forum can give me some advice.
Thanks
Loading...