[ 
https://issues.apache.org/jira/browse/AVRO-1642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Prateek Rungta updated AVRO-1642:
---------------------------------
    Status: Patch Available  (was: Open)

The attached patch does the following:
- [{{avro-compiler}}] Adds the ability to specify if the All-args constructor 
should be created; and it counts the parameters at the time of code-gen, 
throwing an exception if generating the All-args constructor is specified and 
would violate the JVM. Plus associated tests.
- [{{avro-ipc}}] Adds test cases to use the features from {{avro-compiler}}
- [{{avro-maven-plugin}}] exposes the constructor generation option via a 
xml-child in the plugin called {{createAllArgsConstructor}}, associated tests
- [{{avro-tools}}] similar to the maven plugin, it exposes the cli flag 
{{-no-constructor}}, and adds a test case to check. 

I have two gripes with it:
- The naming of the options in the maven plugin and tools should be consistent. 
I'm personally leaning towards {{-skipAllArgsConstructor}} and leave the plugin 
one as-is.
- I'm duplicating the {{createSampleRecordSchema}} method in the compiler and 
ipc modules. I couldn't think of a way to avoid this without publishing a 
test-jar artifact from the compiler. 

> JVM Spec Violation 255 Parameter Limit Exceeded 
> ------------------------------------------------
>
>                 Key: AVRO-1642
>                 URL: https://issues.apache.org/jira/browse/AVRO-1642
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.7
>         Environment: Windows/Linux all Java
>            Reporter: Bryce Alcock
>            Assignee: Prateek Rungta
>            Priority: Critical
>              Labels: build, maven, specific
>         Attachments: AVRO-1642-0.patch, avro-1642-fail.tar
>
>
> The JVM Spec indicates that:
> {quote}The number of method parameters is limited to 255 by the definition of 
> a method descriptor (ยง4.3.3), where the limit includes one unit for this in 
> the case of instance or interface method invocations. Note that a method 
> descriptor is defined in terms of a notion of method parameter length in 
> which a parameter of type long or double contributes two units to the length, 
> so parameters of these types further reduce the limit. {quote}
> Avro Generated Java code with say more than 255 fields will create a 
> constructor that is not valid and won't compile.
> Simple test is to create a 256 field avro schema, use the avro-maven auto 
> code gen plugin, and try to compile the resulting class.
> DON'T use linux when doing this use windows, my suspicion is that Linux JavaC 
> generates invalid byte code but does not complain.
> Windows will correctly complain indicating that you are a violator of the JVM 
> specification.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to