Class LexerProvider<T extends org.antlr.runtime.Lexer>

  • All Implemented Interfaces:
    com.google.inject.Provider<T>, javax.inject.Provider<T>

    public class LexerProvider<T extends org.antlr.runtime.Lexer>
    extends java.lang.Object
    implements com.google.inject.Provider<T>
    A Guice provider implementation, that does not use the default constructor of the lexer class, but call the other available constructor that takes a CharStream as argument. This provider is a workaround for a bug in ANTLR that leads to partially initialized Lexer instances. They may cause NullPointerExceptions in some rare situations, when backtracking is involved.
    • Constructor Summary

      Constructors 
      Constructor Description
      LexerProvider​(java.lang.Class<T> clazz)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends org.antlr.runtime.Lexer>
      LexerProvider<T>
      create​(java.lang.Class<T> clazz)  
      T get()
      Creates a lexer instance via reflection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LexerProvider

        public LexerProvider​(java.lang.Class<T> clazz)
    • Method Detail

      • create

        public static <T extends org.antlr.runtime.Lexer> LexerProvider<T> create​(java.lang.Class<T> clazz)
      • get

        public T get()
        Creates a lexer instance via reflection. The object is not created with the default constructor because it will not initialize the backtracking state of the lexer. Instead, we pass null as CharStream argument.
        Specified by:
        get in interface com.google.inject.Provider<T extends org.antlr.runtime.Lexer>
        Specified by:
        get in interface javax.inject.Provider<T extends org.antlr.runtime.Lexer>