#fixed code
                                @SuppressWarnings("unchecked")
    static <S extends Geometry> S toGeometry(Geometry_ g) {
        final Geometry result;
        byte type = g.type();
        if (type == GeometryType_.Box) {
            result = createBox(g.box());
        } else if (type == GeometryType_.Point) {
            Point_ p = g.point();
            result = Geometries.point(p.x(), p.y());
        } else if (type == GeometryType_.Circle) {
            Circle_ c = g.circle();
            result = Geometries.circle(c.x(), c.y(), c.radius());
        } else if (type == GeometryType_.Line) {
            result = createLine(g.line());
        } else
            throw new RuntimeException("unexpected");
        return (S) result;
    }
#vulnerable code 
                                @SuppressWarnings("unchecked")
    static <S extends Geometry> S toGeometry(Geometry_ g) {
        final Geometry result;
        byte type = g.type();
        if (type == GeometryType_.Box) {
            result = createBox(g.box());
        } else if (type == GeometryType_.Point) {
            result = Geometries.point(g.point().x(), g.point().y());
        } else if (type == GeometryType_.Circle) {
            Circle_ c = g.circle();
            result = Geometries.circle(c.x(), c.y(), c.radius());
        } else if (type == GeometryType_.Line) {
            result = createLine(g.line());
        } else
            throw new RuntimeException("unexpected");
        return (S) result;
    } 
                            #location 8 
                            #vulnerability type NULL_DEREFERENCE