Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7402221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:41:19+00:00 2026-05-29T04:41:19+00:00

I have a question about the compliance mode. What happens with my class which

  • 0

I have a question about the compliance mode.
What happens with my class which extends a basic java class, for example Properties and is compiled with JDK5 and packaged into a jar. Now I use this jar in a project which gets build with JDK 6 but in compliance mode 5.
Can someone now use the new method stringPropertyNames() – which is new in JDK6 – on my class in the JDK6 project?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:41:22+00:00Added an answer on May 29, 2026 at 4:41 am

    It works, as long as you run your project on JRE 6 JVM. And you don’t need your project to be compiled with compliance to Java 1.5. That is, when compiling your project, you don’t need to use either -source 1.5 nor -target 1.5 options.

    On the other hand, when running you project on JRE 5 JVM, it will fail with

    java.lang.NoSuchMethodError:B.stringPropertyNames()Ljava/util/Set;
    

    regardless of the options used on compilation of your project.

    What happens in runtime, is that the JVM searches corresponding execution bytecode for Properties.stringPropertyNames(). When running on JRE 6, such code exists (no matter what options were used in compilation). When running on JRE 5, it doesn’t exist.

    I checked the scenario you suggested:

    B.java:

    public class B extends Properties {
    
        public B() {
            setProperty("a", "aaa");
            setProperty("b", "bbb");
        }
    }
    

    C.java:

    public class C {
    
        public static void main(String[] args) {
            B b = new B();
            System.out.println(b.stringPropertyNames());
        }
    }
    

    The following output resulted the same, compiling with JDK 6, either using -source 1.5 and/or -target 1.5 or not.

    Output on JVM 6:

    [b, a]
    

    Output on JVM 5:

    Exception in thread "main" java.lang.NoSuchMethodError: B.stringPropertyNames()Ljava/util/Set;
            at C.main(C.java:17)
    

    So, why use -source and -target on compilation at all?

    This site explains succinctly that you can use -source options to make the compiler fail if certain features of releases later than the specified are used. E.g., -source 1.4 ensures you don’t use generics (which would otherwise fail only at runtime).

    The -target options is, according to the official docs, for enabling executing the compiled code on other (earlier) JVMs. E.g, if I use JDK 6 to compile my code but I need it to run on JVM 5, I’d use -target 5 on compilation. If I don’t, I’ll get java.lang.UnsupportedClassVersionError: Bad version number in .class file.

    I hope you’re not overwhelmed by the answer ;)…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have question about parsing a specific json string. I didn't find anything which
i have question about how to count matched elements in ArrayList in java.. Ex:
I have question about 301 Redirect please: example: http://stackapp.com/post/35642 to: http://google.com/posts/index.php?q=http://stackapp.com/post/35642 Note: I want
I'm learning asp.net. I have question about example buttons I can use two types
I have question about managing transaction in asp.net application. For example i have application
I have a question about local classes in Java (classes that declares in the
I have a question about the images displaying using a function getImage_w($image,$dst_w), which takes
I have a question about some C++ standard compliance or lack of it. In
I have question about try, catch and finally in Java. Consider the following scenario:
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.