Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2428

Inner anonymous inner class' initial method is not invoked

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: 7.0.2, 6.5.7
    • Fix Version/s: 6.5.8, 7.0.4
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None

      Description

      Problem Description:

      According to our document http://books.zkoss.org/wiki/ZK%20Developer's%20Reference/MVVM/ViewModel/Initialization, child class can have a initial method. But if we create a inner anonymous inner class', its initial method is not invoked.

      Steps to Reproduce

      1. run attached zul innerClass-init.zul

      Actual Result

      an exception throw

      java.lang.IllegalAccessException: Class org.zkoss.bind.impl.ParamCall can not access a member of class support.mvvm.OuterVM$1 with modifiers "public" at file:/D:/git/zkcase/src/main/webapp/mvvm/innerClass-init.zul, line:4

      Expected Result

      "initialized" is displayed.

      Root Cause:

      A JVM bug, http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4819108
      Using an object of an inner class, which defines public methods cannot be invoked via "Method.invoke(...)".

      Proposed Solution

      package org.zkoss.bind.impl;
      
      public class ParamCall {
          public void call(Object base, Method method) {
      	...			
      			//check whether if the method is public or not, if it's public open the access
      			method.setAccessible(true); // fix
      			method.invoke(base, params);
          }
      }
      

        Attachments

        1. childClass-init.zul
          0.1 kB
        2. ChildVM.java
          0.4 kB
        3. innerClass-init.zul
          0.3 kB
        4. InnerVM.java
          0.4 kB
        5. OuterVM.java
          0.4 kB

          Activity

            People

            Assignee:
            jumperchen jumperchen
            Reporter:
            hawk hawk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: