Skip to content

Bug: unable to create instance of IteratorTester #5254

Open
@jbduncan

Description

@jbduncan

Bug description

When I attempt to create an instance of com.google.common.collect.testing.IteratorTester from guava-testlib version 29-jre, I end up with the following compilation error message:

/path/to/IteratorTesterExampleTests.java:3: error: package com.google.common.collect.testing.AbstractIteratorTester does not exist
import com.google.common.collect.testing.AbstractIteratorTester.KnownOrder;
                                                               ^
/path/to/IteratorTesterExampleTests.java:26: error: cannot find symbol
            3, IteratorFeature.UNMODIFIABLE, Arrays.asList("a", "b", "c"), KnownOrder.KNOWN_ORDER) {
                                                                           ^
  symbol:   variable KnownOrder
  location: class IteratorTesterExampleTests

My workaround is to copy IteratorTester, AbstractIteratorTester and Helpers into my project.

How to reproduce

  1. git clone https://github.com/jbduncan/iteratortester-compilation-bug.git
  2. ./gradlew build

Possible fixes

  • Make AbstractIteratorTester public and its constructor non-public, documenting that it's not intended to be extended
  • Move KnownOrder into a separate file (breaking change)
  • Make IteratorTester non-public, at the risk of making guava-testlib users except Guava itself not being able to use it anymore (breaking change)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions