Incorrect Java vararg method usage cause editing problems in Studio

Incorrect Java vararg method usage cause editing problems in Studio

book

Article ID: KB0074743

calendar_today

Updated On:

Products Versions
TIBCO Streaming 7

Description

When editing an EventFlow application which uses a custom Java operator, if there is an incorrect use of a method that takes a vararg (variable number of arguments), then numerous error dialogs appear when editing that application or switching to other editors. The canvas may also fail to draw the EventFlow application.
 

Issue/Introduction

Incorrect Java source in a custom Operator or Adapter causes problems in the EventFlow editor.

Resolution

In all cases, correcting the Java operator source resolves this problem.

For example, the Java code for an operator may use an expression like this:
static final String currecyFormat = String.format("%s.%s");
While this is not identified as an error in the Eclipse Java editor, it does prevent compilation since String.format() is defined as:
public static String format(String format, Object... args)

Supplying a "null" Object is incorrect and prevents compilation. Any method which allows a variable number of parameters can be miss-configured in this way.

A correct statement is:
static final String currecyFormat = String.format("%s.%s", str1, str2);
where str1 and str2 are both String variables defined earlier.

Studio attempts to build the class for this Java source file in order to typecheck the open EventFlow code. This compilation fails and raises error dialogs repeatedly.

The errors which are likely to be seen are...
(Example: operator SimpleOp, in project UncaughtJava, in application main.sbapp)

1) In a pop-up dialog box: 
An internal error occurred during "main.sbapp: Typechecking"; Details: "Could not initialize class com.sb.support.SimpleOp".

2) In the Problems view:
Embedded Java class cannot be instantiated; referenced class definition not found (Could not initialize class com.sb.support.SimpleOp), see application for details    main.sbapp    /UncaughtJava    (unknown location)    StreamBase Typecheck Problem
and
StreamBase Operator/Adapter class "com.sb.support.SimpleOp" failed to load (see Error Log for details): null    UncaughtJava        Typecheck Environment (Java Operators/Adapters)    StreamBase Typecheck Problem

3) In the Error Log view:
eclipse.buildId=StreamBase 7.6.7_1702011527
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments:  -os win32 -ws win32 -arch x86_64

org.eclipse.core.jobs
Error
Thu Mar 02 11:46:12 EST 2017
An internal error occurred during: "main.sbapp: Typechecking".

java.lang.NoClassDefFoundError: Could not initialize class com.sb.support.SimpleOp
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at com.streambase.sb.expr.TypecheckEnv.loadClass(TypecheckEnv.java:738)
    at com.streambase.sb.expr.TypecheckEnv.loadJavaOperatorClass(TypecheckEnv.java:806)
    at com.streambase.sb.typecheck.JavaTypecheckInfo.createTypecheckInfo(JavaTypecheckInfo.java:362)
    at com.streambase.sb.eventflow.JavaTypechecker.doTypecheck(JavaTypechecker.java:22)
    at com.streambase.sb.eventflow.JavaTypechecker.doTypecheck(JavaTypechecker.java:35)
    at com.streambase.sb.eventflow.OpTypechecker.typecheck(OpTypechecker.java:95)
    at com.streambase.sb.eventflow.EventFlowApplication.createAndTypecheckOperator(EventFlowApplication.java:614)
    at com.streambase.sb.eventflow.EventFlowApplication.createAndTypecheckOperator(EventFlowApplication.java:497)
    at com.streambase.sb.expr.ir.AppIrTypechecker.typecheck(AppIrTypechecker.java:138)
    at com.streambase.sb.studio.TypecheckState$OperatorTypecheckState.doIrTypecheck(TypecheckState.java:211)
    at com.streambase.sb.studio.TypecheckState.irTypecheck(TypecheckState.java:136)
    at com.streambase.sb.studio.TypecheckState.typecheck(TypecheckState.java:102)
    at com.streambase.sb.studio.TBox.typecheck(TBox.java:889)
    at com.streambase.sb.studio.TOperator.typecheck(TOperator.java:472)
    at com.streambase.sb.studio.TBox.revalidate(TBox.java:858)
    at com.streambase.sb.studio.TBox.revalidate(TBox.java:827)
    at com.streambase.sb.studio.Topology$5.run(Topology.java:1572)
    at com.streambase.sb.studio.ui.eventflow.editors.EventFlowEditor$TypecheckJob.doRunWithLocalContext(EventFlowEditor.java:2914)
    at com.streambase.sb.studio.ui.eventflow.editors.EventFlowEditor$TypecheckJob.run(EventFlowEditor.java:2888)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)