Uploaded image for project: 'SLF4J'
  1. SLF4J
  2. SLF4J-201

Illegal Access to SINGLETON field

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.6.x
    • log4j-over-slf4j
    • None
    • Operating System: Windows XP
      Platform: PC

    Description

      While running a JUnit test using SLF4J 1.6.1 under Java 1.4.2, I was unable to proceed because the lines 49-53 of the StaticLoggerBinder in the log4j-over-slf4j JAR file (well, the source for that class) read:

      /**

      • The unique instance of this class.
      • */
        private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();

      The private variable was somehow involved in what the LoggerFactory was doing. Following a suggestion on the web, I replaced this line with:

      /**

      • The unique instance of this class.
      • */
        public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();

      and everything works great.

      It may be that there's a reason to keep the SINGLETON private, but one cannot use the logger in that case, as the JVM at runtime throws an IllegalAccessException. However, it seems (though I can find no specific reason why this might be the case) that the LoggerFactory must itself be recompiled in conjunction with this change in order to work.

      It may be that SLF4J 1.6.1 shouldn't run under 1.4.2 (though I see nothing that forbids it), but if it should, this one-line change would make, I would think, a significant difference.

      Attachments

        Activity

          People

            slf4j-dev SLF4J developers list
            dsills@datasourceinc.com David Sills
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: