#520 confirmed
lpolovets (at gmail)

play.classloading.enhancers.LocalvariablesNamesEnhancer issue, possibly related to auto-boxing

Reported by lpolovets (at gmail) | December 31st, 2010 @ 03:10 AM | in 1.4.x

Framework version: 1.1
Platform you're using: Ubuntu 10.04, 64 bit

Reproduction steps:

Create a new play project. Replace the contents of controllers.Application with:

package controllers;

import play.mvc.Controller;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Application extends Controller {
  public static void index() {
    Map<String, Integer> map = new ConcurrentHashMap<String, Integer>();
    int counter = 0;
    for (int i = 0; i < 10; i++) {
      map.put("string", counter++);
    }
    renderText(map.size());
  }

//  public static void index() {
//    Map<String, Integer> map = new ConcurrentHashMap<String, Integer>();
//    int counter = 0;
//    for (int i = 0; i < 10; i++) {
//      map.put("string", counter);
//      counter++;
//    }
//    renderText(map.size());
//  }
}

If you run with the first version of index() and go to localhost:9000/application/index, you will see an error with the following stack trace:

Internal Server Error (500) for request GET /favicon.ico

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

play.exceptions.UnexpectedException: While applying play.CorePlugin@6ab30913 on controllers.Application
    at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:215)
    at play.classloading.ApplicationClassloader.loadApplicationClass(ApplicationClassloader.java:139)
    at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:419)
    at play.Play.start(Play.java:416)
    at play.Play.detectChanges(Play.java:520)
    at play.Invoker$Invocation.init(Invoker.java:100)
    at Invocation.HTTP Request(Play!)
Caused by: play.exceptions.UnexpectedException: While applying class play.classloading.enhancers.LocalvariablesNamesEnhancer on controllers.Application
    at play.CorePlugin.enhance(CorePlugin.java:295)
    at play.classloading.ApplicationClasses$ApplicationClass.enhance(ApplicationClasses.java:212)
    ... 6 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
    at javassist.bytecode.stackmap.Tracer.doLDC(Tracer.java:273)
    at javassist.bytecode.stackmap.Tracer.doOpcode0_53(Tracer.java:185)
    at javassist.bytecode.stackmap.Tracer.doOpcode(Tracer.java:94)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:161)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:171)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:120)
    at javassist.bytecode.stackmap.MapMaker.make(MapMaker.java:96)
    at javassist.bytecode.MethodInfo.rebuildStackMap(MethodInfo.java:404)
    at javassist.bytecode.MethodInfo.rebuildStackMapIf6(MethodInfo.java:389)
    at javassist.CtBehavior.insertBefore(CtBehavior.java:674)
    at javassist.CtBehavior.insertBefore(CtBehavior.java:640)
    at play.classloading.enhancers.LocalvariablesNamesEnhancer.enhanceThisClass(LocalvariablesNamesEnhancer.java:193)
    at play.CorePlugin.enhance(CorePlugin.java:292)
    ... 7 more

If you comment out the first version of index() and uncomment the 2nd version, the error goes away.

Something about doing counter++ inside of put() instead of outside seems to make things break.

Comments and changes to this ticket

  • Nicolas Leroux

    Nicolas Leroux December 7th, 2011 @ 10:30 PM

    • Milestone set to 1.2.5
    • State changed from “new” to “confirmed”
    • Assigned user changed from “Guillaume Bort” to “Morten Kjetland”
    • Milestone order changed from “295” to “0”

    I guess it is related with what you are working on...

  • Stephane Godbillon

    Stephane Godbillon December 11th, 2011 @ 05:48 PM

    Yes, it should be fixed now.

  • Morten Kjetland

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

    This works in master now, but not in 1.2.x.

    The test case is included in this app:
    https://github.com/mbknor/play_enhancher_problem_code

    This is the fresh error message on 1.2.x:

    [t3]$ ../play/play precompile
    ~        _            _ 
    ~  _ __ | | __ _ _  _| |
    ~ | '_ \| |/ _' | || |_|
    ~ |  __/|_|\____|\__ (_)
    ~ |_|            |__/   
    ~
    ~ play! 1.2.x-951d0b1, http://www.playframework.org
    ~
    Listening for transport dt_socket at address: 8000
    23:38:04,439 INFO  ~ Starting t3
    23:38:05,010 INFO  ~ Precompiling ...
    23:38:06,161 WARN  ~ weird: skipping method java.lang.Object controllers.B.parseSomething() as its number of local variables is incorrect (lv=javassist.bytecode.LocalVariableAttribute@19ded4c9 || lv.length=0 || params.length=0 || (isStatic? false)
    23:38:06,162 WARN  ~ While applying localvariables to controllers.B.parseSomething, param 0
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.RangeCheck(ArrayList.java:547)
        at java.util.ArrayList.get(ArrayList.java:322)
        at play.classloading.enhancers.LocalvariablesNamesEnhancer.enhanceThisClass(LocalvariablesNamesEnhancer.java:154)
        at play.CorePlugin.enhance(CorePlugin.java:297)
        at play.plugins.PluginCollection.enhance(PluginCollection.java:506)
        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)
    23:38:09,187 INFO  ~ Done.
    
  • Stephane Godbillon

    Stephane Godbillon December 14th, 2011 @ 12:09 AM

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

    I think this is javassist-related.
    I'll try to fix this bug with javassist 3.0.15.

  • Morten Kjetland

    Morten Kjetland April 12th, 2012 @ 01:28 PM

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

    this is still a confirmed bug with javassist-3.15.0.GA.jar

  • Morten Kjetland

    Morten Kjetland April 26th, 2012 @ 08:48 PM

    • Milestone cleared.
    • Milestone order changed from “8” to “0”
  • Morten Kjetland

    Morten Kjetland April 26th, 2012 @ 08:49 PM

    • no changes were found...
  • Nicolas Leroux

    Nicolas Leroux May 29th, 2012 @ 10:39 AM

    • Milestone set to 1.3
    • Milestone order changed from “2” to “0”
  • notalifeform (at gmail)

    notalifeform (at gmail) April 21st, 2014 @ 07:59 PM

    • Milestone changed from 1.3 to 1.4.x

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.

Tags

Pages