#857 ✓resolved
Dominik Dorn

UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer

Reported by Dominik Dorn | May 21st, 2011 @ 02:49 PM | in 1.2.5 (closed)

Framework version: 1.2.1
Platform you're using: Ubuntu 11.04, java version "1.6.0_21

Reproduction steps:
- create a controller - add the method posted below to the controller - load a page of the app - -> boom!

Details:
I'm receiving the following exception, when loading any page of my play webapp:
@66fgmo9l8 Internal Server Error (500) for request GET /

Oops: UnexpectedException
An unexpected error occured caused by exception UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Texts

play.exceptions.UnexpectedException: While applying play.CorePlugin@688c4a77 on controllers.Texts

at play.plugins.PluginCollection.enhance(PluginCollection.java:437)
at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:208)
at play.classloading.ApplicationClassloader.detectChanges(ApplicationClassloader.java:309)
at play.Play.detectChanges(Play.java:560)
at play.Invoker$Invocation.init(Invoker.java:186)
at Invocation.HTTP Request(Play!)

Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Texts

at play.CorePlugin.enhance(CorePlugin.java:299)
at play.plugins.PluginCollection.enhance(PluginCollection.java:434)
... 5 more

Caused by: java.lang.ArrayIndexOutOfBoundsException
16:41:55,671 ERROR ~

The problem arises, if I have such a method in my controller (controllers.Texts)

public static List<String> getLetters() {
    String[] array = new String[36];

    int i = 0;
    for (int nCharCode = 65; nCharCode <= 90; nCharCode++) // a-z = 26
        array[i++] = String.valueOf((char) nCharCode);
    for (int nCharCode = 48; nCharCode <= 57; nCharCode++) // 0-9 = 10
        array[i++] = String.valueOf((char) nCharCode);

    return Arrays.asList(array);
}

If I comment out the for loops, the page loads correctly. I'm not sure, why this blows up play,
as its valid Java code.

