question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Interaction with Java's raw generic types is not possible

See original GitHub issue

See for instance Javafx’s method https://docs.oracle.com/javase/8/javafx/api/javafx/scene/control/TreeTableView.html#setColumnResizePolicy-javafx.util.Callback- it takes a Callback<TreeTableView.ResizeFeatures,Boolean> but do notice that ResizeFeatures defines one generic parameter, the method defines a callback that takes it raw though. In scalac, you would pass a javafx.util.Callback[javafx.scene.control.TreeTableView.ResizeFeatures[_], Boolean] and it would typecheck, but with dottyc it doesn’t work

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
smartercommented, Jan 5, 2018

Yes, for now we’ve decided to not try to make the dotty Java source parser work with raw types since it’s usually pretty easy to fix Java code in your own project to not require raw types. We may change this in the future but it’s low priority.

0reactions
rcanocommented, Jan 5, 2018

Also worth noting, that if you happen to try and compile the java source in mixed mode with dotty (by placing the file under src/main/java), then when dotty parses the java file for the signatures you get this

[error] -- Error: TryMe.java:3:72 ------
[error] 3 |  public static <R> void ifYouCan(java.util.function.Function<java.util.List, R> f) {
[error]   |                                                              ^^^^^^^^^^^^^^
[error]   |          Type argument java.util.List has not the same kind as its bound 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Java Raw Type and generics interaction - Stack Overflow
All of them are unsafe because Java generics, by virtue of type erasure, are just syntactic sugar. For example, this is entirely valid...
Read more >
Effective Java Generics | Item 26: Don't use raw types - InformIT
Item 26: Don't use raw types ... First, a few terms. A class or interface whose declaration has one or more type parameters...
Read more >
Raw Types - Learning the Java Language
However, a non-generic class or interface type is not a raw type. Raw types show up in legacy code because lots of API...
Read more >
4.1. Generic Types - Java in a Nutshell, 5th Edition [Book]
A generic type used without type parameters is known as a raw type . Existing pre-5.0 code continues to work: you simply write...
Read more >
Convert Raw Types to Generics refactoring - IntelliJ IDEA
IntelliJ IDEA tries to generate code, which is as correct as possible from the Java point of view. In other words, each context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found