Compiler-Fehler Null type safety (type annotations)

tanzverfuehrung

Bekanntes Mitglied
Hallo,
und zwar wird mir hier:
Code:
Arrays.asList(coordinates)
der Fehler angezeigt :

Null type safety (type annotations): The expression of type 'String[]' needs unchecked conversion to conform to '@NonNull String []'

und ich verstehe nicht wieso? weil ich prüfe ja ob coordinates nicht null ist. Ich habe es auch mit Objects.requireNonNull probiert aber funktioniert auch nicht.

Kann mir bitte jemand helfen.bitte
Hier die Methode



Java:
    private List<Point> getPoints(@Nonnull String pointString) {
    
        String[] coordinates = pointString.split(",");
        if (coordinates != null) {
            List<String> coordinatesList = new ArrayList<String>(Arrays.asList(coordinates));
           //TODO
            }
        }
        return null;
    }
 
Wenn ich das tue wird mir trotzdem noch der Fehler angezeigt🙁

und zwar trotzdem noch hier:
Code:
Arrays.asList(coordinates)

und hier sagt er:
Redundant null check: The variable asList cannot be null at this location
Code:
if (asList != null)

Code:
    if (coordinates != null) {
            List<String> asList = requireNonNull(Arrays.asList(coordinates));
            if (asList != null) {
                List<String> coordinatesList = new ArrayList<String>(asList);

KAnn es sein dass das ein Eclipse Bug ist, hatte shcon ob und zu komisch compilerfehler in eclipse.😱
 
ICh habe jetzt auch leerheit geprüft und ob null enthalten ist.
Compilerfehler wird mir trotzdem noch anegzeigt😕
Code:
if (coordinates != null)
            if (isValidCoordinates(coordinates)) {
                List<String> coordinatesList = new ArrayList<String>(Arrays.asList(coordinates));

Code:
    private boolean isValidCoordinates(@Nonnull String[] coordinates) {
        if (coordinates.length == 0)
            return false;
        for (String coordinate : coordinates) {
            if (coordinate == null)
                return false;
        }
        return true;
    }
 

Zurück
Oben