diff --git a/generator/mavgen_java.py b/generator/mavgen_java.py
index cbc8fe4010c07d99199a26725fd928a7dde58280..52b452347f4dd70319da85b050b298b54ab4c6b8 100644
--- a/generator/mavgen_java.py
+++ b/generator/mavgen_java.py
@@ -30,11 +30,11 @@ def generate_enums(basename, xml):
 
 package com.MAVLink.enums;
 
-/** 
+/**
  * ${description}
  */
 public class ${name} {
-${{entry:   public static final int ${name} = ${value}; /* ${description} |${{param:${description}| }} */
+${{entry:   public static final long ${name} = ${value}L; /* ${description} |${{param:${description}| }} */
 }}
 }
             ''', en)
@@ -47,7 +47,7 @@ def generate_CRC(directory, xml):
     xml.message_crcs_array = ''
     for msgid, crc in sorted(xml.message_crcs.items()):
         xml.message_crcs_array += 'MAVLINK_MESSAGE_CRCS.put(%u, %u);\n        ' % (msgid, crc)
-    
+
     f = open(os.path.join(directory, "CRC.java"), mode='w')
     t.write(f,'''
 /* AUTO-GENERATED FILE.  DO NOT MODIFY.
@@ -128,7 +128,7 @@ public class CRC {
 
 }
         ''',xml)
-    
+
     f.close()
 
 
@@ -151,7 +151,7 @@ package com.MAVLink.%s;
 import com.MAVLink.MAVLinkPacket;
 import com.MAVLink.Messages.MAVLinkMessage;
 import com.MAVLink.Messages.MAVLinkPayload;
-        
+
 /**
  * ${description}
  */
@@ -161,7 +161,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
     public static final int MAVLINK_MSG_LENGTH = ${wire_length};
     private static final long serialVersionUID = MAVLINK_MSG_ID_${name};
 
-    ${{ordered_fields:  
+    ${{ordered_fields:
     /**
      * ${description}
      */
@@ -178,7 +178,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
         packet.sysid = sysid;
         packet.compid = compid;
         packet.msgid = MAVLINK_MSG_ID_${name};
-        
+
         ${{base_fields:${packField}
         }}
         if (isMavlink2) {
@@ -196,7 +196,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
     @Override
     public void unpack(MAVLinkPayload payload) {
         payload.resetIndex();
-        
+
         ${{base_fields:${unpackField}
         }}
         if (isMavlink2) {
@@ -211,7 +211,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
     public msg_${name_lower}() {
         this.msgid = MAVLINK_MSG_ID_${name};
     }
-    
+
     /**
      * Constructor for a new message, initializes msgid and all payload variables
      */
@@ -221,7 +221,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
         ${{ordered_fields:this.${name} = ${name};
         }}
     }
-    
+
     /**
      * Constructor for a new message, initializes everything
      */
@@ -242,7 +242,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
      */
     public msg_${name_lower}(MAVLinkPacket mavLinkPacket) {
         this.msgid = MAVLINK_MSG_ID_${name};
-        
+
         this.sysid = mavLinkPacket.sysid;
         this.compid = mavLinkPacket.compid;
         this.isMavlink2 = mavLinkPacket.isMavlink2;
@@ -257,7 +257,7 @@ public class msg_${name_lower} extends MAVLinkMessage {
     public String toString() {
         return "MAVLINK_MSG_ID_${name} - sysid:"+sysid+" compid:"+compid+${{ordered_fields:" ${name}:"+${name}+}}"";
     }
-    
+
     /**
      * Returns a human-readable string of the name of the message
      */
@@ -287,7 +287,7 @@ def generate_MAVLinkMessage(directory, xml_list):
  * This class was automatically generated by the
  * java mavlink generator tool. It should not be modified by hand.
  */
-        
+
 package com.MAVLink;
 
 import java.io.Serializable;
@@ -338,7 +338,7 @@ ${importString}
  *
  * The signature is a combination of a typeid, timestamp, and SHA256 hash.
  * OPTIONAL fields mean that, if they are not used, they do not exist in the MAVLink frame at all. Typically target sysid and target compid are not used, and signature is only used if signing is set up between both ends.
- * 
+ *
  * @see <a href="https://mavlink.io">mavlink.io</a> for more documentation on the MAVLink protocol
  */
 public class MAVLinkPacket implements Serializable {
@@ -481,7 +481,7 @@ public class MAVLinkPacket implements Serializable {
         }
         return length;
     }
-    
+
     /**
      * Encode this packet for transmission.
      *
@@ -490,7 +490,7 @@ public class MAVLinkPacket implements Serializable {
     public byte[] encodePacket() {
         final int bufLen;
         final int payloadSize;
-        
+
         if (isMavlink2) {
             payloadSize = mavTrimPayload(payload.payload.array());
             bufLen = MAVLINK2_HEADER_LEN + payloadSize + 2;
@@ -500,7 +500,7 @@ public class MAVLinkPacket implements Serializable {
 
         }
         byte[] buffer = new byte[bufLen];
-        
+
         int i = 0;
         if (isMavlink2) {
             buffer[i++] = (byte) MAVLINK_STX_MAVLINK2;
@@ -535,7 +535,7 @@ public class MAVLinkPacket implements Serializable {
         return buffer;
     }
         ''', xml_list[0])
-    
+
     f.write('''
     /**
      * Unpack the data in this packet and return a MAVLink message
@@ -554,7 +554,7 @@ public class MAVLinkPacket implements Serializable {
     xml_msgs.sort(key=lambda msg: msg.id)
 
     for msg in xml_msgs:
-        t.write(f, ''' 
+        t.write(f, '''
             case msg_${name_lower}.MAVLINK_MSG_ID_${name}:
                 return  new msg_${name_lower}(this);
             ''',msg)
@@ -610,46 +610,46 @@ def mavfmt(field, typeInfo=0):
         'int64_t'  : ('long', 'Long'),
         'uint64_t' : ('long', 'UnsignedLong'),
     }
-    
+
     return map[field.type][typeInfo]
 
 def generate_one(basename, xml):
     '''generate headers for one XML file'''
-    
+
     directory = os.path.join(basename, xml.basename)
-    
+
     print("Generating Java implementation in directory %s" % directory)
     mavparse.mkdir_p(directory)
-    
+
     if xml.little_endian:
         xml.mavlink_endian = "MAVLINK_LITTLE_ENDIAN"
     else:
         xml.mavlink_endian = "MAVLINK_BIG_ENDIAN"
-    
+
     if xml.crc_extra:
         xml.crc_extra_define = "1"
     else:
         xml.crc_extra_define = "0"
-    
+
     if xml.sort_fields:
         xml.aligned_fields_define = "1"
     else:
         xml.aligned_fields_define = "0"
-    
+
     # work out the included headers
     xml.include_list = []
     for i in xml.include:
         base = i[:-4]
         xml.include_list.append(mav_include(base))
-    
+
     # form message lengths array
     xml.message_lengths_array = ''
     for mlen in xml.message_lengths:
         xml.message_lengths_array += '%u, ' % mlen
     xml.message_lengths_array = xml.message_lengths_array[:-2]
-    
-    
-    
+
+
+
     # form message info array
     xml.message_info_array = ''
     for name in xml.message_names:
@@ -661,7 +661,7 @@ def generate_one(basename, xml):
             # feed the compiler a "filled" empty message
             xml.message_info_array += '{"EMPTY",0,{{"","",MAVLINK_TYPE_CHAR,0,0,0}}}, '
     xml.message_info_array = xml.message_info_array[:-2]
-    
+
     # add some extra field attributes for convenience with arrays
     for m in xml.message:
         m.msg_name = m.name
@@ -685,8 +685,8 @@ def generate_one(basename, xml):
                 f.array_const = 'const '
                 f.decode_left = ''
                 f.decode_right = 'm.%s' % (f.name)
-                
-                f.unpackField = ''' 
+
+                f.unpackField = '''
         for (int i = 0; i < this.%s.length; i++) {
             this.%s[i] = payload.get%s();
         }
@@ -759,7 +759,7 @@ def generate_one(basename, xml):
                     f.c_test_value = "%sLL" % f.test_value
                 else:
                     f.c_test_value = f.test_value
-    
+
     # cope with uint8_t_mavlink_version
     for m in xml.message:
         m.arg_fields = []
@@ -776,7 +776,7 @@ def generate_one(basename, xml):
                 f.putname = f.name
             else:
                 f.putname = f.const_value
-    
+
     # fix types to java
     for m in xml.message:
         for f in m.ordered_fields:
@@ -788,9 +788,9 @@ def generate_one(basename, xml):
         m.extended_fields = []
         if m.extensions_start is not None:
             m.extended_fields = m.ordered_fields[m.extensions_start:]
-    
+
     generate_CRC(directory, xml)
-    
+
     for m in xml.message:
         generate_message_h(directory, m)