All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Documentation/java.txt: add Java 7 support
@ 2014-03-31  3:47 Jonathan Callen
  2014-04-09 16:21 ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Callen @ 2014-03-31  3:47 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-doc, linux-kernel, Jonathan Callen

The sample wrapper currently fails on some Java 7 .class files.  This
updates the wrapper to properly handle those files.

Signed-off-by: Jonathan Callen <jcallen@gentoo.org>
---
 Documentation/java.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/java.txt b/Documentation/java.txt
index e6a7232..4180205 100644
--- a/Documentation/java.txt
+++ b/Documentation/java.txt
@@ -188,6 +188,9 @@ shift
 #define CP_METHODREF 10
 #define CP_INTERFACEMETHODREF 11
 #define CP_NAMEANDTYPE 12
+#define CP_METHODHANDLE 15
+#define CP_METHODTYPE 16
+#define CP_INVOKEDYNAMIC 18
 
 /* Define some commonly used error messages */
 
@@ -242,14 +245,19 @@ void skip_constant(FILE *classfile, u_int16_t *cur)
 		break;
 	case CP_CLASS:
 	case CP_STRING:
+	case CP_METHODTYPE:
 		seekerr = fseek(classfile, 2, SEEK_CUR);
 		break;
+	case CP_METHODHANDLE:
+		seekerr = fseek(classfile, 3, SEEK_CUR);
+		break;
 	case CP_INTEGER:
 	case CP_FLOAT:
 	case CP_FIELDREF:
 	case CP_METHODREF:
 	case CP_INTERFACEMETHODREF:
 	case CP_NAMEANDTYPE:
+	case CP_INVOKEDYNAMIC:
 		seekerr = fseek(classfile, 4, SEEK_CUR);
 		break;
 	case CP_LONG:
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Documentation/java.txt: add Java 7 support
  2014-03-31  3:47 [PATCH] Documentation/java.txt: add Java 7 support Jonathan Callen
@ 2014-04-09 16:21 ` Randy Dunlap
  2014-04-10  8:24   ` Jonathan Callen
  0 siblings, 1 reply; 5+ messages in thread
From: Randy Dunlap @ 2014-04-09 16:21 UTC (permalink / raw)
  To: Jonathan Callen; +Cc: linux-doc, linux-kernel

On 03/30/2014 08:47 PM, Jonathan Callen wrote:
> The sample wrapper currently fails on some Java 7 .class files.  This
> updates the wrapper to properly handle those files.
> 
> Signed-off-by: Jonathan Callen <jcallen@gentoo.org>

Applied.  Thanks.

How would I test this?


> ---
>  Documentation/java.txt | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/java.txt b/Documentation/java.txt
> index e6a7232..4180205 100644
> --- a/Documentation/java.txt
> +++ b/Documentation/java.txt
> @@ -188,6 +188,9 @@ shift
>  #define CP_METHODREF 10
>  #define CP_INTERFACEMETHODREF 11
>  #define CP_NAMEANDTYPE 12
> +#define CP_METHODHANDLE 15
> +#define CP_METHODTYPE 16
> +#define CP_INVOKEDYNAMIC 18
>  
>  /* Define some commonly used error messages */
>  
> @@ -242,14 +245,19 @@ void skip_constant(FILE *classfile, u_int16_t *cur)
>  		break;
>  	case CP_CLASS:
>  	case CP_STRING:
> +	case CP_METHODTYPE:
>  		seekerr = fseek(classfile, 2, SEEK_CUR);
>  		break;
> +	case CP_METHODHANDLE:
> +		seekerr = fseek(classfile, 3, SEEK_CUR);
> +		break;
>  	case CP_INTEGER:
>  	case CP_FLOAT:
>  	case CP_FIELDREF:
>  	case CP_METHODREF:
>  	case CP_INTERFACEMETHODREF:
>  	case CP_NAMEANDTYPE:
> +	case CP_INVOKEDYNAMIC:
>  		seekerr = fseek(classfile, 4, SEEK_CUR);
>  		break;
>  	case CP_LONG:
> 


