Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 437511

Summary: Class's raw version does not propagate transitively to its superclasses
Product: [Eclipse Project] JDT Reporter: Matus Abaffy <matus.bafco>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact: Sasikanth Bharadwaj <sasikanth.bharadwaj>
Severity: normal    
Priority: P3 CC: manoj.palat, shankhba, stephan.herrmann
Version: 4.2.2   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Whiteboard: stalebug

Description Matus Abaffy CLA 2014-06-16 04:29:01 EDT
Assume the following hierarchy:

public interface MySuperInterface<T> {}

public interface MyInterface extends MySuperInterface<Number> {}

public class MyBean<T> implements MyInterface {}

public class MyRawBean extends MyBean implements MySuperInterface<Number> {}

This results in "Compilation failure
[ERROR] /home/bafco/projects/core/tests-arquillian/src/test/java/org/jboss/weld/tests/specialization/weld1651/MyRawBean.java:[23,7] error: MySuperInterface cannot be inherited with different arguments: <java.lang.Number> and <>"

However, NO warning in Eclipse - the failure is not detected by the IDE.

The problem is that as 'MyRawBean extends MyBean', "raw version" of MyBean propagates transitively (you can imagine it as a flag) to its superclasses, i.e. to MyInterface and also to MySuperInterface; even though it seems non-intuitive as MyInterface is not a generic interface and does not depend on the type variable T from MyBean. Howevere, this is how Java works.
Comment 1 Stephan Herrmann CLA 2014-06-16 15:22:51 EDT
I assume you are referring to this sentence:

"The superclasses (respectively, superinterfaces) of a raw type are the erasures of the superclasses (superinterfaces) of any of the parameterizations of the generic type."

right?

I was going to argue that it doesn't explicitly state whether this refers to directs supers only, or to all transitive supers, but then "the superclasses" in plural clearly indicates transitiveness.


Point taken.


OTOH:

"The use of raw types is allowed only as a concession to compatibility of legacy code. The use of raw types in code written after the introduction of generics into the Java programming language is strongly discouraged. It is possible that future versions of the Java programming language will disallow the use of raw types."

(we do report the due warning on the use of the raw type!)


Given the above I tend to address raw-type related bugs at a lower priority than others, unless perhaps, if you can show that we successfully compile a program that will cause a type error at runtime...
Comment 2 Eclipse Genie CLA 2020-03-29 11:35:33 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.