onlyUseNewAPI is a static, so non-instance variable. It is used only to initialize TokenStreams and can be changed after. Because of that the tests in incrementToken()/next()/next(Token) should not use it. It is enough to test for tokenWrapper==null to detect a onlyNewAPI TokenStream instance.