Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Andreas Leitgeb Newsgroups: comp.lang.java.programmer Subject: Re: DefaultTableModel.getDataVector() and Java 11 Date: Wed, 3 Apr 2019 16:41:17 -0000 (UTC) Organization: A noiseless patient Spider Lines: 33 Message-ID: References: Reply-To: avl@logic.at Injection-Date: Wed, 3 Apr 2019 16:41:17 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="05711f75fa384a44df8cf21cb0776d58"; logging-data="31693"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/WyRpf2ISLXhdOifGTPnFA" User-Agent: slrn/1.0.3 (Linux) Cancel-Lock: sha1:Sg8sXoCHPcSB9zSge9VIKwZtcAg= Xref: csiph.com comp.lang.java.programmer:38849 Patrick Roemer wrote: > Responding to Andreas Leitgeb: >> In Java up to 8 DefaultTableModel had a method getDataVector() >> that returned a raw Vector. >> >> My application's custom TableModel overrode the method to return >> a Vector, where MyRowType provided direct type-safe >> accessors for each column. >> >> In Java 11 it seems to have changed to returning a Vector of >> raw Vectors. >> >> At first glance this seems just goofy to me, because that doesn't >> really make it type-safe (it still involves a raw type), and it even >> prevents me from making it type-safe myself. >> >> I hope, someone here can provide me with a second glance that >> clarifies the rationale behind the change. > > API doc for this method in Java 8: "Returns the Vector of Vectors that > contains the table's data values." There's quite a few occurrences of > casts such as "(Vector)dataVector.elementAt(row)" in the > DefaultTableModel code, too. > > So it seems that using another element type than Vector with > DefaultTableModel has never really been a safe option, and the change > only codifies to types what the contract has always been saying. Custom > [Abstract]TableModel to the rescue... Thanks a lot - it now makes sense with that background. Will see what I really need beyond AbstractTableModel.