GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — public HashSet(Collection<>) behaves differently on JDK 8 and JDK 11 · Issue #2926 · typetools/checker-framework

public HashSet(Collection<>) behaves differently on JDK 8 and JDK 11 #2926

New issue
Copy link
New issue
Copy link
Closed
Closed
public HashSet(Collection<>) behaves differently on JDK 8 and JDK 11#2926
Copy link
Assignees
smillst
Milestone
High

Description

@smillst
smillst
opened on Nov 22, 2019
Issue body actions
        for (VariableElement field : new HashSet<>(fieldElts)) {
            field.toString(); // error with JDK 8, not JDK 11
        }

The above code issues an error with JDK 8, but not JDK 11. See the full test case below. I suspect it is because JDK 8 annotations are from classf iles, but JDK 11 annotations are from stub files.

import java.util.AbstractSet;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.VariableElement;

public class HashSetTest {

    void method(Set<VariableElement> fieldElts) {
        for (VariableElement field : new MySet<>(fieldElts)) {
            field.toString(); // ok with both JDK 8 and JDK 11
        }

        for (VariableElement field : new HashSet<>(fieldElts)) {
            field.toString(); // error with JDK 8, not JDK 11
        }
    }

    static class MySet<E> extends AbstractSet<E> {
        public MySet(Collection<? extends E> other) { }

        @Override
        public Iterator<E> iterator() {
            throw new RuntimeException();
        }

        @Override
        public int size() {
            return 0;
        }
    }
}

Activity

  1. smillst
    added this to the High milestone on Nov 25, 2019
  2. smillst
    self-assigned this
    on Nov 25, 2019
  3. smillst commented on May 21, 2024

    @smillst
    smillst
    on May 21, 2024
    MemberAuthor
    More actions

    This no longer reproduces.

  4. smillst
    closed this as completedon May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @smillst
    smillst

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    • HighNo due date

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.