Integer ints[]=new Integer[1]; Object objs[]=ints; objs[0]="Hallo Arno";
A really nice one, which I really like. It compiles without any warnings, but it is completely broken. For inexperienced ( Java) developers maybe a little hard to spot why. It would be easy and nice to create a nice Java Puzzle out of this theme. The java-generics documentation states,
“Because the program compiles without warnings, we can state with certainty that it will not throw a ClassCastException at run time.”
This is right, because the code throws a java.lang.ArrayStoreException. So the statement is formally correct, but in practice, there is no difference. In any case the method terminates with a runtime exception. On the other hand I understand the initial design forces for the java team. They wanted a simple typed language and they wanted to be able to write some array handling library code.
I haven´t made up my mind jet, which solution to this dilemma I would prefer. These are:
- The highly sophisticated inheritance model of the latest languages like scala
- the dynamic duc typing of languages with a pure dynamic type system like J/Python, J/Ruby,
... link (1 Kommentar) ... comment
(Please note: I have received the academic grades for calling me a software engineer from one of the best Universities in Germany.)
So I was more than happy to see and sign the manifesto of softwarecraftsmanship
... link (0 Kommentare) ... comment
If you are interested you can now download it here and the source here. This version is released under Apache License, Version 2.0 You can use it with an ant target like:
<target name="compile_proto" >
<taskdef name="pb" classname= "org.schmidmeier.protocolbuffer.ant.PbTask"
classpath="lib/PbTask.jar"/>
<pb ProtoFile="Sample.proto" ipath="/prj/pbuffer/include"
java="${java_output}"
python="${python_output}"
cpp="${cpp_output}">
<protopathentry ipath="proto_includes "/>
<protopathentry ipath="protolibs "/>
<pb/>
</target>
At first you have to define the task. You do it with the taskdef statement. From here on you can use the pb task. ipath defines the includefiles. java, cpp, and python define for which languages code should be generated. (and where it should be dropped)
Here are the possible attributes for the task.
Attributes
| Attribute | Description | Required |
| java | if set, output will be generated for java. The value must be the java output directory | at least on of java, python, cpp |
| cpp | if set, output will be generated for C++. The value must be the C++ output directory | at least on of java, python, cpp |
| python | if set, output will be generated for python. The value must be the python output directory | at least on of java, python, cpp |
| ipath | The directory which may contain include files | No, default unset |
| failonerror | if set, the compilation aborts in case of errors | No, Default, true |
| protopathentry | The possibility to add multiple include file to the command line | No, Required unset |
Current open issues:
- The ant-job was currently only tested on windows. If you find some issues on other platform, please notify me
- The pb-compiler which is invoked from the ant-job has some problems with Windows drive names, when it should generate C++ or python code.
... link (0 Kommentare) ... comment
software craftsman and pattern writer from Hersbruck (Germany)