Results 1 to 9 of 9

Thread: Java syntax

  1. #1
    Icandoit is offline Member
    Join Date
    Oct 2013
    Posts
    13
    Rep Power
    0

    Default Java syntax

    1. What would happen if someone used "enum" as a variable name in java4, and then upgraded to java5?

    2. If I went from java7 to java8 would some of my java7 code fail to compile?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Java syntax

    Quote Originally Posted by Icandoit View Post
    1. What would happen if someone used "enum" as a variable name in java4, and then upgraded to java5?
    It probably wouldn't compile. But then similar problems would also cause variable names of strictfp and assert which
    were not keywords until Java 1.2 and Java 1.3 respectively.

    2. If I went from java7 to java8 would some of my java7 code fail to compile?
    Any code written and compilable using 1.5+ should be compilable using a 1.8 compiler.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Java syntax

    One possible problem is if a new final method in an existing JDK class has the same name as a method added to a custom subclass. This actually happened somewhere in the world when migrating to Java 7, but I can't remember where I read about it.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Java syntax

    Now that you mention it, I can imagine a situation in which someone implements their own
    interface which has method X. Then, the JDK offers a new default method X with same signature
    in an interface which that same someone has implemented. Now the JDK X conflicts with the custom X.
    This would not be a problem unless the coder now wants to take advantage of the new default method.
    S/he can't rename the JDK version so they have to change their version. And their version is implemented
    in some 1000 classes of their project. There is probably a work around of some sort but I'm too tired to
    think about it.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Java syntax

    Quote Originally Posted by jim829 View Post
    It probably wouldn't compile. But then similar problems would also cause variable names of strictfp and assert which
    were not keywords until Java 1.2 and Java 1.3 respectively.
    Assertions saw the light (officially) in version 1.4 (Using Assertions in Java Technology)

    kind regards,

    Jos (<--- nitpicker)
    Build a wall around Donald Trump; I'll pay for it.

  6. #6
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Java syntax

    But the word assert was reserved as of 1.3 so the OP could not have written a program using that
    word as a variable starting in 1.3. It should have been flagged by the compiler.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Java syntax

    Jeeez, I'm becoming old ... I forgot all about that (I never use and never used assertions). Thanks for correcting me.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Java syntax

    Quote Originally Posted by JosAH View Post
    Jeeez, I'm becoming old ...
    Becoming?

    db <- hobbles off as fast as his walker permits
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Java syntax

    This place is turning into a home for old Java devs...

    I remember when all this was fields.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Don't understand this Java syntax.
    By Kareng in forum New To Java
    Replies: 9
    Last Post: 09-25-2012, 04:05 PM
  2. Replies: 0
    Last Post: 05-01-2012, 11:10 PM
  3. Strange java syntax
    By weps in forum New To Java
    Replies: 3
    Last Post: 09-07-2011, 05:27 PM
  4. What type of java syntax is this?
    By castiel in forum New To Java
    Replies: 2
    Last Post: 02-07-2011, 06:59 PM
  5. Java Syntax If statement
    By Blasz in forum New To Java
    Replies: 9
    Last Post: 09-01-2010, 12:21 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •