Microsoft KB Archive/250538

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Article ID: 250538

Article Last Modified on 6/14/2006



APPLIES TO

  • Microsoft Java Virtual Machine



This article was previously published under Q250538

SYMPTOMS

When you try to call static and/or overloaded methods of a Java class that is registered as a Java COM object from Active Server Pages (ASP) or a Microsoft Visual Basic Scripting file, you may receive the following errors:

For a static method:

Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'staticMethod'

For an overloaded method:

Microsoft VBScript runtime error '800a000d'
Type Mismatch:'OverLoadedMethodName'

NOTE: The overloaded method has the same method name and the same number of parameters but has different parameter types.

In some cases, you may not receive an error message, but you may notice that only one of the overloaded methods is being called.

CAUSE

For static methods, this problem occurs because static methods are not exposed through the Auto-IDispatch feature.

For overloaded methods, this problem occurs because the Microsoft virtual machine (Microsoft VM) for Java only differentiates between overloaded methods by number of parameters; it does not differentiate based on parameter types. When the overloaded method has the same number of parameters, the Microsoft VM chooses to expose the last method in the .class file through the Auto-IDispatch feature.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual J++ 6.0 or the Microsoft SDK for Java 4.0, create a new Java file named Test.java, and paste the following code:

    import java.util.Vector;
    public class Test {
    
       public static void main(String args[]) {
          Test test = new Test();
       }
    
       public Test() {
          System.out.println("Constrcutor Called");
       }
    
       public static String staticMethod() {
          return "Static Method";
       }
    
       public String nonStaticMethod() {
          return "Non-Static Method";
       }
    
       public int func1 (int i) {
          return i*2;
       }
    
       public int func1(Vector v) {
          if (v == null)
             return 0;
          else
             return 3;
       }
    }
                        
  2. Copy the resultant Test.class file to your Web server's <Windir>/Java/Trustlib folder.
  3. At a command prompt on the server computer, type the following command to register Test.class as a COM object:

    javareg /register /class:Test /progid:Test.1 /typelib:Test.tlb

  4. Create a new ASP file named Test.asp, and paste the following code:

    <html>
    <body>
    <h1>Simple Test</h1>
    <% Set SimpleObj = Server.CreateObject("Test.1") %><BR/>
    <%= SimpleObj.staticMethod()%>
    <%=SimpleObj.func1(123)%>
    <%=SimpleObj.func1(0)%>
    <hr>
    <body></html>
                        
  5. Copy Test.asp to your Web server's Wwwroot folder.
  6. Run Test.asp. You receive one of the above-mentioned errors, or you see that only one of the overloaded methods is called.


REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:


Additional query words: 800a01b6 800a000d

Keywords: kbjava kbprb KB250538