problem with char in Visual COBOL for Eclipse

[Migrated content. Thread originally posted on 20 January 2012]

Greetings.

New to JVM COBOL and this forum.

Wondering if anyone can shed any light on what I am experiencing in Visual COBOL for Eclipse.

I have created a .java file in the Visual COBOL for Eclipse IDE and it seems I cannot save the file when I try to populate a byte in a byte array with a cast of a char to a byte. This code construct works elsewhere in java.

byte[] crtioDataByteArray = new byte[16240];

crtioDataByteArray[0] = (byte) 'a';


I get the same error if I even define a char as below:
char OPENED = 'O';

When I attempt to save the file I get a dialogue box indicating

"Save Failed
java.lang.NullPointerException"

and the detail button offers no further explanation.

Thanks



  • I am really not sure what you are referring to here.

    On which platform are you running, Windows, Linux?
    Are you using the Dev Hub product to compile under Unix?

    It sounds as if you are using the Eclipse IDE to create a Java project not a COBOL project is that correct?
    I used the Visual COBOL Eclipse R4 product to create a new Java class in a Java project and I successfully added the code that you are getting an error on.

    Can you please explain the exact steps that you are taking so that I can try to reproduce this error?

    Be aware that the Java compiler and Eclipse IDE themselves are not Micro Focus products.
    Visual COBOL Eclipse is the plugin that Micro Focus supports that allows you to create COBOL applications using the Eclipse IDE that will compile to either native code or to JVM byte code.

    Thanks.
  • Thanks for the response, Chris.

    Sorry I did not include all the information.

    I am working on Windows.

    Yes, I created a java project to add java classes to call and be called from separate JVM COBOL project members.

    I do realize that Eclipse is separate from JVM COBOL.

    For some reason char constants seem to cause problems. I am getting another error (when I build the java project) when the java class references an existing java class which contains char constants.

    "Problems occurred building the selected resources.
    Errors running builder 'Java Builder' on project 'LawsonAppsJavaProject'.
    org/eclipse/jdt/internal/compiler/impl/CharConstant"

    I will explore further given the new info in the build error...



  • Chris,

    BTW version of Eclipse I am using is also "Micro Focus Visual COBOL R4 for Eclipse"
  • Chris,

    BTW version of Eclipse I am using is also "Micro Focus Visual COBOL R4 for Eclipse"
  • Chris,

    BTW version of Eclipse I am using is also "Micro Focus Visual COBOL R4 for Eclipse"
  • Is anything extra shown in the Error Log view?
    This can be shown by selecting via the Window/Show View/Other... Open the General item and select Error Log.
    If there's a stack trace in there for the NPE, then that might help pinpoint where things are going wrong.

    Regards, Darren
  • byte[] crtioDataByteArray = new byte[16240];

    crtioDataByteArray[0] = (byte) 'a';


    results in 4 log entries:

    Error in JDT Core during AST creation

    java.lang.ClassFormatError: org/eclipse/jdt/internal/compiler/impl/CharConstant
    at org.eclipse.jdt.internal.compiler.ast.CharLiteral.computeConstant(CharLiteral.java:32)
    at org.eclipse.jdt.internal.compiler.ast.Literal.resolveType(Literal.java:48)
    at org.eclipse.jdt.internal.compiler.ast.CastExpression.resolveType(CastExpression.java:484)
    at org.eclipse.jdt.internal.compiler.ast.Assignment.resolveType(Assignment.java:157)
    at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:915)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:451)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:212)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:410)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1147)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1235)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:540)
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1181)
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:681)
    at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1175)
    at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:543)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:536)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:479)
    at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:126)
    at org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.internalGetHoverInfo(NLSStringHover.java:133)
    at org.eclipse.jdt.internal.ui.text.java.hover.NLSStringHover.getHoverInfo2(NLSStringHover.java:112)
    at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo2(BestMatchHover.java:141)
    at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo2(JavaEditorTextHoverProxy.java:82)
    at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:166)



    Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".

    stack same as previous


    Error in JDT Core during reconcile

    java.lang.ClassFormatError: org/eclipse/jdt/internal/compiler/impl/CharConstant
    at org.eclipse.jdt.internal.compiler.ast.CharLiteral.computeConstant(CharLiteral.java:32)
    at org.eclipse.jdt.internal.compiler.ast.Literal.resolveType(Literal.java:48)
    at org.eclipse.jdt.internal.compiler.ast.CastExpression.resolveType(CastExpression.java:484)
    at org.eclipse.jdt.internal.compiler.ast.Assignment.resolveType(Assignment.java:157)
    at org.eclipse.jdt.internal.compiler.ast.Expression.resolve(Expression.java:915)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:451)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:212)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:410)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1147)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1235)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:540)
    at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:883)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody0(CompilationUnitProblemFinder.java:181)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody1$advice(CompilationUnitProblemFinder.java:246)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:1)
    at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:195)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:515)
    at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1079)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:170)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
    at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1244)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
    at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
    at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102)
    at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)


    Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".

    stack same as previous




    Inclusion of a reference to a class that contains char constants (SizedString contains char constants)

    public byte[] getALPHAFromRecArea(byte[] recArea, int recAreaSub, int fldSize)
    {
    SizedString sizedStr;


    results in log entries:

    Error in JDT Core during reconcile

    java.lang.ClassFormatError: org/eclipse/jdt/internal/compiler/impl/CharConstant
    at org.eclipse.jdt.internal.compiler.classfmt.FieldInfo.readConstantAttribute(FieldInfo.java:296)
    at org.eclipse.jdt.internal.compiler.classfmt.FieldInfo.getConstant(FieldInfo.java:98)
    at org.eclipse.jdt.internal.compiler.classfmt.FieldInfo.initialize(FieldInfo.java:221)
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.initialize(ClassFileReader.java:1069)
    at org.eclipse.jdt.internal.compiler.classfmt.ClassFileReader.(ClassFileReader.java:367)
    at org.eclipse.jdt.internal.core.ClassFile.getJarBinaryTypeInfo(ClassFile.java:349)
    at org.eclipse.jdt.internal.core.ClassFile.existsUsingJarTypeCache(ClassFile.java:207)
    at org.eclipse.jdt.internal.core.NameLookup.seekTypesInBinaryPackage(NameLookup.java:1009)
    at org.eclipse.jdt.internal.core.NameLookup.seekTypes(NameLookup.java:984)
    at org.eclipse.jdt.internal.core.NameLookup.findType(NameLookup.java:776)
    at org.eclipse.jdt.internal.core.NameLookup.findType(NameLookup.java:660)
    at org.eclipse.jdt.internal.core.NameLookup.findType(NameLookup.java:619)
    at org.eclipse.jdt.internal.core.SearchableEnvironment.find(SearchableEnvironment.java:101)
    at org.eclipse.jdt.internal.core.SearchableEnvironment.findType(SearchableEnvironment.java:287)
    at org.eclipse.jdt.internal.core.CancelableNameEnvironment.findType(CancelableNameEnvironment.java:45)
    at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:128)
    at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getType(PackageBinding.java:127)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.findType(Scope.java:1536)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2631)
    at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:2328)
    at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:44)
    at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:131)
    at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:203)
    at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:138)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:451)
    at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:212)
    at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:410)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1147)
    at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1235)
    at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:540)
    at org.eclipse.jdt.internal.compiler.Compiler.resolve(Compiler.java:883)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody0(CompilationUnitProblemFinder.java:181)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process_aroundBody1$advice(CompilationUnitProblemFinder.java:246)
    at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:1)
    at org.eclipse.jdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:195)
    at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:258)
    at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:515)
    at org.eclipse.jdt.internal.core.CompilationUnit.makeConsistent(CompilationUnit.java:1079)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:170)
    at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:89)
    at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728)
    at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:788)
    at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1244)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:126)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:108)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:89)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:87)
    at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:151)
    at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:86)
    at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:102)
    at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
    at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)


    Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui".

    stack same as previous
  • Hard to know what to suggest here. As can be seen, there is no Micro Focus code in the stack and this is pure Java JDK code. The obvious thought is that somehow your Eclipse has become corrupted - there's certainly something wrong anyhow. I hate to say it, but you might try reinstalling and see if that fixes it.
    If that doesn't fix it, there should be a vanilla copy of the Eclipse JDK in your product (eclipse-java-helios-win32.zip)- you could try unzipping that into another location and seeing if the Java code you are trying works without any of the Micro Focus parts present (including all COBOL support).

    Regards,
    Darren
  • Verified Answer

    Issue Resolved.

    Updated JAVA JRE 1.1.18 to latest and installed Visual COBOL for Eclipse R4 Update 2.

    Everything now behaving as expected.