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

Inner anonymous inner class' initial method is not invoked

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.5.8, 7.0.4
    • 7.0.2, 6.5.7
    • None
    • Security Level: Jimmy
    • None

      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);
          }
      }
      

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

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

              Created:
              Updated:
              Resolved: