javastruct()关于java结构体javastruct A library to treat java objects asC structs. Project Home Downloads Wiki Issues Source Search for HowToUseJavaStruct This page explains how to use JavaStruct library. Featured , Phase-Implementation Updated Feb 4, 2010 by mda...@ Introduction Struct classes can be used to greatly work protocol codes of Java applications when working with embedded devices and other applications which uses C style structs. Instead of manually encoding and decoding messages, JavaStruct allows programmers to treat java classes asc structs. JavaStruct uses Java 5 annotations to mark Classes and fields as structs. JavaStruct is not the first attempt to provide struct like functionality, Jean-Marie Dautelle's Javolution library also has an excellent struct implementation. But instead of using special classes in Javolution, POJO approach is preferred JavaStruct. General usage JavaStruct fa ? ade class is used to pack and unpack struct classes. Below isa simple unit test method for checking a struct class. Struct fields hasan order value, because Java JVM specification does not tell anything about order of the class members. They are ordered as their appearance in Sun's implementation but it differs on other JVM's. So every Struct field has to supply an order value. ***@StructClass public class Foo { ***@StructField ( order =0) public byte b; ***@StructField ( order =1) public int i;} try { // Pack th
javastruct关于java结构体 来自淘豆网m.daumloan.com转载请标明出处.