7

During build of our project we get a rather unexplained warning:

    [javac] (...)\SessionKeeper.java:39: warning: NEW is internal proprietary API and may be removed in a future release
    [javac]     private static final int timeOfInactivity = 1000 * 60 * 9; // allowed time of inactivity
    [javac]                                ^

Additional info:

  • Apache Ant(TM) version 1.8.4 compiled on May 22 2012
  • Java(TM) SE Runtime Environment (build 1.7.0_25-b16)

Can anyone explain why the compiler makes this warning, and what I should change to avoid it?

[Edit] Added nearby code

private static final String CLASS_NAME = SessionKeeper.class.getName();

    private static final int logoutDelaySeconds = 1000 * 60; // logout after 1 min. from the point when dialog was shown to the user
    private static final int timeOfInactivity = 1000 * 60 * 9; // allowed time of inactivity

    private boolean isSchedulerStarted = false; // indicates if SessionKeeper was started or not

    private static SessionKeeper instance;

[edit] Since quite a few requested the source I attached it here (expires in 24h): http://pastebin.com/t2M5mgd0

[edit] What have been tried so far:

  • Inlining the constant -> error goes to the line above
  • Reactoring SessionKeeper to not extend any class -> same error
  • Removing CLASS_NAME and logging statements
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Albatros
  • 129
  • 1
  • 7
  • 10
    Please show us the relevant code from SessionKeeper.java – supersam654 Aug 08 '13 at 12:17
  • 8
    Have you mistakenly written the new operator in uppercase, and it somehow auto imported a class like com.sun.org.apache.bcel.internal.generic.NEW ? – Luciano Aug 08 '13 at 12:24
  • @supersam654 I can attach a few lines before and after to the question. – Albatros Aug 08 '13 at 12:27
  • @Luciano. there is a 15 instance of "new" in the file, but grepping it for "NEW" return no results. – Albatros Aug 08 '13 at 12:31
  • And what imports do you have in that file? – Jaa-c Aug 08 '13 at 12:32
  • 1
    @Albatros What is on line 39 of SessionKeeper.java? – assylias Aug 08 '13 at 12:32
  • @Albatros Which line is 39? Is the file getting changed or modified during compilation? – nanofarad Aug 08 '13 at 12:32
  • @assylias it is the line in the original question with the static int, and afaik there shouldn't be anything modifying it. – Albatros Aug 08 '13 at 12:36
  • Did you even post the correct source file? In the compiler message, it looks like the code line says `timeOfInactivity = 1000 * 60 * 9;`, but in the posted code snippet, it says `timeOfInactivity = 540000;`. Maybe you are compiling a different version than you think? Even so, the compilation error message still sounds strange though... – Alderath Aug 08 '13 at 12:37
  • @Alderath sorry...that was an attempt to fix it :$ – Albatros Aug 08 '13 at 12:40
  • That makes little sense... If it were in an IDE I would say: try to clean and build. – assylias Aug 08 '13 at 12:45
  • 4
    Please post more code... – vikingsteve Aug 08 '13 at 12:56
  • Check your imports for entries outside of the java namespace... But obviously you're not posting enough code. – Samuel Aug 08 '13 at 13:25
  • sorry for the long answer time, I had to clear it upwards since it is proprietary ;) The source for the file can be seen here (for the next day): http://pastebin.com/t2M5mgd0 – Albatros Aug 08 '13 at 13:43
  • @Albatros: Don't use pastebin since it is blocked by most of the corporate websites. Paste your code in your original post. – Sanjay T. Sharma Aug 08 '13 at 14:12
  • @Albatros You can look at [import sun.misc.BASE64Encoder got error in Eclipse](http://stackoverflow.com/questions/5549464/import-sun-misc-base64encoder-got-error-in-eclipse) post. May be your issue is identical – Alex K Aug 08 '13 at 14:28
  • possible duplicate of [Suppress javac warning](http://stackoverflow.com/questions/13855700/suppress-javac-warning) – Alex K Aug 08 '13 at 14:36
  • I think the file is too large to include directly, I'll just try some more drastic experiments on the file and see if that removes the error, and if not I might have a shorter file to paste here ;) – Albatros Aug 09 '13 at 07:42

1 Answers1

3

Solution found I removed all all imports in the file, and replaced everything with stubs.

That made java report the error in another file.

The other file had a bad and unused import (import com.sun.org.apache.bcel.internal.generic.NEW).

So I'll recommend anyone getting this error to search your entire workspace for NEW

Albatros
  • 129
  • 1
  • 7
  • 3
    The recommendation is to check for unused imports after each change of the source-code. Those NEW is probably the result of a misused quickfix of an IDE. – mschenk74 Aug 09 '13 at 09:19
  • yea, personally I use the eclipse save actions to clean up unused imports and reformat edited lines, but not everyone on the team does that ;) – Albatros Aug 09 '13 at 10:09
  • More generally, the error about "internal proprietary API" refers to the use of classes in the `com.sun.*` packages. You should never use any `com.sun.*` classes in your programs. – Kevin Krumwiede Jun 15 '15 at 03:21