digitalmars.D.bugs - [Issue 6046] New: Not true for Java about Function Hijacking.
- d-bugmail puremagic.com (62/62) May 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6046
- d-bugmail puremagic.com (17/17) May 23 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6046
- d-bugmail puremagic.com (12/12) Jan 20 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6046
http://d.puremagic.com/issues/show_bug.cgi?id=6046 Summary: Not true for Java about Function Hijacking. Product: D Version: unspecified Platform: Other OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: websites AssignedTo: nobody puremagic.com ReportedBy: ongbp yahoo.com --- Comment #0 from Matthew Ong <ongbp yahoo.com> 2011-05-23 02:45:48 PDT --- Hi Digitalmars/Walter Bright, http://www.digitalmars.com/d/2.0/hijack.html This talk covers function hijacking, where adding innocent and reasonable declarations in a module can wreak arbitrary havoc on an application program in C++(maybe true) and Java(not true). Since I have not done C++ for a long while, I am not going to comment about that. But Java I have to place this request for correction from DigitalMars. javac(from sun) Compiler will complain if there is an ambiguous to link any indentifier that has the same signature for contructor, methods(static/overloaded/overriden) Overload Sets Java denys global functions. All functions/methods are within a single class. Within the same class, the overloaded methods cannot have the same signature. public class MyClass{ public int myVal(){ } public String myVal(){ // compiler will complain here as error and NOT warning. } } Both the method identifier and zero param list makes a identical signature. Derived Class Member Function Hijacking IDE like Netbeans and does flag: override public void myMethodA(){ // Say you did not use the override tag } Base Class Member Function Hijacking to prevent the child class from stealing your implementation for this single method, do: public final void myMethodA(){ // final == sealed in C# } That is shown clearly when you tries to import both this 2 classes within Java: import java.util.Date; import java.sql.Date; public class MyTest{ public static void main(String[] args){ Date now=new Date(); // thinking that you are using java.util.Date; } } Again, as a senior Java Developer since java jdk 1.1 I agrees D as a good replacement for C++ because of modern design and approaches. Kindly correct that to avoid confusing the new Java to D developer. There are also other run time intelligent build into JVM to avoid malicious hacker attack on such thing using class proxy & stub. -- Matthew Ong email: ongbp yahoo.com -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6046 Steven Schveighoffer <schveiguy yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schveiguy yahoo.com --- Comment #1 from Steven Schveighoffer <schveiguy yahoo.com> 2011-05-23 04:40:59 PDT --- I would say the only valid request here is to mention that Java has the override flag which can be used to prevent hijacking, but is not the default. I think you misunderstood the point of this article. The point is to prevent hijacking the *default* must be to prevent hijacking. Having annotations and modifiers that allow you to prevent hijacking is not good enough. I think you also misunderstood the scope in the article of Java's shortcomings. I think the author only singles out one aspect of Java, it's overload resolution for inherited methods. Nothing else applies to Java. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 23 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6046 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |INVALID --- Comment #2 from Walter Bright <bugzilla digitalmars.com> 2012-01-20 22:12:16 PST --- I agree with Steven. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 20 2012