-- 
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Documentation/java.txt: add Java 7 support
  2014-04-09 16:21 ` Randy Dunlap
@ 2014-04-10  8:24   ` Jonathan Callen
  2014-04-10 19:11     ` Randy Dunlap
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Callen @ 2014-04-10  8:24 UTC (permalink / raw)
  To: Randy Dunlap; +Cc: linux-doc, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1820 bytes --]

On 04/09/2014 12:21 PM, Randy Dunlap wrote:
> On 03/30/2014 08:47 PM, Jonathan Callen wrote:
>> The sample wrapper currently fails on some Java 7 .class files.  This
>> updates the wrapper to properly handle those files.
>>
>> Signed-off-by: Jonathan Callen <jcallen@gentoo.org>
> 
> Applied.  Thanks.
> 
> How would I test this?
> 

I have attached a hand-crafted HelloWorld.class file that fails unless this patch is applied.  This
.class file intentionally has extra entries in its constant pool that are not used by Java, but the
file does pass validation.

A complete disassembly of that file, showing the purpose of each byte, is attached as HelloWorld.jj.

> 
>> ---
>>  Documentation/java.txt | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/Documentation/java.txt b/Documentation/java.txt
>> index e6a7232..4180205 100644
>> --- a/Documentation/java.txt
>> +++ b/Documentation/java.txt
>> @@ -188,6 +188,9 @@ shift
>>  #define CP_METHODREF 10
>>  #define CP_INTERFACEMETHODREF 11
>>  #define CP_NAMEANDTYPE 12
>> +#define CP_METHODHANDLE 15
>> +#define CP_METHODTYPE 16
>> +#define CP_INVOKEDYNAMIC 18
>>  
>>  /* Define some commonly used error messages */
>>  
>> @@ -242,14 +245,19 @@ void skip_constant(FILE *classfile, u_int16_t *cur)
>>  		break;
>>  	case CP_CLASS:
>>  	case CP_STRING:
>> +	case CP_METHODTYPE:
>>  		seekerr = fseek(classfile, 2, SEEK_CUR);
>>  		break;
>> +	case CP_METHODHANDLE:
>> +		seekerr = fseek(classfile, 3, SEEK_CUR);
>> +		break;
>>  	case CP_INTEGER:
>>  	case CP_FLOAT:
>>  	case CP_FIELDREF:
>>  	case CP_METHODREF:
>>  	case CP_INTERFACEMETHODREF:
>>  	case CP_NAMEANDTYPE:
>> +	case CP_INVOKEDYNAMIC:
>>  		seekerr = fseek(classfile, 4, SEEK_CUR);
>>  		break;
>>  	case CP_LONG:
>>
> 
> 


[-- Attachment #1.2: HelloWorld.class --]
[-- Type: application/java-vm, Size: 349 bytes --]

[-- Attachment #1.3: HelloWorld.jj --]
[-- Type: text/plain, Size: 6987 bytes --]

{
	u4 magic = cafebabe;
	u2 minor_version = 0000;
	u2 major_version = 0033;
	u2 constant_pool_count = 001c;
	cp_info constant_pool[constant_pool_count-1] = {
		{ // 0001 = Methodref java/lang/Object.<init>:()V
			u1 tag = 0a; // CONSTANT_Methodref
			u2 class_index = 0006; // Class java/lang/Object
			u2 name_and_type_index = 000c; // NameAndType <init>:()V
		},
		{ // 0002 = Fieldref java/lang/System.out:Ljava/io/PrintStream;
			u1 tag = 09; // CONSTANT_Fieldref
			u2 class_index = 000d; // Class java/lang/System
			u2 name_and_type_index = 000e; // NameAndType out:Ljava/io/PrintStream;
		},
		{ // 0003 = String "Hello, world!"
			u1 tag = 08; // CONSTANT_String_info
			u2 string_index = 000f; // Utf8 Hello, world!
		},
		{ // 0004 = Methodref java/io/PrintStream.println:(Ljava/lang/String;)V
			u1 tag = 0a; // CONSTANT_Methodref
			u2 class_index = 0010; // Class java/io/PrintStream
			u2 name_and_type_index = 0011; // NameAndType println:(Ljava/lang/String;)V
		},
		{ // 0005 = Class HelloWorld
			u1 tag = 07; // CONSTANT_Class_info
			u2 name_index = 0012; // Utf8 HelloWorld
		},
		{ // 0006 = Class java/lang/Object
			u1 tag = 07; // CONSTANT_Class_info
			u2 name_index = 0013; // Utf8 java/lang/Object
		},
		{ // 0007 = Utf8 <init>
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0006;
			u1 bytes[] = {3c,69,6e,69,74,3e}; // <init>
		},
		{ // 0008 = Utf8 ()V
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0003;
			u1 bytes[] = {28,29,56}; // ()V
		},
		{ // 0009 = Utf8 Code
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0004;
			u1 bytes[] = {43,6f,64,65}; // Code
		},
		{ // 000a = Utf8 main
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0004;
			u1 bytes[] = {6d,61,69,6e}; // main
		},
		{ // 000b = Utf8 ([Ljava/lang/String;)V
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0016;
			u1 bytes[] = {28,5b,4c,6a,61,76,61,2f,6c,61,6e,67,2f,53,74,72,69,6e,67,3b,29,56}; // ([Ljava/lang/String;)V
		},
		{ // 000c = NameAndType <init>:()V
			u1 tag = 0c; // CONSTANT_NameAndType
			u2 name_index = 0007; // Utf8 <init>
			u2 descriptor_index = 0008; // Utf8 ()V
		},
		{ // 000d = Class java/lang/System
			u1 tag = 07; // CONSTANT_Class_info
			u2 name_index = 0014; // Utf8 java/lang/System
		},
		{ // 000e = NameAndType out:Ljava/io/PrintStream;
			u1 tag = 0c; // CONSTANT_NameAndType
			u2 name_index = 0015; // Utf8 out
			u2 descriptor_index = 0016; // Utf8 Ljava/io/PrintStream;
		},
		{ // 000f = Utf8 Hello, world!
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 000d;
			u1 bytes[] = {48,65,6c,6c,6f,2c,20,77,6f,72,6c,64,21}; // Hello, world!
		},
		{ // 0010 = Class java/io/PrintStream
			u1 tag = 07;
			u2 name_index = 0017; // Utf8 java/io/PrintStream
		},
		{ // 0011 = NameAndType println:(Ljava/lang/String;)V
			u1 tag = 0c; // CONSTANT_NameAndType
			u2 name_index = 0018; // Utf8 println
			u2 descriptor_index = 0019; // Utf8 (Ljava/lang/String;)V
		},
		{ // 0012 = Utf8 HelloWorld
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 000a;
			u1 bytes[] = {48,65,6c,6c,6f,57,6f,72,6c,64}; // HelloWorld
		},
		{ // 0013 = Utf8 java/lang/Object
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0010;
			u1 bytes[] = {6a,61,76,61,2f,6c,61,6e,67,2f,4f,62,6a,65,63,74}; // java/lang/Object
		},
		{ // 0014 = Utf8 java/lang/System
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0010;
			u1 bytes[] = {6a,61,76,61,2f,6c,61,6e,67,2f,53,79,73,74,65,6d}; // java/lang/System
		},
		{ // 0015 = Utf8 out
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0003;
			u1 bytes[] = {6f,75,74}; // out
		},
		{ // 0016 = Utf8 Ljava/io/PrintStream;
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0015;
			u1 bytes[] = {4c,6a,61,76,61,2f,69,6f,2f,50,72,69,6e,74,53,74,72,65,61,6d,3b}; // Ljava/io/PrintStream;
		},
		{ // 0017 = Utf8 java/io/PrintStream
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0013;
			u1 bytes[] = {6a,61,76,61,2f,69,6f,2f,50,72,69,6e,74,53,74,72,65,61,6d}; // java/io/PrintStream
		},
		{ // 0018 = Utf8 println
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0007;
			u1 bytes[] = {70,72,69,6e,74,6c,6e}; // println
		},
		{ // 0019 = Utf8 (Ljava/lang/String;)V
			u1 tag = 01; // CONSTANT_Utf8
			u2 length = 0015;
			u1 bytes[] = {28,4c,6a,61,76,61,2f,6c,61,6e,67,2f,53,74,72,69,6e,67,3b,29,56}; // (Ljava/lang/String;)V
		},
		{ // 001a = MethodHandle getStatic java/lang/System.out:Ljava/io/PrintStream;
			u1 tag = 0f; // CONSTANT_MethodHandle
			u1 reference_kind = 02; // REF_getStatic
			u2 reference_index = 0002; // Field java/lang/System.out:Ljava/io/PrintStream;
		},
		{ // 001b = MethodType (Ljava/lang/String;)V
			u1 tag = 10; // CONSTANT_MethodType
			u2 descriptor_index = 0019;
		},
	};
	u2 access_flags = 0021; // ACC_PUBLIC | ACC_SUPER
	u2 this_class = 0005; // Class: HelloWorld
	u2 super_class = 0006; // Class: java/lang/Object
	u2 interfaces_count = 0000;
	u2 interfaces[interfaces_count] = {};
	u2 fields_count = 0000;
	field_info fields[fields_count] = {};
	u2 methods_count = 0002;
	method_info methods[methods_count] = {
		{
			u2 access_flags = 0001; // ACC_PUBLIC
			u2 name_index = 0007; // Utf8 <init>
			u2 descriptor_index = 0008; // Utf8 ()V
			u2 attributes_count = 0001;
			attribute_info attributes[attributes_count] = {
				{
					u2 attribute_name_index = 0009; // Utf8 Code
					u4 attribute_length = 00000011;
					u2 max_stack = 0001;
					u2 max_locals = 0001;
					u4 code_length = 00000005;
					u1 code[code_length] = {
						2a, // aload_0
						b7, 00,01, // invokespecial 0001 // Method java/lang/Object.<init>:()V
						b1, // return
					};
					u2 exception_table_length = 0000;
					exception_table_item exception_table[exception_table_length] = {};
					u2 attributes_count = 0000;
					attribute_info attributes[attributes_count] = {};
				},
			};
		},
		{
			u2 access_flags = 0009; // ACC_PUBLIC | ACC_STATIC
			u2 name_index = 000a; // Utf8 main
			u2 descriptor_index = 000b; // Utf8 ([Ljava/lang/String;)V
			u2 attributes_count = 0001;
			attribute_info attributes[attributes_count] = {
				{
					u2 attribute_name_index = 0009; // Utf8 Code
					u4 attribute_length = 00000015;
					u2 max_stack = 0002;
					u2 max_locals = 0001;
					u4 code_length = 00000009;
					u1 code[code_length] = {
						b2, 00,02, // getstatic 0002 // Field java/lang/System.out:Ljava/io/PrintStream;
						12, 03, // ldc 03 // String "Hello, world!"
						b6, 00,04, // invokevirtual 0004 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
						b1, // return
					};
					u2 exception_table_length = 0000;
					exception_table_item exception_table[exception_table_length] = {};
					u2 attributes_count = 0000;
					attribute_info attributes[attributes_count] = {};
				},
			};
		},
	};
	u2 attributes_count = 0000;
	attribute_info attributes[attributes_count] = {};
}

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 901 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Documentation/java.txt: add Java 7 support
  2014-04-10  8:24   ` Jonathan Callen
