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

  • Home
  • SEARCH
  • 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 694637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:52:37+00:00 2026-05-14T02:52:37+00:00

Consider a private method which is called from JNI and not used otherwise, generating

  • 0

Consider a private method which is called from JNI and not used otherwise, generating a compiler warning about an unused method:

private void someMethodCalledOnlyFromJNI() { // WARNING: method is never used
    // ....
}

This is some legacy code in Java 1.4 – so no dice on @SuppressWarnings.

What hack would you use to suppress this compiler warning?


Edit: Obviously this is just a warning and it can easily be ignored. But, personally, I hate warnings in my code just as much as I don’t want to see errors in it. AFAIC – my code should have 0 warnings, it might be an exaggeration, but I am very pedantic about this.

Just as an example, someone might see this function, not know it is used from JNI, and simply delete it.

  • 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-14T02:52:38+00:00Added an answer on May 14, 2026 at 2:52 am
    1. Ignore it. It is a warning, after all – best option
    2. use protected (and add a comment for the reason why) – bearable
    3. Make a dummy method just above it and make the two call each other (again with comments) – ugly
    4. configure the IDE not to show this warning at all (in eclipse it is Windows > Preferences > Java > Compiler > Errors/Warnings) – not preferable

    As per your update: having 0 warnings is not a goal you should set. The number of warnings depends on the settings, so if you don’t all have unified IDEs, this number will vary. And then you can add checkstyle / PMD to report warnings as well – then you’ll have even more. The reasonable behaviour is to have a warnings treshold.

    If you don’t want anyone to delete this method, just add a comment:

    // This method is used is used by JNI. (Don't delete)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.