Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
public class BeanWithInstanceWithWildcardEvent {

@Inject
Instance<Event<? super String>> veryWildInstance;
Instance<Event<? extends String>> veryWildInstance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.cdi.Sections;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.cdi.tck.tests.event.broken.wildcard.EventWithWildcardTest;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
Expand All @@ -33,7 +32,7 @@ public class InstanceWithEventWithWildcardTest extends AbstractTest {
@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder().withTestClass(EventWithWildcardTest.class)
return new WebArchiveBuilder().withTestClass(InstanceWithEventWithWildcardTest.class)
.withClasses(BeanWithInstanceWithWildcardEvent.class).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.cdi.Sections;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.cdi.tck.tests.event.broken.wildcard.EventWithWildcardTest;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
Expand All @@ -33,7 +32,7 @@ public class InstanceWithWildcardTest extends AbstractTest {
@ShouldThrowException(DefinitionException.class)
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder().withTestClass(EventWithWildcardTest.class)
return new WebArchiveBuilder().withTestClass(InstanceWithWildcardTest.class)
.withClasses(BeanWithWildcardInstance.class).build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.lookup.dynamic.wildcard;

import java.util.ArrayList;
import java.util.List;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Event;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;

@ApplicationScoped
public class BeanWithInstanceWithWildcardEvent {
static List<String> seen = new ArrayList<String>();

@Inject
Instance<Event<? super String>> instance1;

@Inject
Instance<? extends Event<? super String>> instance2;

public void fire() {
instance1.get().fire("hello");
instance2.get().fire("world");
}

public void observe(@Observes String str) {
seen.add(str);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.lookup.dynamic.wildcard;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Dependent;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

@ApplicationScoped
public class BeanWithWildcardInstance {
@Inject
Instance<? extends Number> instance;

public long count() {
return instance.stream().count();
}

@Produces
@Dependent
public static Integer produceInteger() {
return 42;
}

@Produces
@Dependent
public static Double produceDouble() {
return 42.0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.lookup.dynamic.wildcard;

import static org.testng.Assert.assertEquals;

import java.util.List;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.cdi.Sections;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

@SpecVersion(spec = "cdi", version = "5.0")
public class InstanceWithEventWithWildcardTest extends AbstractTest {
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder().withTestClass(InstanceWithEventWithWildcardTest.class)
.withClasses(BeanWithInstanceWithWildcardEvent.class).build();
}

@Test
@SpecAssertion(section = Sections.DYNAMIC_LOOKUP, id = "ca")
public void test() {
getContextualReference(BeanWithInstanceWithWildcardEvent.class).fire();
assertEquals(BeanWithInstanceWithWildcardEvent.seen, List.of("hello", "world"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* Apache Software License 2.0 which is available at:
* https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.jboss.cdi.tck.tests.lookup.dynamic.wildcard;

import static org.testng.Assert.assertEquals;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.cdi.tck.AbstractTest;
import org.jboss.cdi.tck.cdi.Sections;
import org.jboss.cdi.tck.shrinkwrap.WebArchiveBuilder;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecVersion;
import org.testng.annotations.Test;

@SpecVersion(spec = "cdi", version = "5.0")
public class InstanceWithWildcardTest extends AbstractTest {
@Deployment
public static WebArchive createTestArchive() {
return new WebArchiveBuilder().withTestClass(InstanceWithWildcardTest.class)
.withClasses(BeanWithWildcardInstance.class)
.build();
}

@Test
@SpecAssertion(section = Sections.DYNAMIC_LOOKUP, id = "ca")
public void test() {
assertEquals(getContextualReference(BeanWithWildcardInstance.class).count(), 2L);
}
}
13 changes: 7 additions & 6 deletions impl/src/main/resources/tck-audit-cdi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3615,9 +3615,9 @@
</assertion>

<assertion id="ca">
<text>The required type must not be a wildcard type.
If an injected |Instance| has a required type that is either a wildcard type or an |Event| whose specified type is a wildcard type, the container treats it as a definition error.
If a programmatically obtained |Instance| has a required type that is a wildcard type, non-portable behavior results.
<text>The required type may be a wildcard type only if it does not have a lower bound.
If an injected |Instance| has a required type that is either a wildcard type with lower bound or an |Event| whose specified type is a wildcard type without lower bound, the container treats it as a definition error.
If a programmatically obtained |Instance| has a required type that is a wildcard type with lower bound, non-portable behavior results.
</text>
</assertion>

Expand Down Expand Up @@ -5767,9 +5767,10 @@
</assertion>

<assertion id="eac">
<text>The specified type must not be a wildcard type.
If an injected |Event| has a specified type that is a wildcard type, the container treats it as a definition error.
If a programmatically obtained |Event| has a specified type that is a wildcard type, non-portable behavior results..</text>
<text>The specified type may be a wildcard type only if it has a lower bound.
If an injected |Event| has a specified type that is a wildcard type without lower bound, the container treats it as a definition error.
If a programmatically obtained |Event| has a specified type that is a wildcard type without lower bound, non-portable behavior results.
</text>
</assertion>

<assertion id="eba">
Expand Down