From: Charlie G. <cha...@gm...> - 2007-01-23 05:40:13
|
On 1/19/07, Alexander Stoddard <ast...@ma...> wrote: > Generally should questions or comments about jython documentation be > sent to the users list, dev list or submitted to sourceforge as bugs > or feature requests? If it's something that's factually incorrect or missing in the documentation, submit a bug or even better a patch. If you're not sure if the docs are wrong or you are, I'd ask the users list first. > 1) Java Collections Integration. > I encountered jython when this was a hot topic on the lists and the > implementation was becoming complete. I think someone coming to > jython now might remain ignorant of it. > > Of course it is absent from the canonical "Jython essentials" and > "Jython for Java Developers" as it is part of Jython 2.2. When I > checked the web site I failed to find any mention of this feature. It > is really not written up on the current web site or am I missing it? I think it hasn't been written up because it wasn't completed. Hopefully someone will fact check me on this, but PyList now implements List but PySet doesn't implement Set. The integration is only partially complete. > 2) Jython (non)interaction with java generics > Jython completely ignores java generics. In my opinion this is > trivial but non-obvious. It is trivial once I remember that java > generics have no support in the JVM and are essentially compile time > magic (please correct me if i am wrong on this). It is non-obvious > because I don't normally think about such things when just using > code. I wouldn't have seen this behavior without deliberately setting > out to test it. > > Generics provide no type safety to jython scripting on java > collections. I suspect this could be the source of nasty bugs for the > unwary. Is this issue worthy of documenting? It does sound like a confusing bug, but I'm not sure how common or confusing it would be in the wild. Since Jython doesn't know about generics, it can't create objects with generics either. The only way one makes it into Jython is for Java code to create it and give it to Jython. If the Jython code is making meaningful additions to the object it gets, there has to be some shared expectation of the type being added. Otherwise the Java code on the outside couldn't do anything with the added objects since it's statically typed and all. Java 5 codified this with generics, but I never actually had a problem with an Object of an unexpected class showing up in my Lists in Java 1.4; generics really just seem like a documentation enhancer and typing reducer. If I did get a ClassCastException(actually, what happens when an unexpected class gets into a generic list?), I think I'd quickly assume that my dynamically typed code is knocking down my statically typed house of cards. Charlie |