Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ice-dev] [ice-build] [eclipse/ice] 52b561: Adding hooks to register glazed list listeners to ...

On 2/12/2015 4:18 PM, Jay Jay Billings wrote:
Keep in mind that the code example you show is a strawman argument: that code will fail fast with an exception at runtime, so it is still checked and nothing bad will actually happen. It's not like in C where it will either cause SIGSEGV or run with automatically casted values that compute invalid results.

True, it does throw a useful runtime exception, but my point is that using raw types can lead to this kind of bug, when adding in the types would cause it to not compile in the first place.
I'll have to look at the ListEventListener piece. Casting to <Object> is worse than not specifying the type if the generic can be a primitive (<int>, <double>) because primitives are not Objects. I'm not sure that is the case here, so it is probably fine. This is the same reason that I extracted the Identifiable interface from ICEObject years ago because I needed an Identifiable that was not an ICEObject. The result was about three hours of unplanned work to fix casts to ICEObject across the code.
But you can't use a primitive as a type with generics...

I would think you could register a ListEventListener<?>, but it's registered to both an EventList<T> and an EventList<String>. For it to not be a raw ListEventListener, it must be a ListEventListener<? super {T, String}>, which is not permitted as far as I can tell.

Jordan
On Thu, Feb 12, 2015 at 11:04 AM, Jordan Deyton <deytonjh@xxxxxxxx> wrote:
Jay,

There were a few places where raw types were an issue.

In ListComponent, the value type of the listenerMap was just ListEventListener, a raw type. I changed this to ListEventListener<Object>. (I did this because these listeners are added to both an EventList<T> (the source list) and an EventList<String> (the ID list), and the only guaranteed super class of both T and String is Object).

There was also an unchecked type cast exception in the ListComponent.equals(Object) method. Since Java removes the generic types at run time, you can't cast a ListComponent<?> to a ListComponent<T> without the compiler complaining.

Most of the raw types were in the tests. I suppose raw types are not a big deal in the test code, but from what I've read raw types are an artifact from pre-generics Java and are strongly discouraged in new code. I went ahead and changed those as well. Also, using a raw type lets you do some strange things like...

ListComponent component = new ListComponent<Integer>();
component.add("string");

Jordan
Jordan Deyton
Oak Ridge National Laboratory
Telephone: (865) 574-1091
Email: deytonjh@xxxxxxxx
On 2/12/2015 10:40 AM, Jay Jay Billings wrote:

Jordan,

Do you mean that you made it ListComponent<T> instead of ListComponent<>?

Jay

On Feb 12, 2015 10:26 AM, "GitHub" <noreply@xxxxxxxxxx> wrote:
  Branch: refs/heads/jordan/VisItVisService
  Home:   https://github.com/eclipse/ice
  Commit: 52b561e61e70261a396b7d308d021edaa8896ef0
      https://github.com/eclipse/ice/commit/52b561e61e70261a396b7d308d021edaa8896ef0
  Author: Jordan Deyton <deytonjh@xxxxxxxx>
  Date:   2015-02-11 (Wed, 11 Feb 2015)

  Changed paths:
    M src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/ListComponent.java
    M src/org.eclipse.ice.datastructures/src/org/eclipse/ice/datastructures/ICEObject/WrappedGlazedEventListener.java
    M tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/ListComponentTester.java
    A tests/org.eclipse.ice.datastructures.test/src/org/eclipse/ice/datastructures/test/TestListComponentListener.java

  Log Message:
  -----------
  Adding hooks to register glazed list listeners to ListComponents. The
IUpdateableListeners work as well, but if client code wants more detail
about what changed, a ListEventListener can be registered. Note that
these ListEventListeners are not notified when the ListComponent's ID
info is updated.

Added test code to handle this.

Added types to a lot of places where raw types were used previously.
Most of those are internal to ListComponent or in the tests.

Signed-off-by: Jordan Deyton <deytonjh@xxxxxxxx>


  Commit: 1aa198eaa36c9113fd22a19394b968e6f726b208
      https://github.com/eclipse/ice/commit/1aa198eaa36c9113fd22a19394b968e6f726b208
  Author: Jordan Deyton <deytonjh@xxxxxxxx>
  Date:   2015-02-11 (Wed, 11 Feb 2015)

  Changed paths:
    M src/org.eclipse.ice.client.widgets.moose/src/org/eclipse/ice/client/widgets/moose/MOOSEFormEditor.java
    M src/org.eclipse.ice.item/src/org/eclipse/ice/item/nuclear/MOOSEModel.java
    M src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItPlot.java
    M src/org.eclipse.ice.viz.service.visit/src/org/eclipse/ice/viz/service/visit/VisItVizService.java

  Log Message:
  -----------
  Added code to register a listener with the MOOSE Model's
ResourceComponent (which contains the mesh). If the ResourceComponent is
updated with a new mesh file, the plot is updated to use the mesh file.

Signed-off-by: Jordan Deyton <deytonjh@xxxxxxxx>


Compare: https://github.com/eclipse/ice/compare/e37972908580...1aa198eaa36c
_______________________________________________
ice-build mailing list
ice-build@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-build



_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev


_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev



--
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings


_______________________________________________
ice-dev mailing list
ice-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ice-dev


Back to the top