Comments and changes to this ticket

  • Ivan Meredith

    Ivan Meredith May 24th, 2011 @ 10:42 AM

    I can confirm this. The issue is using ++ or += or -- or -= (and variations i imagine when its in another code block.

    // This example failes. int i=0;
    for(int j = 0; j < 10; j++) System.out.println(i++);

    // This example works. int i=0;
    for(int j = 0; j < 10; j++) { i++; System.out.println(i);}

  • Play Duck

    Play Duck December 2nd, 2011 @ 09:42 PM

    (from [8823d3827557df3e8bfdbd181bfc8befc9e644d4]) [#857] [#491] [#1221] [#1198] [#811] Big fix for local variable enhancer and javaflow (fixes multiple Enhancer bugs) (many thanks to Stéphane Godbillon!) * fix localvariable assignment as last block instruction. Refactored localvariable enhancement. * duplicate member exception bugfix * fix commons-javaflow lib (bipush overflow) https://github.com/playframework/play/commit/8823d3827557df3e8bfdbd...

  • Morten Kjetland

    Morten Kjetland December 2nd, 2011 @ 09:45 PM

    • Assigned user set to “Morten Kjetland”
    • State changed from “new” to “resolved”
    • Milestone set to 1.2.5
    • Milestone order changed from “583” to “0”

    Thanks to Stéphane Godbillon's big fix, this issue is now resolved

  • Nicolas Leroux

    Nicolas Leroux December 7th, 2011 @ 09:11 PM

    • State changed from “resolved” to “inprogress”

    Reopen till fixed in master and scala module is no more broken.

  • Play Duck
  • Morten Kjetland

    Morten Kjetland December 13th, 2011 @ 10:18 PM

    • State changed from “inprogress” to “resolved”

    Manuel Bernhardt confirmes that it now works with 1.2.x and scala.
    I've tested this problem against master and confirmes it works.

  • Ron Gross

    Ron Gross December 28th, 2011 @ 09:59 AM

    • Milestone order changed from “2” to “0”

    This bug should be reopened.

    This is reproducing again in latest builds off 1.2.x branch.
    I just tested commit https://github.com/playframework/play/commit/6f4a1f2af859df588d5da2... from December 27, which exhibited this issue on my ubuntu server - immediately during startup.

    I reverted to an earlier commit from 1.2.x - https://github.com/playframework/play/commit/c40cf37d13050ab28aac67... (from December 03) - and it did not have the problem.

    I was using Java 7 (OpenJDK) to run Play, and Java 6 to compile it (Play does not compile under Java 7).

  • Ron Gross

    Ron Gross December 28th, 2011 @ 10:15 AM

    Here is a complete stack trace

    10:13:06,907 TRACE (play.Logger) ~ 408ms to apply PropertiesEnhancer to controllers.Websites
    10:13:06,910 TRACE (play.Logger) ~ for variable 'websites' in slot=0, sig was 'Ljava/util/List;' and is now 'Ljava/lang/Object;'
    10:13:06,920 TRACE (play.Logger) ~ for variable '__stackRecorder' in slot=1, sig was 'Lorg/apache/commons/javaflow/bytecode/StackRecorder;' and is now 'Ljava/lang/Object;'
    10:13:06,931 ERROR (play.Logger) ~

    @68pailme7 Cannot start in PROD mode with errors

    Oops: UnexpectedException
    An unexpected error occured caused by exception UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Websites

    play.exceptions.UnexpectedException: While applying play.CorePlugin@1d3659b on controllers.Websites

        at play.plugins.PluginCollection.enhance(PluginCollection.java:511)
        at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:235)
        at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:165)
        at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:429)
        at play.Play.preCompile(Play.java:582)
        at play.Play.init(Play.java:299)
        at play.server.Server.main(Server.java:158)
    

    Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Websites

        at play.CorePlugin.enhance(CorePlugin.java:302)
        at play.plugins.PluginCollection.enhance(PluginCollection.java:506)
        ... 6 more
    

    Caused by: java.lang.ArrayIndexOutOfBoundsException: 7

        at javassist.bytecode.stackmap.Tracer.doLDC(Tracer.java:273)
        at javassist.bytecode.stackmap.Tracer.doOpcode0_53(Tracer.java:189)
        at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:94)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:182)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:192)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:141)
        at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
        at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:416)
        at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:398)
        at javassist.CtBehavior.insertBefore(CtBehavior.java:719)
        at javassist.CtBehavior.insertBefore(CtBehavior.java:685)
        at play.classloading.enhancers.LocalvariablesNamesEnhancer.enhanceThisClass(LocalvariablesNamesEnhancer.java:268)
        at play.CorePlugin.enhance(CorePlugin.java:297)
        ... 7 more
    
  • Morten Kjetland

    Morten Kjetland January 2nd, 2012 @ 07:09 AM

    Hi Ron,

    Can you please try to create a minimal test project that reproduces your problem with current 1.2.x-branch, and file a new ticket with the project attached?

  • Ron Gross

    Ron Gross February 3rd, 2012 @ 12:15 AM

    Hi Morten

    Sadly, I never received any emails about your comment from Jan 2nd.
    I just saw your comment because I happened to browse this bug.

    Either something is wrong with Lighthouse, or my user settings, not sure which.

    I'll try to reproduce it when I get a chance (might take some time before I do, I'm pretty busy these days).

  • Ron Gross

    Ron Gross February 3rd, 2012 @ 12:35 AM

    I now understand - I had assumed that commenting on this issue was enough for me to get emails.
    In fact, I needed to click "Watch Ticket".
    Done now.

  • Ron Gross
  • JulOz

    JulOz April 26th, 2019 @ 08:32 AM

    You need to look at this article to know how to write a SAT essay and get the highest score.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2>Play framework</h2>

Play makes it easier to build Web applications with Java. It is a clean alternative to bloated Enterprise Java stacks. It focuses on developer productivity and targets RESTful architectures. Learn more on the <a href="http://www.playframework.org">http://www.playframework.org</a> website.<br><br>

<h2>Source code is hosted on github</h2>Check out our repository at <a href="http://github.com/playframework/play">http://github.com/playframework/play</a><br><br>

<h2>Contributing, creating a patch</h2> Please read the <a href="http://play.lighthouseapp.com/projects/57987/contributor-guide">contributor guide</a><br><br>

<h2>Reporting Security Vulnerabilities</h2> Since all bug reports are public, please report any security vulnerability directly to <em>guillaume dot bort at gmail dot com</em>.<br><br>

<h2>Creating a bug report</h2> Bug reports are incredibly helpful, so take time to report bugs and request features in our ticket tracker. We’re always grateful for patches to Play’s code. Indeed, bug reports with attached patches will get fixed far quickly than those without any.<br><br>

Please include as much relevant information as possible including the exact framework version you're using and a code snippet that reproduces the problem.<br><br>

Don't have too much expectations. Unless the bug is really a serious "everything is broken" thing, you're creating a ticket to start a discussion. Having a patch (or a branch on Github we can pull from) is better, but then again we'll only pull high quality branches that make sense to be in the core of Play.

Referenced by

Pages