@ 2014-04-10 19:11     ` Randy Dunlap
  0 siblings, 0 replies; 5+ messages in thread
From: Randy Dunlap @ 2014-04-10 19:11 UTC (permalink / raw)
  To: Jonathan Callen; +Cc: linux-doc, linux-kernel

On 04/10/2014 01:24 AM, Jonathan Callen wrote:
> On 04/09/2014 12:21 PM, Randy Dunlap wrote:
>> On 03/30/2014 08:47 PM, Jonathan Callen wrote:
>>> The sample wrapper currently fails on some Java 7 .class files.  This
>>> updates the wrapper to properly handle those files.
>>>
>>> Signed-off-by: Jonathan Callen <jcallen@gentoo.org>
>>
>> Applied.  Thanks.
>>
>> How would I test this?
>>
> 
> I have attached a hand-crafted HelloWorld.class file that fails unless this patch is applied.  This
> .class file intentionally has extra entries in its constant pool that are not used by Java, but the
> file does pass validation.
> 
> A complete disassembly of that file, showing the purpose of each byte, is attached as HelloWorld.jj.

Thanks much.



-- 
~Randy

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Documentation/java.txt: add Java 7 support
@ 2012-12-13  3:06 Jonathan Callen
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Callen @ 2012-12-13  3:06 UTC (permalink / raw)
  To: Rob Landley, linux-doc, linux-kernel; +Cc: Jonathan Callen

The sample wrapper currently fails on some Java 7 .class files.  This
updates the wrapper to properly handle those files.

Signed-off-by: Jonathan Callen <abcd@gentoo.org>
---
 Documentation/java.txt | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/Documentation/java.txt b/Documentation/java.txt
index e6a7232..4180205 100644
--- a/Documentation/java.txt
+++ b/Documentation/java.txt
@@ -188,6 +188,9 @@ shift
 #define CP_METHODREF 10
 #define CP_INTERFACEMETHODREF 11
 #define CP_NAMEANDTYPE 12
+#define CP_METHODHANDLE 15
+#define CP_METHODTYPE 16
+#define CP_INVOKEDYNAMIC 18
 
 /* Define some commonly used error messages */
 
@@ -242,14 +245,19 @@ void skip_constant(FILE *classfile, u_int16_t *cur)
 		break;
 	case CP_CLASS:
 	case CP_STRING:
+	case CP_METHODTYPE:
 		seekerr = fseek(classfile, 2, SEEK_CUR);
 		break;
+	case CP_METHODHANDLE:
+		seekerr = fseek(classfile, 3, SEEK_CUR);
+		break;
 	case CP_INTEGER:
 	case CP_FLOAT:
 	case CP_FIELDREF:
 	case CP_METHODREF:
 	case CP_INTERFACEMETHODREF:
 	case CP_NAMEANDTYPE:
+	case CP_INVOKEDYNAMIC:
 		seekerr = fseek(classfile, 4, SEEK_CUR);
 		break;
 	case CP_LONG:
-- 
1.7.12


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-04-10 19:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31  3:47 [PATCH] Documentation/java.txt: add Java 7 support Jonathan Callen
2014-04-09 16:21 ` Randy Dunlap
2014-04-10  8:24   ` Jonathan Callen
2014-04-10 19:11     ` Randy Dunlap
  -- strict thread matches above, loose matches on Subject: below --
2012-12-13  3:06 Jonathan Callen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.